@sphereon/ssi-sdk.sd-jwt 0.33.1-feature.vcdm2.tsup.31 → 0.33.1-next.2

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.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/action-handler.ts","../src/defaultCallbacks.ts","../src/trustAnchors.ts","../src/utils.ts","../src/types.ts"],"sourcesContent":["import { Jwt, SDJwt } from '@sd-jwt/core'\nimport { SDJwtVcInstance, SdJwtVcPayload } from '@sd-jwt/sd-jwt-vc'\nimport { DisclosureFrame, Hasher, JwtPayload, KbVerifier, PresentationFrame, Signer, Verifier } from '@sd-jwt/types'\nimport { calculateJwkThumbprint, signatureAlgorithmFromKey } from '@sphereon/ssi-sdk-ext.key-utils'\nimport { X509CertificateChainValidationOpts } from '@sphereon/ssi-sdk-ext.x509-utils'\nimport { HasherSync, JsonWebKey, JWK, SdJwtTypeMetadata } from '@sphereon/ssi-types'\nimport { IAgentPlugin } from '@veramo/core'\nimport { decodeBase64url } from '@veramo/utils'\nimport Debug from 'debug'\nimport { defaultGenerateDigest, defaultGenerateSalt, defaultVerifySignature } from './defaultCallbacks'\nimport { funkeTestCA, sphereonCA } from './trustAnchors'\nimport { assertValidTypeMetadata, fetchUrlWithErrorHandling, validateIntegrity } from './utils'\nimport {\n Claims,\n FetchSdJwtTypeMetadataFromVctUrlArgs,\n GetSignerForIdentifierArgs,\n GetSignerResult,\n ICreateSdJwtPresentationArgs,\n ICreateSdJwtPresentationResult,\n ICreateSdJwtVcArgs,\n ICreateSdJwtVcResult,\n IRequiredContext,\n ISDJwtPlugin,\n IVerifySdJwtPresentationArgs,\n IVerifySdJwtPresentationResult,\n IVerifySdJwtVcArgs,\n IVerifySdJwtVcResult,\n SdJWTImplementation,\n SdJwtVerifySignature,\n SignKeyArgs,\n SignKeyResult,\n} from './types'\n\nconst debug = Debug('@sphereon/ssi-sdk.sd-jwt')\n\n/**\n * @beta\n * SD-JWT plugin\n */\nexport class SDJwtPlugin implements IAgentPlugin {\n // @ts-ignore\n private readonly trustAnchorsInPEM: string[]\n private readonly registeredImplementations: SdJWTImplementation\n private _signers: Record<string, Signer>\n private _defaultSigner?: Signer\n\n constructor(\n registeredImplementations?: SdJWTImplementation & {\n signers?: Record<string, Signer>\n defaultSigner?: Signer\n },\n trustAnchorsInPEM?: string[],\n ) {\n this.trustAnchorsInPEM = trustAnchorsInPEM ?? []\n if (!registeredImplementations) {\n registeredImplementations = {}\n }\n if (typeof registeredImplementations?.hasher !== 'function') {\n registeredImplementations.hasher = defaultGenerateDigest\n }\n if (typeof registeredImplementations?.saltGenerator !== 'function') {\n registeredImplementations.saltGenerator = defaultGenerateSalt\n }\n this.registeredImplementations = registeredImplementations\n this._signers = registeredImplementations?.signers ?? {}\n this._defaultSigner = registeredImplementations?.defaultSigner\n\n // Verify signature default is used below in the methods if not provided here, as it needs the context of the agent\n }\n\n // map the methods your plugin is declaring to their implementation\n readonly methods: ISDJwtPlugin = {\n createSdJwtVc: this.createSdJwtVc.bind(this),\n createSdJwtPresentation: this.createSdJwtPresentation.bind(this),\n verifySdJwtVc: this.verifySdJwtVc.bind(this),\n verifySdJwtPresentation: this.verifySdJwtPresentation.bind(this),\n fetchSdJwtTypeMetadataFromVctUrl: this.fetchSdJwtTypeMetadataFromVctUrl.bind(this),\n }\n\n private async getSignerForIdentifier(args: GetSignerForIdentifierArgs, context: IRequiredContext): Promise<GetSignerResult> {\n const { identifier, resolution } = args\n if (Object.keys(this._signers).includes(identifier) && typeof this._signers[identifier] === 'function') {\n return { signer: this._signers[identifier] }\n } else if (typeof this._defaultSigner === 'function') {\n return { signer: this._defaultSigner }\n }\n const signingKey = await this.getSignKey({ identifier, vmRelationship: 'assertionMethod', resolution }, context)\n const { key, alg } = signingKey\n\n const signer: Signer = async (data: string): Promise<string> => {\n return context.agent.keyManagerSign({ keyRef: key.kmsKeyRef, data })\n }\n\n return { signer, alg, signingKey }\n }\n\n /**\n * Create a signed SD-JWT credential.\n * @param args - Arguments necessary for the creation of a SD-JWT credential.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n * @returns A signed SD-JWT credential.\n */\n async createSdJwtVc(args: ICreateSdJwtVcArgs, context: IRequiredContext): Promise<ICreateSdJwtVcResult> {\n const issuer = args.credentialPayload.iss\n if (!issuer) {\n throw new Error('credential.issuer must not be empty')\n }\n const { alg, signer, signingKey } = await this.getSignerForIdentifier({ identifier: issuer, resolution: args.resolution }, context)\n const sdjwt = new SDJwtVcInstance({\n signer,\n hasher: this.registeredImplementations.hasher,\n saltGenerator: this.registeredImplementations.saltGenerator,\n signAlg: alg ?? 'ES256',\n hashAlg: 'sha-256',\n })\n\n const credential = await sdjwt.issue(args.credentialPayload, args.disclosureFrame as DisclosureFrame<typeof args.credentialPayload>, {\n header: {\n ...(signingKey?.key.kid !== undefined && { kid: signingKey.key.kid }),\n ...(signingKey?.key.x5c !== undefined && { x5c: signingKey.key.x5c }),\n },\n })\n\n return { credential }\n }\n\n /**\n * Get the key to sign the SD-JWT\n * @param args - consists of twp arguments: identifier like a did and other forms of identifiers and vmRelationship which represents the purpose of the key\n * @param context - agent instance\n * @returns the key to sign the SD-JWT\n */\n async getSignKey(args: SignKeyArgs, context: IRequiredContext): Promise<SignKeyResult> {\n // TODO Using identifierManagedGetByDid now (new managed identifier resolution). Evaluate of we need to implement more identifier types here\n const { identifier, resolution } = { ...args }\n if (resolution) {\n const key = resolution.key\n const alg = await signatureAlgorithmFromKey({ key })\n switch (resolution.method) {\n case 'did':\n debug(`Signing key ${key.publicKeyHex} found for identifier ${identifier}`)\n return { alg, key: { ...key, kmsKeyRef: resolution.kmsKeyRef, kid: resolution.kid } }\n default:\n if (key.meta?.x509 && key.meta.x509.x5c) {\n return { alg, key: { kid: resolution.kid, kmsKeyRef: resolution.kmsKeyRef, x5c: key.meta.x509.x5c as string[] } }\n } else if (key.meta?.jwkThumbprint) {\n return { alg, key: { kid: resolution.kid, kmsKeyRef: resolution.kmsKeyRef, jwkThumbprint: key.meta.jwkThumbprint } }\n } else {\n return { alg, key: { kid: resolution.kid, kmsKeyRef: resolution.kmsKeyRef } }\n }\n }\n } else if (identifier.startsWith('did:')) {\n const didIdentifier = await context.agent.identifierManagedGetByDid({ identifier })\n if (!didIdentifier) {\n throw new Error(`No identifier found with the given did: ${identifier}`)\n }\n const key = didIdentifier.key\n const alg = await signatureAlgorithmFromKey({ key })\n debug(`Signing key ${key.publicKeyHex} found for identifier ${identifier}`)\n\n return { alg, key: { ...key, kmsKeyRef: didIdentifier.kmsKeyRef, kid: didIdentifier.kid } }\n } else {\n const kidIdentifier = await context.agent.identifierManagedGetByKid({ identifier })\n if (!kidIdentifier) {\n throw new Error(`No identifier found with the given kid: ${identifier}`)\n }\n const key = kidIdentifier.key\n const alg = await signatureAlgorithmFromKey({ key })\n if (key.meta?.x509 && key.meta.x509.x5c) {\n return { alg, key: { kid: kidIdentifier.kid, kmsKeyRef: kidIdentifier.kmsKeyRef, x5c: key.meta.x509.x5c as string[] } }\n } else if (key.meta?.jwkThumbprint) {\n return { alg, key: { kid: kidIdentifier.kid, kmsKeyRef: kidIdentifier.kmsKeyRef, jwkThumbprint: key.meta.jwkThumbprint } }\n } else {\n return { alg, key: { kid: kidIdentifier.kid, kmsKeyRef: kidIdentifier.kmsKeyRef } }\n }\n }\n }\n\n /**\n * Create a signed SD-JWT presentation.\n * @param args - Arguments necessary for the creation of a SD-JWT presentation.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n * @returns A signed SD-JWT presentation.\n */\n async createSdJwtPresentation(args: ICreateSdJwtPresentationArgs, context: IRequiredContext): Promise<ICreateSdJwtPresentationResult> {\n const cred = await SDJwt.fromEncode(args.presentation, this.registeredImplementations.hasher!)\n const claims = await cred.getClaims<Claims>(this.registeredImplementations.hasher!)\n let holder: string\n // we primarly look for a cnf field, if it's not there we look for a sub field. If this is also not given, we throw an error since we can not sign it.\n if (args.holder) {\n holder = args.holder\n } else if (claims.cnf?.jwk) {\n const jwk = claims.cnf.jwk\n holder = calculateJwkThumbprint({ jwk: jwk as JWK })\n } else if (claims.cnf?.kid) {\n holder = claims.cnf?.kid\n } else if (claims.sub) {\n holder = claims.sub as string\n } else {\n throw new Error('invalid_argument: credential does not include a holder reference')\n }\n const { alg, signer } = await this.getSignerForIdentifier({ identifier: holder }, context)\n\n const sdjwt = new SDJwtVcInstance({\n hasher: this.registeredImplementations.hasher ?? defaultGenerateDigest,\n saltGenerator: this.registeredImplementations.saltGenerator,\n kbSigner: signer,\n kbSignAlg: alg ?? 'ES256',\n })\n const presentation = await sdjwt.present(args.presentation, args.presentationFrame as PresentationFrame<SdJwtVcPayload>, { kb: args.kb })\n\n return { presentation }\n }\n\n /**\n * Verify a signed SD-JWT credential.\n * @param args - Arguments necessary for the verify a SD-JWT credential.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n * @returns\n */\n async verifySdJwtVc(args: IVerifySdJwtVcArgs, context: IRequiredContext): Promise<IVerifySdJwtVcResult> {\n // callback\n const verifier: Verifier = async (data: string, signature: string) => this.verify(sdjwt, context, data, signature)\n const sdjwt = new SDJwtVcInstance({ verifier, hasher: this.registeredImplementations.hasher ?? defaultGenerateDigest })\n const { header = {}, payload, kb } = await sdjwt.verify(args.credential)\n\n return { header, payload: payload as SdJwtVcPayload, kb }\n }\n\n /**\n * Verify the key binding of a SD-JWT by validating the signature of the key bound to the SD-JWT\n * @param sdjwt - SD-JWT instance\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n * @param data - signed data\n * @param signature - The signature\n * @param payload - The payload of the SD-JWT\n * @returns\n */\n private verifyKb(sdjwt: SDJwtVcInstance, context: IRequiredContext, data: string, signature: string, payload: JwtPayload): Promise<boolean> {\n if (!payload.cnf) {\n throw Error('other method than cnf is not supported yet')\n }\n return this.verifySignatureCallback(context)(data, signature, this.getJwk(payload))\n }\n\n /**\n * Validates the signature of a SD-JWT\n * @param sdjwt - SD-JWT instance\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n * @param data - signed data\n * @param signature - The signature\n * @returns\n */\n async verify(\n sdjwt: SDJwtVcInstance,\n context: IRequiredContext,\n data: string,\n signature: string,\n opts?: { x5cValidation?: X509CertificateChainValidationOpts },\n ): Promise<boolean> {\n const decodedVC = await sdjwt.decode(`${data}.${signature}`)\n const issuer: string = ((decodedVC.jwt as Jwt).payload as Record<string, unknown>).iss as string\n const header = (decodedVC.jwt as Jwt).header as Record<string, any>\n const x5c: string[] | undefined = header?.x5c as string[]\n let jwk: JWK | JsonWebKey | undefined = header.jwk\n if (x5c) {\n const trustAnchors = new Set<string>([...this.trustAnchorsInPEM])\n if (trustAnchors.size === 0) {\n trustAnchors.add(sphereonCA)\n trustAnchors.add(funkeTestCA)\n }\n const certificateValidationResult = await context.agent.x509VerifyCertificateChain({\n chain: x5c,\n trustAnchors: Array.from(trustAnchors),\n // TODO: Defaults to allowing untrusted certs! Fine for now, not when wallets go mainstream\n opts: opts?.x5cValidation ?? { trustRootWhenNoAnchors: true, allowNoTrustAnchorsFound: true },\n })\n\n if (certificateValidationResult.error || !certificateValidationResult?.certificateChain) {\n return Promise.reject(Error(`Certificate chain validation failed. ${certificateValidationResult.message}`))\n }\n const certInfo = certificateValidationResult.certificateChain[0]\n jwk = certInfo.publicKeyJWK as JWK\n }\n\n if (!jwk && header.kid?.includes('did:')) {\n const didDoc = await context.agent.resolveDid({ didUrl: header.kid })\n if (!didDoc) {\n throw new Error('invalid_issuer: issuer did not resolve to a did document')\n }\n //TODO SDK-20: This should be checking for an assertionMethod and not just an verificationMethod with an id\n const didDocumentKey = didDoc.didDocument?.verificationMethod?.find((key) => key.id)\n if (!didDocumentKey) {\n throw new Error('invalid_issuer: issuer did document does not include referenced key')\n }\n //FIXME SDK-21: in case it's another did method, the value of the key can be also encoded as a base64url\n // needs more checks. some DID methods do not expose the keys as publicKeyJwk\n jwk = didDocumentKey.publicKeyJwk as JsonWebKey\n }\n\n if (!jwk && issuer.includes('did:')) {\n // TODO refactor\n const didDoc = await context.agent.resolveDid({ didUrl: issuer })\n if (!didDoc) {\n throw new Error('invalid_issuer: issuer did not resolve to a did document')\n }\n //TODO SDK-20: This should be checking for an assertionMethod and not just an verificationMethod with an id\n const didDocumentKey = didDoc.didDocument?.verificationMethod?.find((key) => key.id)\n if (!didDocumentKey) {\n throw new Error('invalid_issuer: issuer did document does not include referenced key')\n }\n //FIXME SDK-21: in case it's another did method, the value of the key can be also encoded as a base64url\n // needs more checks. some DID methods do not expose the keys as publicKeyJwk\n jwk = didDocumentKey.publicKeyJwk as JsonWebKey\n }\n\n if (!jwk) {\n throw new Error('No valid public key found for signature verification')\n }\n\n return this.verifySignatureCallback(context)(data, signature, jwk)\n }\n\n /**\n * Verify a signed SD-JWT presentation.\n * @param args - Arguments necessary for the verify a SD-JWT presentation.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n * @returns\n */\n async verifySdJwtPresentation(args: IVerifySdJwtPresentationArgs, context: IRequiredContext): Promise<IVerifySdJwtPresentationResult> {\n let sdjwt: SDJwtVcInstance\n const verifier: Verifier = async (data: string, signature: string) => this.verify(sdjwt, context, data, signature)\n const verifierKb: KbVerifier = async (data: string, signature: string, payload: JwtPayload) =>\n this.verifyKb(sdjwt, context, data, signature, payload)\n sdjwt = new SDJwtVcInstance({\n verifier,\n hasher: this.registeredImplementations.hasher,\n kbVerifier: verifierKb,\n })\n\n return sdjwt.verify(args.presentation, args.requiredClaimKeys, args.kb)\n }\n\n /**\n * Fetch and validate Type Metadata.\n * @param args - Arguments necessary for fetching and validating the type metadata.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n * @returns\n */\n async fetchSdJwtTypeMetadataFromVctUrl(args: FetchSdJwtTypeMetadataFromVctUrlArgs, context: IRequiredContext): Promise<SdJwtTypeMetadata> {\n const { vct, vctIntegrity, opts } = args\n const url = new URL(vct)\n\n const response = await fetchUrlWithErrorHandling(url.toString())\n const metadata: SdJwtTypeMetadata = (await response.json()) as SdJwtTypeMetadata\n assertValidTypeMetadata(metadata, vct)\n\n const validate = async (vct: string, input: unknown, integrityValue?: string, hasher?: Hasher | HasherSync) => {\n if (hasher && integrityValue) {\n const validation = await validateIntegrity({ integrityValue, input, hasher })\n if (!validation) {\n return Promise.reject(Error(`Integrity check failed for vct: ${vct}, extends: ${metadata.extends}, integrity: ${integrityValue}}`))\n }\n }\n }\n\n const hasher = (opts?.hasher ?? this.registeredImplementations.hasher ?? defaultGenerateDigest) as Hasher | HasherSync | undefined\n if (hasher) {\n if (vctIntegrity) {\n await validate(vct, metadata, vctIntegrity, hasher)\n const vctValidation = await validateIntegrity({ integrityValue: vctIntegrity, input: metadata, hasher })\n if (!vctValidation) {\n return Promise.reject(Error(`Integrity check failed for vct: ${vct}, integrity: ${vctIntegrity}`))\n }\n }\n\n if (metadata['extends#integrity']) {\n const extendsMetadata = await this.fetchSdJwtTypeMetadataFromVctUrl({ vct: metadata['extends#integrity'], opts }, context)\n await validate(vct, extendsMetadata, metadata['extends#integrity'], hasher)\n }\n\n if (metadata['schema_uri#integrity']) {\n const schemaResponse = await fetchUrlWithErrorHandling(metadata.schema_uri!)\n const schema = await schemaResponse.json()\n await validate(vct, schema, metadata['schema_uri#integrity'], hasher)\n }\n\n metadata.display?.forEach((display) => {\n const simpleLogoIntegrity = display.rendering?.simple?.logo?.['uri#integrity']\n if (simpleLogoIntegrity) {\n console.log('TODO: Logo integrity check')\n }\n })\n }\n\n return metadata\n }\n\n private verifySignatureCallback(context: IRequiredContext): SdJwtVerifySignature {\n if (typeof this.registeredImplementations.verifySignature === 'function') {\n return this.registeredImplementations.verifySignature\n }\n\n return defaultVerifySignature(context)\n }\n\n private getJwk(payload: JwtPayload): JsonWebKey {\n if (payload.cnf?.jwk !== undefined) {\n return payload.cnf.jwk as JsonWebKey\n } else if (payload.cnf !== undefined && 'kid' in payload.cnf && typeof payload.cnf.kid === 'string' && payload.cnf.kid.startsWith('did:jwk:')) {\n // extract JWK from kid FIXME isn't there a did function for this already? Otherwise create one\n // FIXME this is a quick-fix to make verification but we need a real solution\n const encoded = this.extractBase64FromDIDJwk(payload.cnf.kid)\n const decoded = decodeBase64url(encoded)\n const jwt = JSON.parse(decoded)\n return jwt as JsonWebKey\n }\n throw Error('Unable to extract JWK from SD-JWT payload')\n }\n\n private extractBase64FromDIDJwk(did: string): string {\n const parts = did.split(':')\n if (parts.length < 3) {\n throw new Error('Invalid DID format')\n }\n return parts[2].split('#')[0]\n }\n}\n","import { digestMethodParams } from '@sphereon/ssi-sdk-ext.key-utils'\nimport { HasherSync, JsonWebKey, JWK, Loggers } from '@sphereon/ssi-types'\nimport { v4 } from 'uuid'\n// @ts-ignore\nimport { fromString } from 'uint8arrays/from-string'\nimport { IRequiredContext, SdJwtVerifySignature } from './types'\n\nexport const defaultGenerateDigest: HasherSync = (data: string | ArrayBuffer, alg: string): Uint8Array => {\n return digestMethodParams(alg.includes('256') ? 'SHA-256' : 'SHA-512').hash(\n typeof data === 'string' ? fromString(data, 'utf-8') : new Uint8Array(data),\n )\n}\n\nexport const defaultGenerateSalt = (): string => {\n return v4()\n}\n\nexport const defaultVerifySignature =\n (context: IRequiredContext): SdJwtVerifySignature =>\n async (data: string, signature: string, publicKey: JsonWebKey): Promise<boolean> => {\n // The data and signature from the sd-jwt lib are a jwt header.payload and signature, so let's recombine into a compact jwt\n const result = await context.agent.jwtVerifyJwsSignature({ jws: `${data}.${signature}`, jwk: publicKey as JWK })\n Loggers.DEFAULT.get('sd-jwt').info(`SD-JWT signature verified. Result: ${result.message}`)\n return !result.error\n }\n","export const funkeTestCA =\n '-----BEGIN CERTIFICATE-----\\n' +\n 'MIICeTCCAiCgAwIBAgIUB5E9QVZtmUYcDtCjKB/H3VQv72gwCgYIKoZIzj0EAwIwgYgxCzAJBgNVBAYTAkRFMQ8wDQYDVQQHDAZCZXJsaW4xHTAbBgNVBAoMFEJ1bmRlc2RydWNrZXJlaSBHbWJIMREwDwYDVQQLDAhUIENTIElERTE2MDQGA1UEAwwtU1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kGA1UECwwCSVQxGDAW\\n' +\n 'BgNVBAMMD2NhLnNwaGVyZW9uLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA\\n' +\n 'BEiA0KeESSNrOcmCDga8YsBkUTgowZGwqvL2n91JUpAMdRSwvlVFdqdiLXnk2pQq\\n' +\n 'T1vZnDG0I+x+iz2EbdsG0aajUzBRMB0GA1UdDgQWBBTnB8pdlVz5yKD+zuNkRR6A\\n' +\n 'sywywTAOBgNVHQ8BAf8EBAMCAaYwDwYDVR0lBAgwBgYEVR0lADAPBgNVHRMBAf8E\\n' +\n 'BTADAQH/MAoGCCqGSM49BAMCA0gAMEUCIHH7ie1OAAbff5262rzZVQa8J9zENG8A\\n' +\n 'QlHHFydMdgaXAiEA1Ib82mhHIYDziE0DDbHEAXOs98al+7dpo8fPGVGTeKI=\\n' +\n '-----END CERTIFICATE-----'\n","import { SdJwtTypeMetadata } from '@sphereon/ssi-types'\n// @ts-ignore\nimport { toString } from 'uint8arrays/to-string'\nimport { Hasher, HasherSync } from '@sd-jwt/types'\n\n// Helper function to fetch API with error handling\nexport async function fetchUrlWithErrorHandling(url: string): Promise<Response> {\n const response = await fetch(url)\n if (!response.ok) {\n throw new Error(`${response.status}: ${response.statusText}`)\n }\n return response\n}\n\nexport type IntegrityAlg = 'sha256' | 'sha384' | 'sha512'\n\nfunction extractHashAlgFromIntegrity(integrityValue?: string): IntegrityAlg | undefined {\n const val = integrityValue?.toLowerCase().trim().split('-')[0]\n if (val === 'sha256' || val === 'sha384' || val === 'sha512') {\n return val as IntegrityAlg\n }\n return undefined\n}\n\nexport function extractHashFromIntegrity(integrityValue?: string): string | undefined {\n return integrityValue?.toLowerCase().trim().split('-')[1]\n}\n\nexport async function validateIntegrity({\n input,\n integrityValue,\n hasher,\n}: {\n input: any\n integrityValue?: string\n hasher: HasherSync | Hasher\n}): Promise<boolean> {\n if (!integrityValue) {\n return true\n }\n const alg = extractHashAlgFromIntegrity(integrityValue)\n if (!alg) {\n return false\n }\n const calculatedHash = await createIntegrity({ hasher, input, alg })\n return calculatedHash == integrityValue\n}\n\nexport async function createIntegrity({\n input,\n hasher,\n alg = 'sha256',\n}: {\n input: any\n hasher: HasherSync | Hasher\n alg?: IntegrityAlg\n}): Promise<string> {\n const calculatedHash = await hasher(typeof input === 'string' ? input : JSON.stringify(input), alg)\n return `${alg}-${toString(calculatedHash, 'base64')}`\n}\n\nexport function assertValidTypeMetadata(metadata: SdJwtTypeMetadata, vct: string): void {\n if (metadata.vct !== vct) {\n throw new Error('VCT mismatch in metadata and credential')\n }\n}\n","import { SdJwtVcPayload as SdJwtPayload } from '@sd-jwt/sd-jwt-vc'\nimport { Hasher, kbHeader, KBOptions, kbPayload, SaltGenerator, Signer } from '@sd-jwt/types'\nimport { IIdentifierResolution, ManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'\nimport { X509CertificateChainValidationOpts } from '@sphereon/ssi-sdk-ext.x509-utils'\nimport { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'\nimport { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc'\nimport { HasherSync, JoseSignatureAlgorithm, JsonWebKey, SdJwtTypeMetadata } from '@sphereon/ssi-types'\nimport { DIDDocumentSection, IAgentContext, IDIDManager, IKeyManager, IPluginMethodMap, IResolver } from '@veramo/core'\n\nexport const sdJwtPluginContextMethods: Array<string> = ['createSdJwtVc', 'createSdJwtPresentation', 'verifySdJwtVc', 'verifySdJwtPresentation']\n\n/**\n * My Agent Plugin description.\n *\n * This is the interface that describes what your plugin can do.\n * The methods listed here, will be directly available to the veramo agent where your plugin is going to be used.\n * Depending on the agent configuration, other agent plugins, as well as the application where the agent is used\n * will be able to call these methods.\n *\n * To build a schema for your plugin using standard tools, you must link to this file in your package.json.\n * Example:\n * ```\n * \"veramo\": {\n * \"pluginInterfaces\": {\n * \"IMyAgentPlugin\": \"./src/types/IMyAgentPlugin.ts\"\n * }\n * },\n * ```\n *\n * @beta\n */\nexport interface ISDJwtPlugin extends IPluginMethodMap {\n /**\n * Your plugin method description\n *\n * @param args - Input parameters for this method\n * @param context - The required context where this method can run.\n * Declaring a context type here lets other developers know which other plugins\n * need to also be installed for this method to work.\n */\n /**\n * Create a signed SD-JWT credential.\n * @param args - Arguments necessary for the creation of a SD-JWT credential.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n */\n createSdJwtVc(args: ICreateSdJwtVcArgs, context: IRequiredContext): Promise<ICreateSdJwtVcResult>\n\n /**\n * Create a signed SD-JWT presentation.\n * @param args - Arguments necessary for the creation of a SD-JWT presentation.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n */\n createSdJwtPresentation(args: ICreateSdJwtPresentationArgs, context: IRequiredContext): Promise<ICreateSdJwtPresentationResult>\n\n /**\n * Verify a signed SD-JWT credential.\n * @param args - Arguments necessary for the verification of a SD-JWT credential.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n */\n verifySdJwtVc(args: IVerifySdJwtVcArgs, context: IRequiredContext): Promise<IVerifySdJwtVcResult>\n\n /**\n * Verify a signed SD-JWT presentation.\n * @param args - Arguments necessary for the verification of a SD-JWT presentation.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n */\n verifySdJwtPresentation(args: IVerifySdJwtPresentationArgs, context: IRequiredContext): Promise<IVerifySdJwtPresentationResult>\n\n /**\n * Fetch and validate Type Metadata.\n * @param args - Arguments necessary for fetching and validating the type metadata.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n */\n fetchSdJwtTypeMetadataFromVctUrl(args: FetchSdJwtTypeMetadataFromVctUrlArgs, context: IRequiredContext): Promise<SdJwtTypeMetadata>\n}\n\nexport function contextHasSDJwtPlugin(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ISDJwtPlugin> {\n return contextHasPlugin(context, 'verifySdJwtVc')\n}\n\n/**\n * ICreateSdJwtVcArgs\n *\n * @beta\n */\n\nexport interface SdJwtVcPayload extends SdJwtPayload {\n x5c?: string[]\n}\n\nexport interface ICreateSdJwtVcArgs {\n credentialPayload: SdJwtVcPayload\n\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n disclosureFrame?: IDisclosureFrame\n\n resolution?: ManagedIdentifierResult\n}\n\n/**\n * @beta\n */\nexport interface IDisclosureFrame {\n _sd?: string[]\n _sd_decoy?: number\n\n [x: string]: string[] | number | IDisclosureFrame | undefined\n}\n\n/**\n * ICreateSdJwtVcResult\n *\n * @beta\n */\nexport interface ICreateSdJwtVcResult {\n /**\n * the encoded sd-jwt credential\n */\n credential: string\n}\n\n/**\n *\n * @beta\n */\nexport interface ICreateSdJwtPresentationArgs {\n /**\n * Encoded SD-JWT credential\n */\n presentation: string\n\n /*\n * The keys to use for selective disclosure for presentation\n * if not provided, all keys will be disclosed\n * if empty object, no keys will be disclosed\n */\n presentationFrame?: IPresentationFrame\n\n /**\n * Allows to override the holder. Normally it will be looked up from the cnf or sub values\n */\n holder?: string\n\n /**\n * Information to include to add key binding.\n */\n kb?: KBOptions\n}\n\n/**\n * @beta\n */\nexport interface IPresentationFrame {\n [x: string]: boolean | IPresentationFrame\n}\n\n/**\n * Created presentation\n * @beta\n */\nexport interface ICreateSdJwtPresentationResult {\n /**\n * Encoded presentation.\n */\n presentation: string\n}\n\n/**\n * @beta\n */\nexport interface IVerifySdJwtVcArgs {\n credential: string\n opts?: {\n x5cValidation?: X509CertificateChainValidationOpts\n }\n}\n\n/**\n * @beta\n */\nexport type IVerifySdJwtVcResult = {\n payload: SdJwtPayload\n header: Record<string, unknown>\n kb?: { header: kbHeader; payload: kbPayload }\n}\n\n/**\n * @beta\n */\nexport interface IVerifySdJwtPresentationArgs {\n presentation: string\n\n requiredClaimKeys?: string[]\n\n kb?: boolean\n}\n\n/**\n * @beta\n */\nexport type IVerifySdJwtPresentationResult = {\n payload: unknown //fixme: maybe this can be `SdJwtPayload`\n header: Record<string, unknown> | undefined\n kb?: { header: kbHeader; payload: kbPayload }\n}\n\nexport type SignKeyArgs = {\n identifier: string\n vmRelationship: DIDDocumentSection\n resolution?: ManagedIdentifierResult\n}\n\nexport type SignKeyResult = {\n alg: JoseSignatureAlgorithm\n key: {\n kid?: string\n kmsKeyRef: string\n x5c?: string[]\n jwkThumbprint?: string\n }\n}\n/**\n * This context describes the requirements of this plugin.\n * For this plugin to function properly, the agent needs to also have other plugins installed that implement the\n * interfaces declared here.\n * You can also define requirements on a more granular level, for each plugin method or event handler of your plugin.\n *\n * @beta\n */\nexport type IRequiredContext = IAgentContext<IDIDManager & IIdentifierResolution & IJwtService & IResolver & IKeyManager & ImDLMdoc>\n\nexport type SdJwtVerifySignature = (data: string, signature: string, publicKey: JsonWebKey) => Promise<boolean>\nexport interface SdJWTImplementation {\n saltGenerator?: SaltGenerator\n hasher?: HasherSync\n verifySignature?: SdJwtVerifySignature\n}\n\nexport interface Claims {\n /**\n * Subject of the SD-JWT\n */\n sub?: string\n cnf?: {\n jwk?: JsonWebKey\n kid?: string\n }\n\n [key: string]: unknown\n}\n\nexport type FetchSdJwtTypeMetadataFromVctUrlArgs = {\n vct: string\n vctIntegrity?: string\n opts?: FetchSdJwtTypeMetadataFromVctUrlOpts\n}\n\nexport type FetchSdJwtTypeMetadataFromVctUrlOpts = {\n hasher?: HasherSync | Hasher\n}\n\nexport type GetSignerForIdentifierArgs = {\n identifier: string\n resolution?: ManagedIdentifierResult\n}\n\nexport type GetSignerResult = {\n signer: Signer\n alg?: string\n signingKey?: SignKeyResult\n}\n"],"mappings":";;;;AAAA,SAAcA,aAAa;AAC3B,SAASC,uBAAuC;AAEhD,SAASC,wBAAwBC,iCAAiC;AAIlE,SAASC,uBAAuB;AAChC,OAAOC,WAAW;;;ACRlB,SAASC,0BAA0B;AACnC,SAAsCC,eAAe;AACrD,SAASC,UAAU;AAEnB,SAASC,kBAAkB;AAGpB,IAAMC,wBAAoC,wBAACC,MAA4BC,QAAAA;AAC5E,SAAOC,mBAAmBD,IAAIE,SA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ams","Loggers","v4","fromString","defaultGenerateDigest","data","alg","digestMethodParams","includes","hash","fromString","Uint8Array","defaultGenerateSalt","v4","defaultVerifySignature","context","signature","publicKey","result","agent","jwtVerifyJwsSignature","jws","jwk","Loggers","DEFAULT","get","info","message","error","funkeTestCA","sphereonCA","toString","fetchUrlWithErrorHandling","url","response","fetch","ok","Error","status","statusText","extractHashAlgFromIntegrity","integrityValue","val","toLowerCase","trim","split","undefined","extractHashFromIntegrity","validateIntegrity","input","hasher","alg","calculatedHash","createIntegrity","JSON","stringify","toString","assertValidTypeMetadata","metadata","vct","debug","Debug","SDJwtPlugin","trustAnchorsInPEM","registeredImplementations","_signers","_defaultSigner","constructor","hasher","defaultGenerateDigest","saltGenerator","defaultGenerateSalt","signers","defaultSigner","methods","createSdJwtVc","bind","createSdJwtPresentation","verifySdJwtVc","verifySdJwtPresentation","fetchSdJwtTypeMetadataFromVctUrl","getSignerForIdentifier","args","context","identifier","resolution","Object","keys","includes","signer","signingKey","getSignKey","vmRelationship","key","alg","data","agent","keyManagerSign","keyRef","kmsKeyRef","issuer","credentialPayload","iss","Error","sdjwt","SDJwtVcInstance","signAlg","hashAlg","credential","issue","disclosureFrame","header","kid","undefined","x5c","signatureAlgorithmFromKey","method","publicKeyHex","meta","x509","jwkThumbprint","startsWith","didIdentifier","identifierManagedGetByDid","kidIdentifier","identifierManagedGetByKid","cred","SDJwt","fromEncode","presentation","claims","getClaims","holder","cnf","jwk","calculateJwkThumbprint","sub","kbSigner","kbSignAlg","present","presentationFrame","kb","verifier","signature","verify","payload","verifyKb","verifySignatureCallback","getJwk","opts","decodedVC","decode","jwt","trustAnchors","Set","size","add","sphereonCA","funkeTestCA","certificateValidationResult","x509VerifyCertificateChain","chain","Array","from","x5cValidation","trustRootWhenNoAnchors","allowNoTrustAnchorsFound","error","certificateChain","Promise","reject","message","certInfo","publicKeyJWK","didDoc","resolveDid","didUrl","didDocumentKey","didDocument","verificationMethod","find","id","publicKeyJwk","verifierKb","kbVerifier","requiredClaimKeys","vct","vctIntegrity","url","URL","response","fetchUrlWithErrorHandling","toString","metadata","json","assertValidTypeMetadata","validate","input","integrityValue","validation","validateIntegrity","extends","vctValidation","extendsMetadata","schemaResponse","schema_uri","schema","display","forEach","simpleLogoIntegrity","rendering","simple","logo","console","log","verifySignature","defaultVerifySignature","encoded","extractBase64FromDIDJwk","decoded","decodeBase64url","JSON","parse","did","parts","split","length","contextHasPlugin","sdJwtPluginContextMethods","contextHasSDJwtPlugin","context","contextHasPlugin"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAA8C;AAArC,6GAAA,WAAW,OAAA;AACpB,0CAAuB;AACvB,0CAAuB"}
@@ -0,0 +1,3 @@
1
+ export declare const funkeTestCA: string;
2
+ export declare const sphereonCA: string;
3
+ //# sourceMappingURL=trustAnchors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trustAnchors.d.ts","sourceRoot":"","sources":["../src/trustAnchors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAGK,CAAA;AAE7B,eAAO,MAAM,UAAU,QAaM,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sphereonCA = exports.funkeTestCA = void 0;
4
+ exports.funkeTestCA = '-----BEGIN CERTIFICATE-----\n' +
5
+ 'MIICeTCCAiCgAwIBAgIUB5E9QVZtmUYcDtCjKB/H3VQv72gwCgYIKoZIzj0EAwIwgYgxCzAJBgNVBAYTAkRFMQ8wDQYDVQQHDAZCZXJsaW4xHTAbBgNVBAoMFEJ1bmRlc2RydWNrZXJlaSBHbWJIMREwDwYDVQQLDAhUIENTIElERTE2MDQGA1UEAwwtU1BSSU5EIEZ1bmtlIEVVREkgV2FsbGV0IFByb3RvdHlwZSBJc3N1aW5nIENBMB4XDTI0MDUzMTA2NDgwOVoXDTM0MDUyOTA2NDgwOV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IA\n' +
14
+ 'BEiA0KeESSNrOcmCDga8YsBkUTgowZGwqvL2n91JUpAMdRSwvlVFdqdiLXnk2pQq\n' +
15
+ 'T1vZnDG0I+x+iz2EbdsG0aajUzBRMB0GA1UdDgQWBBTnB8pdlVz5yKD+zuNkRR6A\n' +
16
+ 'sywywTAOBgNVHQ8BAf8EBAMCAaYwDwYDVR0lBAgwBgYEVR0lADAPBgNVHRMBAf8E\n' +
17
+ 'BTADAQH/MAoGCCqGSM49BAMCA0gAMEUCIHH7ie1OAAbff5262rzZVQa8J9zENG8A\n' +
18
+ 'QlHHFydMdgaXAiEA1Ib82mhHIYDziE0DDbHEAXOs98al+7dpo8fPGVGTeKI=\n' +
19
+ '-----END CERTIFICATE-----';
20
+ //# sourceMappingURL=trustAnchors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trustAnchors.js","sourceRoot":"","sources":["../src/trustAnchors.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GACtB,+BAA+B;IAC/B,w1BAAw1B;IACx1B,2BAA2B,CAAA;AAEhB,QAAA,UAAU,GACrB,+BAA+B;IAC/B,oEAAoE;IACpE,oEAAoE;IACpE,oEAAoE;IACpE,oEAAoE;IACpE,oEAAoE;IACpE,oEAAoE;IACpE,oEAAoE;IACpE,oEAAoE;IACpE,oEAAoE;IACpE,oEAAoE;IACpE,gEAAgE;IAChE,2BAA2B,CAAA"}
@@ -0,0 +1,234 @@
1
+ import { SdJwtVcPayload as SdJwtPayload } from '@sd-jwt/sd-jwt-vc';
2
+ import { Hasher, kbHeader, KBOptions, kbPayload, SaltGenerator, Signer } from '@sd-jwt/types';
3
+ import { IIdentifierResolution, ManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution';
4
+ import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
5
+ import { X509CertificateChainValidationOpts } from '@sphereon/ssi-sdk-ext.x509-utils';
6
+ import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc';
7
+ import { HasherSync, JoseSignatureAlgorithm, SdJwtTypeMetadata } from '@sphereon/ssi-types';
8
+ import { DIDDocumentSection, IAgentContext, IDIDManager, IKeyManager, IPluginMethodMap, IResolver } from '@veramo/core';
9
+ export declare const sdJwtPluginContextMethods: Array<string>;
10
+ /**
11
+ * My Agent Plugin description.
12
+ *
13
+ * This is the interface that describes what your plugin can do.
14
+ * The methods listed here, will be directly available to the veramo agent where your plugin is going to be used.
15
+ * Depending on the agent configuration, other agent plugins, as well as the application where the agent is used
16
+ * will be able to call these methods.
17
+ *
18
+ * To build a schema for your plugin using standard tools, you must link to this file in your package.json.
19
+ * Example:
20
+ * ```
21
+ * "veramo": {
22
+ * "pluginInterfaces": {
23
+ * "IMyAgentPlugin": "./src/types/IMyAgentPlugin.ts"
24
+ * }
25
+ * },
26
+ * ```
27
+ *
28
+ * @beta
29
+ */
30
+ export interface ISDJwtPlugin extends IPluginMethodMap {
31
+ /**
32
+ * Your plugin method description
33
+ *
34
+ * @param args - Input parameters for this method
35
+ * @param context - The required context where this method can run.
36
+ * Declaring a context type here lets other developers know which other plugins
37
+ * need to also be installed for this method to work.
38
+ */
39
+ /**
40
+ * Create a signed SD-JWT credential.
41
+ * @param args - Arguments necessary for the creation of a SD-JWT credential.
42
+ * @param context - This reserved param is automatically added and handled by the framework, *do not override*
43
+ */
44
+ createSdJwtVc(args: ICreateSdJwtVcArgs, context: IRequiredContext): Promise<ICreateSdJwtVcResult>;
45
+ /**
46
+ * Create a signed SD-JWT presentation.
47
+ * @param args - Arguments necessary for the creation of a SD-JWT presentation.
48
+ * @param context - This reserved param is automatically added and handled by the framework, *do not override*
49
+ */
50
+ createSdJwtPresentation(args: ICreateSdJwtPresentationArgs, context: IRequiredContext): Promise<ICreateSdJwtPresentationResult>;
51
+ /**
52
+ * Verify a signed SD-JWT credential.
53
+ * @param args - Arguments necessary for the verification of a SD-JWT credential.
54
+ * @param context - This reserved param is automatically added and handled by the framework, *do not override*
55
+ */
56
+ verifySdJwtVc(args: IVerifySdJwtVcArgs, context: IRequiredContext): Promise<IVerifySdJwtVcResult>;
57
+ /**
58
+ * Verify a signed SD-JWT presentation.
59
+ * @param args - Arguments necessary for the verification of a SD-JWT presentation.
60
+ * @param context - This reserved param is automatically added and handled by the framework, *do not override*
61
+ */
62
+ verifySdJwtPresentation(args: IVerifySdJwtPresentationArgs, context: IRequiredContext): Promise<IVerifySdJwtPresentationResult>;
63
+ /**
64
+ * Fetch and validate Type Metadata.
65
+ * @param args - Arguments necessary for fetching and validating the type metadata.
66
+ * @param context - This reserved param is automatically added and handled by the framework, *do not override*
67
+ */
68
+ fetchSdJwtTypeMetadataFromVctUrl(args: FetchSdJwtTypeMetadataFromVctUrlArgs, context: IRequiredContext): Promise<SdJwtTypeMetadata>;
69
+ }
70
+ export declare function contextHasSDJwtPlugin(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ISDJwtPlugin>;
71
+ /**
72
+ * ICreateSdJwtVcArgs
73
+ *
74
+ * @beta
75
+ */
76
+ export interface SdJwtVcPayload extends SdJwtPayload {
77
+ x5c?: string[];
78
+ }
79
+ export interface ICreateSdJwtVcArgs {
80
+ credentialPayload: SdJwtVcPayload;
81
+ disclosureFrame?: IDisclosureFrame;
82
+ resolution?: ManagedIdentifierResult;
83
+ }
84
+ /**
85
+ * @beta
86
+ */
87
+ export interface IDisclosureFrame {
88
+ _sd?: string[];
89
+ _sd_decoy?: number;
90
+ [x: string]: string[] | number | IDisclosureFrame | undefined;
91
+ }
92
+ /**
93
+ * ICreateSdJwtVcResult
94
+ *
95
+ * @beta
96
+ */
97
+ export interface ICreateSdJwtVcResult {
98
+ /**
99
+ * the encoded sd-jwt credential
100
+ */
101
+ credential: string;
102
+ }
103
+ /**
104
+ *
105
+ * @beta
106
+ */
107
+ export interface ICreateSdJwtPresentationArgs {
108
+ /**
109
+ * Encoded SD-JWT credential
110
+ */
111
+ presentation: string;
112
+ presentationFrame?: IPresentationFrame;
113
+ /**
114
+ * Allows to override the holder. Normally it will be looked up from the cnf or sub values
115
+ */
116
+ holder?: string;
117
+ /**
118
+ * Information to include to add key binding.
119
+ */
120
+ kb?: KBOptions;
121
+ }
122
+ /**
123
+ * @beta
124
+ */
125
+ export interface IPresentationFrame {
126
+ [x: string]: boolean | IPresentationFrame;
127
+ }
128
+ /**
129
+ * Created presentation
130
+ * @beta
131
+ */
132
+ export interface ICreateSdJwtPresentationResult {
133
+ /**
134
+ * Encoded presentation.
135
+ */
136
+ presentation: string;
137
+ }
138
+ /**
139
+ * @beta
140
+ */
141
+ export interface IVerifySdJwtVcArgs {
142
+ credential: string;
143
+ opts?: {
144
+ x5cValidation?: X509CertificateChainValidationOpts;
145
+ };
146
+ }
147
+ /**
148
+ * @beta
149
+ */
150
+ export type IVerifySdJwtVcResult = {
151
+ payload: SdJwtPayload;
152
+ header: Record<string, unknown>;
153
+ kb?: {
154
+ header: kbHeader;
155
+ payload: kbPayload;
156
+ };
157
+ };
158
+ /**
159
+ * @beta
160
+ */
161
+ export interface IVerifySdJwtPresentationArgs {
162
+ presentation: string;
163
+ requiredClaimKeys?: string[];
164
+ kb?: boolean;
165
+ }
166
+ /**
167
+ * @beta
168
+ */
169
+ export type IVerifySdJwtPresentationResult = {
170
+ payload: unknown;
171
+ header: Record<string, unknown> | undefined;
172
+ kb?: {
173
+ header: kbHeader;
174
+ payload: kbPayload;
175
+ };
176
+ };
177
+ export type SignKeyArgs = {
178
+ identifier: string;
179
+ vmRelationship: DIDDocumentSection;
180
+ resolution?: ManagedIdentifierResult;
181
+ };
182
+ export type SignKeyResult = {
183
+ alg: JoseSignatureAlgorithm;
184
+ key: {
185
+ kid?: string;
186
+ kmsKeyRef: string;
187
+ x5c?: string[];
188
+ jwkThumbprint?: string;
189
+ };
190
+ };
191
+ /**
192
+ * This context describes the requirements of this plugin.
193
+ * For this plugin to function properly, the agent needs to also have other plugins installed that implement the
194
+ * interfaces declared here.
195
+ * You can also define requirements on a more granular level, for each plugin method or event handler of your plugin.
196
+ *
197
+ * @beta
198
+ */
199
+ export type IRequiredContext = IAgentContext<IDIDManager & IIdentifierResolution & IJwtService & IResolver & IKeyManager & ImDLMdoc>;
200
+ export type SdJwtVerifySignature = (data: string, signature: string, publicKey: JsonWebKey) => Promise<boolean>;
201
+ export interface SdJWTImplementation {
202
+ saltGenerator?: SaltGenerator;
203
+ hasher?: HasherSync;
204
+ verifySignature?: SdJwtVerifySignature;
205
+ }
206
+ export interface Claims {
207
+ /**
208
+ * Subject of the SD-JWT
209
+ */
210
+ sub?: string;
211
+ cnf?: {
212
+ jwk?: JsonWebKey;
213
+ kid?: string;
214
+ };
215
+ [key: string]: unknown;
216
+ }
217
+ export type FetchSdJwtTypeMetadataFromVctUrlArgs = {
218
+ vct: string;
219
+ vctIntegrity?: string;
220
+ opts?: FetchSdJwtTypeMetadataFromVctUrlOpts;
221
+ };
222
+ export type FetchSdJwtTypeMetadataFromVctUrlOpts = {
223
+ hasher?: HasherSync | Hasher;
224
+ };
225
+ export type GetSignerForIdentifierArgs = {
226
+ identifier: string;
227
+ resolution?: ManagedIdentifierResult;
228
+ };
229
+ export type GetSignerResult = {
230
+ signer: Signer;
231
+ alg?: string;
232
+ signingKey?: SignKeyResult;
233
+ };
234
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC7F,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAA;AAC5G,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAA;AAErF,OAAO,EAAE,QAAQ,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,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE;QACJ,GAAG,CAAC,EAAE,UAAU,CAAA;QAChB,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;IAED,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,oCAAoC,GAAG;IACjD,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,oCAAoC,CAAA;CAC5C,CAAA;AAED,MAAM,MAAM,oCAAoC,GAAG;IACjD,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,uBAAuB,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,aAAa,CAAA;CAC3B,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sdJwtPluginContextMethods = void 0;
4
+ exports.contextHasSDJwtPlugin = contextHasSDJwtPlugin;
5
+ const ssi_sdk_agent_config_1 = require("@sphereon/ssi-sdk.agent-config");
6
+ exports.sdJwtPluginContextMethods = ['createSdJwtVc', 'createSdJwtPresentation', 'verifySdJwtVc', 'verifySdJwtPresentation'];
7
+ function contextHasSDJwtPlugin(context) {
8
+ return (0, ssi_sdk_agent_config_1.contextHasPlugin)(context, 'verifySdJwtVc');
9
+ }
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA6EA,sDAEC;AA1ED,yEAAiE;AAKpD,QAAA,yBAAyB,GAAkB,CAAC,eAAe,EAAE,yBAAyB,EAAE,eAAe,EAAE,yBAAyB,CAAC,CAAA;AAmEhJ,SAAgB,qBAAqB,CAAC,OAAwC;IAC5E,OAAO,IAAA,uCAAgB,EAAC,OAAO,EAAE,eAAe,CAAC,CAAA;AACnD,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { SdJwtTypeMetadata } from '@sphereon/ssi-types';
2
+ import { HasherSync } from '@sd-jwt/types';
3
+ import { Hasher } from '@sd-jwt/types';
4
+ export declare function fetchUrlWithErrorHandling(url: string): Promise<Response>;
5
+ export type IntegrityAlg = 'sha256' | 'sha384' | 'sha512';
6
+ export declare function extractHashFromIntegrity(integrityValue?: string): string | undefined;
7
+ export declare function validateIntegrity({ input, integrityValue, hasher, }: {
8
+ input: any;
9
+ integrityValue?: string;
10
+ hasher: HasherSync | Hasher;
11
+ }): Promise<boolean>;
12
+ export declare function createIntegrity({ input, hasher, alg, }: {
13
+ input: any;
14
+ hasher: HasherSync | Hasher;
15
+ alg?: IntegrityAlg;
16
+ }): Promise<string>;
17
+ export declare function assertValidTypeMetadata(metadata: SdJwtTypeMetadata, vct: string): void;
18
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGtC,wBAAsB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAM9E;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAUzD,wBAAgB,wBAAwB,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEpF;AAED,wBAAsB,iBAAiB,CAAC,EACtC,KAAK,EACL,cAAc,EACd,MAAM,GACP,EAAE;IACD,KAAK,EAAE,GAAG,CAAA;IACV,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,UAAU,GAAG,MAAM,CAAA;CAC5B,GAAG,OAAO,CAAC,OAAO,CAAC,CAUnB;AAED,wBAAsB,eAAe,CAAC,EACpC,KAAK,EACL,MAAM,EACN,GAAc,GACf,EAAE;IACD,KAAK,EAAE,GAAG,CAAA;IACV,MAAM,EAAE,UAAU,GAAG,MAAM,CAAA;IAC3B,GAAG,CAAC,EAAE,YAAY,CAAA;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlB;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAItF"}
package/dist/utils.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.fetchUrlWithErrorHandling = fetchUrlWithErrorHandling;
36
+ exports.extractHashFromIntegrity = extractHashFromIntegrity;
37
+ exports.validateIntegrity = validateIntegrity;
38
+ exports.createIntegrity = createIntegrity;
39
+ exports.assertValidTypeMetadata = assertValidTypeMetadata;
40
+ const u8a = __importStar(require("uint8arrays"));
41
+ // Helper function to fetch API with error handling
42
+ function fetchUrlWithErrorHandling(url) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const response = yield fetch(url);
45
+ if (!response.ok) {
46
+ throw new Error(`${response.status}: ${response.statusText}`);
47
+ }
48
+ return response;
49
+ });
50
+ }
51
+ function extractHashAlgFromIntegrity(integrityValue) {
52
+ const val = integrityValue === null || integrityValue === void 0 ? void 0 : integrityValue.toLowerCase().trim().split('-')[0];
53
+ if (val === 'sha256' || val === 'sha384' || val === 'sha512') {
54
+ return val;
55
+ }
56
+ return undefined;
57
+ }
58
+ function extractHashFromIntegrity(integrityValue) {
59
+ return integrityValue === null || integrityValue === void 0 ? void 0 : integrityValue.toLowerCase().trim().split('-')[1];
60
+ }
61
+ function validateIntegrity(_a) {
62
+ return __awaiter(this, arguments, void 0, function* ({ input, integrityValue, hasher, }) {
63
+ if (!integrityValue) {
64
+ return true;
65
+ }
66
+ const alg = extractHashAlgFromIntegrity(integrityValue);
67
+ if (!alg) {
68
+ return false;
69
+ }
70
+ const calculatedHash = yield createIntegrity({ hasher, input, alg });
71
+ return calculatedHash == integrityValue;
72
+ });
73
+ }
74
+ function createIntegrity(_a) {
75
+ return __awaiter(this, arguments, void 0, function* ({ input, hasher, alg = 'sha256', }) {
76
+ const calculatedHash = yield hasher(typeof input === 'string' ? input : JSON.stringify(input), alg);
77
+ return `${alg}-${u8a.toString(calculatedHash, 'base64')}`;
78
+ });
79
+ }
80
+ function assertValidTypeMetadata(metadata, vct) {
81
+ if (metadata.vct !== vct) {
82
+ throw new Error('VCT mismatch in metadata and credential');
83
+ }
84
+ }
85
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,8DAMC;AAYD,4DAEC;AAED,8CAkBC;AAED,0CAWC;AAED,0DAIC;AAhED,iDAAkC;AAIlC,mDAAmD;AACnD,SAAsB,yBAAyB,CAAC,GAAW;;QACzD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;QACjC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;QAC/D,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;CAAA;AAID,SAAS,2BAA2B,CAAC,cAAuB;IAC1D,MAAM,GAAG,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC9D,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7D,OAAO,GAAmB,CAAA;IAC5B,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CA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ad",
3
+ "version": "0.33.1-next.2+6f7f40b9",
4
4
  "source": "src/index.ts",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- "import": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js"
13
- },
14
- "require": {
15
- "types": "./dist/index.d.cts",
16
- "require": "./dist/index.cjs"
17
- }
18
- },
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
19
7
  "scripts": {
20
- "build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
8
+ "build": "tsc",
9
+ "build:clean": "tsc --build --clean && tsc --build"
21
10
  },
22
11
  "veramo": {
23
12
  "pluginInterfaces": {
@@ -27,27 +16,27 @@
27
16
  "dependencies": {
28
17
  "@sd-jwt/core": "^0.9.2",
29
18
  "@sd-jwt/sd-jwt-vc": "^0.9.2",
30
- "@sphereon/ssi-sdk-ext.did-utils": "0.28.1-feature.esm.cjs.16",
31
- "@sphereon/ssi-sdk-ext.identifier-resolution": "0.28.1-feature.esm.cjs.16",
32
- "@sphereon/ssi-sdk-ext.jwt-service": "0.28.1-feature.esm.cjs.16",
33
- "@sphereon/ssi-sdk-ext.key-utils": "0.28.1-feature.esm.cjs.16",
34
- "@sphereon/ssi-sdk-ext.x509-utils": "0.28.1-feature.esm.cjs.16",
35
- "@sphereon/ssi-sdk.agent-config": "^0.33.1-feature.vcdm2.tsup.31+71b615ad",
36
- "@sphereon/ssi-sdk.mdl-mdoc": "^0.33.1-feature.vcdm2.tsup.31+71b615ad",
37
- "@sphereon/ssi-types": "^0.33.1-feature.vcdm2.tsup.31+71b615ad",
19
+ "@sphereon/ssi-sdk-ext.did-utils": "0.28.0",
20
+ "@sphereon/ssi-sdk-ext.identifier-resolution": "0.28.0",
21
+ "@sphereon/ssi-sdk-ext.jwt-service": "0.28.0",
22
+ "@sphereon/ssi-sdk-ext.key-utils": "0.28.0",
23
+ "@sphereon/ssi-sdk-ext.x509-utils": "0.28.0",
24
+ "@sphereon/ssi-sdk.agent-config": "0.33.1-next.2+6f7f40b9",
25
+ "@sphereon/ssi-sdk.mdl-mdoc": "0.33.1-next.2+6f7f40b9",
26
+ "@sphereon/ssi-types": "0.33.1-next.2+6f7f40b9",
38
27
  "@veramo/utils": "4.2.0",
39
28
  "debug": "^4.3.5",
40
- "uint8arrays": "^3.1.1",
29
+ "uint8arrays": "3.1.1",
41
30
  "uuid": "^9.0.1"
42
31
  },
43
32
  "devDependencies": {
44
33
  "@sd-jwt/decode": "^0.9.2",
45
34
  "@sd-jwt/types": "^0.9.2",
46
35
  "@sd-jwt/utils": "^0.9.2",
47
- "@sphereon/ssi-sdk-ext.did-provider-jwk": "0.28.1-feature.esm.cjs.16",
48
- "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.28.1-feature.esm.cjs.16",
49
- "@sphereon/ssi-sdk-ext.key-manager": "0.28.1-feature.esm.cjs.16",
50
- "@sphereon/ssi-sdk-ext.kms-local": "0.28.1-feature.esm.cjs.16",
36
+ "@sphereon/ssi-sdk-ext.did-provider-jwk": "0.28.0",
37
+ "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.28.0",
38
+ "@sphereon/ssi-sdk-ext.key-manager": "0.28.0",
39
+ "@sphereon/ssi-sdk-ext.kms-local": "0.28.0",
51
40
  "@types/node": "^20.17.1",
52
41
  "@types/uuid": "^9.0.8",
53
42
  "@veramo/core": "4.2.0",
@@ -55,12 +44,12 @@
55
44
  "@veramo/did-manager": "4.2.0",
56
45
  "@veramo/did-resolver": "4.2.0",
57
46
  "did-resolver": "^4.1.0",
58
- "typeorm": "^0.3.22",
59
- "typescript": "5.8.3"
47
+ "typeorm": "^0.3.21",
48
+ "typescript": "5.4.2"
60
49
  },
61
50
  "files": [
62
- "dist",
63
- "src",
51
+ "dist/**/*",
52
+ "src/**/*",
64
53
  "README.md",
65
54
  "plugin.schema.json",
66
55
  "LICENSE"
@@ -82,5 +71,6 @@
82
71
  "Selective Disclosure",
83
72
  "Verifiable Credential"
84
73
  ],
85
- "gitHead": "71b615adbfef8ecd843edb2f3d0c58cb6453cff9"
74
+ "nx": {},
75
+ "gitHead": "6f7f40b94beb385369fede046c3912bd0c053408"
86
76
  }
@@ -1,6 +1,6 @@
1
- import { describe, it } from 'vitest'
2
1
  import { defaultGenerateDigest } from '../defaultCallbacks'
3
2
  import { createIntegrity, validateIntegrity } from '../index'
3
+
4
4
  // type AgentType = IDIDManager & IKeyManager & IIdentifierResolution & IJwtService & IResolver & ISDJwtPlugin & ImDLMdoc
5
5
  const fs = require('node:fs')
6
6