MCPcopy Index your code
hub / github.com/mailvelope/mailvelope / checkLicense

Function checkLicense

src/modules/gmail.js:145–169  ·  view source on GitHub ↗
({email, legacyGsuite})

Source from the content-addressed store, hash-verified

143}
144
145export async function checkLicense({email, legacyGsuite}) {
146 const storedAuthData = await mvelo.storage.get(GOOGLE_OAUTH_STORE);
147 const storedData = storedAuthData[email];
148 if (!storedData.gsuite) {
149 return;
150 }
151 if (legacyGsuite && storedData.legacyGsuite) {
152 return;
153 }
154 if (validateLicense(storedData)) {
155 return;
156 }
157 const {gsuite, gmail_account_id} = storedData;
158 let valid = false;
159 try {
160 await requestLicense(gsuite, gmail_account_id);
161 valid = true;
162 } catch (e) {
163 if (!legacyGsuite) {
164 throw new MvError(`Mailvelope Business license required to use this feature. ${e.message}`, 'GSUITE_LICENSING_ERROR');
165 }
166 } finally {
167 await storeAuthData(email, {...buildLicenseData(valid), legacyGsuite});
168 }
169}
170
171async function requestLicense(domain, gmail_account_id) {
172 const ab = str2ab(gmail_account_id);

Callers

nothing calls this directly

Calls 5

validateLicenseFunction · 0.85
requestLicenseFunction · 0.85
storeAuthDataFunction · 0.85
buildLicenseDataFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected