@middag-io/licensing 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["decodeBase64URL","jwk.isJWK","jwk.isSecretJWK","invalidKeyInput","jwk.isPrivateJWK","jwk.isPublicJWK","b64u"],"sources":["../../node_modules/jose/dist/webapi/lib/buffer_utils.js","../../node_modules/jose/dist/webapi/lib/base64.js","../../node_modules/jose/dist/webapi/util/base64url.js","../../node_modules/jose/dist/webapi/lib/crypto_key.js","../../node_modules/jose/dist/webapi/lib/invalid_key_input.js","../../node_modules/jose/dist/webapi/util/errors.js","../../node_modules/jose/dist/webapi/lib/is_key_like.js","../../node_modules/jose/dist/webapi/lib/helpers.js","../../node_modules/jose/dist/webapi/lib/type_checks.js","../../node_modules/jose/dist/webapi/lib/signing.js","../../node_modules/jose/dist/webapi/lib/jwk_to_key.js","../../node_modules/jose/dist/webapi/lib/normalize_key.js","../../node_modules/jose/dist/webapi/key/import.js","../../node_modules/jose/dist/webapi/lib/validate_crit.js","../../node_modules/jose/dist/webapi/lib/validate_algorithms.js","../../node_modules/jose/dist/webapi/lib/check_key_type.js","../../node_modules/jose/dist/webapi/jws/flattened/verify.js","../../node_modules/jose/dist/webapi/jws/compact/verify.js","../../src/client/index.ts"],"sourcesContent":["export const encoder = new TextEncoder();\nexport const decoder = new TextDecoder();\nconst MAX_INT32 = 2 ** 32;\nexport function concat(...buffers) {\n const size = buffers.reduce((acc, { length }) => acc + length, 0);\n const buf = new Uint8Array(size);\n let i = 0;\n for (const buffer of buffers) {\n buf.set(buffer, i);\n i += buffer.length;\n }\n return buf;\n}\nfunction writeUInt32BE(buf, value, offset) {\n if (value < 0 || value >= MAX_INT32) {\n throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);\n }\n buf.set([value >>> 24, value >>> 16, value >>> 8, value & 0xff], offset);\n}\nexport function uint64be(value) {\n const high = Math.floor(value / MAX_INT32);\n const low = value % MAX_INT32;\n const buf = new Uint8Array(8);\n writeUInt32BE(buf, high, 0);\n writeUInt32BE(buf, low, 4);\n return buf;\n}\nexport function uint32be(value) {\n const buf = new Uint8Array(4);\n writeUInt32BE(buf, value);\n return buf;\n}\nexport function encode(string) {\n const bytes = new Uint8Array(string.length);\n for (let i = 0; i < string.length; i++) {\n const code = string.charCodeAt(i);\n if (code > 127) {\n throw new TypeError('non-ASCII string encountered in encode()');\n }\n bytes[i] = code;\n }\n return bytes;\n}\n","export function encodeBase64(input) {\n if (Uint8Array.prototype.toBase64) {\n return input.toBase64();\n }\n const CHUNK_SIZE = 0x8000;\n const arr = [];\n for (let i = 0; i < input.length; i += CHUNK_SIZE) {\n arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));\n }\n return btoa(arr.join(''));\n}\nexport function decodeBase64(encoded) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(encoded);\n }\n const binary = atob(encoded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n","import { encoder, decoder } from '../lib/buffer_utils.js';\nimport { encodeBase64, decodeBase64 } from '../lib/base64.js';\nexport function decode(input) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(typeof input === 'string' ? input : decoder.decode(input), {\n alphabet: 'base64url',\n });\n }\n let encoded = input;\n if (encoded instanceof Uint8Array) {\n encoded = decoder.decode(encoded);\n }\n encoded = encoded.replace(/-/g, '+').replace(/_/g, '/');\n try {\n return decodeBase64(encoded);\n }\n catch {\n throw new TypeError('The input to be decoded is not correctly encoded.');\n }\n}\nexport function encode(input) {\n let unencoded = input;\n if (typeof unencoded === 'string') {\n unencoded = encoder.encode(unencoded);\n }\n if (Uint8Array.prototype.toBase64) {\n return unencoded.toBase64({ alphabet: 'base64url', omitPadding: true });\n }\n return encodeBase64(unencoded).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n","const unusable = (name, prop = 'algorithm.name') => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);\nconst isAlgorithm = (algorithm, name) => algorithm.name === name;\nfunction getHashLength(hash) {\n return parseInt(hash.name.slice(4), 10);\n}\nfunction checkHashLength(algorithm, expected) {\n const actual = getHashLength(algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n}\nfunction getNamedCurve(alg) {\n switch (alg) {\n case 'ES256':\n return 'P-256';\n case 'ES384':\n return 'P-384';\n case 'ES512':\n return 'P-521';\n default:\n throw new Error('unreachable');\n }\n}\nfunction checkUsage(key, usage) {\n if (usage && !key.usages.includes(usage)) {\n throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);\n }\n}\nexport function checkSigCryptoKey(key, alg, usage) {\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512': {\n if (!isAlgorithm(key.algorithm, 'HMAC'))\n throw unusable('HMAC');\n checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));\n break;\n }\n case 'RS256':\n case 'RS384':\n case 'RS512': {\n if (!isAlgorithm(key.algorithm, 'RSASSA-PKCS1-v1_5'))\n throw unusable('RSASSA-PKCS1-v1_5');\n checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));\n break;\n }\n case 'PS256':\n case 'PS384':\n case 'PS512': {\n if (!isAlgorithm(key.algorithm, 'RSA-PSS'))\n throw unusable('RSA-PSS');\n checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));\n break;\n }\n case 'Ed25519':\n case 'EdDSA': {\n if (!isAlgorithm(key.algorithm, 'Ed25519'))\n throw unusable('Ed25519');\n break;\n }\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87': {\n if (!isAlgorithm(key.algorithm, alg))\n throw unusable(alg);\n break;\n }\n case 'ES256':\n case 'ES384':\n case 'ES512': {\n if (!isAlgorithm(key.algorithm, 'ECDSA'))\n throw unusable('ECDSA');\n const expected = getNamedCurve(alg);\n const actual = key.algorithm.namedCurve;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.namedCurve');\n break;\n }\n default:\n throw new TypeError('CryptoKey does not support this operation');\n }\n checkUsage(key, usage);\n}\nexport function checkEncCryptoKey(key, alg, usage) {\n switch (alg) {\n case 'A128GCM':\n case 'A192GCM':\n case 'A256GCM': {\n if (!isAlgorithm(key.algorithm, 'AES-GCM'))\n throw unusable('AES-GCM');\n const expected = parseInt(alg.slice(1, 4), 10);\n const actual = key.algorithm.length;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.length');\n break;\n }\n case 'A128KW':\n case 'A192KW':\n case 'A256KW': {\n if (!isAlgorithm(key.algorithm, 'AES-KW'))\n throw unusable('AES-KW');\n const expected = parseInt(alg.slice(1, 4), 10);\n const actual = key.algorithm.length;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.length');\n break;\n }\n case 'ECDH': {\n switch (key.algorithm.name) {\n case 'ECDH':\n case 'X25519':\n break;\n default:\n throw unusable('ECDH or X25519');\n }\n break;\n }\n case 'PBES2-HS256+A128KW':\n case 'PBES2-HS384+A192KW':\n case 'PBES2-HS512+A256KW':\n if (!isAlgorithm(key.algorithm, 'PBKDF2'))\n throw unusable('PBKDF2');\n break;\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512': {\n if (!isAlgorithm(key.algorithm, 'RSA-OAEP'))\n throw unusable('RSA-OAEP');\n checkHashLength(key.algorithm, parseInt(alg.slice(9), 10) || 1);\n break;\n }\n default:\n throw new TypeError('CryptoKey does not support this operation');\n }\n checkUsage(key, usage);\n}\n","function message(msg, actual, ...types) {\n types = types.filter(Boolean);\n if (types.length > 2) {\n const last = types.pop();\n msg += `one of type ${types.join(', ')}, or ${last}.`;\n }\n else if (types.length === 2) {\n msg += `one of type ${types[0]} or ${types[1]}.`;\n }\n else {\n msg += `of type ${types[0]}.`;\n }\n if (actual == null) {\n msg += ` Received ${actual}`;\n }\n else if (typeof actual === 'function' && actual.name) {\n msg += ` Received function ${actual.name}`;\n }\n else if (typeof actual === 'object' && actual != null) {\n if (actual.constructor?.name) {\n msg += ` Received an instance of ${actual.constructor.name}`;\n }\n }\n return msg;\n}\nexport const invalidKeyInput = (actual, ...types) => message('Key must be ', actual, ...types);\nexport const withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);\n","export class JOSEError extends Error {\n static code = 'ERR_JOSE_GENERIC';\n code = 'ERR_JOSE_GENERIC';\n constructor(message, options) {\n super(message, options);\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\nexport class JWTClaimValidationFailed extends JOSEError {\n static code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JWTExpired extends JOSEError {\n static code = 'ERR_JWT_EXPIRED';\n code = 'ERR_JWT_EXPIRED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JOSEAlgNotAllowed extends JOSEError {\n static code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n}\nexport class JOSENotSupported extends JOSEError {\n static code = 'ERR_JOSE_NOT_SUPPORTED';\n code = 'ERR_JOSE_NOT_SUPPORTED';\n}\nexport class JWEDecryptionFailed extends JOSEError {\n static code = 'ERR_JWE_DECRYPTION_FAILED';\n code = 'ERR_JWE_DECRYPTION_FAILED';\n constructor(message = 'decryption operation failed', options) {\n super(message, options);\n }\n}\nexport class JWEInvalid extends JOSEError {\n static code = 'ERR_JWE_INVALID';\n code = 'ERR_JWE_INVALID';\n}\nexport class JWSInvalid extends JOSEError {\n static code = 'ERR_JWS_INVALID';\n code = 'ERR_JWS_INVALID';\n}\nexport class JWTInvalid extends JOSEError {\n static code = 'ERR_JWT_INVALID';\n code = 'ERR_JWT_INVALID';\n}\nexport class JWKInvalid extends JOSEError {\n static code = 'ERR_JWK_INVALID';\n code = 'ERR_JWK_INVALID';\n}\nexport class JWKSInvalid extends JOSEError {\n static code = 'ERR_JWKS_INVALID';\n code = 'ERR_JWKS_INVALID';\n}\nexport class JWKSNoMatchingKey extends JOSEError {\n static code = 'ERR_JWKS_NO_MATCHING_KEY';\n code = 'ERR_JWKS_NO_MATCHING_KEY';\n constructor(message = 'no applicable key found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSMultipleMatchingKeys extends JOSEError {\n [Symbol.asyncIterator];\n static code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n constructor(message = 'multiple matching keys found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSTimeout extends JOSEError {\n static code = 'ERR_JWKS_TIMEOUT';\n code = 'ERR_JWKS_TIMEOUT';\n constructor(message = 'request timed out', options) {\n super(message, options);\n }\n}\nexport class JWSSignatureVerificationFailed extends JOSEError {\n static code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n constructor(message = 'signature verification failed', options) {\n super(message, options);\n }\n}\n","export function assertCryptoKey(key) {\n if (!isCryptoKey(key)) {\n throw new Error('CryptoKey instance expected');\n }\n}\nexport const isCryptoKey = (key) => {\n if (key?.[Symbol.toStringTag] === 'CryptoKey')\n return true;\n try {\n return key instanceof CryptoKey;\n }\n catch {\n return false;\n }\n};\nexport const isKeyObject = (key) => key?.[Symbol.toStringTag] === 'KeyObject';\nexport const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);\n","import { decode } from '../util/base64url.js';\nexport const unprotected = Symbol();\nexport function assertNotSet(value, name) {\n if (value) {\n throw new TypeError(`${name} can only be called once`);\n }\n}\nexport function decodeBase64url(value, label, ErrorClass) {\n try {\n return decode(value);\n }\n catch {\n throw new ErrorClass(`Failed to base64url decode the ${label}`);\n }\n}\nexport async function digest(algorithm, data) {\n const subtleDigest = `SHA-${algorithm.slice(-3)}`;\n return new Uint8Array(await crypto.subtle.digest(subtleDigest, data));\n}\n","const isObjectLike = (value) => typeof value === 'object' && value !== null;\nexport function isObject(input) {\n if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {\n return false;\n }\n if (Object.getPrototypeOf(input) === null) {\n return true;\n }\n let proto = input;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(input) === proto;\n}\nexport function isDisjoint(...headers) {\n const sources = headers.filter(Boolean);\n if (sources.length === 0 || sources.length === 1) {\n return true;\n }\n let acc;\n for (const header of sources) {\n const parameters = Object.keys(header);\n if (!acc || acc.size === 0) {\n acc = new Set(parameters);\n continue;\n }\n for (const parameter of parameters) {\n if (acc.has(parameter)) {\n return false;\n }\n acc.add(parameter);\n }\n }\n return true;\n}\nexport const isJWK = (key) => isObject(key) && typeof key.kty === 'string';\nexport const isPrivateJWK = (key) => key.kty !== 'oct' &&\n ((key.kty === 'AKP' && typeof key.priv === 'string') || typeof key.d === 'string');\nexport const isPublicJWK = (key) => key.kty !== 'oct' && key.d === undefined && key.priv === undefined;\nexport const isSecretJWK = (key) => key.kty === 'oct' && typeof key.k === 'string';\n","import { JOSENotSupported } from '../util/errors.js';\nimport { checkSigCryptoKey } from './crypto_key.js';\nimport { invalidKeyInput } from './invalid_key_input.js';\nexport function checkKeyLength(alg, key) {\n if (alg.startsWith('RS') || alg.startsWith('PS')) {\n const { modulusLength } = key.algorithm;\n if (typeof modulusLength !== 'number' || modulusLength < 2048) {\n throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);\n }\n }\n}\nfunction subtleAlgorithm(alg, algorithm) {\n const hash = `SHA-${alg.slice(-3)}`;\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512':\n return { hash, name: 'HMAC' };\n case 'PS256':\n case 'PS384':\n case 'PS512':\n return { hash, name: 'RSA-PSS', saltLength: parseInt(alg.slice(-3), 10) >> 3 };\n case 'RS256':\n case 'RS384':\n case 'RS512':\n return { hash, name: 'RSASSA-PKCS1-v1_5' };\n case 'ES256':\n case 'ES384':\n case 'ES512':\n return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };\n case 'Ed25519':\n case 'EdDSA':\n return { name: 'Ed25519' };\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87':\n return { name: alg };\n default:\n throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n }\n}\nasync function getSigKey(alg, key, usage) {\n if (key instanceof Uint8Array) {\n if (!alg.startsWith('HS')) {\n throw new TypeError(invalidKeyInput(key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));\n }\n return crypto.subtle.importKey('raw', key, { hash: `SHA-${alg.slice(-3)}`, name: 'HMAC' }, false, [usage]);\n }\n checkSigCryptoKey(key, alg, usage);\n return key;\n}\nexport async function sign(alg, key, data) {\n const cryptoKey = await getSigKey(alg, key, 'sign');\n checkKeyLength(alg, cryptoKey);\n const signature = await crypto.subtle.sign(subtleAlgorithm(alg, cryptoKey.algorithm), cryptoKey, data);\n return new Uint8Array(signature);\n}\nexport async function verify(alg, key, signature, data) {\n const cryptoKey = await getSigKey(alg, key, 'verify');\n checkKeyLength(alg, cryptoKey);\n const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);\n try {\n return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);\n }\n catch {\n return false;\n }\n}\n","import { JOSENotSupported } from '../util/errors.js';\nconst unsupportedAlg = 'Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value';\nfunction subtleMapping(jwk) {\n let algorithm;\n let keyUsages;\n switch (jwk.kty) {\n case 'AKP': {\n switch (jwk.alg) {\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87':\n algorithm = { name: jwk.alg };\n keyUsages = jwk.priv ? ['sign'] : ['verify'];\n break;\n default:\n throw new JOSENotSupported(unsupportedAlg);\n }\n break;\n }\n case 'RSA': {\n switch (jwk.alg) {\n case 'PS256':\n case 'PS384':\n case 'PS512':\n algorithm = { name: 'RSA-PSS', hash: `SHA-${jwk.alg.slice(-3)}` };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'RS256':\n case 'RS384':\n case 'RS512':\n algorithm = { name: 'RSASSA-PKCS1-v1_5', hash: `SHA-${jwk.alg.slice(-3)}` };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512':\n algorithm = {\n name: 'RSA-OAEP',\n hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`,\n };\n keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];\n break;\n default:\n throw new JOSENotSupported(unsupportedAlg);\n }\n break;\n }\n case 'EC': {\n switch (jwk.alg) {\n case 'ES256':\n case 'ES384':\n case 'ES512':\n algorithm = {\n name: 'ECDSA',\n namedCurve: { ES256: 'P-256', ES384: 'P-384', ES512: 'P-521' }[jwk.alg],\n };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n algorithm = { name: 'ECDH', namedCurve: jwk.crv };\n keyUsages = jwk.d ? ['deriveBits'] : [];\n break;\n default:\n throw new JOSENotSupported(unsupportedAlg);\n }\n break;\n }\n case 'OKP': {\n switch (jwk.alg) {\n case 'Ed25519':\n case 'EdDSA':\n algorithm = { name: 'Ed25519' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n algorithm = { name: jwk.crv };\n keyUsages = jwk.d ? ['deriveBits'] : [];\n break;\n default:\n throw new JOSENotSupported(unsupportedAlg);\n }\n break;\n }\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"kty\" (Key Type) Parameter value');\n }\n return { algorithm, keyUsages };\n}\nexport async function jwkToKey(jwk) {\n if (!jwk.alg) {\n throw new TypeError('\"alg\" argument is required when \"jwk.alg\" is not present');\n }\n const { algorithm, keyUsages } = subtleMapping(jwk);\n const keyData = { ...jwk };\n if (keyData.kty !== 'AKP') {\n delete keyData.alg;\n }\n delete keyData.use;\n return crypto.subtle.importKey('jwk', keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);\n}\n","import { isJWK } from './type_checks.js';\nimport { decode } from '../util/base64url.js';\nimport { jwkToKey } from './jwk_to_key.js';\nimport { isCryptoKey, isKeyObject } from './is_key_like.js';\nconst unusableForAlg = 'given KeyObject instance cannot be used for this algorithm';\nlet cache;\nconst handleJWK = async (key, jwk, alg, freeze = false) => {\n cache ||= new WeakMap();\n let cached = cache.get(key);\n if (cached?.[alg]) {\n return cached[alg];\n }\n const cryptoKey = await jwkToKey({ ...jwk, alg });\n if (freeze)\n Object.freeze(key);\n if (!cached) {\n cache.set(key, { [alg]: cryptoKey });\n }\n else {\n cached[alg] = cryptoKey;\n }\n return cryptoKey;\n};\nconst handleKeyObject = (keyObject, alg) => {\n cache ||= new WeakMap();\n let cached = cache.get(keyObject);\n if (cached?.[alg]) {\n return cached[alg];\n }\n const isPublic = keyObject.type === 'public';\n const extractable = isPublic ? true : false;\n let cryptoKey;\n if (keyObject.asymmetricKeyType === 'x25519') {\n switch (alg) {\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n break;\n default:\n throw new TypeError(unusableForAlg);\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ['deriveBits']);\n }\n if (keyObject.asymmetricKeyType === 'ed25519') {\n if (alg !== 'EdDSA' && alg !== 'Ed25519') {\n throw new TypeError(unusableForAlg);\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [\n isPublic ? 'verify' : 'sign',\n ]);\n }\n switch (keyObject.asymmetricKeyType) {\n case 'ml-dsa-44':\n case 'ml-dsa-65':\n case 'ml-dsa-87': {\n if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {\n throw new TypeError(unusableForAlg);\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [\n isPublic ? 'verify' : 'sign',\n ]);\n }\n }\n if (keyObject.asymmetricKeyType === 'rsa') {\n let hash;\n switch (alg) {\n case 'RSA-OAEP':\n hash = 'SHA-1';\n break;\n case 'RS256':\n case 'PS256':\n case 'RSA-OAEP-256':\n hash = 'SHA-256';\n break;\n case 'RS384':\n case 'PS384':\n case 'RSA-OAEP-384':\n hash = 'SHA-384';\n break;\n case 'RS512':\n case 'PS512':\n case 'RSA-OAEP-512':\n hash = 'SHA-512';\n break;\n default:\n throw new TypeError(unusableForAlg);\n }\n if (alg.startsWith('RSA-OAEP')) {\n return keyObject.toCryptoKey({\n name: 'RSA-OAEP',\n hash,\n }, extractable, isPublic ? ['encrypt'] : ['decrypt']);\n }\n cryptoKey = keyObject.toCryptoKey({\n name: alg.startsWith('PS') ? 'RSA-PSS' : 'RSASSA-PKCS1-v1_5',\n hash,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (keyObject.asymmetricKeyType === 'ec') {\n const nist = new Map([\n ['prime256v1', 'P-256'],\n ['secp384r1', 'P-384'],\n ['secp521r1', 'P-521'],\n ]);\n const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);\n if (!namedCurve) {\n throw new TypeError(unusableForAlg);\n }\n const expectedCurve = { ES256: 'P-256', ES384: 'P-384', ES512: 'P-521' };\n if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDSA',\n namedCurve,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (alg.startsWith('ECDH-ES')) {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDH',\n namedCurve,\n }, extractable, isPublic ? [] : ['deriveBits']);\n }\n }\n if (!cryptoKey) {\n throw new TypeError(unusableForAlg);\n }\n if (!cached) {\n cache.set(keyObject, { [alg]: cryptoKey });\n }\n else {\n cached[alg] = cryptoKey;\n }\n return cryptoKey;\n};\nexport async function normalizeKey(key, alg) {\n if (key instanceof Uint8Array) {\n return key;\n }\n if (isCryptoKey(key)) {\n return key;\n }\n if (isKeyObject(key)) {\n if (key.type === 'secret') {\n return key.export();\n }\n if ('toCryptoKey' in key && typeof key.toCryptoKey === 'function') {\n try {\n return handleKeyObject(key, alg);\n }\n catch (err) {\n if (err instanceof TypeError) {\n throw err;\n }\n }\n }\n let jwk = key.export({ format: 'jwk' });\n return handleJWK(key, jwk, alg);\n }\n if (isJWK(key)) {\n if (key.k) {\n return decode(key.k);\n }\n return handleJWK(key, key, alg, true);\n }\n throw new Error('unreachable');\n}\n","import { decode as decodeBase64URL } from '../util/base64url.js';\nimport { fromSPKI, fromPKCS8, fromX509 } from '../lib/asn1.js';\nimport { jwkToKey } from '../lib/jwk_to_key.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { isObject } from '../lib/type_checks.js';\nexport async function importSPKI(spki, alg, options) {\n if (typeof spki !== 'string' || spki.indexOf('-----BEGIN PUBLIC KEY-----') !== 0) {\n throw new TypeError('\"spki\" must be SPKI formatted string');\n }\n return fromSPKI(spki, alg, options);\n}\nexport async function importX509(x509, alg, options) {\n if (typeof x509 !== 'string' || x509.indexOf('-----BEGIN CERTIFICATE-----') !== 0) {\n throw new TypeError('\"x509\" must be X.509 formatted string');\n }\n return fromX509(x509, alg, options);\n}\nexport async function importPKCS8(pkcs8, alg, options) {\n if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {\n throw new TypeError('\"pkcs8\" must be PKCS#8 formatted string');\n }\n return fromPKCS8(pkcs8, alg, options);\n}\nexport async function importJWK(jwk, alg, options) {\n if (!isObject(jwk)) {\n throw new TypeError('JWK must be an object');\n }\n let ext;\n alg ??= jwk.alg;\n ext ??= options?.extractable ?? jwk.ext;\n switch (jwk.kty) {\n case 'oct':\n if (typeof jwk.k !== 'string' || !jwk.k) {\n throw new TypeError('missing \"k\" (Key Value) Parameter value');\n }\n return decodeBase64URL(jwk.k);\n case 'RSA':\n if ('oth' in jwk && jwk.oth !== undefined) {\n throw new JOSENotSupported('RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported');\n }\n return jwkToKey({ ...jwk, alg, ext });\n case 'AKP': {\n if (typeof jwk.alg !== 'string' || !jwk.alg) {\n throw new TypeError('missing \"alg\" (Algorithm) Parameter value');\n }\n if (alg !== undefined && alg !== jwk.alg) {\n throw new TypeError('JWK alg and alg option value mismatch');\n }\n return jwkToKey({ ...jwk, ext });\n }\n case 'EC':\n case 'OKP':\n return jwkToKey({ ...jwk, alg, ext });\n default:\n throw new JOSENotSupported('Unsupported \"kty\" (Key Type) Parameter value');\n }\n}\n","import { JOSENotSupported, JWEInvalid, JWSInvalid } from '../util/errors.js';\nexport function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {\n if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {\n throw new Err('\"crit\" (Critical) Header Parameter MUST be integrity protected');\n }\n if (!protectedHeader || protectedHeader.crit === undefined) {\n return new Set();\n }\n if (!Array.isArray(protectedHeader.crit) ||\n protectedHeader.crit.length === 0 ||\n protectedHeader.crit.some((input) => typeof input !== 'string' || input.length === 0)) {\n throw new Err('\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present');\n }\n let recognized;\n if (recognizedOption !== undefined) {\n recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);\n }\n else {\n recognized = recognizedDefault;\n }\n for (const parameter of protectedHeader.crit) {\n if (!recognized.has(parameter)) {\n throw new JOSENotSupported(`Extension Header Parameter \"${parameter}\" is not recognized`);\n }\n if (joseHeader[parameter] === undefined) {\n throw new Err(`Extension Header Parameter \"${parameter}\" is missing`);\n }\n if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {\n throw new Err(`Extension Header Parameter \"${parameter}\" MUST be integrity protected`);\n }\n }\n return new Set(protectedHeader.crit);\n}\n","export function validateAlgorithms(option, algorithms) {\n if (algorithms !== undefined &&\n (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== 'string'))) {\n throw new TypeError(`\"${option}\" option must be an array of strings`);\n }\n if (!algorithms) {\n return undefined;\n }\n return new Set(algorithms);\n}\n","import { withAlg as invalidKeyInput } from './invalid_key_input.js';\nimport { isKeyLike } from './is_key_like.js';\nimport * as jwk from './type_checks.js';\nconst tag = (key) => key?.[Symbol.toStringTag];\nconst jwkMatchesOp = (alg, key, usage) => {\n if (key.use !== undefined) {\n let expected;\n switch (usage) {\n case 'sign':\n case 'verify':\n expected = 'sig';\n break;\n case 'encrypt':\n case 'decrypt':\n expected = 'enc';\n break;\n }\n if (key.use !== expected) {\n throw new TypeError(`Invalid key for this operation, its \"use\" must be \"${expected}\" when present`);\n }\n }\n if (key.alg !== undefined && key.alg !== alg) {\n throw new TypeError(`Invalid key for this operation, its \"alg\" must be \"${alg}\" when present`);\n }\n if (Array.isArray(key.key_ops)) {\n let expectedKeyOp;\n switch (true) {\n case usage === 'sign' || usage === 'verify':\n case alg === 'dir':\n case alg.includes('CBC-HS'):\n expectedKeyOp = usage;\n break;\n case alg.startsWith('PBES2'):\n expectedKeyOp = 'deriveBits';\n break;\n case /^A\\d{3}(?:GCM)?(?:KW)?$/.test(alg):\n if (!alg.includes('GCM') && alg.endsWith('KW')) {\n expectedKeyOp = usage === 'encrypt' ? 'wrapKey' : 'unwrapKey';\n }\n else {\n expectedKeyOp = usage;\n }\n break;\n case usage === 'encrypt' && alg.startsWith('RSA'):\n expectedKeyOp = 'wrapKey';\n break;\n case usage === 'decrypt':\n expectedKeyOp = alg.startsWith('RSA') ? 'unwrapKey' : 'deriveBits';\n break;\n }\n if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {\n throw new TypeError(`Invalid key for this operation, its \"key_ops\" must include \"${expectedKeyOp}\" when present`);\n }\n }\n return true;\n};\nconst symmetricTypeCheck = (alg, key, usage) => {\n if (key instanceof Uint8Array)\n return;\n if (jwk.isJWK(key)) {\n if (jwk.isSecretJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK \"kty\" (Key Type) equal to \"oct\" and the JWK \"k\" (Key Value) present`);\n }\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key', 'Uint8Array'));\n }\n if (key.type !== 'secret') {\n throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type \"secret\"`);\n }\n};\nconst asymmetricTypeCheck = (alg, key, usage) => {\n if (jwk.isJWK(key)) {\n switch (usage) {\n case 'decrypt':\n case 'sign':\n if (jwk.isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for this operation must be a private JWK`);\n case 'encrypt':\n case 'verify':\n if (jwk.isPublicJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for this operation must be a public JWK`);\n }\n }\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));\n }\n if (key.type === 'secret') {\n throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type \"secret\"`);\n }\n if (key.type === 'public') {\n switch (usage) {\n case 'sign':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type \"private\"`);\n case 'decrypt':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type \"private\"`);\n }\n }\n if (key.type === 'private') {\n switch (usage) {\n case 'verify':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type \"public\"`);\n case 'encrypt':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type \"public\"`);\n }\n }\n};\nexport function checkKeyType(alg, key, usage) {\n switch (alg.substring(0, 2)) {\n case 'A1':\n case 'A2':\n case 'di':\n case 'HS':\n case 'PB':\n symmetricTypeCheck(alg, key, usage);\n break;\n default:\n asymmetricTypeCheck(alg, key, usage);\n }\n}\n","import { decode as b64u } from '../../util/base64url.js';\nimport { verify } from '../../lib/signing.js';\nimport { JOSEAlgNotAllowed, JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';\nimport { concat, encoder, decoder, encode } from '../../lib/buffer_utils.js';\nimport { decodeBase64url } from '../../lib/helpers.js';\nimport { isDisjoint } from '../../lib/type_checks.js';\nimport { isObject } from '../../lib/type_checks.js';\nimport { checkKeyType } from '../../lib/check_key_type.js';\nimport { validateCrit } from '../../lib/validate_crit.js';\nimport { validateAlgorithms } from '../../lib/validate_algorithms.js';\nimport { normalizeKey } from '../../lib/normalize_key.js';\nexport async function flattenedVerify(jws, key, options) {\n if (!isObject(jws)) {\n throw new JWSInvalid('Flattened JWS must be an object');\n }\n if (jws.protected === undefined && jws.header === undefined) {\n throw new JWSInvalid('Flattened JWS must have either of the \"protected\" or \"header\" members');\n }\n if (jws.protected !== undefined && typeof jws.protected !== 'string') {\n throw new JWSInvalid('JWS Protected Header incorrect type');\n }\n if (jws.payload === undefined) {\n throw new JWSInvalid('JWS Payload missing');\n }\n if (typeof jws.signature !== 'string') {\n throw new JWSInvalid('JWS Signature missing or incorrect type');\n }\n if (jws.header !== undefined && !isObject(jws.header)) {\n throw new JWSInvalid('JWS Unprotected Header incorrect type');\n }\n let parsedProt = {};\n if (jws.protected) {\n try {\n const protectedHeader = b64u(jws.protected);\n parsedProt = JSON.parse(decoder.decode(protectedHeader));\n }\n catch {\n throw new JWSInvalid('JWS Protected Header is invalid');\n }\n }\n if (!isDisjoint(parsedProt, jws.header)) {\n throw new JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');\n }\n const joseHeader = {\n ...parsedProt,\n ...jws.header,\n };\n const extensions = validateCrit(JWSInvalid, new Map([['b64', true]]), options?.crit, parsedProt, joseHeader);\n let b64 = true;\n if (extensions.has('b64')) {\n b64 = parsedProt.b64;\n if (typeof b64 !== 'boolean') {\n throw new JWSInvalid('The \"b64\" (base64url-encode payload) Header Parameter must be a boolean');\n }\n }\n const { alg } = joseHeader;\n if (typeof alg !== 'string' || !alg) {\n throw new JWSInvalid('JWS \"alg\" (Algorithm) Header Parameter missing or invalid');\n }\n const algorithms = options && validateAlgorithms('algorithms', options.algorithms);\n if (algorithms && !algorithms.has(alg)) {\n throw new JOSEAlgNotAllowed('\"alg\" (Algorithm) Header Parameter value not allowed');\n }\n if (b64) {\n if (typeof jws.payload !== 'string') {\n throw new JWSInvalid('JWS Payload must be a string');\n }\n }\n else if (typeof jws.payload !== 'string' && !(jws.payload instanceof Uint8Array)) {\n throw new JWSInvalid('JWS Payload must be a string or an Uint8Array instance');\n }\n let resolvedKey = false;\n if (typeof key === 'function') {\n key = await key(parsedProt, jws);\n resolvedKey = true;\n }\n checkKeyType(alg, key, 'verify');\n const data = concat(jws.protected !== undefined ? encode(jws.protected) : new Uint8Array(), encode('.'), typeof jws.payload === 'string'\n ? b64\n ? encode(jws.payload)\n : encoder.encode(jws.payload)\n : jws.payload);\n const signature = decodeBase64url(jws.signature, 'signature', JWSInvalid);\n const k = await normalizeKey(key, alg);\n const verified = await verify(alg, k, signature, data);\n if (!verified) {\n throw new JWSSignatureVerificationFailed();\n }\n let payload;\n if (b64) {\n payload = decodeBase64url(jws.payload, 'payload', JWSInvalid);\n }\n else if (typeof jws.payload === 'string') {\n payload = encoder.encode(jws.payload);\n }\n else {\n payload = jws.payload;\n }\n const result = { payload };\n if (jws.protected !== undefined) {\n result.protectedHeader = parsedProt;\n }\n if (jws.header !== undefined) {\n result.unprotectedHeader = jws.header;\n }\n if (resolvedKey) {\n return { ...result, key: k };\n }\n return result;\n}\n","import { flattenedVerify } from '../flattened/verify.js';\nimport { JWSInvalid } from '../../util/errors.js';\nimport { decoder } from '../../lib/buffer_utils.js';\nexport async function compactVerify(jws, key, options) {\n if (jws instanceof Uint8Array) {\n jws = decoder.decode(jws);\n }\n if (typeof jws !== 'string') {\n throw new JWSInvalid('Compact JWS must be a string or Uint8Array');\n }\n const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split('.');\n if (length !== 3) {\n throw new JWSInvalid('Invalid Compact JWS');\n }\n const verified = await flattenedVerify({ payload, protected: protectedHeader, signature }, key, options);\n const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };\n if (typeof key === 'function') {\n return { ...result, key: verified.key };\n }\n return result;\n}\n","/**\n * Runtime loader for @middag-io/licensing.\n *\n * Runs inside the consuming host (Moodle, WordPress, ...). The browser never\n * calls the worker's HMAC-protected `/v1/protected/manifest` endpoint — the\n * PHP host bridge does that, persists the `ManifestResponse`, and serves it\n * to the browser at `manifest_url` (per ADR-012 §\"Server-side host bridge\").\n *\n * This loader:\n *\n * 1. Fetches the manifest JSON from the host-served URL (or via a caller-\n * supplied `fetchManifest` for embedded use cases).\n * 2. Verifies the JWS signature against the worker's JWKS endpoint\n * `${workerOrigin}/api/protected/jwks` (cached in-memory per kid).\n * 3. Validates the decoded payload against the bootstrap context\n * (`install_id`, `host_origin`, `host_type`, `product`, `contract_version`)\n * so a manifest swapped between installs is rejected client-side.\n * 4. Loads a requested module by fetching its CDN URL, recomputing the\n * SRI hash against the bytes, and dynamic-importing from a Blob URL.\n * Native `import()` does not yet take an integrity attribute, so we\n * compute SRI ourselves before handing the bytes to the JS engine.\n */\n\nimport { compactVerify, importJWK, type JWK } from \"jose\";\nimport {\n CONTRACT_VERSION,\n type AuthorizedManifest,\n type HostType,\n type ManifestResponse,\n} from \"../contract/index.js\";\n\nexport interface CreateLicensingClientOptions {\n hostType: HostType;\n hostOrigin: string;\n product: string;\n installId: string;\n /**\n * Worker base origin used to fetch the JWKS, e.g.\n * `https://licensing.middag.io`. Required unless `jwks` is supplied.\n */\n workerOrigin?: string;\n /**\n * Static JWKS document (escape hatch for tests / pre-fetched keys).\n * When supplied, the loader skips the network fetch.\n */\n jwks?: { keys: JWK[] };\n /**\n * Manifest URL served by the host (PHP bridge). The body must be the\n * JSON shape worker returns from POST /v1/protected/manifest.\n */\n manifestUrl?: string;\n /** Caller-supplied manifest fetcher; overrides `manifestUrl` when given. */\n fetchManifest?: () => Promise<ManifestResponse>;\n /**\n * Fetch implementation override. Defaults to `globalThis.fetch`. Tests\n * can pass a mock here; SSR contexts can pass a polyfill.\n */\n fetch?: typeof fetch;\n /**\n * Clock skew tolerance in seconds when checking `bundle_expires_at`.\n * Defaults to 60s.\n */\n clockSkewSeconds?: number;\n}\n\nexport interface LicensingClient {\n readonly manifest: AuthorizedManifest;\n readonly response: ManifestResponse;\n has(moduleName: string): boolean;\n loadModule<T = unknown>(moduleName: string): Promise<T>;\n refresh(): Promise<AuthorizedManifest>;\n}\n\ninterface JwksDocument {\n keys: JWK[];\n}\n\nconst JWKS_PATH = \"/api/protected/jwks\";\n\nclass JwksCache {\n private byKid = new Map<string, CryptoKey>();\n constructor(\n private readonly fetcher: typeof fetch,\n private readonly endpoint: string | undefined,\n private readonly staticDoc?: JwksDocument,\n ) {}\n\n async resolve(kid: string): Promise<CryptoKey> {\n const cached = this.byKid.get(kid);\n if (cached) return cached;\n\n const doc = await this.loadDocument();\n const jwk = doc.keys.find((k) => k.kid === kid);\n if (!jwk) {\n throw new LicensingError(\n \"jwks_kid_not_found\",\n `manifest signing kid \"${kid}\" not present in JWKS`,\n );\n }\n const key = (await importJWK(jwk, \"EdDSA\")) as CryptoKey;\n this.byKid.set(kid, key);\n return key;\n }\n\n private async loadDocument(): Promise<JwksDocument> {\n if (this.staticDoc) return this.staticDoc;\n if (!this.endpoint) {\n throw new LicensingError(\n \"jwks_endpoint_missing\",\n \"workerOrigin (or static jwks) must be supplied to verify the manifest\",\n );\n }\n const res = await this.fetcher(this.endpoint, {\n headers: { accept: \"application/json\" },\n });\n if (!res.ok) {\n throw new LicensingError(\n \"jwks_fetch_failed\",\n `JWKS fetch failed: ${res.status} ${res.statusText}`,\n );\n }\n const doc = (await res.json()) as JwksDocument;\n if (!doc || !Array.isArray(doc.keys)) {\n throw new LicensingError(\"jwks_malformed\", \"JWKS response did not contain a keys array\");\n }\n return doc;\n }\n}\n\nexport class LicensingError extends Error {\n constructor(\n public readonly code: string,\n message: string,\n ) {\n super(message);\n this.name = \"LicensingError\";\n }\n}\n\nfunction nowSec(): number {\n return Math.floor(Date.now() / 1000);\n}\n\nasync function fetchManifestDefault(fetcher: typeof fetch, url: string): Promise<ManifestResponse> {\n const res = await fetcher(url, { headers: { accept: \"application/json\" } });\n if (!res.ok) {\n throw new LicensingError(\n \"manifest_fetch_failed\",\n `manifest fetch failed: ${res.status} ${res.statusText}`,\n );\n }\n return (await res.json()) as ManifestResponse;\n}\n\nfunction decodeJwsHeader(jws: string): { alg: string; kid: string; typ?: string } {\n const dot = jws.indexOf(\".\");\n if (dot <= 0) {\n throw new LicensingError(\"jws_malformed\", \"JWS missing header segment\");\n }\n const headerB64 = jws.slice(0, dot);\n const json = atob(headerB64.replace(/-/g, \"+\").replace(/_/g, \"/\"));\n const header = JSON.parse(json) as { alg?: string; kid?: string; typ?: string };\n if (typeof header.alg !== \"string\" || typeof header.kid !== \"string\") {\n throw new LicensingError(\"jws_header_invalid\", \"JWS header missing alg or kid\");\n }\n return { alg: header.alg, kid: header.kid, typ: header.typ };\n}\n\nfunction assertEqual(field: string, actual: unknown, expected: unknown): void {\n if (actual !== expected) {\n throw new LicensingError(\n \"manifest_field_mismatch\",\n `manifest ${field} does not match bootstrap (got ${JSON.stringify(actual)}, expected ${JSON.stringify(expected)})`,\n );\n }\n}\n\ninterface VerifiedManifest {\n payload: AuthorizedManifest;\n response: ManifestResponse;\n}\n\nasync function verifyAndValidate(\n options: CreateLicensingClientOptions,\n jwks: JwksCache,\n response: ManifestResponse,\n): Promise<VerifiedManifest> {\n const header = decodeJwsHeader(response.jws);\n if (header.alg !== \"EdDSA\") {\n throw new LicensingError(\n \"jws_alg_unsupported\",\n `unsupported JWS alg \"${header.alg}\" — expected EdDSA`,\n );\n }\n if (header.kid !== response.signing_kid) {\n throw new LicensingError(\n \"jws_kid_mismatch\",\n \"JWS header kid does not match response signing_kid\",\n );\n }\n\n const key = await jwks.resolve(header.kid);\n let verified;\n try {\n verified = await compactVerify(response.jws, key);\n } catch (err) {\n throw new LicensingError(\n \"jws_signature_invalid\",\n `JWS verification failed: ${(err as Error).message}`,\n );\n }\n\n const payload = JSON.parse(new TextDecoder().decode(verified.payload)) as AuthorizedManifest;\n\n const skew = options.clockSkewSeconds ?? 60;\n const now = nowSec();\n if (payload.bundle_expires_at + skew < now) {\n throw new LicensingError(\n \"manifest_expired\",\n `manifest expired at ${payload.bundle_expires_at} (now=${now})`,\n );\n }\n\n assertEqual(\"install_id\", payload.install_id, options.installId);\n assertEqual(\"host_origin\", payload.host_origin, options.hostOrigin);\n assertEqual(\"host_type\", payload.host_type, options.hostType);\n assertEqual(\"product\", payload.product, options.product);\n assertEqual(\"contract_version\", payload.contract_version, CONTRACT_VERSION);\n\n return { payload, response };\n}\n\nasync function loadModuleBytes(\n fetcher: typeof fetch,\n url: string,\n integrity: string,\n): Promise<ArrayBuffer> {\n const res = await fetcher(url, {\n headers: { accept: \"application/javascript, text/javascript\" },\n });\n if (!res.ok) {\n throw new LicensingError(\n \"module_fetch_failed\",\n `module fetch failed for ${url}: ${res.status} ${res.statusText}`,\n );\n }\n const bytes = await res.arrayBuffer();\n await assertSri(bytes, integrity, url);\n return bytes;\n}\n\nasync function assertSri(bytes: ArrayBuffer, integrity: string, url: string): Promise<void> {\n const match = /^sha384-(.+)$/.exec(integrity);\n if (!match) {\n throw new LicensingError(\n \"module_integrity_unsupported\",\n `unsupported integrity hash format for ${url}: ${integrity}`,\n );\n }\n const expected = match[1]!;\n const digest = await crypto.subtle.digest(\"SHA-384\", bytes);\n const actual = bytesToBase64(new Uint8Array(digest));\n if (actual !== expected) {\n throw new LicensingError(\n \"module_integrity_mismatch\",\n `module bytes did not match SRI for ${url}`,\n );\n }\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n let bin = \"\";\n for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]!);\n return btoa(bin);\n}\n\nexport async function createLicensingClient(\n options: CreateLicensingClientOptions,\n): Promise<LicensingClient> {\n const fetcher = options.fetch ?? globalThis.fetch?.bind(globalThis);\n if (!fetcher) {\n throw new LicensingError(\"fetch_unavailable\", \"no global fetch and no options.fetch supplied\");\n }\n\n const jwksEndpoint = options.workerOrigin\n ? `${options.workerOrigin.replace(/\\/$/, \"\")}${JWKS_PATH}`\n : undefined;\n const jwks = new JwksCache(fetcher, jwksEndpoint, options.jwks);\n\n const fetchManifestFn = async (): Promise<ManifestResponse> => {\n if (options.fetchManifest) return options.fetchManifest();\n if (!options.manifestUrl) {\n throw new LicensingError(\n \"manifest_source_missing\",\n \"either manifestUrl or fetchManifest must be supplied\",\n );\n }\n return fetchManifestDefault(fetcher, options.manifestUrl);\n };\n\n let current = await verifyAndValidate(options, jwks, await fetchManifestFn());\n\n const moduleCache = new Map<string, unknown>();\n\n async function loadModule<T>(name: string): Promise<T> {\n if (moduleCache.has(name)) return moduleCache.get(name) as T;\n const mod = current.payload.modules.find((m) => m.name === name);\n if (!mod) {\n throw new LicensingError(\n \"module_not_authorized\",\n `module \"${name}\" is not present in the current manifest`,\n );\n }\n const bytes = await loadModuleBytes(fetcher, mod.url, mod.integrity);\n const blob = new Blob([bytes], { type: \"application/javascript\" });\n const blobUrl = URL.createObjectURL(blob);\n try {\n const imported = (await import(/* @vite-ignore */ blobUrl)) as T;\n moduleCache.set(name, imported);\n return imported;\n } finally {\n URL.revokeObjectURL(blobUrl);\n }\n }\n\n async function refresh(): Promise<AuthorizedManifest> {\n const next = await verifyAndValidate(options, jwks, await fetchManifestFn());\n current = next;\n moduleCache.clear();\n return next.payload;\n }\n\n return {\n get manifest() {\n return current.payload;\n },\n get response() {\n return current.response;\n },\n has(moduleName: string) {\n return current.payload.modules.some((m) => m.name === moduleName);\n },\n loadModule,\n refresh,\n };\n}\n\nexport { CONTRACT_VERSION };\nexport type { AuthorizedManifest, HostType, ManifestResponse };\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],"mappings":";;AAAA,IAAa,UAAU,IAAI,YAAY;AACvC,IAAa,UAAU,IAAI,YAAY;AAEvC,SAAgB,OAAO,GAAG,SAAS;CAC/B,MAAM,OAAO,QAAQ,QAAQ,KAAK,EAAE,aAAa,MAAM,QAAQ,CAAC;CAChE,MAAM,MAAM,IAAI,WAAW,IAAI;CAC/B,IAAI,IAAI;CACR,KAAK,MAAM,UAAU,SAAS;EAC1B,IAAI,IAAI,QAAQ,CAAC;EACjB,KAAK,OAAO;CAChB;CACA,OAAO;AACX;AAoBA,SAAgB,OAAO,QAAQ;CAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,MAAM;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACpC,MAAM,OAAO,OAAO,WAAW,CAAC;EAChC,IAAI,OAAO,KACP,MAAM,IAAI,UAAU,0CAA0C;EAElE,MAAM,KAAK;CACf;CACA,OAAO;AACX;;;AC/BA,SAAgB,aAAa,SAAS;CAClC,IAAI,WAAW,YACX,OAAO,WAAW,WAAW,OAAO;CAExC,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,MAAM;CAC1C,KAAK,IAAI,IAAI,GAAG,IAA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IAAI,gBAAgB,IAAI;EACxC,IAAI;GACF,MAAM,WAAY,MAAM;;IAA0B;;GAClD,YAAY,IAAI,MAAM,QAAQ;GAC9B,OAAO;EACT,UAAU;GACR,IAAI,gBAAgB,OAAO;EAC7B;CACF;CAEA,eAAe,UAAuC;EACpD,MAAM,OAAO,MAAM,kBAAkB,SAAS,MAAM,MAAM,gBAAgB,CAAC;EAC3E,UAAU;EACV,YAAY,MAAM;EAClB,OAAO,KAAK;CACd;CAEA,OAAO;EACL,IAAI,WAAW;GACb,OAAO,QAAQ;EACjB;EACA,IAAI,WAAW;GACb,OAAO,QAAQ;EACjB;EACA,IAAI,YAAoB;GACtB,OAAO,QAAQ,QAAQ,QAAQ,MAAM,MAAM,EAAE,SAAS,UAAU;EAClE;EACA;EACA;CACF;AACF"}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Shared contract for @middag-io/licensing.
3
+ *
4
+ * Owns the technical schema of manifest, placeholders, and TypeScript types
5
+ * exchanged between build, client, and worker. Policy values (license state,
6
+ * authorized installs, entitlements, signed URLs) are owned by the worker.
7
+ *
8
+ * Adding a placeholder or breaking a manifest field bumps CONTRACT_VERSION.
9
+ */
10
+ export declare const CONTRACT_VERSION: "1.0.0";
11
+ /**
12
+ * Tokens substituted by the worker at materialization time. The names are
13
+ * semantic so a developer reading a protected source can tell what each
14
+ * marker becomes — the protection comes from server-side authorization, not
15
+ * obfuscation of the marker. See ADR-012 §"Protection model".
16
+ *
17
+ * These 5 tokens are the locked contract. Worker code at
18
+ * `src/lib/manifest-materialize.ts:PLACEHOLDERS` MUST mirror this set.
19
+ * Adding, renaming, or removing a token bumps CONTRACT_VERSION.
20
+ */
21
+ export declare const PLACEHOLDERS: {
22
+ readonly host_origin: "__MIDDAG_HOST_ORIGIN__";
23
+ readonly install_id: "__MIDDAG_INSTALL_ID__";
24
+ readonly kid: "__MIDDAG_KID__";
25
+ readonly bundle_expires_at: "__MIDDAG_BUNDLE_EXPIRES_AT__";
26
+ readonly nonce: "__MIDDAG_NONCE__";
27
+ };
28
+ export type PlaceholderKey = keyof typeof PLACEHOLDERS;
29
+ export type PlaceholderToken = (typeof PLACEHOLDERS)[PlaceholderKey];
30
+ export declare const PLACEHOLDER_TOKENS: readonly PlaceholderToken[];
31
+ export type HostType = "moodle" | "wordpress" | (string & {});
32
+ /**
33
+ * Canonical host identity. Products map their platform-specific fields
34
+ * (Moodle `wwwroot`, WordPress `wp_home`, etc.) into these names. `host_key`
35
+ * is computed server-side (sha256 of host_origin) and never round-tripped
36
+ * from the client.
37
+ */
38
+ export interface HostIdentity {
39
+ host_origin: string;
40
+ host_type: HostType;
41
+ install_id: string;
42
+ }
43
+ /**
44
+ * Per-module entry shape used by the build plugin. The worker resolves the
45
+ * final URL and SRI at materialization; the build plugin only declares which
46
+ * compiled artifact carries which logical module name.
47
+ */
48
+ export interface ModuleDefinition {
49
+ /** Logical module name used in the AuthorizedManifest. */
50
+ name: string;
51
+ /** Path to the emitted artifact, relative to Vite `outDir`. */
52
+ entry: string;
53
+ /** Optional commercial/functional grouping. */
54
+ extension?: string;
55
+ /** Entitlement keys that gate this module. Empty = always allowed. */
56
+ entitlements?: string[];
57
+ }
58
+ /**
59
+ * Template manifest emitted by the build plugin. Carries no install state.
60
+ * The worker consumes it as the source of truth for "what modules exist for
61
+ * this product/release/build" and produces an `AuthorizedManifest` from it.
62
+ *
63
+ * `hash_sha384` is computed over the *placeholder-bearing* template bytes.
64
+ * It is informational at this stage — the worker recomputes a fresh
65
+ * post-substitution SRI hash per install.
66
+ */
67
+ export interface ManifestTemplate {
68
+ contract_version: typeof CONTRACT_VERSION;
69
+ product: string;
70
+ release: string;
71
+ build_id: string;
72
+ modules: Array<ModuleDefinition & {
73
+ filename: string;
74
+ hash_sha384: string;
75
+ placeholders_seen: PlaceholderKey[];
76
+ }>;
77
+ }
78
+ /**
79
+ * Decoded payload of the JWS the worker issues per install. Mirrors the
80
+ * payload built in `src/routes/protected-manifest.ts:manifestHandler`.
81
+ *
82
+ * `bundle_expires_at` and `issued_at` are unix seconds (UTC) so they survive
83
+ * JSON without ISO-string parsing cost. Modules carry post-substitution
84
+ * SRI integrity strings (`sha384-...`).
85
+ */
86
+ export interface AuthorizedManifest {
87
+ iss: string;
88
+ install_id: string;
89
+ host_origin: string;
90
+ host_type: HostType;
91
+ product: string;
92
+ release: string;
93
+ build_id: string;
94
+ bundle_kid: string;
95
+ contract_version: string;
96
+ bundle_expires_at: number;
97
+ issued_at: number;
98
+ nonce: string;
99
+ modules: Array<{
100
+ name: string;
101
+ url: string;
102
+ integrity: string;
103
+ }>;
104
+ }
105
+ /**
106
+ * HTTP response shape from the worker's POST /v1/protected/manifest endpoint.
107
+ * The PHP host bridge calls the worker (HMAC-authenticated) and persists
108
+ * this payload. The browser client receives the same shape via the
109
+ * Inertia bootstrap or a host-served `/manifest` URL — it never calls the
110
+ * worker directly because the browser cannot hold the ingest secret.
111
+ */
112
+ export interface ManifestResponse {
113
+ jws: string;
114
+ signing_kid: string;
115
+ bundle_kid: string;
116
+ build_id: string;
117
+ contract_version: string;
118
+ bundle_expires_at: number;
119
+ materialized_at: number;
120
+ etag: string;
121
+ modules_count: number;
122
+ }
123
+ /**
124
+ * Inertia SharedProps payload the PHP library hands to the page so the JS
125
+ * client knows where to fetch the manifest and which keys to expect. Names
126
+ * mirror the worker contract so no per-host translation is needed.
127
+ */
128
+ export interface LicensingBootstrap {
129
+ install_id: string;
130
+ host_origin: string;
131
+ host_type: HostType;
132
+ product: string;
133
+ manifest_url: string;
134
+ manifest_etag?: string;
135
+ expires_at: number;
136
+ contract_version: string;
137
+ }
138
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,gBAAgB,EAAG,OAAgB,CAAC;AAEjD;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY;;;;;;CAMf,CAAC;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AAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;CACJ;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,33 @@
1
+ //#region src/contract/index.ts
2
+ /**
3
+ * Shared contract for @middag-io/licensing.
4
+ *
5
+ * Owns the technical schema of manifest, placeholders, and TypeScript types
6
+ * exchanged between build, client, and worker. Policy values (license state,
7
+ * authorized installs, entitlements, signed URLs) are owned by the worker.
8
+ *
9
+ * Adding a placeholder or breaking a manifest field bumps CONTRACT_VERSION.
10
+ */
11
+ var CONTRACT_VERSION = "1.0.0";
12
+ /**
13
+ * Tokens substituted by the worker at materialization time. The names are
14
+ * semantic so a developer reading a protected source can tell what each
15
+ * marker becomes — the protection comes from server-side authorization, not
16
+ * obfuscation of the marker. See ADR-012 §"Protection model".
17
+ *
18
+ * These 5 tokens are the locked contract. Worker code at
19
+ * `src/lib/manifest-materialize.ts:PLACEHOLDERS` MUST mirror this set.
20
+ * Adding, renaming, or removing a token bumps CONTRACT_VERSION.
21
+ */
22
+ var PLACEHOLDERS = {
23
+ host_origin: "__MIDDAG_HOST_ORIGIN__",
24
+ install_id: "__MIDDAG_INSTALL_ID__",
25
+ kid: "__MIDDAG_KID__",
26
+ bundle_expires_at: "__MIDDAG_BUNDLE_EXPIRES_AT__",
27
+ nonce: "__MIDDAG_NONCE__"
28
+ };
29
+ var PLACEHOLDER_TOKENS = Object.values(PLACEHOLDERS);
30
+ //#endregion
31
+ export { CONTRACT_VERSION, PLACEHOLDERS, PLACEHOLDER_TOKENS };
32
+
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/contract/index.ts"],"sourcesContent":["/**\n * Shared contract for @middag-io/licensing.\n *\n * Owns the technical schema of manifest, placeholders, and TypeScript types\n * exchanged between build, client, and worker. Policy values (license state,\n * authorized installs, entitlements, signed URLs) are owned by the worker.\n *\n * Adding a placeholder or breaking a manifest field bumps CONTRACT_VERSION.\n */\n\nexport const CONTRACT_VERSION = \"1.0.0\" as const;\n\n/**\n * Tokens substituted by the worker at materialization time. The names are\n * semantic so a developer reading a protected source can tell what each\n * marker becomes — the protection comes from server-side authorization, not\n * obfuscation of the marker. See ADR-012 §\"Protection model\".\n *\n * These 5 tokens are the locked contract. Worker code at\n * `src/lib/manifest-materialize.ts:PLACEHOLDERS` MUST mirror this set.\n * Adding, renaming, or removing a token bumps CONTRACT_VERSION.\n */\nexport const PLACEHOLDERS = {\n host_origin: \"__MIDDAG_HOST_ORIGIN__\",\n install_id: \"__MIDDAG_INSTALL_ID__\",\n kid: \"__MIDDAG_KID__\",\n bundle_expires_at: \"__MIDDAG_BUNDLE_EXPIRES_AT__\",\n nonce: \"__MIDDAG_NONCE__\",\n} as const;\n\nexport type PlaceholderKey = keyof typeof PLACEHOLDERS;\nexport type PlaceholderToken = (typeof PLACEHOLDERS)[PlaceholderKey];\n\nexport const PLACEHOLDER_TOKENS: readonly PlaceholderToken[] = Object.values(PLACEHOLDERS);\n\nexport type HostType = \"moodle\" | \"wordpress\" | (string & {});\n\n/**\n * Canonical host identity. Products map their platform-specific fields\n * (Moodle `wwwroot`, WordPress `wp_home`, etc.) into these names. `host_key`\n * is computed server-side (sha256 of host_origin) and never round-tripped\n * from the client.\n */\nexport interface HostIdentity {\n host_origin: string;\n host_type: HostType;\n install_id: string;\n}\n\n/**\n * Per-module entry shape used by the build plugin. The worker resolves the\n * final URL and SRI at materialization; the build plugin only declares which\n * compiled artifact carries which logical module name.\n */\nexport interface ModuleDefinition {\n /** Logical module name used in the AuthorizedManifest. */\n name: string;\n /** Path to the emitted artifact, relative to Vite `outDir`. */\n entry: string;\n /** Optional commercial/functional grouping. */\n extension?: string;\n /** Entitlement keys that gate this module. Empty = always allowed. */\n entitlements?: string[];\n}\n\n/**\n * Template manifest emitted by the build plugin. Carries no install state.\n * The worker consumes it as the source of truth for \"what modules exist for\n * this product/release/build\" and produces an `AuthorizedManifest` from it.\n *\n * `hash_sha384` is computed over the *placeholder-bearing* template bytes.\n * It is informational at this stage — the worker recomputes a fresh\n * post-substitution SRI hash per install.\n */\nexport interface ManifestTemplate {\n contract_version: typeof CONTRACT_VERSION;\n product: string;\n release: string;\n build_id: string;\n modules: Array<\n ModuleDefinition & {\n filename: string;\n hash_sha384: string;\n placeholders_seen: PlaceholderKey[];\n }\n >;\n}\n\n/**\n * Decoded payload of the JWS the worker issues per install. Mirrors the\n * payload built in `src/routes/protected-manifest.ts:manifestHandler`.\n *\n * `bundle_expires_at` and `issued_at` are unix seconds (UTC) so they survive\n * JSON without ISO-string parsing cost. Modules carry post-substitution\n * SRI integrity strings (`sha384-...`).\n */\nexport interface AuthorizedManifest {\n iss: string;\n install_id: string;\n host_origin: string;\n host_type: HostType;\n product: string;\n release: string;\n build_id: string;\n bundle_kid: string;\n contract_version: string;\n bundle_expires_at: number;\n issued_at: number;\n nonce: string;\n modules: Array<{\n name: string;\n url: string;\n integrity: string;\n }>;\n}\n\n/**\n * HTTP response shape from the worker's POST /v1/protected/manifest endpoint.\n * The PHP host bridge calls the worker (HMAC-authenticated) and persists\n * this payload. The browser client receives the same shape via the\n * Inertia bootstrap or a host-served `/manifest` URL — it never calls the\n * worker directly because the browser cannot hold the ingest secret.\n */\nexport interface ManifestResponse {\n jws: string;\n signing_kid: string;\n bundle_kid: string;\n build_id: string;\n contract_version: string;\n bundle_expires_at: number;\n materialized_at: number;\n etag: string;\n modules_count: number;\n}\n\n/**\n * Inertia SharedProps payload the PHP library hands to the page so the JS\n * client knows where to fetch the manifest and which keys to expect. Names\n * mirror the worker contract so no per-host translation is needed.\n */\nexport interface LicensingBootstrap {\n install_id: string;\n host_origin: string;\n host_type: HostType;\n product: string;\n manifest_url: string;\n manifest_etag?: string;\n expires_at: number;\n contract_version: string;\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,mBAAmB;;;;;;;;;;;AAYhC,IAAa,eAAe;CAC1B,aAAa;CACb,YAAY;CACZ,KAAK;CACL,mBAAmB;CACnB,OAAO;AACT;AAKA,IAAa,qBAAkD,OAAO,OAAO,YAAY"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Root barrel for @middag-io/licensing.
3
+ *
4
+ * Re-exports the contract surface so consumers can pull shared types from
5
+ * the root import. Build- and client-only code stay behind their subpath
6
+ * exports (`/build`, `/client`).
7
+ */
8
+ export * from "./contract/index.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { CONTRACT_VERSION, PLACEHOLDERS, PLACEHOLDER_TOKENS } from "./contract/index.js";
2
+ export { CONTRACT_VERSION, PLACEHOLDERS, PLACEHOLDER_TOKENS };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@middag-io/licensing",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "MIDDAG protected code delivery — build-time placeholder injection, manifest contract, and runtime loader for licensed JS modules",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/middag-io/middag-js-licensing.git"
9
+ },
10
+ "engines": {
11
+ "node": ">=20.0.0"
12
+ },
13
+ "main": "dist/index.js",
14
+ "module": "dist/index.js",
15
+ "types": "dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/index.js",
19
+ "types": "./dist/index.d.ts"
20
+ },
21
+ "./contract": {
22
+ "import": "./dist/contract/index.js",
23
+ "types": "./dist/contract/index.d.ts"
24
+ },
25
+ "./build": {
26
+ "import": "./dist/build/index.js",
27
+ "types": "./dist/build/index.d.ts"
28
+ },
29
+ "./client": {
30
+ "import": "./dist/client/index.js",
31
+ "types": "./dist/client/index.d.ts"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "peerDependencies": {
38
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "vite": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "dependencies": {
46
+ "jose": "^6.2.3"
47
+ }
48
+ }