MCPcopy Create free account
hub / github.com/massCodeIO/massCode / verifyLicenseKey

Function verifyLicenseKey

src/main/license/index.ts:28–60  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

26}
27
28export function verifyLicenseKey(key: string): LicensePayload | null {
29 try {
30 const [payloadBase64, signatureBase64] = key.trim().split('.')
31
32 if (!payloadBase64 || !signatureBase64) {
33 return null
34 }
35
36 const isValid = verify(
37 null,
38 Buffer.from(payloadBase64),
39 publicKey,
40 Buffer.from(signatureBase64, 'base64url'),
41 )
42
43 if (!isValid) {
44 return null
45 }
46
47 const payload = JSON.parse(
48 Buffer.from(payloadBase64, 'base64url').toString('utf8'),
49 )
50
51 if (typeof payload?.email !== 'string') {
52 return null
53 }
54
55 return payload as LicensePayload
56 }
57 catch {
58 return null
59 }
60}
61
62export function activateLicense(key: string): LicenseStatus {
63 const payload = verifyLicenseKey(key)

Callers 3

activateLicenseFunction · 0.85
validateStoredLicenseFunction · 0.85
license.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected