@sphereon/ssi-sdk.vc-status-list 0.33.1-feature.vcdm2.tsup.39 → 0.33.1-feature.vcdm2.tsup.41
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.cjs +17 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/impl/encoding/cbor.ts +19 -18
package/dist/index.cjs
CHANGED
|
@@ -459,10 +459,11 @@ var getSigningAlgo = /* @__PURE__ */ __name((type) => {
|
|
|
459
459
|
// src/impl/encoding/cbor.ts
|
|
460
460
|
var import_jwt_status_list2 = require("@sd-jwt/jwt-status-list");
|
|
461
461
|
var import_pako = require("pako");
|
|
462
|
-
var
|
|
462
|
+
var cborpkg = __toESM(require("@sphereon/kmp-cbor"), 1);
|
|
463
463
|
var import_base64url2 = __toESM(require("base64url"), 1);
|
|
464
|
-
var cbor =
|
|
465
|
-
var kmp =
|
|
464
|
+
var cbor = cborpkg.com.sphereon.cbor;
|
|
465
|
+
var kmp = cborpkg.com.sphereon.kmp;
|
|
466
|
+
var kotlin2 = cborpkg.kotlin;
|
|
466
467
|
var decompressRawStatusList = import_jwt_status_list2.StatusList.decodeStatusList.bind(import_jwt_status_list2.StatusList);
|
|
467
468
|
var CWT_CLAIMS = {
|
|
468
469
|
SUBJECT: 2,
|
|
@@ -479,7 +480,7 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
479
480
|
level: 9
|
|
480
481
|
});
|
|
481
482
|
const compressedBytes = new Int8Array(compressedList);
|
|
482
|
-
const statusListMap = new cbor.CborMap(
|
|
483
|
+
const statusListMap = new cbor.CborMap(kotlin2.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
483
484
|
[
|
|
484
485
|
new cbor.CborString("bits"),
|
|
485
486
|
new cbor.CborUInt(kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))
|
|
@@ -489,7 +490,7 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
489
490
|
new cbor.CborByteString(compressedBytes)
|
|
490
491
|
]
|
|
491
492
|
])));
|
|
492
|
-
const protectedHeader = new cbor.CborMap(
|
|
493
|
+
const protectedHeader = new cbor.CborMap(kotlin2.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
493
494
|
[
|
|
494
495
|
new cbor.CborUInt(kmp.LongKMP.fromNumber(16)),
|
|
495
496
|
new cbor.CborString("statuslist+cwt")
|
|
@@ -512,7 +513,7 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
512
513
|
new cbor.CborByteString(claimsEncodedInt8),
|
|
513
514
|
new cbor.CborByteString(signatureInt8)
|
|
514
515
|
];
|
|
515
|
-
const cwtArray = new cbor.CborArray(
|
|
516
|
+
const cwtArray = new cbor.CborArray(kotlin2.collections.KtMutableList.fromJsArray(cwtArrayElements));
|
|
516
517
|
const cwtEncoded = cbor.Cbor.encode(cwtArray);
|
|
517
518
|
const cwtBuffer = Buffer.from(cwtEncoded);
|
|
518
519
|
return {
|
|
@@ -552,7 +553,7 @@ function buildClaimsMap(id, issuerString, statusListMap, expiresAt) {
|
|
|
552
553
|
new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)),
|
|
553
554
|
statusListMap
|
|
554
555
|
]);
|
|
555
|
-
const claimsMap = new cbor.CborMap(
|
|
556
|
+
const claimsMap = new cbor.CborMap(kotlin2.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)));
|
|
556
557
|
return claimsMap;
|
|
557
558
|
}
|
|
558
559
|
__name(buildClaimsMap, "buildClaimsMap");
|
|
@@ -564,7 +565,7 @@ var getCborValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
564
565
|
return value;
|
|
565
566
|
}, "getCborValueFromMap");
|
|
566
567
|
var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
567
|
-
const value = map.get(new
|
|
568
|
+
const value = map.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)));
|
|
568
569
|
if (!value) {
|
|
569
570
|
return void 0;
|
|
570
571
|
}
|
|
@@ -573,22 +574,22 @@ var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
573
574
|
var decodeStatusListCWT = /* @__PURE__ */ __name((cwt) => {
|
|
574
575
|
const encodedCbor = import_base64url2.default.toBuffer(cwt);
|
|
575
576
|
const encodedCborArray = new Int8Array(encodedCbor);
|
|
576
|
-
const decodedCbor =
|
|
577
|
-
if (!(decodedCbor instanceof
|
|
577
|
+
const decodedCbor = cborpkg.com.sphereon.cbor.Cbor.decode(encodedCborArray);
|
|
578
|
+
if (!(decodedCbor instanceof cborpkg.com.sphereon.cbor.CborArray)) {
|
|
578
579
|
throw new Error("Invalid CWT format: Expected a CBOR array");
|
|
579
580
|
}
|
|
580
581
|
const [, payload] = decodedCbor.value.asJsArrayView();
|
|
581
|
-
if (!(payload instanceof
|
|
582
|
+
if (!(payload instanceof cborpkg.com.sphereon.cbor.CborByteString)) {
|
|
582
583
|
throw new Error("Invalid payload format: Expected a CBOR ByteString");
|
|
583
584
|
}
|
|
584
|
-
const claims =
|
|
585
|
-
if (!(claims instanceof
|
|
585
|
+
const claims = cborpkg.com.sphereon.cbor.Cbor.decode(payload.value);
|
|
586
|
+
if (!(claims instanceof cborpkg.com.sphereon.cbor.CborMap)) {
|
|
586
587
|
throw new Error("Invalid claims format: Expected a CBOR map");
|
|
587
588
|
}
|
|
588
589
|
const claimsMap = claims.value.asJsMapView();
|
|
589
|
-
const statusListMap = claimsMap.get(new
|
|
590
|
-
const bits = Number(statusListMap.get(new
|
|
591
|
-
const decoded = new Uint8Array(statusListMap.get(new
|
|
590
|
+
const statusListMap = claimsMap.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView();
|
|
591
|
+
const bits = Number(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString("bits")).value);
|
|
592
|
+
const decoded = new Uint8Array(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString("lst")).value);
|
|
592
593
|
const uint8Array = (0, import_pako.inflate)(decoded);
|
|
593
594
|
const rawStatusList = decompressRawStatusList(uint8Array, bits);
|
|
594
595
|
const statusList = new import_jwt_status_list2.StatusList(rawStatusList, bits);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/functions.ts","../src/utils.ts","../src/impl/StatusList2021.ts","../src/impl/OAuthStatusList.ts","../src/impl/encoding/jwt.ts","../src/impl/encoding/common.ts","../src/impl/encoding/cbor.ts","../src/impl/StatusListFactory.ts"],"sourcesContent":["/**\n */\n\nexport * from './types'\nexport * from './functions'\n","import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport {\n ICredential,\n ICredentialStatus,\n IIssuer,\n IVerifiableCredential,\n OrPromise,\n ProofFormat,\n StatusListCredential,\n StatusListCredentialIdMode,\n StatusListDriverType,\n StatusListIndexingDirection,\n StatusListType,\n StatusPurpose2021,\n} from '@sphereon/ssi-types'\nimport {\n CredentialPayload,\n IAgentContext,\n ICredentialIssuer,\n ICredentialPlugin,\n ICredentialVerifier,\n IKeyManager,\n IPluginMethodMap,\n} from '@veramo/core'\nimport { DataSource } from 'typeorm'\nimport { BitsPerStatus } from '@sd-jwt/jwt-status-list'\nimport { SdJwtVcPayload } from '@sd-jwt/sd-jwt-vc'\nimport { StatusListOpts } from '@sphereon/oid4vci-common'\n\nexport enum StatusOAuth {\n Valid = 0,\n Invalid = 1,\n Suspended = 2,\n}\n\nexport enum Status2021 {\n Valid = 0,\n Invalid = 1,\n}\n\nexport type StatusList2021Args = {\n indexingDirection: StatusListIndexingDirection\n statusPurpose?: StatusPurpose2021\n // todo: validFrom and validUntil\n}\n\nexport type OAuthStatusListArgs = {\n bitsPerStatus?: BitsPerStatus\n expiresAt?: Date\n}\n\nexport type BaseCreateNewStatusListArgs = {\n type: StatusListType\n id: string\n issuer: string | IIssuer\n correlationId?: string\n length?: number\n proofFormat?: ProofFormat\n keyRef?: string\n statusList2021?: StatusList2021Args\n oauthStatusList?: OAuthStatusListArgs\n driverType?: StatusListDriverType\n}\n\nexport type UpdateStatusList2021Args = {\n statusPurpose: StatusPurpose2021\n}\n\nexport type UpdateOAuthStatusListArgs = {\n bitsPerStatus: BitsPerStatus\n expiresAt?: Date\n}\n\nexport interface UpdateStatusListFromEncodedListArgs {\n type?: StatusListType\n statusListIndex: number | string\n value: boolean\n proofFormat?: ProofFormat\n keyRef?: string\n correlationId?: string\n encodedList: string\n issuer: string | IIssuer\n id: string\n statusList2021?: UpdateStatusList2021Args\n oauthStatusList?: UpdateOAuthStatusListArgs\n}\n\nexport interface UpdateStatusListFromStatusListCredentialArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n keyRef?: string\n statusListIndex: number | string\n value: number | Status2021 | StatusOAuth\n}\n\nexport interface StatusListResult {\n encodedList: string\n statusListCredential: StatusListCredential\n length: number\n type: StatusListType\n proofFormat: ProofFormat\n id: string\n statuslistContentType: string\n issuer: string | IIssuer\n statusList2021?: StatusList2021Details\n oauthStatusList?: OAuthStatusDetails\n\n // These cannot be deduced from the VC, so they are present when callers pass in these values as params\n correlationId?: string\n driverType?: StatusListDriverType\n credentialIdMode?: StatusListCredentialIdMode\n}\n\ninterface StatusList2021Details {\n indexingDirection: StatusListIndexingDirection\n statusPurpose?: StatusPurpose2021\n}\n\ninterface OAuthStatusDetails {\n bitsPerStatus?: BitsPerStatus\n expiresAt?: Date\n}\n\nexport interface StatusList2021EntryCredentialStatus extends ICredentialStatus {\n type: 'StatusList2021Entry'\n statusPurpose: StatusPurpose2021\n statusListIndex: string\n statusListCredential: string\n}\n\nexport interface StatusListOAuthEntryCredentialStatus extends ICredentialStatus {\n type: 'OAuthStatusListEntry'\n bitsPerStatus: number\n statusListIndex: string\n statusListCredential: string\n expiresAt?: Date\n}\n\nexport interface StatusList2021ToVerifiableCredentialArgs {\n issuer: string | IIssuer\n id: string\n type?: StatusListType\n proofFormat?: ProofFormat\n keyRef?: string\n encodedList: string\n statusPurpose: StatusPurpose2021\n}\n\nexport interface CreateStatusListArgs {\n issuer: string | IIssuer\n id: string\n proofFormat?: ProofFormat\n keyRef?: string\n correlationId?: string\n length?: number\n statusList2021?: StatusList2021Args\n oauthStatusList?: OAuthStatusListArgs\n}\n\nexport interface UpdateStatusListIndexArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n statusListIndex: number | string\n value: number | Status2021 | StatusOAuth\n keyRef?: string\n expiresAt?: Date\n}\n\nexport interface CheckStatusIndexArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n statusListIndex: string | number\n}\n\nexport interface ToStatusListDetailsArgs {\n statusListPayload: StatusListCredential\n correlationId?: string\n driverType?: StatusListDriverType\n}\n\n/**\n * The interface definition for a plugin that can add statuslist info to a credential\n *\n * @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}\n *\n * @beta This API is likely to change without a BREAKING CHANGE notice\n */\nexport interface IStatusListPlugin extends IPluginMethodMap {\n /**\n * Create a new status list\n *\n * @param args Status list information like type and size\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n *\n * @returns - The details of the newly created status list\n */\n slCreateStatusList(args: CreateNewStatusListArgs, context: IRequiredContext): Promise<StatusListResult>\n\n /**\n * Ensures status list info like index and list id is added to a credential\n *\n * @param args - Arguments necessary to add the statuslist info.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n *\n * @returns - a promise that resolves to the credential now with status support\n *\n * @beta This API is likely to change without a BREAKING CHANGE notice\n */\n slAddStatusToCredential(args: IAddStatusToCredentialArgs, context: IRequiredContext): Promise<CredentialWithStatusSupport>\n\n slAddStatusToSdJwtCredential(args: IAddStatusToSdJwtCredentialArgs, context: IRequiredContext): Promise<SdJwtVcPayload>\n\n /**\n * Get the status list using the configured driver for the SL. Normally a correlationId or id should suffice. Optionally accepts a dbName/datasource\n * @param args\n * @param context\n */\n slGetStatusList(args: GetStatusListArgs, context: IRequiredContext): Promise<StatusListResult>\n\n /**\n * Import status lists when noy yet present\n *\n * @param imports Array of status list information like type and size\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n */\n slImportStatusLists(imports: Array<CreateNewStatusListArgs>, context: IRequiredContext): Promise<boolean>\n}\n\nexport type CreateNewStatusListFuncArgs = BaseCreateNewStatusListArgs\n\nexport type CreateNewStatusListArgs = BaseCreateNewStatusListArgs & {\n dbName?: string\n dataSource?: OrPromise<DataSource>\n isDefault?: boolean\n}\n\nexport type IAddStatusToCredentialArgs = Omit<IIssueCredentialStatusOpts, 'dataSource'> & {\n credential: CredentialWithStatusSupport\n}\n\nexport type IAddStatusToSdJwtCredentialArgs = Omit<IIssueCredentialStatusOpts, 'dataSource'> & {\n credential: SdJwtVcPayload\n}\n\nexport interface IIssueCredentialStatusOpts {\n dataSource?: DataSource\n statusLists?: Array<StatusListOpts>\n credentialId?: string // An id to use for the credential. Normally should be set as the crdential.id value\n value?: string\n}\n\nexport type GetStatusListArgs = {\n id?: string\n correlationId?: string\n dataSource?: OrPromise<DataSource>\n dbName?: string\n}\n\nexport type CredentialWithStatusSupport = ICredential | CredentialPayload | IVerifiableCredential\n\nexport type SignedStatusListData = {\n statusListCredential: StatusListCredential\n encodedList: string\n}\n\nexport type IRequiredPlugins = ICredentialPlugin & IIdentifierResolution\nexport type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager & ICredentialPlugin>\n","import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport {\n CredentialMapper,\n DocumentFormat,\n ProofFormat,\n StatusListCredential,\n StatusListDriverType,\n StatusListType,\n StatusPurpose2021,\n} from '@sphereon/ssi-types'\nimport { CredentialStatus, DIDDocument, IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core'\n\nimport { checkStatus } from '@sphereon/vc-status-list'\n\n// @ts-ignore\nimport { CredentialJwtOrJSON, StatusMethod } from 'credential-status'\nimport {\n CreateNewStatusListFuncArgs,\n Status2021,\n StatusList2021ToVerifiableCredentialArgs,\n StatusListResult,\n StatusOAuth,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from './types'\nimport { assertValidProofType, determineStatusListType, getAssertedValue, getAssertedValues } from './utils'\nimport { getStatusListImplementation } from './impl/StatusListFactory'\n\nexport async function fetchStatusListCredential(args: { statusListCredential: string }): Promise<StatusListCredential> {\n const url = getAssertedValue('statusListCredential', args.statusListCredential)\n try {\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(`Fetching status list ${url} resulted in an error: ${response.status} : ${response.statusText}`)\n }\n const responseAsText = await response.text()\n if (responseAsText.trim().startsWith('{')) {\n return JSON.parse(responseAsText) as StatusListCredential\n }\n return responseAsText as StatusListCredential\n } catch (error) {\n console.error(`Fetching status list ${url} resulted in an unexpected error: ${error instanceof Error ? error.message : JSON.stringify(error)}`)\n throw error\n }\n}\n\nexport function statusPluginStatusFunction(args: {\n documentLoader: any\n suite: any\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}): StatusMethod {\n return async (credential: CredentialJwtOrJSON, didDoc: DIDDocument): Promise<CredentialStatus> => {\n const result = await checkStatusForCredential({\n ...args,\n documentLoader: args.documentLoader,\n credential: credential as StatusListCredential,\n errorUnknownListType: args.errorUnknownListType,\n })\n\n return {\n revoked: !result.verified || result.error,\n ...(result.error && { error: result.error }),\n }\n }\n}\n\n/**\n * Function that can be used together with @digitalbazar/vc and @digitialcredentials/vc\n * @param args\n */\nexport function vcLibCheckStatusFunction(args: {\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}) {\n const { mandatoryCredentialStatus, verifyStatusListCredential, verifyMatchingIssuers, errorUnknownListType } = args\n return (args: {\n credential: StatusListCredential\n documentLoader: any\n suite: any\n }): Promise<{\n verified: boolean\n error?: any\n }> => {\n return checkStatusForCredential({\n ...args,\n mandatoryCredentialStatus,\n verifyStatusListCredential,\n verifyMatchingIssuers,\n errorUnknownListType,\n })\n }\n}\n\nexport async function checkStatusForCredential(args: {\n credential: StatusListCredential\n documentLoader: any\n suite: any\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}): Promise<{ verified: boolean; error?: any }> {\n const verifyStatusListCredential = args.verifyStatusListCredential ?? true\n const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true\n const uniform = CredentialMapper.toUniformCredential(args.credential)\n if (!('credentialStatus' in uniform) || !uniform.credentialStatus) {\n if (args.mandatoryCredentialStatus) {\n const error = 'No credential status object found in the Verifiable Credential and it is mandatory'\n console.log(error)\n return { verified: false, error }\n }\n return { verified: true }\n }\n if ('credentialStatus' in uniform && uniform.credentialStatus) {\n if (uniform.credentialStatus.type === 'StatusList2021Entry') {\n return checkStatus({ ...args, verifyStatusListCredential, verifyMatchingIssuers })\n } else if (args?.errorUnknownListType) {\n const error = `Credential status type ${uniform.credentialStatus.type} is not supported, and check status has been configured to not allow for that`\n console.log(error)\n return { verified: false, error }\n } else {\n console.log(`Skipped verification of status type ${uniform.credentialStatus.type} as we do not support it (yet)`)\n }\n }\n return { verified: true }\n}\n\nexport async function simpleCheckStatusFromStatusListUrl(args: {\n statusListCredential: string\n statusPurpose?: StatusPurpose2021\n type?: StatusListType | 'StatusList2021Entry'\n id?: string\n statusListIndex: string\n}): Promise<number | Status2021 | StatusOAuth> {\n return checkStatusIndexFromStatusListCredential({\n ...args,\n statusListCredential: await fetchStatusListCredential(args),\n })\n}\n\nexport async function checkStatusIndexFromStatusListCredential(args: {\n statusListCredential: StatusListCredential\n statusPurpose?: StatusPurpose2021\n type?: StatusListType | 'StatusList2021Entry'\n id?: string\n statusListIndex: string | number\n}): Promise<number | Status2021 | StatusOAuth> {\n const statusListType: StatusListType = determineStatusListType(args.statusListCredential)\n const implementation = getStatusListImplementation(statusListType)\n return implementation.checkStatusIndex(args)\n}\n\nexport async function createNewStatusList(\n args: CreateNewStatusListFuncArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const { type } = getAssertedValues(args)\n const implementation = getStatusListImplementation(type)\n return implementation.createNewStatusList(args, context)\n}\n\nexport async function updateStatusIndexFromStatusListCredential(\n args: UpdateStatusListIndexArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const credential = getAssertedValue('statusListCredential', args.statusListCredential)\n const statusListType: StatusListType = determineStatusListType(credential)\n const implementation = getStatusListImplementation(statusListType)\n return implementation.updateStatusListIndex(args, context)\n}\n\n// Keeping helper function for backward compatibility\nexport async function statusListCredentialToDetails(args: {\n statusListCredential: StatusListCredential\n correlationId?: string\n driverType?: StatusListDriverType\n}): Promise<StatusListResult> {\n const credential = getAssertedValue('statusListCredential', args.statusListCredential)\n\n let statusListType: StatusListType | undefined\n const documentFormat = CredentialMapper.detectDocumentType(credential)\n if (documentFormat === DocumentFormat.JWT) {\n const [header] = credential.split('.')\n const decodedHeader = JSON.parse(Buffer.from(header, 'base64').toString())\n\n if (decodedHeader.typ === 'statuslist+jwt') {\n statusListType = StatusListType.OAuthStatusList\n }\n } else if (documentFormat === DocumentFormat.MSO_MDOC) {\n statusListType = StatusListType.OAuthStatusList\n // TODO check CBOR content?\n }\n if (!statusListType) {\n const uniform = CredentialMapper.toUniformCredential(credential)\n const type = uniform.type.find((t) => t.includes('StatusList2021') || t.includes('OAuth2StatusList'))\n if (!type) {\n throw new Error('Invalid status list credential type')\n }\n statusListType = type.replace('Credential', '') as StatusListType\n }\n\n const implementation = getStatusListImplementation(statusListType)\n return await implementation.toStatusListDetails({\n statusListPayload: credential,\n correlationId: args.correlationId,\n driverType: args.driverType,\n })\n}\n\nexport async function updateStatusListIndexFromEncodedList(\n args: UpdateStatusListFromEncodedListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const { type } = getAssertedValue('type', args)\n const implementation = getStatusListImplementation(type!)\n return implementation.updateStatusListFromEncodedList(args, context)\n}\n\nexport async function statusList2021ToVerifiableCredential(\n args: StatusList2021ToVerifiableCredentialArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListCredential> {\n const { issuer, id, type } = getAssertedValues(args)\n const identifier = await context.agent.identifierManagedGet({\n identifier: typeof issuer === 'string' ? issuer : issuer.id,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true, // FIXME Fix identifier resolution for EBSI\n })\n const proofFormat: ProofFormat = args?.proofFormat ?? 'lds'\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const encodedList = getAssertedValue('encodedList', args.encodedList)\n const statusPurpose = getAssertedValue('statusPurpose', args.statusPurpose)\n const credential = {\n '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],\n id,\n issuer,\n // issuanceDate: \"2021-03-10T04:24:12.164Z\",\n type: ['VerifiableCredential', `${type}Credential`],\n credentialSubject: {\n id,\n type,\n statusPurpose,\n encodedList,\n },\n }\n // TODO copy statuslist schema to local and disable fetching remote contexts\n const verifiableCredential = await context.agent.createVerifiableCredential({\n credential,\n keyRef: identifier.kmsKeyRef,\n proofFormat: veramoProofFormat,\n fetchRemoteContexts: true,\n })\n\n return CredentialMapper.toWrappedVerifiableCredential(verifiableCredential as StatusListCredential).original as StatusListCredential\n}\n","import {\n CredentialMapper,\n IIssuer,\n ProofFormat,\n StatusListType,\n StatusListType as StatusListTypeW3C,\n StatusListCredential,\n DocumentFormat,\n} from '@sphereon/ssi-types'\nimport { jwtDecode } from 'jwt-decode'\n\nexport function getAssertedStatusListType(type?: StatusListType) {\n const assertedType = type ?? StatusListType.StatusList2021\n if (![StatusListType.StatusList2021, StatusListType.OAuthStatusList].includes(assertedType)) {\n throw Error(`StatusList type ${assertedType} is not supported (yet)`)\n }\n return assertedType\n}\n\nexport function getAssertedValue<T>(name: string, value: T): NonNullable<T> {\n if (value === undefined || value === null) {\n throw Error(`Missing required ${name} value`)\n }\n return value\n}\n\nexport function getAssertedValues(args: { issuer: string | IIssuer; id: string; type?: StatusListTypeW3C | StatusListType }) {\n const type = getAssertedStatusListType(args?.type)\n const id = getAssertedValue('id', args.id)\n const issuer = getAssertedValue('issuer', args.issuer)\n return { id, issuer, type }\n}\n\nexport function getAssertedProperty<T extends object>(propertyName: string, obj: T): NonNullable<any> {\n if (!(propertyName in obj)) {\n throw Error(`The input object does not contain required property: ${propertyName}`)\n }\n return getAssertedValue(propertyName, (obj as any)[propertyName])\n}\n\nconst ValidProofTypeMap = new Map<StatusListType, ProofFormat[]>([\n [StatusListType.StatusList2021, ['jwt', 'lds', 'EthereumEip712Signature2021']],\n [StatusListType.OAuthStatusList, ['jwt', 'cbor']],\n])\n\nexport function assertValidProofType(type: StatusListType, proofFormat: ProofFormat) {\n const validProofTypes = ValidProofTypeMap.get(type)\n if (!validProofTypes?.includes(proofFormat)) {\n throw Error(`Invalid proof format '${proofFormat}' for status list type ${type}`)\n }\n}\n\nexport function determineStatusListType(credential: StatusListCredential): StatusListType {\n const proofFormat = determineProofFormat(credential)\n switch (proofFormat) {\n case 'jwt':\n const payload: StatusListCredential = jwtDecode(credential as string)\n const keys = Object.keys(payload)\n if (keys.includes('status_list')) {\n return StatusListType.OAuthStatusList\n } else if (keys.includes('vc')) {\n return StatusListType.StatusList2021\n }\n break\n case 'lds':\n const uniform = CredentialMapper.toUniformCredential(credential)\n const type = uniform.type.find((t) => {\n return Object.values(StatusListType).some((statusType) => t.includes(statusType))\n })\n if (!type) {\n throw new Error('Invalid status list credential type')\n }\n return type.replace('Credential', '') as StatusListType\n\n case 'cbor':\n return StatusListType.OAuthStatusList\n }\n\n throw new Error('Cannot determine status list type from credential payload')\n}\n\nexport function determineProofFormat(credential: StatusListCredential): ProofFormat {\n const type: DocumentFormat = CredentialMapper.detectDocumentType(credential)\n switch (type) {\n case DocumentFormat.JWT:\n return 'jwt'\n case DocumentFormat.MSO_MDOC:\n // Not really mdoc, just assume Cbor for now, I'd need to decode at least the header to what type of Cbor we have\n return 'cbor'\n case DocumentFormat.JSONLD:\n return 'lds'\n default:\n throw Error('Cannot determine credential payload type')\n }\n}\n","import { IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core'\nimport { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport { CredentialMapper, DocumentFormat, IIssuer, ProofFormat, StatusListCredential, StatusListType } from '@sphereon/ssi-types'\n\nimport { StatusList } from '@sphereon/vc-status-list'\nimport { IStatusList } from './IStatusList'\nimport {\n CheckStatusIndexArgs,\n CreateStatusListArgs,\n Status2021,\n StatusListResult,\n ToStatusListDetailsArgs,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from '../types'\nimport { assertValidProofType, getAssertedProperty, getAssertedValue, getAssertedValues } from '../utils'\n\nexport const DEFAULT_LIST_LENGTH = 250000\nexport const DEFAULT_PROOF_FORMAT = 'lds' as VeramoProofFormat\n\nexport class StatusList2021Implementation implements IStatusList {\n async createNewStatusList(\n args: CreateStatusListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n const length = args?.length ?? DEFAULT_LIST_LENGTH\n const proofFormat: ProofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const { issuer, id } = args\n const correlationId = getAssertedValue('correlationId', args.correlationId)\n\n const list = new StatusList({ length })\n const encodedList = await list.encode()\n const statusPurpose = 'revocation'\n\n const statusListCredential = await this.createVerifiableCredential(\n {\n ...args,\n encodedList,\n proofFormat: veramoProofFormat,\n },\n context,\n )\n\n return {\n encodedList,\n statusListCredential: statusListCredential,\n statusList2021: {\n statusPurpose,\n indexingDirection: 'rightToLeft',\n },\n length,\n type: StatusListType.StatusList2021,\n proofFormat,\n id,\n correlationId,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListIndex(\n args: UpdateStatusListIndexArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n const credential = args.statusListCredential\n const uniform = CredentialMapper.toUniformCredential(credential)\n const { issuer, credentialSubject } = uniform\n const id = getAssertedValue('id', uniform.id)\n const origEncodedList = getAssertedProperty('encodedList', credentialSubject)\n\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n const statusList = await StatusList.decode({ encodedList: origEncodedList })\n statusList.setStatus(index, args.value != 0)\n const encodedList = await statusList.encode()\n\n const proofFormat = CredentialMapper.detectDocumentType(credential) === DocumentFormat.JWT ? 'jwt' : 'lds'\n const updatedCredential = await this.createVerifiableCredential(\n {\n ...args,\n id,\n issuer,\n encodedList,\n proofFormat: proofFormat,\n },\n context,\n )\n\n return {\n statusListCredential: updatedCredential,\n encodedList,\n statusList2021: {\n ...('statusPurpose' in credentialSubject ? { statusPurpose: credentialSubject.statusPurpose } : {}),\n indexingDirection: 'rightToLeft',\n },\n length: statusList.length - 1,\n type: StatusListType.StatusList2021,\n proofFormat: proofFormat,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListFromEncodedList(\n args: UpdateStatusListFromEncodedListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n if (!args.statusList2021) {\n throw new Error('statusList2021 options required for type StatusList2021')\n }\n const proofFormat: ProofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const { issuer, id } = getAssertedValues(args)\n const statusList = await StatusList.decode({ encodedList: args.encodedList })\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n statusList.setStatus(index, args.value)\n\n const newEncodedList = await statusList.encode()\n const credential = await this.createVerifiableCredential(\n {\n id,\n issuer,\n encodedList: newEncodedList,\n proofFormat: veramoProofFormat,\n keyRef: args.keyRef,\n },\n context,\n )\n\n return {\n type: StatusListType.StatusList2021,\n statusListCredential: credential,\n encodedList: newEncodedList,\n statusList2021: {\n statusPurpose: args.statusList2021.statusPurpose,\n indexingDirection: 'rightToLeft',\n },\n length: statusList.length,\n proofFormat: args.proofFormat ?? 'lds',\n id: id,\n issuer: issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | Status2021> {\n const uniform = CredentialMapper.toUniformCredential(args.statusListCredential)\n const { credentialSubject } = uniform\n const encodedList = getAssertedProperty('encodedList', credentialSubject)\n\n const statusList = await StatusList.decode({ encodedList })\n const status = statusList.getStatus(typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex))\n return status ? Status2021.Invalid : Status2021.Valid\n }\n\n async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {\n const { statusListPayload } = args\n const uniform = CredentialMapper.toUniformCredential(statusListPayload)\n const { issuer, credentialSubject } = uniform\n const id = getAssertedValue('id', uniform.id)\n const encodedList = getAssertedProperty('encodedList', credentialSubject)\n const proofFormat: ProofFormat = CredentialMapper.detectDocumentType(statusListPayload) === DocumentFormat.JWT ? 'jwt' : 'lds'\n\n const statusPurpose = getAssertedProperty('statusPurpose', credentialSubject)\n const list = await StatusList.decode({ encodedList })\n\n return {\n id,\n encodedList,\n issuer,\n type: StatusListType.StatusList2021,\n proofFormat,\n length: list.length,\n statusListCredential: statusListPayload,\n statuslistContentType: this.buildContentType(proofFormat),\n statusList2021: {\n indexingDirection: 'rightToLeft',\n statusPurpose,\n },\n ...(args.correlationId && { correlationId: args.correlationId }),\n ...(args.driverType && { driverType: args.driverType }),\n }\n }\n\n private async createVerifiableCredential(\n args: {\n id: string\n issuer: string | IIssuer\n encodedList: string\n proofFormat: VeramoProofFormat\n keyRef?: string\n },\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListCredential> {\n const identifier = await context.agent.identifierManagedGet({\n identifier: typeof args.issuer === 'string' ? args.issuer : args.issuer.id,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true,\n })\n\n const credential = {\n '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],\n id: args.id,\n issuer: args.issuer,\n type: ['VerifiableCredential', 'StatusList2021Credential'],\n credentialSubject: {\n id: args.id,\n type: 'StatusList2021',\n statusPurpose: 'revocation',\n encodedList: args.encodedList,\n },\n }\n\n const verifiableCredential = await context.agent.createVerifiableCredential({\n credential,\n keyRef: args.keyRef ?? identifier.kmsKeyRef,\n proofFormat: args.proofFormat,\n fetchRemoteContexts: true,\n })\n\n return CredentialMapper.toWrappedVerifiableCredential(verifiableCredential as StatusListCredential).original as StatusListCredential\n }\n\n private buildContentType(proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor' | undefined) {\n switch (proofFormat) {\n case 'jwt':\n return `application/statuslist+jwt`\n case 'cbor':\n return `application/statuslist+cwt`\n case 'lds':\n return 'application/statuslist+ld+json'\n default:\n throw Error(`Unsupported content type '${proofFormat}' for status lists`)\n }\n }\n}\n","import { IAgentContext, ICredentialPlugin, IKeyManager } from '@veramo/core'\nimport { CompactJWT, CWT, ProofFormat, StatusListType } from '@sphereon/ssi-types'\nimport {\n CheckStatusIndexArgs,\n CreateStatusListArgs,\n SignedStatusListData,\n StatusListResult,\n StatusOAuth,\n ToStatusListDetailsArgs,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from '../types'\nimport { determineProofFormat, getAssertedValue, getAssertedValues } from '../utils'\nimport { IStatusList } from './IStatusList'\nimport { StatusList } from '@sd-jwt/jwt-status-list'\nimport { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'\nimport { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport { createSignedJwt, decodeStatusListJWT } from './encoding/jwt'\nimport { createSignedCbor, decodeStatusListCWT } from './encoding/cbor'\n\ntype IRequiredContext = IAgentContext<ICredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>\n\nexport const DEFAULT_BITS_PER_STATUS = 1 // 1 bit is sufficient for 0x00 - \"VALID\" 0x01 - \"INVALID\" saving space in the process\nexport const DEFAULT_LIST_LENGTH = 250000\nexport const DEFAULT_PROOF_FORMAT = 'jwt' as ProofFormat\n\nexport class OAuthStatusListImplementation implements IStatusList {\n async createNewStatusList(args: CreateStatusListArgs, context: IRequiredContext): Promise<StatusListResult> {\n if (!args.oauthStatusList) {\n throw new Error('OAuthStatusList options are required for type OAuthStatusList')\n }\n\n const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n const { issuer, id, oauthStatusList, keyRef } = args\n const { bitsPerStatus, expiresAt } = oauthStatusList\n const length = args.length ?? DEFAULT_LIST_LENGTH\n const issuerString = typeof issuer === 'string' ? issuer : issuer.id\n const correlationId = getAssertedValue('correlationId', args.correlationId)\n\n const statusList = new StatusList(new Array(length).fill(0), bitsPerStatus ?? DEFAULT_BITS_PER_STATUS)\n const encodedList = statusList.compressStatusList()\n const { statusListCredential } = await this.createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef)\n\n return {\n encodedList,\n statusListCredential,\n oauthStatusList: { bitsPerStatus },\n length,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n id,\n correlationId,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListIndex(args: UpdateStatusListIndexArgs, context: IRequiredContext): Promise<StatusListResult> {\n const { statusListCredential, value, expiresAt, keyRef } = args\n if (typeof statusListCredential !== 'string') {\n return Promise.reject('statusListCredential in neither JWT nor CWT')\n }\n\n const proofFormat = determineProofFormat(statusListCredential)\n const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential)\n const { statusList, issuer, id } = decoded\n\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n if (index < 0 || index >= statusList.statusList.length) {\n throw new Error('Status list index out of bounds')\n }\n\n statusList.setStatus(index, value)\n const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(\n proofFormat,\n context,\n statusList,\n issuer,\n id,\n expiresAt,\n keyRef,\n )\n\n return {\n statusListCredential: signedCredential,\n encodedList,\n oauthStatusList: {\n bitsPerStatus: statusList.getBitsPerStatus(),\n },\n length: statusList.statusList.length,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n // FIXME: This still assumes only two values (boolean), whilst this list supports 8 bits max\n async updateStatusListFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IRequiredContext): Promise<StatusListResult> {\n if (!args.oauthStatusList) {\n throw new Error('OAuthStatusList options are required for type OAuthStatusList')\n }\n const { proofFormat, oauthStatusList, keyRef } = args\n const { bitsPerStatus, expiresAt } = oauthStatusList\n\n const { issuer, id } = getAssertedValues(args)\n const issuerString = typeof issuer === 'string' ? issuer : issuer.id\n\n const listToUpdate = StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS)\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n // FIXME: See above.\n listToUpdate.setStatus(index, args.value ? 1 : 0)\n\n const { statusListCredential, encodedList } = await this.createSignedStatusList(\n proofFormat ?? DEFAULT_PROOF_FORMAT,\n context,\n listToUpdate,\n issuerString,\n id,\n expiresAt,\n keyRef,\n )\n\n return {\n encodedList,\n statusListCredential,\n oauthStatusList: {\n bitsPerStatus,\n expiresAt,\n },\n length: listToUpdate.statusList.length,\n type: StatusListType.OAuthStatusList,\n proofFormat: proofFormat ?? DEFAULT_PROOF_FORMAT,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n private buildContentType(proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor' | undefined) {\n return `application/statuslist+${proofFormat === 'cbor' ? 'cwt' : 'jwt'}`\n }\n\n async checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | StatusOAuth> {\n const { statusListCredential, statusListIndex } = args\n if (typeof statusListCredential !== 'string') {\n return Promise.reject('statusListCredential in neither JWT nor CWT')\n }\n\n const proofFormat = determineProofFormat(statusListCredential)\n const { statusList } = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential)\n\n const index = typeof statusListIndex === 'number' ? statusListIndex : parseInt(statusListIndex)\n if (index < 0 || index >= statusList.statusList.length) {\n throw new Error('Status list index out of bounds')\n }\n\n return statusList.getStatus(index)\n }\n\n async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {\n const { statusListPayload } = args as { statusListPayload: CompactJWT | CWT }\n const proofFormat = determineProofFormat(statusListPayload)\n const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload)\n const { statusList, issuer, id, exp } = decoded\n\n return {\n id,\n encodedList: statusList.compressStatusList(),\n issuer,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n length: statusList.statusList.length,\n statusListCredential: statusListPayload,\n statuslistContentType: this.buildContentType(proofFormat),\n oauthStatusList: {\n bitsPerStatus: statusList.getBitsPerStatus(),\n ...(exp && { expiresAt: new Date(exp * 1000) }),\n },\n ...(args.correlationId && { correlationId: args.correlationId }),\n ...(args.driverType && { driverType: args.driverType }),\n }\n }\n\n private async createSignedStatusList(\n proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor',\n context: IAgentContext<ICredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n ): Promise<SignedStatusListData> {\n switch (proofFormat) {\n case 'jwt': {\n return await createSignedJwt(context, statusList, issuerString, id, expiresAt, keyRef)\n }\n case 'cbor': {\n return await createSignedCbor(context, statusList, issuerString, id, expiresAt, keyRef)\n }\n default:\n throw new Error(`Invalid proof format '${proofFormat}' for OAuthStatusList`)\n }\n }\n}\n","import { CompactJWT, JoseSignatureAlgorithm } from '@sphereon/ssi-types'\nimport { createHeaderAndPayload, StatusList, StatusListJWTHeaderParameters, StatusListJWTPayload } from '@sd-jwt/jwt-status-list'\nimport base64url from 'base64url'\nimport { JWTPayload } from 'did-jwt'\nimport { IRequiredContext, SignedStatusListData } from '../../types'\nimport { DecodedStatusListPayload, resolveIdentifier } from './common'\nimport { TKeyType } from '@veramo/core'\nimport { ensureManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution'\n\nconst STATUS_LIST_JWT_TYP = 'statuslist+jwt'\n\nexport const createSignedJwt = async (\n context: IRequiredContext,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n): Promise<SignedStatusListData> => {\n const identifier = await resolveIdentifier(context, issuerString, keyRef)\n const resolution = await ensureManagedIdentifierResult(identifier, context)\n\n const payload: JWTPayload = {\n iss: issuerString,\n sub: id,\n iat: Math.floor(Date.now() / 1000),\n ...(expiresAt && { exp: Math.floor(expiresAt.getTime() / 1000) }),\n }\n\n const header: StatusListJWTHeaderParameters = {\n alg: getSigningAlgo(resolution.key.type),\n typ: STATUS_LIST_JWT_TYP,\n }\n const values = createHeaderAndPayload(statusList, payload, header)\n const signedJwt = await context.agent.jwtCreateJwsCompactSignature({\n issuer: { ...identifier, noIssPayloadUpdate: false },\n protectedHeader: values.header,\n payload: values.payload,\n })\n\n return {\n statusListCredential: signedJwt.jwt,\n encodedList: (values.payload as StatusListJWTPayload).status_list.lst,\n }\n}\n\nexport const decodeStatusListJWT = (jwt: CompactJWT): DecodedStatusListPayload => {\n const [, payloadBase64] = jwt.split('.')\n const payload = JSON.parse(base64url.decode(payloadBase64))\n\n if (!payload.iss || !payload.sub || !payload.status_list) {\n throw new Error('Missing required fields in JWT payload')\n }\n\n const statusList = StatusList.decompressStatusList(payload.status_list.lst, payload.status_list.bits)\n\n return {\n issuer: payload.iss,\n id: payload.sub,\n statusList,\n exp: payload.exp,\n ttl: payload.ttl,\n iat: payload.iat,\n }\n}\n\nexport const getSigningAlgo = (type: TKeyType): JoseSignatureAlgorithm => {\n switch (type) {\n case 'Ed25519':\n return JoseSignatureAlgorithm.EdDSA\n case 'Secp256k1':\n return JoseSignatureAlgorithm.ES256K\n case 'Secp256r1':\n return JoseSignatureAlgorithm.ES256\n case 'RSA':\n return JoseSignatureAlgorithm.RS256\n default:\n throw Error('Key type not yet supported')\n }\n}\n","import { IRequiredContext } from '../../types'\nimport { StatusList } from '@sd-jwt/jwt-status-list'\n\nexport interface DecodedStatusListPayload {\n issuer: string\n id: string\n statusList: StatusList\n exp?: number\n ttl?: number\n iat: number\n}\n\nexport const resolveIdentifier = async (context: IRequiredContext, issuer: string, keyRef?: string) => {\n return await context.agent.identifierManagedGet({\n identifier: issuer,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true,\n ...(keyRef && { kmsKeyRef: keyRef }), // TODO the getDid resolver should look at this ASAP\n })\n}\n","import { StatusList } from '@sd-jwt/jwt-status-list'\nimport { deflate, inflate } from 'pako'\nimport { com, kotlin } from '@sphereon/kmp-cbor'\nimport base64url from 'base64url'\nimport { IRequiredContext, SignedStatusListData } from '../../types'\nimport { DecodedStatusListPayload, resolveIdentifier } from './common'\nimport { BitsPerStatus } from '@sd-jwt/jwt-status-list'\n\nconst cbor = com.sphereon.cbor\nconst kmp = com.sphereon.kmp\nconst decompressRawStatusList = (StatusList as any).decodeStatusList.bind(StatusList)\n\nconst CWT_CLAIMS = {\n SUBJECT: 2,\n ISSUER: 1,\n ISSUED_AT: 6,\n EXPIRATION: 4,\n TIME_TO_LIVE: 65534,\n STATUS_LIST: 65533,\n} as const\n\nexport const createSignedCbor = async (\n context: IRequiredContext,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n): Promise<SignedStatusListData> => {\n const identifier = await resolveIdentifier(context, issuerString, keyRef)\n\n const encodeStatusList = statusList.encodeStatusList()\n const compressedList = deflate(encodeStatusList, { level: 9 })\n const compressedBytes = new Int8Array(compressedList)\n\n const statusListMap = new cbor.CborMap(\n kotlin.collections.KtMutableMap.fromJsMap(\n new Map<com.sphereon.cbor.CborString, com.sphereon.cbor.CborItem<any>>([\n [new cbor.CborString('bits'), new cbor.CborUInt(kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))],\n [new cbor.CborString('lst'), new cbor.CborByteString(compressedBytes)],\n ]),\n ),\n )\n\n const protectedHeader = new cbor.CborMap(\n kotlin.collections.KtMutableMap.fromJsMap(\n new Map([[new cbor.CborUInt(kmp.LongKMP.fromNumber(16)), new cbor.CborString('statuslist+cwt')]]), // \"type\"\n ),\n )\n const protectedHeaderEncoded = cbor.Cbor.encode(protectedHeader)\n const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt)\n const claimsEncoded: Int8Array = cbor.Cbor.encode(claimsMap)\n\n const signedCWT: string = await context.agent.keyManagerSign({\n keyRef: identifier.kmsKeyRef,\n data: base64url.encode(Buffer.from(claimsEncoded)), // TODO test on RN\n encoding: undefined,\n })\n\n const protectedHeaderEncodedInt8 = new Int8Array(protectedHeaderEncoded)\n const claimsEncodedInt8 = new Int8Array(claimsEncoded)\n const signatureBytes = base64url.decode(signedCWT)\n const signatureInt8 = new Int8Array(Buffer.from(signatureBytes))\n\n const cwtArrayElements: Array<com.sphereon.cbor.CborItem<any>> = [\n new cbor.CborByteString(protectedHeaderEncodedInt8),\n new cbor.CborByteString(claimsEncodedInt8),\n new cbor.CborByteString(signatureInt8),\n ]\n const cwtArray = new cbor.CborArray(kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements))\n const cwtEncoded = cbor.Cbor.encode(cwtArray)\n const cwtBuffer = Buffer.from(cwtEncoded)\n return {\n statusListCredential: base64url.encode(cwtBuffer),\n encodedList: base64url.encode(compressedList as Buffer), // JS in @sd-jwt/jwt-status-list drops it in like this, so keep the same method\n }\n}\n\nfunction buildClaimsMap(\n id: string,\n issuerString: string,\n statusListMap: com.sphereon.cbor.CborMap<com.sphereon.cbor.CborString, com.sphereon.cbor.CborItem<any>>,\n expiresAt?: Date,\n) {\n const ttl = 65535 // FIXME figure out what value should be / come from and what the difference is with exp\n const claimsEntries: Array<[com.sphereon.cbor.CborUInt, com.sphereon.cbor.CborItem<any>]> = [\n [new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)), new cbor.CborString(id)], // \"sub\"\n [new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)), new cbor.CborString(issuerString)], // \"iss\"\n [\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1000))), // \"iat\"\n ],\n ]\n\n if (expiresAt) {\n claimsEntries.push([\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1000))), // \"exp\"\n ])\n }\n\n if (ttl) {\n claimsEntries.push([\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(ttl)), // \"time to live\"\n ])\n }\n\n claimsEntries.push([new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)), statusListMap])\n\n const claimsMap = new cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)))\n return claimsMap\n}\n\nconst getCborValueFromMap = <T>(map: Map<com.sphereon.cbor.CborItem<any>, com.sphereon.cbor.CborItem<any>>, key: number): T => {\n const value = getCborOptionalValueFromMap<T>(map, key)\n if (value === undefined) {\n throw new Error(`Required claim ${key} not found`)\n }\n return value\n}\n\nconst getCborOptionalValueFromMap = <T>(\n map: Map<com.sphereon.cbor.CborItem<any>, com.sphereon.cbor.CborItem<any>>,\n key: number,\n): T | undefined | never => {\n const value = map.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)))\n if (!value) {\n return undefined\n }\n return value.value as T\n}\n\nexport const decodeStatusListCWT = (cwt: string): DecodedStatusListPayload => {\n const encodedCbor = base64url.toBuffer(cwt)\n const encodedCborArray = new Int8Array(encodedCbor)\n const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray)\n\n if (!(decodedCbor instanceof com.sphereon.cbor.CborArray)) {\n throw new Error('Invalid CWT format: Expected a CBOR array')\n }\n\n const [, payload] = decodedCbor.value.asJsArrayView()\n if (!(payload instanceof com.sphereon.cbor.CborByteString)) {\n throw new Error('Invalid payload format: Expected a CBOR ByteString')\n }\n\n const claims = com.sphereon.cbor.Cbor.decode(payload.value)\n if (!(claims instanceof com.sphereon.cbor.CborMap)) {\n throw new Error('Invalid claims format: Expected a CBOR map')\n }\n\n const claimsMap = claims.value.asJsMapView()\n\n const statusListMap = claimsMap.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView()\n\n const bits = Number(statusListMap.get(new com.sphereon.cbor.CborString('bits')).value) as BitsPerStatus\n const decoded = new Uint8Array(statusListMap.get(new com.sphereon.cbor.CborString('lst')).value)\n const uint8Array = inflate(decoded)\n const rawStatusList = decompressRawStatusList(uint8Array, bits)\n const statusList = new StatusList(rawStatusList, bits)\n\n return {\n issuer: getCborValueFromMap<string>(claimsMap, CWT_CLAIMS.ISSUER),\n id: getCborValueFromMap<string>(claimsMap, CWT_CLAIMS.SUBJECT),\n statusList,\n iat: Number(getCborValueFromMap<number>(claimsMap, CWT_CLAIMS.ISSUED_AT)),\n exp: getCborOptionalValueFromMap<number>(claimsMap, CWT_CLAIMS.EXPIRATION),\n ttl: getCborOptionalValueFromMap<number>(claimsMap, CWT_CLAIMS.TIME_TO_LIVE),\n }\n}\n","import { IStatusList } from './IStatusList'\nimport { StatusList2021Implementation } from './StatusList2021'\nimport { OAuthStatusListImplementation } from './OAuthStatusList'\nimport { StatusListType } from '@sphereon/ssi-types'\n\nexport class StatusListFactory {\n private static instance: StatusListFactory\n private implementations: Map<StatusListType, IStatusList>\n\n private constructor() {\n this.implementations = new Map()\n this.implementations.set(StatusListType.StatusList2021, new StatusList2021Implementation())\n this.implementations.set(StatusListType.OAuthStatusList, new OAuthStatusListImplementation())\n }\n\n public static getInstance(): StatusListFactory {\n if (!StatusListFactory.instance) {\n StatusListFactory.instance = new StatusListFactory()\n }\n return StatusListFactory.instance\n }\n\n public getByType(type: StatusListType): IStatusList {\n const statusList = this.implementations.get(type)\n if (!statusList) {\n throw new Error(`No implementation found for status list type: ${type}`)\n }\n return statusList\n }\n}\n\nexport function getStatusListImplementation(type: StatusListType): IStatusList {\n return StatusListFactory.getInstance().getByType(type)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AC6BO,IAAKA,cAAAA,yBAAAA,cAAAA;;;;SAAAA;;AAML,IAAKC,aAAAA,yBAAAA,aAAAA;;;SAAAA;;;;AClCZ,IAAAC,oBAQO;AAGP,IAAAC,yBAA4B;;;ACZ5B,uBAQO;AACP,wBAA0B;AAEnB,SAASC,0BAA0BC,MAAqB;AAC7D,QAAMC,eAAeD,QAAQE,gCAAeC;AAC5C,MAAI,CAAC;IAACD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AWe;IACnBV,aAAaG;IACbQ,qBAAqB;EACvB,CAAA;AAEA,SAAO9D,mCAAiB+D,8BAA8BL,oBAAAA,EAA8CM;AACtG;AAtCsBrB;","names":["StatusOAuth","Status2021","import_ssi_types","import_vc_status_list","getAssertedStatusListType","type","assertedType","StatusListType","StatusList2021","OAuthStatusList","includes","Error","getAssertedValue","name","value","undefined","getAssertedValues","args","id","issuer","getAssertedProperty","propertyName","obj","ValidProofTypeMap","Map","assertValidProofType","proofFormat","validProofTypes","get","determineStatusListType","credential","determineProofFormat","payload","jwtDecode","keys","Object","uniform","CredentialMapper","toUniformCredential","find","t","values","some","statusType","replace","detectDocumentType","DocumentFormat","JWT","MSO_MDOC","JSONLD","import_ssi_types","DEFAULT_LIST_LENGTH","DEFAULT_PROOF_FORMAT","StatusList2021Implementation","createNewStatusList","args","context","length","proofFormat","assertValidProofType","StatusListType","StatusList2021","veramoProofFormat","issuer","id","correlationId","getAssertedValue","list","StatusList","encodedList","encode","statusPurpose","statusListCredential","createVerifiableCredential","statusList2021","indexingDirection","type","statuslistContentType","buildContentType","updateStatusListIndex","credential","uniform","CredentialMapper","toUniformCredential","credentialSubject","origEncodedList","getAssertedProperty","index","statusListIndex","parseInt","statusList","decode","setStatus","value","detectDocumentType","DocumentFormat","JWT","updatedCredential","updateStatusListFromEncodedList","Error","getAssertedValues","newEncodedList","keyRef","checkStatusIndex","status","getStatus","Status2021","Invalid","Valid","toStatusListDetails","statusListPayload","driverType","identifier","agent","identifierManagedGet","vmRelationship","offlineWhenNoDIDRegistered","verifiableCredential","kmsKeyRef","fetchRemoteContexts","toWrappedVerifiableCredential","original","import_ssi_types","import_jwt_status_list","import_ssi_types","resolveIdentifier","context","issuer","keyRef","agent","identifierManagedGet","identifier","vmRelationship","offlineWhenNoDIDRegistered","kmsKeyRef","STATUS_LIST_JWT_TYP","createSignedJwt","context","statusList","issuerString","id","expiresAt","keyRef","identifier","resolveIdentifier","resolution","ensureManagedIdentifierResult","payload","iss","sub","iat","Math","floor","Date","now","exp","getTime","header","alg","getSigningAlgo","key","type","typ","values","createHeaderAndPayload","signedJwt","agent","jwtCreateJwsCompactSignature","issuer","noIssPayloadUpdate","protectedHeader","statusListCredential","jwt","encodedList","status_list","lst","decodeStatusListJWT","payloadBase64","split","JSON","parse","base64url","decode","Error","StatusList","decompressStatusList","bits","ttl","JoseSignatureAlgorithm","EdDSA","ES256K","ES256","RS256","import_jwt_status_list","import_base64url","cbor","com","sphereon","kmp","decompressRawStatusList","StatusList","decodeStatusList","bind","CWT_CLAIMS","SUBJECT","ISSUER","ISSUED_AT","EXPIRATION","TIME_TO_LIVE","STATUS_LIST","createSignedCbor","context","statusList","issuerString","id","expiresAt","keyRef","identifier","resolveIdentifier","encodeStatusList","compressedList","deflate","level","compressedBytes","Int8Array","statusListMap","CborMap","kotlin","collections","KtMutableMap","fromJsMap","Map","CborString","CborUInt","LongKMP","fromNumber","getBitsPerStatus","CborByteString","protectedHeader","protectedHeaderEncoded","Cbor","encode","claimsMap","buildClaimsMap","claimsEncoded","signedCWT","agent","keyManagerSign","kmsKeyRef","data","base64url","Buffer","from","encoding","undefined","protectedHeaderEncodedInt8","claimsEncodedInt8","signatureBytes","decode","signatureInt8","cwtArrayElements","cwtArray","CborArray","KtMutableList","fromJsArray","cwtEncoded","cwtBuffer","statusListCredential","encodedList","ttl","claimsEntries","Math","floor","Date","now","push","getTime","getCborValueFromMap","map","key","value","getCborOptionalValueFromMap","Error","get","decodeStatusListCWT","cwt","encodedCbor","toBuffer","encodedCborArray","decodedCbor","payload","asJsArrayView","claims","asJsMapView","bits","Number","decoded","Uint8Array","uint8Array","inflate","rawStatusList","issuer","iat","exp","DEFAULT_BITS_PER_STATUS","DEFAULT_LIST_LENGTH","DEFAULT_PROOF_FORMAT","OAuthStatusListImplementation","createNewStatusList","args","context","oauthStatusList","Error","proofFormat","issuer","id","keyRef","bitsPerStatus","expiresAt","length","issuerString","correlationId","getAssertedValue","statusList","StatusList","Array","fill","encodedList","compressStatusList","statusListCredential","createSignedStatusList","type","StatusListType","OAuthStatusList","statuslistContentType","buildContentType","updateStatusListIndex","value","Promise","reject","determineProofFormat","decoded","decodeStatusListJWT","decodeStatusListCWT","index","statusListIndex","parseInt","setStatus","signedCredential","getBitsPerStatus","updateStatusListFromEncodedList","getAssertedValues","listToUpdate","decompressStatusList","checkStatusIndex","getStatus","toStatusListDetails","statusListPayload","exp","Date","driverType","createSignedJwt","createSignedCbor","import_ssi_types","StatusListFactory","instance","implementations","Map","set","StatusListType","StatusList2021","StatusList2021Implementation","OAuthStatusList","OAuthStatusListImplementation","getInstance","getByType","type","statusList","get","Error","getStatusListImplementation","fetchStatusListCredential","args","url","getAssertedValue","statusListCredential","response","fetch","ok","Error","status","statusText","responseAsText","text","trim","startsWith","JSON","parse","error","console","message","stringify","statusPluginStatusFunction","credential","didDoc","result","checkStatusForCredential","documentLoader","errorUnknownListType","revoked","verified","vcLibCheckStatusFunction","mandatoryCredentialStatus","verifyStatusListCredential","verifyMatchingIssuers","uniform","CredentialMapper","toUniformCredential","credentialStatus","log","type","checkStatus","simpleCheckStatusFromStatusListUrl","checkStatusIndexFromStatusListCredential","statusListType","determineStatusListType","implementation","getStatusListImplementation","checkStatusIndex","createNewStatusList","context","getAssertedValues","updateStatusIndexFromStatusListCredential","updateStatusListIndex","statusListCredentialToDetails","documentFormat","detectDocumentType","DocumentFormat","JWT","header","split","decodedHeader","Buffer","from","toString","typ","StatusListType","OAuthStatusList","MSO_MDOC","find","t","includes","replace","toStatusListDetails","statusListPayload","correlationId","driverType","updateStatusListIndexFromEncodedList","updateStatusListFromEncodedList","statusList2021ToVerifiableCredential","issuer","id","identifier","agent","identifierManagedGet","vmRelationship","offlineWhenNoDIDRegistered","proofFormat","assertValidProofType","StatusList2021","veramoProofFormat","encodedList","statusPurpose","credentialSubject","verifiableCredential","createVerifiableCredential","keyRef","kmsKeyRef","fetchRemoteContexts","toWrappedVerifiableCredential","original"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/functions.ts","../src/utils.ts","../src/impl/StatusList2021.ts","../src/impl/OAuthStatusList.ts","../src/impl/encoding/jwt.ts","../src/impl/encoding/common.ts","../src/impl/encoding/cbor.ts","../src/impl/StatusListFactory.ts"],"sourcesContent":["/**\n */\n\nexport * from './types'\nexport * from './functions'\n","import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport {\n ICredential,\n ICredentialStatus,\n IIssuer,\n IVerifiableCredential,\n OrPromise,\n ProofFormat,\n StatusListCredential,\n StatusListCredentialIdMode,\n StatusListDriverType,\n StatusListIndexingDirection,\n StatusListType,\n StatusPurpose2021,\n} from '@sphereon/ssi-types'\nimport {\n CredentialPayload,\n IAgentContext,\n ICredentialIssuer,\n ICredentialPlugin,\n ICredentialVerifier,\n IKeyManager,\n IPluginMethodMap,\n} from '@veramo/core'\nimport { DataSource } from 'typeorm'\nimport { BitsPerStatus } from '@sd-jwt/jwt-status-list'\nimport { SdJwtVcPayload } from '@sd-jwt/sd-jwt-vc'\nimport { StatusListOpts } from '@sphereon/oid4vci-common'\n\nexport enum StatusOAuth {\n Valid = 0,\n Invalid = 1,\n Suspended = 2,\n}\n\nexport enum Status2021 {\n Valid = 0,\n Invalid = 1,\n}\n\nexport type StatusList2021Args = {\n indexingDirection: StatusListIndexingDirection\n statusPurpose?: StatusPurpose2021\n // todo: validFrom and validUntil\n}\n\nexport type OAuthStatusListArgs = {\n bitsPerStatus?: BitsPerStatus\n expiresAt?: Date\n}\n\nexport type BaseCreateNewStatusListArgs = {\n type: StatusListType\n id: string\n issuer: string | IIssuer\n correlationId?: string\n length?: number\n proofFormat?: ProofFormat\n keyRef?: string\n statusList2021?: StatusList2021Args\n oauthStatusList?: OAuthStatusListArgs\n driverType?: StatusListDriverType\n}\n\nexport type UpdateStatusList2021Args = {\n statusPurpose: StatusPurpose2021\n}\n\nexport type UpdateOAuthStatusListArgs = {\n bitsPerStatus: BitsPerStatus\n expiresAt?: Date\n}\n\nexport interface UpdateStatusListFromEncodedListArgs {\n type?: StatusListType\n statusListIndex: number | string\n value: boolean\n proofFormat?: ProofFormat\n keyRef?: string\n correlationId?: string\n encodedList: string\n issuer: string | IIssuer\n id: string\n statusList2021?: UpdateStatusList2021Args\n oauthStatusList?: UpdateOAuthStatusListArgs\n}\n\nexport interface UpdateStatusListFromStatusListCredentialArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n keyRef?: string\n statusListIndex: number | string\n value: number | Status2021 | StatusOAuth\n}\n\nexport interface StatusListResult {\n encodedList: string\n statusListCredential: StatusListCredential\n length: number\n type: StatusListType\n proofFormat: ProofFormat\n id: string\n statuslistContentType: string\n issuer: string | IIssuer\n statusList2021?: StatusList2021Details\n oauthStatusList?: OAuthStatusDetails\n\n // These cannot be deduced from the VC, so they are present when callers pass in these values as params\n correlationId?: string\n driverType?: StatusListDriverType\n credentialIdMode?: StatusListCredentialIdMode\n}\n\ninterface StatusList2021Details {\n indexingDirection: StatusListIndexingDirection\n statusPurpose?: StatusPurpose2021\n}\n\ninterface OAuthStatusDetails {\n bitsPerStatus?: BitsPerStatus\n expiresAt?: Date\n}\n\nexport interface StatusList2021EntryCredentialStatus extends ICredentialStatus {\n type: 'StatusList2021Entry'\n statusPurpose: StatusPurpose2021\n statusListIndex: string\n statusListCredential: string\n}\n\nexport interface StatusListOAuthEntryCredentialStatus extends ICredentialStatus {\n type: 'OAuthStatusListEntry'\n bitsPerStatus: number\n statusListIndex: string\n statusListCredential: string\n expiresAt?: Date\n}\n\nexport interface StatusList2021ToVerifiableCredentialArgs {\n issuer: string | IIssuer\n id: string\n type?: StatusListType\n proofFormat?: ProofFormat\n keyRef?: string\n encodedList: string\n statusPurpose: StatusPurpose2021\n}\n\nexport interface CreateStatusListArgs {\n issuer: string | IIssuer\n id: string\n proofFormat?: ProofFormat\n keyRef?: string\n correlationId?: string\n length?: number\n statusList2021?: StatusList2021Args\n oauthStatusList?: OAuthStatusListArgs\n}\n\nexport interface UpdateStatusListIndexArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n statusListIndex: number | string\n value: number | Status2021 | StatusOAuth\n keyRef?: string\n expiresAt?: Date\n}\n\nexport interface CheckStatusIndexArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n statusListIndex: string | number\n}\n\nexport interface ToStatusListDetailsArgs {\n statusListPayload: StatusListCredential\n correlationId?: string\n driverType?: StatusListDriverType\n}\n\n/**\n * The interface definition for a plugin that can add statuslist info to a credential\n *\n * @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}\n *\n * @beta This API is likely to change without a BREAKING CHANGE notice\n */\nexport interface IStatusListPlugin extends IPluginMethodMap {\n /**\n * Create a new status list\n *\n * @param args Status list information like type and size\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n *\n * @returns - The details of the newly created status list\n */\n slCreateStatusList(args: CreateNewStatusListArgs, context: IRequiredContext): Promise<StatusListResult>\n\n /**\n * Ensures status list info like index and list id is added to a credential\n *\n * @param args - Arguments necessary to add the statuslist info.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n *\n * @returns - a promise that resolves to the credential now with status support\n *\n * @beta This API is likely to change without a BREAKING CHANGE notice\n */\n slAddStatusToCredential(args: IAddStatusToCredentialArgs, context: IRequiredContext): Promise<CredentialWithStatusSupport>\n\n slAddStatusToSdJwtCredential(args: IAddStatusToSdJwtCredentialArgs, context: IRequiredContext): Promise<SdJwtVcPayload>\n\n /**\n * Get the status list using the configured driver for the SL. Normally a correlationId or id should suffice. Optionally accepts a dbName/datasource\n * @param args\n * @param context\n */\n slGetStatusList(args: GetStatusListArgs, context: IRequiredContext): Promise<StatusListResult>\n\n /**\n * Import status lists when noy yet present\n *\n * @param imports Array of status list information like type and size\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n */\n slImportStatusLists(imports: Array<CreateNewStatusListArgs>, context: IRequiredContext): Promise<boolean>\n}\n\nexport type CreateNewStatusListFuncArgs = BaseCreateNewStatusListArgs\n\nexport type CreateNewStatusListArgs = BaseCreateNewStatusListArgs & {\n dbName?: string\n dataSource?: OrPromise<DataSource>\n isDefault?: boolean\n}\n\nexport type IAddStatusToCredentialArgs = Omit<IIssueCredentialStatusOpts, 'dataSource'> & {\n credential: CredentialWithStatusSupport\n}\n\nexport type IAddStatusToSdJwtCredentialArgs = Omit<IIssueCredentialStatusOpts, 'dataSource'> & {\n credential: SdJwtVcPayload\n}\n\nexport interface IIssueCredentialStatusOpts {\n dataSource?: DataSource\n statusLists?: Array<StatusListOpts>\n credentialId?: string // An id to use for the credential. Normally should be set as the crdential.id value\n value?: string\n}\n\nexport type GetStatusListArgs = {\n id?: string\n correlationId?: string\n dataSource?: OrPromise<DataSource>\n dbName?: string\n}\n\nexport type CredentialWithStatusSupport = ICredential | CredentialPayload | IVerifiableCredential\n\nexport type SignedStatusListData = {\n statusListCredential: StatusListCredential\n encodedList: string\n}\n\nexport type IRequiredPlugins = ICredentialPlugin & IIdentifierResolution\nexport type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager & ICredentialPlugin>\n","import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport {\n CredentialMapper,\n DocumentFormat,\n ProofFormat,\n StatusListCredential,\n StatusListDriverType,\n StatusListType,\n StatusPurpose2021,\n} from '@sphereon/ssi-types'\nimport { CredentialStatus, DIDDocument, IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core'\n\nimport { checkStatus } from '@sphereon/vc-status-list'\n\n// @ts-ignore\nimport { CredentialJwtOrJSON, StatusMethod } from 'credential-status'\nimport {\n CreateNewStatusListFuncArgs,\n Status2021,\n StatusList2021ToVerifiableCredentialArgs,\n StatusListResult,\n StatusOAuth,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from './types'\nimport { assertValidProofType, determineStatusListType, getAssertedValue, getAssertedValues } from './utils'\nimport { getStatusListImplementation } from './impl/StatusListFactory'\n\nexport async function fetchStatusListCredential(args: { statusListCredential: string }): Promise<StatusListCredential> {\n const url = getAssertedValue('statusListCredential', args.statusListCredential)\n try {\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(`Fetching status list ${url} resulted in an error: ${response.status} : ${response.statusText}`)\n }\n const responseAsText = await response.text()\n if (responseAsText.trim().startsWith('{')) {\n return JSON.parse(responseAsText) as StatusListCredential\n }\n return responseAsText as StatusListCredential\n } catch (error) {\n console.error(`Fetching status list ${url} resulted in an unexpected error: ${error instanceof Error ? error.message : JSON.stringify(error)}`)\n throw error\n }\n}\n\nexport function statusPluginStatusFunction(args: {\n documentLoader: any\n suite: any\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}): StatusMethod {\n return async (credential: CredentialJwtOrJSON, didDoc: DIDDocument): Promise<CredentialStatus> => {\n const result = await checkStatusForCredential({\n ...args,\n documentLoader: args.documentLoader,\n credential: credential as StatusListCredential,\n errorUnknownListType: args.errorUnknownListType,\n })\n\n return {\n revoked: !result.verified || result.error,\n ...(result.error && { error: result.error }),\n }\n }\n}\n\n/**\n * Function that can be used together with @digitalbazar/vc and @digitialcredentials/vc\n * @param args\n */\nexport function vcLibCheckStatusFunction(args: {\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}) {\n const { mandatoryCredentialStatus, verifyStatusListCredential, verifyMatchingIssuers, errorUnknownListType } = args\n return (args: {\n credential: StatusListCredential\n documentLoader: any\n suite: any\n }): Promise<{\n verified: boolean\n error?: any\n }> => {\n return checkStatusForCredential({\n ...args,\n mandatoryCredentialStatus,\n verifyStatusListCredential,\n verifyMatchingIssuers,\n errorUnknownListType,\n })\n }\n}\n\nexport async function checkStatusForCredential(args: {\n credential: StatusListCredential\n documentLoader: any\n suite: any\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}): Promise<{ verified: boolean; error?: any }> {\n const verifyStatusListCredential = args.verifyStatusListCredential ?? true\n const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true\n const uniform = CredentialMapper.toUniformCredential(args.credential)\n if (!('credentialStatus' in uniform) || !uniform.credentialStatus) {\n if (args.mandatoryCredentialStatus) {\n const error = 'No credential status object found in the Verifiable Credential and it is mandatory'\n console.log(error)\n return { verified: false, error }\n }\n return { verified: true }\n }\n if ('credentialStatus' in uniform && uniform.credentialStatus) {\n if (uniform.credentialStatus.type === 'StatusList2021Entry') {\n return checkStatus({ ...args, verifyStatusListCredential, verifyMatchingIssuers })\n } else if (args?.errorUnknownListType) {\n const error = `Credential status type ${uniform.credentialStatus.type} is not supported, and check status has been configured to not allow for that`\n console.log(error)\n return { verified: false, error }\n } else {\n console.log(`Skipped verification of status type ${uniform.credentialStatus.type} as we do not support it (yet)`)\n }\n }\n return { verified: true }\n}\n\nexport async function simpleCheckStatusFromStatusListUrl(args: {\n statusListCredential: string\n statusPurpose?: StatusPurpose2021\n type?: StatusListType | 'StatusList2021Entry'\n id?: string\n statusListIndex: string\n}): Promise<number | Status2021 | StatusOAuth> {\n return checkStatusIndexFromStatusListCredential({\n ...args,\n statusListCredential: await fetchStatusListCredential(args),\n })\n}\n\nexport async function checkStatusIndexFromStatusListCredential(args: {\n statusListCredential: StatusListCredential\n statusPurpose?: StatusPurpose2021\n type?: StatusListType | 'StatusList2021Entry'\n id?: string\n statusListIndex: string | number\n}): Promise<number | Status2021 | StatusOAuth> {\n const statusListType: StatusListType = determineStatusListType(args.statusListCredential)\n const implementation = getStatusListImplementation(statusListType)\n return implementation.checkStatusIndex(args)\n}\n\nexport async function createNewStatusList(\n args: CreateNewStatusListFuncArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const { type } = getAssertedValues(args)\n const implementation = getStatusListImplementation(type)\n return implementation.createNewStatusList(args, context)\n}\n\nexport async function updateStatusIndexFromStatusListCredential(\n args: UpdateStatusListIndexArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const credential = getAssertedValue('statusListCredential', args.statusListCredential)\n const statusListType: StatusListType = determineStatusListType(credential)\n const implementation = getStatusListImplementation(statusListType)\n return implementation.updateStatusListIndex(args, context)\n}\n\n// Keeping helper function for backward compatibility\nexport async function statusListCredentialToDetails(args: {\n statusListCredential: StatusListCredential\n correlationId?: string\n driverType?: StatusListDriverType\n}): Promise<StatusListResult> {\n const credential = getAssertedValue('statusListCredential', args.statusListCredential)\n\n let statusListType: StatusListType | undefined\n const documentFormat = CredentialMapper.detectDocumentType(credential)\n if (documentFormat === DocumentFormat.JWT) {\n const [header] = credential.split('.')\n const decodedHeader = JSON.parse(Buffer.from(header, 'base64').toString())\n\n if (decodedHeader.typ === 'statuslist+jwt') {\n statusListType = StatusListType.OAuthStatusList\n }\n } else if (documentFormat === DocumentFormat.MSO_MDOC) {\n statusListType = StatusListType.OAuthStatusList\n // TODO check CBOR content?\n }\n if (!statusListType) {\n const uniform = CredentialMapper.toUniformCredential(credential)\n const type = uniform.type.find((t) => t.includes('StatusList2021') || t.includes('OAuth2StatusList'))\n if (!type) {\n throw new Error('Invalid status list credential type')\n }\n statusListType = type.replace('Credential', '') as StatusListType\n }\n\n const implementation = getStatusListImplementation(statusListType)\n return await implementation.toStatusListDetails({\n statusListPayload: credential,\n correlationId: args.correlationId,\n driverType: args.driverType,\n })\n}\n\nexport async function updateStatusListIndexFromEncodedList(\n args: UpdateStatusListFromEncodedListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const { type } = getAssertedValue('type', args)\n const implementation = getStatusListImplementation(type!)\n return implementation.updateStatusListFromEncodedList(args, context)\n}\n\nexport async function statusList2021ToVerifiableCredential(\n args: StatusList2021ToVerifiableCredentialArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListCredential> {\n const { issuer, id, type } = getAssertedValues(args)\n const identifier = await context.agent.identifierManagedGet({\n identifier: typeof issuer === 'string' ? issuer : issuer.id,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true, // FIXME Fix identifier resolution for EBSI\n })\n const proofFormat: ProofFormat = args?.proofFormat ?? 'lds'\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const encodedList = getAssertedValue('encodedList', args.encodedList)\n const statusPurpose = getAssertedValue('statusPurpose', args.statusPurpose)\n const credential = {\n '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],\n id,\n issuer,\n // issuanceDate: \"2021-03-10T04:24:12.164Z\",\n type: ['VerifiableCredential', `${type}Credential`],\n credentialSubject: {\n id,\n type,\n statusPurpose,\n encodedList,\n },\n }\n // TODO copy statuslist schema to local and disable fetching remote contexts\n const verifiableCredential = await context.agent.createVerifiableCredential({\n credential,\n keyRef: identifier.kmsKeyRef,\n proofFormat: veramoProofFormat,\n fetchRemoteContexts: true,\n })\n\n return CredentialMapper.toWrappedVerifiableCredential(verifiableCredential as StatusListCredential).original as StatusListCredential\n}\n","import {\n CredentialMapper,\n IIssuer,\n ProofFormat,\n StatusListType,\n StatusListType as StatusListTypeW3C,\n StatusListCredential,\n DocumentFormat,\n} from '@sphereon/ssi-types'\nimport { jwtDecode } from 'jwt-decode'\n\nexport function getAssertedStatusListType(type?: StatusListType) {\n const assertedType = type ?? StatusListType.StatusList2021\n if (![StatusListType.StatusList2021, StatusListType.OAuthStatusList].includes(assertedType)) {\n throw Error(`StatusList type ${assertedType} is not supported (yet)`)\n }\n return assertedType\n}\n\nexport function getAssertedValue<T>(name: string, value: T): NonNullable<T> {\n if (value === undefined || value === null) {\n throw Error(`Missing required ${name} value`)\n }\n return value\n}\n\nexport function getAssertedValues(args: { issuer: string | IIssuer; id: string; type?: StatusListTypeW3C | StatusListType }) {\n const type = getAssertedStatusListType(args?.type)\n const id = getAssertedValue('id', args.id)\n const issuer = getAssertedValue('issuer', args.issuer)\n return { id, issuer, type }\n}\n\nexport function getAssertedProperty<T extends object>(propertyName: string, obj: T): NonNullable<any> {\n if (!(propertyName in obj)) {\n throw Error(`The input object does not contain required property: ${propertyName}`)\n }\n return getAssertedValue(propertyName, (obj as any)[propertyName])\n}\n\nconst ValidProofTypeMap = new Map<StatusListType, ProofFormat[]>([\n [StatusListType.StatusList2021, ['jwt', 'lds', 'EthereumEip712Signature2021']],\n [StatusListType.OAuthStatusList, ['jwt', 'cbor']],\n])\n\nexport function assertValidProofType(type: StatusListType, proofFormat: ProofFormat) {\n const validProofTypes = ValidProofTypeMap.get(type)\n if (!validProofTypes?.includes(proofFormat)) {\n throw Error(`Invalid proof format '${proofFormat}' for status list type ${type}`)\n }\n}\n\nexport function determineStatusListType(credential: StatusListCredential): StatusListType {\n const proofFormat = determineProofFormat(credential)\n switch (proofFormat) {\n case 'jwt':\n const payload: StatusListCredential = jwtDecode(credential as string)\n const keys = Object.keys(payload)\n if (keys.includes('status_list')) {\n return StatusListType.OAuthStatusList\n } else if (keys.includes('vc')) {\n return StatusListType.StatusList2021\n }\n break\n case 'lds':\n const uniform = CredentialMapper.toUniformCredential(credential)\n const type = uniform.type.find((t) => {\n return Object.values(StatusListType).some((statusType) => t.includes(statusType))\n })\n if (!type) {\n throw new Error('Invalid status list credential type')\n }\n return type.replace('Credential', '') as StatusListType\n\n case 'cbor':\n return StatusListType.OAuthStatusList\n }\n\n throw new Error('Cannot determine status list type from credential payload')\n}\n\nexport function determineProofFormat(credential: StatusListCredential): ProofFormat {\n const type: DocumentFormat = CredentialMapper.detectDocumentType(credential)\n switch (type) {\n case DocumentFormat.JWT:\n return 'jwt'\n case DocumentFormat.MSO_MDOC:\n // Not really mdoc, just assume Cbor for now, I'd need to decode at least the header to what type of Cbor we have\n return 'cbor'\n case DocumentFormat.JSONLD:\n return 'lds'\n default:\n throw Error('Cannot determine credential payload type')\n }\n}\n","import { IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core'\nimport { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport { CredentialMapper, DocumentFormat, IIssuer, ProofFormat, StatusListCredential, StatusListType } from '@sphereon/ssi-types'\n\nimport { StatusList } from '@sphereon/vc-status-list'\nimport { IStatusList } from './IStatusList'\nimport {\n CheckStatusIndexArgs,\n CreateStatusListArgs,\n Status2021,\n StatusListResult,\n ToStatusListDetailsArgs,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from '../types'\nimport { assertValidProofType, getAssertedProperty, getAssertedValue, getAssertedValues } from '../utils'\n\nexport const DEFAULT_LIST_LENGTH = 250000\nexport const DEFAULT_PROOF_FORMAT = 'lds' as VeramoProofFormat\n\nexport class StatusList2021Implementation implements IStatusList {\n async createNewStatusList(\n args: CreateStatusListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n const length = args?.length ?? DEFAULT_LIST_LENGTH\n const proofFormat: ProofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const { issuer, id } = args\n const correlationId = getAssertedValue('correlationId', args.correlationId)\n\n const list = new StatusList({ length })\n const encodedList = await list.encode()\n const statusPurpose = 'revocation'\n\n const statusListCredential = await this.createVerifiableCredential(\n {\n ...args,\n encodedList,\n proofFormat: veramoProofFormat,\n },\n context,\n )\n\n return {\n encodedList,\n statusListCredential: statusListCredential,\n statusList2021: {\n statusPurpose,\n indexingDirection: 'rightToLeft',\n },\n length,\n type: StatusListType.StatusList2021,\n proofFormat,\n id,\n correlationId,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListIndex(\n args: UpdateStatusListIndexArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n const credential = args.statusListCredential\n const uniform = CredentialMapper.toUniformCredential(credential)\n const { issuer, credentialSubject } = uniform\n const id = getAssertedValue('id', uniform.id)\n const origEncodedList = getAssertedProperty('encodedList', credentialSubject)\n\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n const statusList = await StatusList.decode({ encodedList: origEncodedList })\n statusList.setStatus(index, args.value != 0)\n const encodedList = await statusList.encode()\n\n const proofFormat = CredentialMapper.detectDocumentType(credential) === DocumentFormat.JWT ? 'jwt' : 'lds'\n const updatedCredential = await this.createVerifiableCredential(\n {\n ...args,\n id,\n issuer,\n encodedList,\n proofFormat: proofFormat,\n },\n context,\n )\n\n return {\n statusListCredential: updatedCredential,\n encodedList,\n statusList2021: {\n ...('statusPurpose' in credentialSubject ? { statusPurpose: credentialSubject.statusPurpose } : {}),\n indexingDirection: 'rightToLeft',\n },\n length: statusList.length - 1,\n type: StatusListType.StatusList2021,\n proofFormat: proofFormat,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListFromEncodedList(\n args: UpdateStatusListFromEncodedListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n if (!args.statusList2021) {\n throw new Error('statusList2021 options required for type StatusList2021')\n }\n const proofFormat: ProofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const { issuer, id } = getAssertedValues(args)\n const statusList = await StatusList.decode({ encodedList: args.encodedList })\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n statusList.setStatus(index, args.value)\n\n const newEncodedList = await statusList.encode()\n const credential = await this.createVerifiableCredential(\n {\n id,\n issuer,\n encodedList: newEncodedList,\n proofFormat: veramoProofFormat,\n keyRef: args.keyRef,\n },\n context,\n )\n\n return {\n type: StatusListType.StatusList2021,\n statusListCredential: credential,\n encodedList: newEncodedList,\n statusList2021: {\n statusPurpose: args.statusList2021.statusPurpose,\n indexingDirection: 'rightToLeft',\n },\n length: statusList.length,\n proofFormat: args.proofFormat ?? 'lds',\n id: id,\n issuer: issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | Status2021> {\n const uniform = CredentialMapper.toUniformCredential(args.statusListCredential)\n const { credentialSubject } = uniform\n const encodedList = getAssertedProperty('encodedList', credentialSubject)\n\n const statusList = await StatusList.decode({ encodedList })\n const status = statusList.getStatus(typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex))\n return status ? Status2021.Invalid : Status2021.Valid\n }\n\n async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {\n const { statusListPayload } = args\n const uniform = CredentialMapper.toUniformCredential(statusListPayload)\n const { issuer, credentialSubject } = uniform\n const id = getAssertedValue('id', uniform.id)\n const encodedList = getAssertedProperty('encodedList', credentialSubject)\n const proofFormat: ProofFormat = CredentialMapper.detectDocumentType(statusListPayload) === DocumentFormat.JWT ? 'jwt' : 'lds'\n\n const statusPurpose = getAssertedProperty('statusPurpose', credentialSubject)\n const list = await StatusList.decode({ encodedList })\n\n return {\n id,\n encodedList,\n issuer,\n type: StatusListType.StatusList2021,\n proofFormat,\n length: list.length,\n statusListCredential: statusListPayload,\n statuslistContentType: this.buildContentType(proofFormat),\n statusList2021: {\n indexingDirection: 'rightToLeft',\n statusPurpose,\n },\n ...(args.correlationId && { correlationId: args.correlationId }),\n ...(args.driverType && { driverType: args.driverType }),\n }\n }\n\n private async createVerifiableCredential(\n args: {\n id: string\n issuer: string | IIssuer\n encodedList: string\n proofFormat: VeramoProofFormat\n keyRef?: string\n },\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListCredential> {\n const identifier = await context.agent.identifierManagedGet({\n identifier: typeof args.issuer === 'string' ? args.issuer : args.issuer.id,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true,\n })\n\n const credential = {\n '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],\n id: args.id,\n issuer: args.issuer,\n type: ['VerifiableCredential', 'StatusList2021Credential'],\n credentialSubject: {\n id: args.id,\n type: 'StatusList2021',\n statusPurpose: 'revocation',\n encodedList: args.encodedList,\n },\n }\n\n const verifiableCredential = await context.agent.createVerifiableCredential({\n credential,\n keyRef: args.keyRef ?? identifier.kmsKeyRef,\n proofFormat: args.proofFormat,\n fetchRemoteContexts: true,\n })\n\n return CredentialMapper.toWrappedVerifiableCredential(verifiableCredential as StatusListCredential).original as StatusListCredential\n }\n\n private buildContentType(proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor' | undefined) {\n switch (proofFormat) {\n case 'jwt':\n return `application/statuslist+jwt`\n case 'cbor':\n return `application/statuslist+cwt`\n case 'lds':\n return 'application/statuslist+ld+json'\n default:\n throw Error(`Unsupported content type '${proofFormat}' for status lists`)\n }\n }\n}\n","import { IAgentContext, ICredentialPlugin, IKeyManager } from '@veramo/core'\nimport { CompactJWT, CWT, ProofFormat, StatusListType } from '@sphereon/ssi-types'\nimport {\n CheckStatusIndexArgs,\n CreateStatusListArgs,\n SignedStatusListData,\n StatusListResult,\n StatusOAuth,\n ToStatusListDetailsArgs,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from '../types'\nimport { determineProofFormat, getAssertedValue, getAssertedValues } from '../utils'\nimport { IStatusList } from './IStatusList'\nimport { StatusList } from '@sd-jwt/jwt-status-list'\nimport { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'\nimport { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport { createSignedJwt, decodeStatusListJWT } from './encoding/jwt'\nimport { createSignedCbor, decodeStatusListCWT } from './encoding/cbor'\n\ntype IRequiredContext = IAgentContext<ICredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>\n\nexport const DEFAULT_BITS_PER_STATUS = 1 // 1 bit is sufficient for 0x00 - \"VALID\" 0x01 - \"INVALID\" saving space in the process\nexport const DEFAULT_LIST_LENGTH = 250000\nexport const DEFAULT_PROOF_FORMAT = 'jwt' as ProofFormat\n\nexport class OAuthStatusListImplementation implements IStatusList {\n async createNewStatusList(args: CreateStatusListArgs, context: IRequiredContext): Promise<StatusListResult> {\n if (!args.oauthStatusList) {\n throw new Error('OAuthStatusList options are required for type OAuthStatusList')\n }\n\n const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n const { issuer, id, oauthStatusList, keyRef } = args\n const { bitsPerStatus, expiresAt } = oauthStatusList\n const length = args.length ?? DEFAULT_LIST_LENGTH\n const issuerString = typeof issuer === 'string' ? issuer : issuer.id\n const correlationId = getAssertedValue('correlationId', args.correlationId)\n\n const statusList = new StatusList(new Array(length).fill(0), bitsPerStatus ?? DEFAULT_BITS_PER_STATUS)\n const encodedList = statusList.compressStatusList()\n const { statusListCredential } = await this.createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef)\n\n return {\n encodedList,\n statusListCredential,\n oauthStatusList: { bitsPerStatus },\n length,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n id,\n correlationId,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListIndex(args: UpdateStatusListIndexArgs, context: IRequiredContext): Promise<StatusListResult> {\n const { statusListCredential, value, expiresAt, keyRef } = args\n if (typeof statusListCredential !== 'string') {\n return Promise.reject('statusListCredential in neither JWT nor CWT')\n }\n\n const proofFormat = determineProofFormat(statusListCredential)\n const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential)\n const { statusList, issuer, id } = decoded\n\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n if (index < 0 || index >= statusList.statusList.length) {\n throw new Error('Status list index out of bounds')\n }\n\n statusList.setStatus(index, value)\n const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(\n proofFormat,\n context,\n statusList,\n issuer,\n id,\n expiresAt,\n keyRef,\n )\n\n return {\n statusListCredential: signedCredential,\n encodedList,\n oauthStatusList: {\n bitsPerStatus: statusList.getBitsPerStatus(),\n },\n length: statusList.statusList.length,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n // FIXME: This still assumes only two values (boolean), whilst this list supports 8 bits max\n async updateStatusListFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IRequiredContext): Promise<StatusListResult> {\n if (!args.oauthStatusList) {\n throw new Error('OAuthStatusList options are required for type OAuthStatusList')\n }\n const { proofFormat, oauthStatusList, keyRef } = args\n const { bitsPerStatus, expiresAt } = oauthStatusList\n\n const { issuer, id } = getAssertedValues(args)\n const issuerString = typeof issuer === 'string' ? issuer : issuer.id\n\n const listToUpdate = StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS)\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n // FIXME: See above.\n listToUpdate.setStatus(index, args.value ? 1 : 0)\n\n const { statusListCredential, encodedList } = await this.createSignedStatusList(\n proofFormat ?? DEFAULT_PROOF_FORMAT,\n context,\n listToUpdate,\n issuerString,\n id,\n expiresAt,\n keyRef,\n )\n\n return {\n encodedList,\n statusListCredential,\n oauthStatusList: {\n bitsPerStatus,\n expiresAt,\n },\n length: listToUpdate.statusList.length,\n type: StatusListType.OAuthStatusList,\n proofFormat: proofFormat ?? DEFAULT_PROOF_FORMAT,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n private buildContentType(proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor' | undefined) {\n return `application/statuslist+${proofFormat === 'cbor' ? 'cwt' : 'jwt'}`\n }\n\n async checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | StatusOAuth> {\n const { statusListCredential, statusListIndex } = args\n if (typeof statusListCredential !== 'string') {\n return Promise.reject('statusListCredential in neither JWT nor CWT')\n }\n\n const proofFormat = determineProofFormat(statusListCredential)\n const { statusList } = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential)\n\n const index = typeof statusListIndex === 'number' ? statusListIndex : parseInt(statusListIndex)\n if (index < 0 || index >= statusList.statusList.length) {\n throw new Error('Status list index out of bounds')\n }\n\n return statusList.getStatus(index)\n }\n\n async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {\n const { statusListPayload } = args as { statusListPayload: CompactJWT | CWT }\n const proofFormat = determineProofFormat(statusListPayload)\n const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload)\n const { statusList, issuer, id, exp } = decoded\n\n return {\n id,\n encodedList: statusList.compressStatusList(),\n issuer,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n length: statusList.statusList.length,\n statusListCredential: statusListPayload,\n statuslistContentType: this.buildContentType(proofFormat),\n oauthStatusList: {\n bitsPerStatus: statusList.getBitsPerStatus(),\n ...(exp && { expiresAt: new Date(exp * 1000) }),\n },\n ...(args.correlationId && { correlationId: args.correlationId }),\n ...(args.driverType && { driverType: args.driverType }),\n }\n }\n\n private async createSignedStatusList(\n proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor',\n context: IAgentContext<ICredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n ): Promise<SignedStatusListData> {\n switch (proofFormat) {\n case 'jwt': {\n return await createSignedJwt(context, statusList, issuerString, id, expiresAt, keyRef)\n }\n case 'cbor': {\n return await createSignedCbor(context, statusList, issuerString, id, expiresAt, keyRef)\n }\n default:\n throw new Error(`Invalid proof format '${proofFormat}' for OAuthStatusList`)\n }\n }\n}\n","import { CompactJWT, JoseSignatureAlgorithm } from '@sphereon/ssi-types'\nimport { createHeaderAndPayload, StatusList, StatusListJWTHeaderParameters, StatusListJWTPayload } from '@sd-jwt/jwt-status-list'\nimport base64url from 'base64url'\nimport { JWTPayload } from 'did-jwt'\nimport { IRequiredContext, SignedStatusListData } from '../../types'\nimport { DecodedStatusListPayload, resolveIdentifier } from './common'\nimport { TKeyType } from '@veramo/core'\nimport { ensureManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution'\n\nconst STATUS_LIST_JWT_TYP = 'statuslist+jwt'\n\nexport const createSignedJwt = async (\n context: IRequiredContext,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n): Promise<SignedStatusListData> => {\n const identifier = await resolveIdentifier(context, issuerString, keyRef)\n const resolution = await ensureManagedIdentifierResult(identifier, context)\n\n const payload: JWTPayload = {\n iss: issuerString,\n sub: id,\n iat: Math.floor(Date.now() / 1000),\n ...(expiresAt && { exp: Math.floor(expiresAt.getTime() / 1000) }),\n }\n\n const header: StatusListJWTHeaderParameters = {\n alg: getSigningAlgo(resolution.key.type),\n typ: STATUS_LIST_JWT_TYP,\n }\n const values = createHeaderAndPayload(statusList, payload, header)\n const signedJwt = await context.agent.jwtCreateJwsCompactSignature({\n issuer: { ...identifier, noIssPayloadUpdate: false },\n protectedHeader: values.header,\n payload: values.payload,\n })\n\n return {\n statusListCredential: signedJwt.jwt,\n encodedList: (values.payload as StatusListJWTPayload).status_list.lst,\n }\n}\n\nexport const decodeStatusListJWT = (jwt: CompactJWT): DecodedStatusListPayload => {\n const [, payloadBase64] = jwt.split('.')\n const payload = JSON.parse(base64url.decode(payloadBase64))\n\n if (!payload.iss || !payload.sub || !payload.status_list) {\n throw new Error('Missing required fields in JWT payload')\n }\n\n const statusList = StatusList.decompressStatusList(payload.status_list.lst, payload.status_list.bits)\n\n return {\n issuer: payload.iss,\n id: payload.sub,\n statusList,\n exp: payload.exp,\n ttl: payload.ttl,\n iat: payload.iat,\n }\n}\n\nexport const getSigningAlgo = (type: TKeyType): JoseSignatureAlgorithm => {\n switch (type) {\n case 'Ed25519':\n return JoseSignatureAlgorithm.EdDSA\n case 'Secp256k1':\n return JoseSignatureAlgorithm.ES256K\n case 'Secp256r1':\n return JoseSignatureAlgorithm.ES256\n case 'RSA':\n return JoseSignatureAlgorithm.RS256\n default:\n throw Error('Key type not yet supported')\n }\n}\n","import { IRequiredContext } from '../../types'\nimport { StatusList } from '@sd-jwt/jwt-status-list'\n\nexport interface DecodedStatusListPayload {\n issuer: string\n id: string\n statusList: StatusList\n exp?: number\n ttl?: number\n iat: number\n}\n\nexport const resolveIdentifier = async (context: IRequiredContext, issuer: string, keyRef?: string) => {\n return await context.agent.identifierManagedGet({\n identifier: issuer,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true,\n ...(keyRef && { kmsKeyRef: keyRef }), // TODO the getDid resolver should look at this ASAP\n })\n}\n","import { StatusList } from '@sd-jwt/jwt-status-list'\nimport { deflate, inflate } from 'pako'\nimport * as cborpkg from '@sphereon/kmp-cbor'\nimport base64url from 'base64url'\nimport { IRequiredContext, SignedStatusListData } from '../../types'\nimport { DecodedStatusListPayload, resolveIdentifier } from './common'\nimport { BitsPerStatus } from '@sd-jwt/jwt-status-list'\n\nconst cbor = cborpkg.com.sphereon.cbor\nconst kmp = cborpkg.com.sphereon.kmp\nconst kotlin = cborpkg.kotlin\nconst decompressRawStatusList = (StatusList as any).decodeStatusList.bind(StatusList)\n\nconst CWT_CLAIMS = {\n SUBJECT: 2,\n ISSUER: 1,\n ISSUED_AT: 6,\n EXPIRATION: 4,\n TIME_TO_LIVE: 65534,\n STATUS_LIST: 65533,\n} as const\n\nexport const createSignedCbor = async (\n context: IRequiredContext,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n): Promise<SignedStatusListData> => {\n const identifier = await resolveIdentifier(context, issuerString, keyRef)\n\n const encodeStatusList = statusList.encodeStatusList()\n const compressedList = deflate(encodeStatusList, { level: 9 })\n const compressedBytes = new Int8Array(compressedList)\n\n const statusListMap = new cbor.CborMap(\n kotlin.collections.KtMutableMap.fromJsMap(\n new Map<cborpkg.com.sphereon.cbor.CborString, cborpkg.com.sphereon.cbor.CborItem<any>>([\n [new cbor.CborString('bits'), new cbor.CborUInt(kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))],\n [new cbor.CborString('lst'), new cbor.CborByteString(compressedBytes)],\n ]),\n ),\n )\n\n const protectedHeader = new cbor.CborMap(\n kotlin.collections.KtMutableMap.fromJsMap(\n new Map([[new cbor.CborUInt(kmp.LongKMP.fromNumber(16)), new cbor.CborString('statuslist+cwt')]]), // \"type\"\n ),\n )\n const protectedHeaderEncoded = cbor.Cbor.encode(protectedHeader)\n const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt)\n const claimsEncoded: Int8Array = cbor.Cbor.encode(claimsMap)\n\n const signedCWT: string = await context.agent.keyManagerSign({\n keyRef: identifier.kmsKeyRef,\n data: base64url.encode(Buffer.from(claimsEncoded)), // TODO test on RN\n encoding: undefined,\n })\n\n const protectedHeaderEncodedInt8 = new Int8Array(protectedHeaderEncoded)\n const claimsEncodedInt8 = new Int8Array(claimsEncoded)\n const signatureBytes = base64url.decode(signedCWT)\n const signatureInt8 = new Int8Array(Buffer.from(signatureBytes))\n\n const cwtArrayElements: Array<cborpkg.com.sphereon.cbor.CborItem<any>> = [\n new cbor.CborByteString(protectedHeaderEncodedInt8),\n new cbor.CborByteString(claimsEncodedInt8),\n new cbor.CborByteString(signatureInt8),\n ]\n const cwtArray = new cbor.CborArray(kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements))\n const cwtEncoded = cbor.Cbor.encode(cwtArray)\n const cwtBuffer = Buffer.from(cwtEncoded)\n return {\n statusListCredential: base64url.encode(cwtBuffer),\n encodedList: base64url.encode(compressedList as Buffer), // JS in @sd-jwt/jwt-status-list drops it in like this, so keep the same method\n }\n}\n\nfunction buildClaimsMap(\n id: string,\n issuerString: string,\n statusListMap: cborpkg.com.sphereon.cbor.CborMap<cborpkg.com.sphereon.cbor.CborString, cborpkg.com.sphereon.cbor.CborItem<any>>,\n expiresAt?: Date,\n) {\n const ttl = 65535 // FIXME figure out what value should be / come from and what the difference is with exp\n const claimsEntries: Array<[cborpkg.com.sphereon.cbor.CborUInt, cborpkg.com.sphereon.cbor.CborItem<any>]> = [\n [new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)), new cbor.CborString(id)], // \"sub\"\n [new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)), new cbor.CborString(issuerString)], // \"iss\"\n [\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1000))), // \"iat\"\n ],\n ]\n\n if (expiresAt) {\n claimsEntries.push([\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1000))), // \"exp\"\n ])\n }\n\n if (ttl) {\n claimsEntries.push([\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(ttl)), // \"time to live\"\n ])\n }\n\n claimsEntries.push([new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)), statusListMap])\n\n const claimsMap = new cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)))\n return claimsMap\n}\n\nconst getCborValueFromMap = <T>(map: Map<cborpkg.com.sphereon.cbor.CborItem<any>, cborpkg.com.sphereon.cbor.CborItem<any>>, key: number): T => {\n const value = getCborOptionalValueFromMap<T>(map, key)\n if (value === undefined) {\n throw new Error(`Required claim ${key} not found`)\n }\n return value\n}\n\nconst getCborOptionalValueFromMap = <T>(\n map: Map<cborpkg.com.sphereon.cbor.CborItem<any>, cborpkg.com.sphereon.cbor.CborItem<any>>,\n key: number,\n): T | undefined | never => {\n const value = map.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)))\n if (!value) {\n return undefined\n }\n return value.value as T\n}\n\nexport const decodeStatusListCWT = (cwt: string): DecodedStatusListPayload => {\n const encodedCbor = base64url.toBuffer(cwt)\n const encodedCborArray = new Int8Array(encodedCbor)\n const decodedCbor = cborpkg.com.sphereon.cbor.Cbor.decode(encodedCborArray)\n\n if (!(decodedCbor instanceof cborpkg.com.sphereon.cbor.CborArray)) {\n throw new Error('Invalid CWT format: Expected a CBOR array')\n }\n\n const [, payload] = decodedCbor.value.asJsArrayView()\n if (!(payload instanceof cborpkg.com.sphereon.cbor.CborByteString)) {\n throw new Error('Invalid payload format: Expected a CBOR ByteString')\n }\n\n const claims = cborpkg.com.sphereon.cbor.Cbor.decode(payload.value)\n if (!(claims instanceof cborpkg.com.sphereon.cbor.CborMap)) {\n throw new Error('Invalid claims format: Expected a CBOR map')\n }\n\n const claimsMap = claims.value.asJsMapView()\n\n const statusListMap = claimsMap.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView()\n\n const bits = Number(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString('bits')).value) as BitsPerStatus\n const decoded = new Uint8Array(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString('lst')).value)\n const uint8Array = inflate(decoded)\n const rawStatusList = decompressRawStatusList(uint8Array, bits)\n const statusList = new StatusList(rawStatusList, bits)\n\n return {\n issuer: getCborValueFromMap<string>(claimsMap, CWT_CLAIMS.ISSUER),\n id: getCborValueFromMap<string>(claimsMap, CWT_CLAIMS.SUBJECT),\n statusList,\n iat: Number(getCborValueFromMap<number>(claimsMap, CWT_CLAIMS.ISSUED_AT)),\n exp: getCborOptionalValueFromMap<number>(claimsMap, CWT_CLAIMS.EXPIRATION),\n ttl: getCborOptionalValueFromMap<number>(claimsMap, CWT_CLAIMS.TIME_TO_LIVE),\n }\n}\n","import { IStatusList } from './IStatusList'\nimport { StatusList2021Implementation } from './StatusList2021'\nimport { OAuthStatusListImplementation } from './OAuthStatusList'\nimport { StatusListType } from '@sphereon/ssi-types'\n\nexport class StatusListFactory {\n private static instance: StatusListFactory\n private implementations: Map<StatusListType, IStatusList>\n\n private constructor() {\n this.implementations = new Map()\n this.implementations.set(StatusListType.StatusList2021, new StatusList2021Implementation())\n this.implementations.set(StatusListType.OAuthStatusList, new OAuthStatusListImplementation())\n }\n\n public static getInstance(): StatusListFactory {\n if (!StatusListFactory.instance) {\n StatusListFactory.instance = new StatusListFactory()\n }\n return StatusListFactory.instance\n }\n\n public getByType(type: StatusListType): IStatusList {\n const statusList = this.implementations.get(type)\n if (!statusList) {\n throw new Error(`No implementation found for status list type: ${type}`)\n }\n return statusList\n }\n}\n\nexport function getStatusListImplementation(type: StatusListType): IStatusList {\n return StatusListFactory.getInstance().getByType(type)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AC6BO,IAAKA,cAAAA,yBAAAA,cAAAA;;;;SAAAA;;AAML,IAAKC,aAAAA,yBAAAA,aAAAA;;;SAAAA;;;;AClCZ,IAAAC,oBAQO;AAGP,IAAAC,yBAA4B;;;ACZ5B,uBAQO;AACP,wBAA0B;AAEnB,SAASC,0BAA0BC,MAAqB;AAC7D,QAAMC,eAAeD,QAAQE,gCAAeC;AAC5C,MAAI,CAAC;IAACD,gCAAeC;IAAgBD,gCAAeE;IAAiBC,SAASJ,YAAAA,GAAe;AAC3F,UAAMK,MAAM,mBAAmBL,YAAAA,yBAAqC;EACtE;AACA,SAAOA;AACT;AANgBF;AAQT,SAASQ,iBAAoB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ssi_types","import_vc_status_list","getAssertedStatusListType","type","assertedType","StatusListType","StatusList2021","OAuthStatusList","includes","Error","getAssertedValue","name","value","undefined","getAssertedValues","args","id","issuer","getAssertedProperty","propertyName","obj","ValidProofTypeMap","Map","assertValidProofType","proofFormat","validProofTypes","get","determineStatusListType","credential","determineProofFormat","payload","jwtDecode","keys","Object","uniform","CredentialMapper","toUniformCredential","find","t","values","some","statusType","replace","detectDocumentType","DocumentFormat","JWT","MSO_MDOC","JSONLD","import_ssi_types","DEFAULT_LIST_LENGTH","DEFAULT_PROOF_FORMAT","StatusList2021Implementation","createNewStatusList","args","context","length","proofFormat","assertValidProofType","StatusListType","StatusList2021","veramoProofFormat","issuer","id","correlationId","getAssertedValue","list","StatusList","encodedList","encode","statusPurpose","statusListCredential","createVerifiableCredential","statusList2021","indexingDirection","type","statuslistContentType","buildContentType","updateStatusListIndex","credential","uniform","CredentialMapper","toUniformCredential","credentialSubject","origEncodedList","getAssertedProperty","index","statusListIndex","parseInt","statusList","decode","setStatus","value","detectDocumentType","DocumentFormat","JWT","updatedCredential","updateStatusListFromEncodedList","Error","getAssertedValues","newEncodedList","keyRef","checkStatusIndex","status","getStatus","Status2021","Invalid","Valid","toStatusListDetails","statusListPayload","driverType","identifier","agent","identifierManagedGet","vmRelationship","offlineWhenNoDIDRegistered","verifiableCredential","kmsKeyRef","fetchRemoteContexts","toWrappedVerifiableCredential","original","import_ssi_types","import_jwt_status_list","import_ssi_types","resolveIdentifier","context","issuer","keyRef","agent","identifierManagedGet","identifier","vmRelationship","offlineWhenNoDIDRegistered","kmsKeyRef","STATUS_LIST_JWT_TYP","createSignedJwt","context","statusList","issuerString","id","expiresAt","keyRef","identifier","resolveIdentifier","resolution","ensureManagedIdentifierResult","payload","iss","sub","iat","Math","floor","Date","now","exp","getTime","header","alg","getSigningAlgo","key","type","typ","values","createHeaderAndPayload","signedJwt","agent","jwtCreateJwsCompactSignature","issuer","noIssPayloadUpdate","protectedHeader","statusListCredential","jwt","encodedList","status_list","lst","decodeStatusListJWT","payloadBase64","split","JSON","parse","base64url","decode","Error","StatusList","decompressStatusList","bits","ttl","JoseSignatureAlgorithm","EdDSA","ES256K","ES256","RS256","import_jwt_status_list","import_base64url","cbor","com","sphereon","kmp","kotlin","decompressRawStatusList","StatusList","decodeStatusList","bind","CWT_CLAIMS","SUBJECT","ISSUER","ISSUED_AT","EXPIRATION","TIME_TO_LIVE","STATUS_LIST","createSignedCbor","context","statusList","issuerString","id","expiresAt","keyRef","identifier","resolveIdentifier","encodeStatusList","compressedList","deflate","level","compressedBytes","Int8Array","statusListMap","CborMap","collections","KtMutableMap","fromJsMap","Map","CborString","CborUInt","LongKMP","fromNumber","getBitsPerStatus","CborByteString","protectedHeader","protectedHeaderEncoded","Cbor","encode","claimsMap","buildClaimsMap","claimsEncoded","signedCWT","agent","keyManagerSign","kmsKeyRef","data","base64url","Buffer","from","encoding","undefined","protectedHeaderEncodedInt8","claimsEncodedInt8","signatureBytes","decode","signatureInt8","cwtArrayElements","cwtArray","CborArray","KtMutableList","fromJsArray","cwtEncoded","cwtBuffer","statusListCredential","encodedList","ttl","claimsEntries","Math","floor","Date","now","push","getTime","getCborValueFromMap","map","key","value","getCborOptionalValueFromMap","Error","get","decodeStatusListCWT","cwt","encodedCbor","toBuffer","encodedCborArray","decodedCbor","payload","asJsArrayView","claims","asJsMapView","bits","Number","decoded","Uint8Array","uint8Array","inflate","rawStatusList","issuer","iat","exp","DEFAULT_BITS_PER_STATUS","DEFAULT_LIST_LENGTH","DEFAULT_PROOF_FORMAT","OAuthStatusListImplementation","createNewStatusList","args","context","oauthStatusList","Error","proofFormat","issuer","id","keyRef","bitsPerStatus","expiresAt","length","issuerString","correlationId","getAssertedValue","statusList","StatusList","Array","fill","encodedList","compressStatusList","statusListCredential","createSignedStatusList","type","StatusListType","OAuthStatusList","statuslistContentType","buildContentType","updateStatusListIndex","value","Promise","reject","determineProofFormat","decoded","decodeStatusListJWT","decodeStatusListCWT","index","statusListIndex","parseInt","setStatus","signedCredential","getBitsPerStatus","updateStatusListFromEncodedList","getAssertedValues","listToUpdate","decompressStatusList","checkStatusIndex","getStatus","toStatusListDetails","statusListPayload","exp","Date","driverType","createSignedJwt","createSignedCbor","import_ssi_types","StatusListFactory","instance","implementations","Map","set","StatusListType","StatusList2021","StatusList2021Implementation","OAuthStatusList","OAuthStatusListImplementation","getInstance","getByType","type","statusList","get","Error","getStatusListImplementation","fetchStatusListCredential","args","url","getAssertedValue","statusListCredential","response","fetch","ok","Error","status","statusText","responseAsText","text","trim","startsWith","JSON","parse","error","console","message","stringify","statusPluginStatusFunction","credential","didDoc","result","checkStatusForCredential","documentLoader","errorUnknownListType","revoked","verified","vcLibCheckStatusFunction","mandatoryCredentialStatus","verifyStatusListCredential","verifyMatchingIssuers","uniform","CredentialMapper","toUniformCredential","credentialStatus","log","type","checkStatus","simpleCheckStatusFromStatusListUrl","checkStatusIndexFromStatusListCredential","statusListType","determineStatusListType","implementation","getStatusListImplementation","checkStatusIndex","createNewStatusList","context","getAssertedValues","updateStatusIndexFromStatusListCredential","updateStatusListIndex","statusListCredentialToDetails","documentFormat","detectDocumentType","DocumentFormat","JWT","header","split","decodedHeader","Buffer","from","toString","typ","StatusListType","OAuthStatusList","MSO_MDOC","find","t","includes","replace","toStatusListDetails","statusListPayload","correlationId","driverType","updateStatusListIndexFromEncodedList","updateStatusListFromEncodedList","statusList2021ToVerifiableCredential","issuer","id","identifier","agent","identifierManagedGet","vmRelationship","offlineWhenNoDIDRegistered","proofFormat","assertValidProofType","StatusList2021","veramoProofFormat","encodedList","statusPurpose","credentialSubject","verifiableCredential","createVerifiableCredential","keyRef","kmsKeyRef","fetchRemoteContexts","toWrappedVerifiableCredential","original"]}
|
package/dist/index.js
CHANGED
|
@@ -413,10 +413,11 @@ var getSigningAlgo = /* @__PURE__ */ __name((type) => {
|
|
|
413
413
|
// src/impl/encoding/cbor.ts
|
|
414
414
|
import { StatusList as StatusList3 } from "@sd-jwt/jwt-status-list";
|
|
415
415
|
import { deflate, inflate } from "pako";
|
|
416
|
-
import
|
|
416
|
+
import * as cborpkg from "@sphereon/kmp-cbor";
|
|
417
417
|
import base64url2 from "base64url";
|
|
418
|
-
var cbor = com.sphereon.cbor;
|
|
419
|
-
var kmp = com.sphereon.kmp;
|
|
418
|
+
var cbor = cborpkg.com.sphereon.cbor;
|
|
419
|
+
var kmp = cborpkg.com.sphereon.kmp;
|
|
420
|
+
var kotlin2 = cborpkg.kotlin;
|
|
420
421
|
var decompressRawStatusList = StatusList3.decodeStatusList.bind(StatusList3);
|
|
421
422
|
var CWT_CLAIMS = {
|
|
422
423
|
SUBJECT: 2,
|
|
@@ -433,7 +434,7 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
433
434
|
level: 9
|
|
434
435
|
});
|
|
435
436
|
const compressedBytes = new Int8Array(compressedList);
|
|
436
|
-
const statusListMap = new cbor.CborMap(
|
|
437
|
+
const statusListMap = new cbor.CborMap(kotlin2.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
437
438
|
[
|
|
438
439
|
new cbor.CborString("bits"),
|
|
439
440
|
new cbor.CborUInt(kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))
|
|
@@ -443,7 +444,7 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
443
444
|
new cbor.CborByteString(compressedBytes)
|
|
444
445
|
]
|
|
445
446
|
])));
|
|
446
|
-
const protectedHeader = new cbor.CborMap(
|
|
447
|
+
const protectedHeader = new cbor.CborMap(kotlin2.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
447
448
|
[
|
|
448
449
|
new cbor.CborUInt(kmp.LongKMP.fromNumber(16)),
|
|
449
450
|
new cbor.CborString("statuslist+cwt")
|
|
@@ -466,7 +467,7 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
466
467
|
new cbor.CborByteString(claimsEncodedInt8),
|
|
467
468
|
new cbor.CborByteString(signatureInt8)
|
|
468
469
|
];
|
|
469
|
-
const cwtArray = new cbor.CborArray(
|
|
470
|
+
const cwtArray = new cbor.CborArray(kotlin2.collections.KtMutableList.fromJsArray(cwtArrayElements));
|
|
470
471
|
const cwtEncoded = cbor.Cbor.encode(cwtArray);
|
|
471
472
|
const cwtBuffer = Buffer.from(cwtEncoded);
|
|
472
473
|
return {
|
|
@@ -506,7 +507,7 @@ function buildClaimsMap(id, issuerString, statusListMap, expiresAt) {
|
|
|
506
507
|
new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)),
|
|
507
508
|
statusListMap
|
|
508
509
|
]);
|
|
509
|
-
const claimsMap = new cbor.CborMap(
|
|
510
|
+
const claimsMap = new cbor.CborMap(kotlin2.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)));
|
|
510
511
|
return claimsMap;
|
|
511
512
|
}
|
|
512
513
|
__name(buildClaimsMap, "buildClaimsMap");
|
|
@@ -518,7 +519,7 @@ var getCborValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
518
519
|
return value;
|
|
519
520
|
}, "getCborValueFromMap");
|
|
520
521
|
var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
521
|
-
const value = map.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)));
|
|
522
|
+
const value = map.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)));
|
|
522
523
|
if (!value) {
|
|
523
524
|
return void 0;
|
|
524
525
|
}
|
|
@@ -527,22 +528,22 @@ var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
527
528
|
var decodeStatusListCWT = /* @__PURE__ */ __name((cwt) => {
|
|
528
529
|
const encodedCbor = base64url2.toBuffer(cwt);
|
|
529
530
|
const encodedCborArray = new Int8Array(encodedCbor);
|
|
530
|
-
const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray);
|
|
531
|
-
if (!(decodedCbor instanceof com.sphereon.cbor.CborArray)) {
|
|
531
|
+
const decodedCbor = cborpkg.com.sphereon.cbor.Cbor.decode(encodedCborArray);
|
|
532
|
+
if (!(decodedCbor instanceof cborpkg.com.sphereon.cbor.CborArray)) {
|
|
532
533
|
throw new Error("Invalid CWT format: Expected a CBOR array");
|
|
533
534
|
}
|
|
534
535
|
const [, payload] = decodedCbor.value.asJsArrayView();
|
|
535
|
-
if (!(payload instanceof com.sphereon.cbor.CborByteString)) {
|
|
536
|
+
if (!(payload instanceof cborpkg.com.sphereon.cbor.CborByteString)) {
|
|
536
537
|
throw new Error("Invalid payload format: Expected a CBOR ByteString");
|
|
537
538
|
}
|
|
538
|
-
const claims = com.sphereon.cbor.Cbor.decode(payload.value);
|
|
539
|
-
if (!(claims instanceof com.sphereon.cbor.CborMap)) {
|
|
539
|
+
const claims = cborpkg.com.sphereon.cbor.Cbor.decode(payload.value);
|
|
540
|
+
if (!(claims instanceof cborpkg.com.sphereon.cbor.CborMap)) {
|
|
540
541
|
throw new Error("Invalid claims format: Expected a CBOR map");
|
|
541
542
|
}
|
|
542
543
|
const claimsMap = claims.value.asJsMapView();
|
|
543
|
-
const statusListMap = claimsMap.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView();
|
|
544
|
-
const bits = Number(statusListMap.get(new com.sphereon.cbor.CborString("bits")).value);
|
|
545
|
-
const decoded = new Uint8Array(statusListMap.get(new com.sphereon.cbor.CborString("lst")).value);
|
|
544
|
+
const statusListMap = claimsMap.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView();
|
|
545
|
+
const bits = Number(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString("bits")).value);
|
|
546
|
+
const decoded = new Uint8Array(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString("lst")).value);
|
|
546
547
|
const uint8Array = inflate(decoded);
|
|
547
548
|
const rawStatusList = decompressRawStatusList(uint8Array, bits);
|
|
548
549
|
const statusList = new StatusList3(rawStatusList, bits);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/index.ts","../src/functions.ts","../src/utils.ts","../src/impl/StatusList2021.ts","../src/impl/OAuthStatusList.ts","../src/impl/encoding/jwt.ts","../src/impl/encoding/common.ts","../src/impl/encoding/cbor.ts","../src/impl/StatusListFactory.ts"],"sourcesContent":["import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport {\n ICredential,\n ICredentialStatus,\n IIssuer,\n IVerifiableCredential,\n OrPromise,\n ProofFormat,\n StatusListCredential,\n StatusListCredentialIdMode,\n StatusListDriverType,\n StatusListIndexingDirection,\n StatusListType,\n StatusPurpose2021,\n} from '@sphereon/ssi-types'\nimport {\n CredentialPayload,\n IAgentContext,\n ICredentialIssuer,\n ICredentialPlugin,\n ICredentialVerifier,\n IKeyManager,\n IPluginMethodMap,\n} from '@veramo/core'\nimport { DataSource } from 'typeorm'\nimport { BitsPerStatus } from '@sd-jwt/jwt-status-list'\nimport { SdJwtVcPayload } from '@sd-jwt/sd-jwt-vc'\nimport { StatusListOpts } from '@sphereon/oid4vci-common'\n\nexport enum StatusOAuth {\n Valid = 0,\n Invalid = 1,\n Suspended = 2,\n}\n\nexport enum Status2021 {\n Valid = 0,\n Invalid = 1,\n}\n\nexport type StatusList2021Args = {\n indexingDirection: StatusListIndexingDirection\n statusPurpose?: StatusPurpose2021\n // todo: validFrom and validUntil\n}\n\nexport type OAuthStatusListArgs = {\n bitsPerStatus?: BitsPerStatus\n expiresAt?: Date\n}\n\nexport type BaseCreateNewStatusListArgs = {\n type: StatusListType\n id: string\n issuer: string | IIssuer\n correlationId?: string\n length?: number\n proofFormat?: ProofFormat\n keyRef?: string\n statusList2021?: StatusList2021Args\n oauthStatusList?: OAuthStatusListArgs\n driverType?: StatusListDriverType\n}\n\nexport type UpdateStatusList2021Args = {\n statusPurpose: StatusPurpose2021\n}\n\nexport type UpdateOAuthStatusListArgs = {\n bitsPerStatus: BitsPerStatus\n expiresAt?: Date\n}\n\nexport interface UpdateStatusListFromEncodedListArgs {\n type?: StatusListType\n statusListIndex: number | string\n value: boolean\n proofFormat?: ProofFormat\n keyRef?: string\n correlationId?: string\n encodedList: string\n issuer: string | IIssuer\n id: string\n statusList2021?: UpdateStatusList2021Args\n oauthStatusList?: UpdateOAuthStatusListArgs\n}\n\nexport interface UpdateStatusListFromStatusListCredentialArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n keyRef?: string\n statusListIndex: number | string\n value: number | Status2021 | StatusOAuth\n}\n\nexport interface StatusListResult {\n encodedList: string\n statusListCredential: StatusListCredential\n length: number\n type: StatusListType\n proofFormat: ProofFormat\n id: string\n statuslistContentType: string\n issuer: string | IIssuer\n statusList2021?: StatusList2021Details\n oauthStatusList?: OAuthStatusDetails\n\n // These cannot be deduced from the VC, so they are present when callers pass in these values as params\n correlationId?: string\n driverType?: StatusListDriverType\n credentialIdMode?: StatusListCredentialIdMode\n}\n\ninterface StatusList2021Details {\n indexingDirection: StatusListIndexingDirection\n statusPurpose?: StatusPurpose2021\n}\n\ninterface OAuthStatusDetails {\n bitsPerStatus?: BitsPerStatus\n expiresAt?: Date\n}\n\nexport interface StatusList2021EntryCredentialStatus extends ICredentialStatus {\n type: 'StatusList2021Entry'\n statusPurpose: StatusPurpose2021\n statusListIndex: string\n statusListCredential: string\n}\n\nexport interface StatusListOAuthEntryCredentialStatus extends ICredentialStatus {\n type: 'OAuthStatusListEntry'\n bitsPerStatus: number\n statusListIndex: string\n statusListCredential: string\n expiresAt?: Date\n}\n\nexport interface StatusList2021ToVerifiableCredentialArgs {\n issuer: string | IIssuer\n id: string\n type?: StatusListType\n proofFormat?: ProofFormat\n keyRef?: string\n encodedList: string\n statusPurpose: StatusPurpose2021\n}\n\nexport interface CreateStatusListArgs {\n issuer: string | IIssuer\n id: string\n proofFormat?: ProofFormat\n keyRef?: string\n correlationId?: string\n length?: number\n statusList2021?: StatusList2021Args\n oauthStatusList?: OAuthStatusListArgs\n}\n\nexport interface UpdateStatusListIndexArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n statusListIndex: number | string\n value: number | Status2021 | StatusOAuth\n keyRef?: string\n expiresAt?: Date\n}\n\nexport interface CheckStatusIndexArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n statusListIndex: string | number\n}\n\nexport interface ToStatusListDetailsArgs {\n statusListPayload: StatusListCredential\n correlationId?: string\n driverType?: StatusListDriverType\n}\n\n/**\n * The interface definition for a plugin that can add statuslist info to a credential\n *\n * @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}\n *\n * @beta This API is likely to change without a BREAKING CHANGE notice\n */\nexport interface IStatusListPlugin extends IPluginMethodMap {\n /**\n * Create a new status list\n *\n * @param args Status list information like type and size\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n *\n * @returns - The details of the newly created status list\n */\n slCreateStatusList(args: CreateNewStatusListArgs, context: IRequiredContext): Promise<StatusListResult>\n\n /**\n * Ensures status list info like index and list id is added to a credential\n *\n * @param args - Arguments necessary to add the statuslist info.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n *\n * @returns - a promise that resolves to the credential now with status support\n *\n * @beta This API is likely to change without a BREAKING CHANGE notice\n */\n slAddStatusToCredential(args: IAddStatusToCredentialArgs, context: IRequiredContext): Promise<CredentialWithStatusSupport>\n\n slAddStatusToSdJwtCredential(args: IAddStatusToSdJwtCredentialArgs, context: IRequiredContext): Promise<SdJwtVcPayload>\n\n /**\n * Get the status list using the configured driver for the SL. Normally a correlationId or id should suffice. Optionally accepts a dbName/datasource\n * @param args\n * @param context\n */\n slGetStatusList(args: GetStatusListArgs, context: IRequiredContext): Promise<StatusListResult>\n\n /**\n * Import status lists when noy yet present\n *\n * @param imports Array of status list information like type and size\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n */\n slImportStatusLists(imports: Array<CreateNewStatusListArgs>, context: IRequiredContext): Promise<boolean>\n}\n\nexport type CreateNewStatusListFuncArgs = BaseCreateNewStatusListArgs\n\nexport type CreateNewStatusListArgs = BaseCreateNewStatusListArgs & {\n dbName?: string\n dataSource?: OrPromise<DataSource>\n isDefault?: boolean\n}\n\nexport type IAddStatusToCredentialArgs = Omit<IIssueCredentialStatusOpts, 'dataSource'> & {\n credential: CredentialWithStatusSupport\n}\n\nexport type IAddStatusToSdJwtCredentialArgs = Omit<IIssueCredentialStatusOpts, 'dataSource'> & {\n credential: SdJwtVcPayload\n}\n\nexport interface IIssueCredentialStatusOpts {\n dataSource?: DataSource\n statusLists?: Array<StatusListOpts>\n credentialId?: string // An id to use for the credential. Normally should be set as the crdential.id value\n value?: string\n}\n\nexport type GetStatusListArgs = {\n id?: string\n correlationId?: string\n dataSource?: OrPromise<DataSource>\n dbName?: string\n}\n\nexport type CredentialWithStatusSupport = ICredential | CredentialPayload | IVerifiableCredential\n\nexport type SignedStatusListData = {\n statusListCredential: StatusListCredential\n encodedList: string\n}\n\nexport type IRequiredPlugins = ICredentialPlugin & IIdentifierResolution\nexport type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager & ICredentialPlugin>\n","import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport {\n CredentialMapper,\n DocumentFormat,\n ProofFormat,\n StatusListCredential,\n StatusListDriverType,\n StatusListType,\n StatusPurpose2021,\n} from '@sphereon/ssi-types'\nimport { CredentialStatus, DIDDocument, IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core'\n\nimport { checkStatus } from '@sphereon/vc-status-list'\n\n// @ts-ignore\nimport { CredentialJwtOrJSON, StatusMethod } from 'credential-status'\nimport {\n CreateNewStatusListFuncArgs,\n Status2021,\n StatusList2021ToVerifiableCredentialArgs,\n StatusListResult,\n StatusOAuth,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from './types'\nimport { assertValidProofType, determineStatusListType, getAssertedValue, getAssertedValues } from './utils'\nimport { getStatusListImplementation } from './impl/StatusListFactory'\n\nexport async function fetchStatusListCredential(args: { statusListCredential: string }): Promise<StatusListCredential> {\n const url = getAssertedValue('statusListCredential', args.statusListCredential)\n try {\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(`Fetching status list ${url} resulted in an error: ${response.status} : ${response.statusText}`)\n }\n const responseAsText = await response.text()\n if (responseAsText.trim().startsWith('{')) {\n return JSON.parse(responseAsText) as StatusListCredential\n }\n return responseAsText as StatusListCredential\n } catch (error) {\n console.error(`Fetching status list ${url} resulted in an unexpected error: ${error instanceof Error ? error.message : JSON.stringify(error)}`)\n throw error\n }\n}\n\nexport function statusPluginStatusFunction(args: {\n documentLoader: any\n suite: any\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}): StatusMethod {\n return async (credential: CredentialJwtOrJSON, didDoc: DIDDocument): Promise<CredentialStatus> => {\n const result = await checkStatusForCredential({\n ...args,\n documentLoader: args.documentLoader,\n credential: credential as StatusListCredential,\n errorUnknownListType: args.errorUnknownListType,\n })\n\n return {\n revoked: !result.verified || result.error,\n ...(result.error && { error: result.error }),\n }\n }\n}\n\n/**\n * Function that can be used together with @digitalbazar/vc and @digitialcredentials/vc\n * @param args\n */\nexport function vcLibCheckStatusFunction(args: {\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}) {\n const { mandatoryCredentialStatus, verifyStatusListCredential, verifyMatchingIssuers, errorUnknownListType } = args\n return (args: {\n credential: StatusListCredential\n documentLoader: any\n suite: any\n }): Promise<{\n verified: boolean\n error?: any\n }> => {\n return checkStatusForCredential({\n ...args,\n mandatoryCredentialStatus,\n verifyStatusListCredential,\n verifyMatchingIssuers,\n errorUnknownListType,\n })\n }\n}\n\nexport async function checkStatusForCredential(args: {\n credential: StatusListCredential\n documentLoader: any\n suite: any\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}): Promise<{ verified: boolean; error?: any }> {\n const verifyStatusListCredential = args.verifyStatusListCredential ?? true\n const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true\n const uniform = CredentialMapper.toUniformCredential(args.credential)\n if (!('credentialStatus' in uniform) || !uniform.credentialStatus) {\n if (args.mandatoryCredentialStatus) {\n const error = 'No credential status object found in the Verifiable Credential and it is mandatory'\n console.log(error)\n return { verified: false, error }\n }\n return { verified: true }\n }\n if ('credentialStatus' in uniform && uniform.credentialStatus) {\n if (uniform.credentialStatus.type === 'StatusList2021Entry') {\n return checkStatus({ ...args, verifyStatusListCredential, verifyMatchingIssuers })\n } else if (args?.errorUnknownListType) {\n const error = `Credential status type ${uniform.credentialStatus.type} is not supported, and check status has been configured to not allow for that`\n console.log(error)\n return { verified: false, error }\n } else {\n console.log(`Skipped verification of status type ${uniform.credentialStatus.type} as we do not support it (yet)`)\n }\n }\n return { verified: true }\n}\n\nexport async function simpleCheckStatusFromStatusListUrl(args: {\n statusListCredential: string\n statusPurpose?: StatusPurpose2021\n type?: StatusListType | 'StatusList2021Entry'\n id?: string\n statusListIndex: string\n}): Promise<number | Status2021 | StatusOAuth> {\n return checkStatusIndexFromStatusListCredential({\n ...args,\n statusListCredential: await fetchStatusListCredential(args),\n })\n}\n\nexport async function checkStatusIndexFromStatusListCredential(args: {\n statusListCredential: StatusListCredential\n statusPurpose?: StatusPurpose2021\n type?: StatusListType | 'StatusList2021Entry'\n id?: string\n statusListIndex: string | number\n}): Promise<number | Status2021 | StatusOAuth> {\n const statusListType: StatusListType = determineStatusListType(args.statusListCredential)\n const implementation = getStatusListImplementation(statusListType)\n return implementation.checkStatusIndex(args)\n}\n\nexport async function createNewStatusList(\n args: CreateNewStatusListFuncArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const { type } = getAssertedValues(args)\n const implementation = getStatusListImplementation(type)\n return implementation.createNewStatusList(args, context)\n}\n\nexport async function updateStatusIndexFromStatusListCredential(\n args: UpdateStatusListIndexArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const credential = getAssertedValue('statusListCredential', args.statusListCredential)\n const statusListType: StatusListType = determineStatusListType(credential)\n const implementation = getStatusListImplementation(statusListType)\n return implementation.updateStatusListIndex(args, context)\n}\n\n// Keeping helper function for backward compatibility\nexport async function statusListCredentialToDetails(args: {\n statusListCredential: StatusListCredential\n correlationId?: string\n driverType?: StatusListDriverType\n}): Promise<StatusListResult> {\n const credential = getAssertedValue('statusListCredential', args.statusListCredential)\n\n let statusListType: StatusListType | undefined\n const documentFormat = CredentialMapper.detectDocumentType(credential)\n if (documentFormat === DocumentFormat.JWT) {\n const [header] = credential.split('.')\n const decodedHeader = JSON.parse(Buffer.from(header, 'base64').toString())\n\n if (decodedHeader.typ === 'statuslist+jwt') {\n statusListType = StatusListType.OAuthStatusList\n }\n } else if (documentFormat === DocumentFormat.MSO_MDOC) {\n statusListType = StatusListType.OAuthStatusList\n // TODO check CBOR content?\n }\n if (!statusListType) {\n const uniform = CredentialMapper.toUniformCredential(credential)\n const type = uniform.type.find((t) => t.includes('StatusList2021') || t.includes('OAuth2StatusList'))\n if (!type) {\n throw new Error('Invalid status list credential type')\n }\n statusListType = type.replace('Credential', '') as StatusListType\n }\n\n const implementation = getStatusListImplementation(statusListType)\n return await implementation.toStatusListDetails({\n statusListPayload: credential,\n correlationId: args.correlationId,\n driverType: args.driverType,\n })\n}\n\nexport async function updateStatusListIndexFromEncodedList(\n args: UpdateStatusListFromEncodedListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const { type } = getAssertedValue('type', args)\n const implementation = getStatusListImplementation(type!)\n return implementation.updateStatusListFromEncodedList(args, context)\n}\n\nexport async function statusList2021ToVerifiableCredential(\n args: StatusList2021ToVerifiableCredentialArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListCredential> {\n const { issuer, id, type } = getAssertedValues(args)\n const identifier = await context.agent.identifierManagedGet({\n identifier: typeof issuer === 'string' ? issuer : issuer.id,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true, // FIXME Fix identifier resolution for EBSI\n })\n const proofFormat: ProofFormat = args?.proofFormat ?? 'lds'\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const encodedList = getAssertedValue('encodedList', args.encodedList)\n const statusPurpose = getAssertedValue('statusPurpose', args.statusPurpose)\n const credential = {\n '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],\n id,\n issuer,\n // issuanceDate: \"2021-03-10T04:24:12.164Z\",\n type: ['VerifiableCredential', `${type}Credential`],\n credentialSubject: {\n id,\n type,\n statusPurpose,\n encodedList,\n },\n }\n // TODO copy statuslist schema to local and disable fetching remote contexts\n const verifiableCredential = await context.agent.createVerifiableCredential({\n credential,\n keyRef: identifier.kmsKeyRef,\n proofFormat: veramoProofFormat,\n fetchRemoteContexts: true,\n })\n\n return CredentialMapper.toWrappedVerifiableCredential(verifiableCredential as StatusListCredential).original as StatusListCredential\n}\n","import {\n CredentialMapper,\n IIssuer,\n ProofFormat,\n StatusListType,\n StatusListType as StatusListTypeW3C,\n StatusListCredential,\n DocumentFormat,\n} from '@sphereon/ssi-types'\nimport { jwtDecode } from 'jwt-decode'\n\nexport function getAssertedStatusListType(type?: StatusListType) {\n const assertedType = type ?? StatusListType.StatusList2021\n if (![StatusListType.StatusList2021, StatusListType.OAuthStatusList].includes(assertedType)) {\n throw Error(`StatusList type ${assertedType} is not supported (yet)`)\n }\n return assertedType\n}\n\nexport function getAssertedValue<T>(name: string, value: T): NonNullable<T> {\n if (value === undefined || value === null) {\n throw Error(`Missing required ${name} value`)\n }\n return value\n}\n\nexport function getAssertedValues(args: { issuer: string | IIssuer; id: string; type?: StatusListTypeW3C | StatusListType }) {\n const type = getAssertedStatusListType(args?.type)\n const id = getAssertedValue('id', args.id)\n const issuer = getAssertedValue('issuer', args.issuer)\n return { id, issuer, type }\n}\n\nexport function getAssertedProperty<T extends object>(propertyName: string, obj: T): NonNullable<any> {\n if (!(propertyName in obj)) {\n throw Error(`The input object does not contain required property: ${propertyName}`)\n }\n return getAssertedValue(propertyName, (obj as any)[propertyName])\n}\n\nconst ValidProofTypeMap = new Map<StatusListType, ProofFormat[]>([\n [StatusListType.StatusList2021, ['jwt', 'lds', 'EthereumEip712Signature2021']],\n [StatusListType.OAuthStatusList, ['jwt', 'cbor']],\n])\n\nexport function assertValidProofType(type: StatusListType, proofFormat: ProofFormat) {\n const validProofTypes = ValidProofTypeMap.get(type)\n if (!validProofTypes?.includes(proofFormat)) {\n throw Error(`Invalid proof format '${proofFormat}' for status list type ${type}`)\n }\n}\n\nexport function determineStatusListType(credential: StatusListCredential): StatusListType {\n const proofFormat = determineProofFormat(credential)\n switch (proofFormat) {\n case 'jwt':\n const payload: StatusListCredential = jwtDecode(credential as string)\n const keys = Object.keys(payload)\n if (keys.includes('status_list')) {\n return StatusListType.OAuthStatusList\n } else if (keys.includes('vc')) {\n return StatusListType.StatusList2021\n }\n break\n case 'lds':\n const uniform = CredentialMapper.toUniformCredential(credential)\n const type = uniform.type.find((t) => {\n return Object.values(StatusListType).some((statusType) => t.includes(statusType))\n })\n if (!type) {\n throw new Error('Invalid status list credential type')\n }\n return type.replace('Credential', '') as StatusListType\n\n case 'cbor':\n return StatusListType.OAuthStatusList\n }\n\n throw new Error('Cannot determine status list type from credential payload')\n}\n\nexport function determineProofFormat(credential: StatusListCredential): ProofFormat {\n const type: DocumentFormat = CredentialMapper.detectDocumentType(credential)\n switch (type) {\n case DocumentFormat.JWT:\n return 'jwt'\n case DocumentFormat.MSO_MDOC:\n // Not really mdoc, just assume Cbor for now, I'd need to decode at least the header to what type of Cbor we have\n return 'cbor'\n case DocumentFormat.JSONLD:\n return 'lds'\n default:\n throw Error('Cannot determine credential payload type')\n }\n}\n","import { IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core'\nimport { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport { CredentialMapper, DocumentFormat, IIssuer, ProofFormat, StatusListCredential, StatusListType } from '@sphereon/ssi-types'\n\nimport { StatusList } from '@sphereon/vc-status-list'\nimport { IStatusList } from './IStatusList'\nimport {\n CheckStatusIndexArgs,\n CreateStatusListArgs,\n Status2021,\n StatusListResult,\n ToStatusListDetailsArgs,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from '../types'\nimport { assertValidProofType, getAssertedProperty, getAssertedValue, getAssertedValues } from '../utils'\n\nexport const DEFAULT_LIST_LENGTH = 250000\nexport const DEFAULT_PROOF_FORMAT = 'lds' as VeramoProofFormat\n\nexport class StatusList2021Implementation implements IStatusList {\n async createNewStatusList(\n args: CreateStatusListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n const length = args?.length ?? DEFAULT_LIST_LENGTH\n const proofFormat: ProofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const { issuer, id } = args\n const correlationId = getAssertedValue('correlationId', args.correlationId)\n\n const list = new StatusList({ length })\n const encodedList = await list.encode()\n const statusPurpose = 'revocation'\n\n const statusListCredential = await this.createVerifiableCredential(\n {\n ...args,\n encodedList,\n proofFormat: veramoProofFormat,\n },\n context,\n )\n\n return {\n encodedList,\n statusListCredential: statusListCredential,\n statusList2021: {\n statusPurpose,\n indexingDirection: 'rightToLeft',\n },\n length,\n type: StatusListType.StatusList2021,\n proofFormat,\n id,\n correlationId,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListIndex(\n args: UpdateStatusListIndexArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n const credential = args.statusListCredential\n const uniform = CredentialMapper.toUniformCredential(credential)\n const { issuer, credentialSubject } = uniform\n const id = getAssertedValue('id', uniform.id)\n const origEncodedList = getAssertedProperty('encodedList', credentialSubject)\n\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n const statusList = await StatusList.decode({ encodedList: origEncodedList })\n statusList.setStatus(index, args.value != 0)\n const encodedList = await statusList.encode()\n\n const proofFormat = CredentialMapper.detectDocumentType(credential) === DocumentFormat.JWT ? 'jwt' : 'lds'\n const updatedCredential = await this.createVerifiableCredential(\n {\n ...args,\n id,\n issuer,\n encodedList,\n proofFormat: proofFormat,\n },\n context,\n )\n\n return {\n statusListCredential: updatedCredential,\n encodedList,\n statusList2021: {\n ...('statusPurpose' in credentialSubject ? { statusPurpose: credentialSubject.statusPurpose } : {}),\n indexingDirection: 'rightToLeft',\n },\n length: statusList.length - 1,\n type: StatusListType.StatusList2021,\n proofFormat: proofFormat,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListFromEncodedList(\n args: UpdateStatusListFromEncodedListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n if (!args.statusList2021) {\n throw new Error('statusList2021 options required for type StatusList2021')\n }\n const proofFormat: ProofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const { issuer, id } = getAssertedValues(args)\n const statusList = await StatusList.decode({ encodedList: args.encodedList })\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n statusList.setStatus(index, args.value)\n\n const newEncodedList = await statusList.encode()\n const credential = await this.createVerifiableCredential(\n {\n id,\n issuer,\n encodedList: newEncodedList,\n proofFormat: veramoProofFormat,\n keyRef: args.keyRef,\n },\n context,\n )\n\n return {\n type: StatusListType.StatusList2021,\n statusListCredential: credential,\n encodedList: newEncodedList,\n statusList2021: {\n statusPurpose: args.statusList2021.statusPurpose,\n indexingDirection: 'rightToLeft',\n },\n length: statusList.length,\n proofFormat: args.proofFormat ?? 'lds',\n id: id,\n issuer: issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | Status2021> {\n const uniform = CredentialMapper.toUniformCredential(args.statusListCredential)\n const { credentialSubject } = uniform\n const encodedList = getAssertedProperty('encodedList', credentialSubject)\n\n const statusList = await StatusList.decode({ encodedList })\n const status = statusList.getStatus(typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex))\n return status ? Status2021.Invalid : Status2021.Valid\n }\n\n async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {\n const { statusListPayload } = args\n const uniform = CredentialMapper.toUniformCredential(statusListPayload)\n const { issuer, credentialSubject } = uniform\n const id = getAssertedValue('id', uniform.id)\n const encodedList = getAssertedProperty('encodedList', credentialSubject)\n const proofFormat: ProofFormat = CredentialMapper.detectDocumentType(statusListPayload) === DocumentFormat.JWT ? 'jwt' : 'lds'\n\n const statusPurpose = getAssertedProperty('statusPurpose', credentialSubject)\n const list = await StatusList.decode({ encodedList })\n\n return {\n id,\n encodedList,\n issuer,\n type: StatusListType.StatusList2021,\n proofFormat,\n length: list.length,\n statusListCredential: statusListPayload,\n statuslistContentType: this.buildContentType(proofFormat),\n statusList2021: {\n indexingDirection: 'rightToLeft',\n statusPurpose,\n },\n ...(args.correlationId && { correlationId: args.correlationId }),\n ...(args.driverType && { driverType: args.driverType }),\n }\n }\n\n private async createVerifiableCredential(\n args: {\n id: string\n issuer: string | IIssuer\n encodedList: string\n proofFormat: VeramoProofFormat\n keyRef?: string\n },\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListCredential> {\n const identifier = await context.agent.identifierManagedGet({\n identifier: typeof args.issuer === 'string' ? args.issuer : args.issuer.id,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true,\n })\n\n const credential = {\n '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],\n id: args.id,\n issuer: args.issuer,\n type: ['VerifiableCredential', 'StatusList2021Credential'],\n credentialSubject: {\n id: args.id,\n type: 'StatusList2021',\n statusPurpose: 'revocation',\n encodedList: args.encodedList,\n },\n }\n\n const verifiableCredential = await context.agent.createVerifiableCredential({\n credential,\n keyRef: args.keyRef ?? identifier.kmsKeyRef,\n proofFormat: args.proofFormat,\n fetchRemoteContexts: true,\n })\n\n return CredentialMapper.toWrappedVerifiableCredential(verifiableCredential as StatusListCredential).original as StatusListCredential\n }\n\n private buildContentType(proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor' | undefined) {\n switch (proofFormat) {\n case 'jwt':\n return `application/statuslist+jwt`\n case 'cbor':\n return `application/statuslist+cwt`\n case 'lds':\n return 'application/statuslist+ld+json'\n default:\n throw Error(`Unsupported content type '${proofFormat}' for status lists`)\n }\n }\n}\n","import { IAgentContext, ICredentialPlugin, IKeyManager } from '@veramo/core'\nimport { CompactJWT, CWT, ProofFormat, StatusListType } from '@sphereon/ssi-types'\nimport {\n CheckStatusIndexArgs,\n CreateStatusListArgs,\n SignedStatusListData,\n StatusListResult,\n StatusOAuth,\n ToStatusListDetailsArgs,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from '../types'\nimport { determineProofFormat, getAssertedValue, getAssertedValues } from '../utils'\nimport { IStatusList } from './IStatusList'\nimport { StatusList } from '@sd-jwt/jwt-status-list'\nimport { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'\nimport { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport { createSignedJwt, decodeStatusListJWT } from './encoding/jwt'\nimport { createSignedCbor, decodeStatusListCWT } from './encoding/cbor'\n\ntype IRequiredContext = IAgentContext<ICredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>\n\nexport const DEFAULT_BITS_PER_STATUS = 1 // 1 bit is sufficient for 0x00 - \"VALID\" 0x01 - \"INVALID\" saving space in the process\nexport const DEFAULT_LIST_LENGTH = 250000\nexport const DEFAULT_PROOF_FORMAT = 'jwt' as ProofFormat\n\nexport class OAuthStatusListImplementation implements IStatusList {\n async createNewStatusList(args: CreateStatusListArgs, context: IRequiredContext): Promise<StatusListResult> {\n if (!args.oauthStatusList) {\n throw new Error('OAuthStatusList options are required for type OAuthStatusList')\n }\n\n const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n const { issuer, id, oauthStatusList, keyRef } = args\n const { bitsPerStatus, expiresAt } = oauthStatusList\n const length = args.length ?? DEFAULT_LIST_LENGTH\n const issuerString = typeof issuer === 'string' ? issuer : issuer.id\n const correlationId = getAssertedValue('correlationId', args.correlationId)\n\n const statusList = new StatusList(new Array(length).fill(0), bitsPerStatus ?? DEFAULT_BITS_PER_STATUS)\n const encodedList = statusList.compressStatusList()\n const { statusListCredential } = await this.createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef)\n\n return {\n encodedList,\n statusListCredential,\n oauthStatusList: { bitsPerStatus },\n length,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n id,\n correlationId,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListIndex(args: UpdateStatusListIndexArgs, context: IRequiredContext): Promise<StatusListResult> {\n const { statusListCredential, value, expiresAt, keyRef } = args\n if (typeof statusListCredential !== 'string') {\n return Promise.reject('statusListCredential in neither JWT nor CWT')\n }\n\n const proofFormat = determineProofFormat(statusListCredential)\n const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential)\n const { statusList, issuer, id } = decoded\n\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n if (index < 0 || index >= statusList.statusList.length) {\n throw new Error('Status list index out of bounds')\n }\n\n statusList.setStatus(index, value)\n const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(\n proofFormat,\n context,\n statusList,\n issuer,\n id,\n expiresAt,\n keyRef,\n )\n\n return {\n statusListCredential: signedCredential,\n encodedList,\n oauthStatusList: {\n bitsPerStatus: statusList.getBitsPerStatus(),\n },\n length: statusList.statusList.length,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n // FIXME: This still assumes only two values (boolean), whilst this list supports 8 bits max\n async updateStatusListFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IRequiredContext): Promise<StatusListResult> {\n if (!args.oauthStatusList) {\n throw new Error('OAuthStatusList options are required for type OAuthStatusList')\n }\n const { proofFormat, oauthStatusList, keyRef } = args\n const { bitsPerStatus, expiresAt } = oauthStatusList\n\n const { issuer, id } = getAssertedValues(args)\n const issuerString = typeof issuer === 'string' ? issuer : issuer.id\n\n const listToUpdate = StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS)\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n // FIXME: See above.\n listToUpdate.setStatus(index, args.value ? 1 : 0)\n\n const { statusListCredential, encodedList } = await this.createSignedStatusList(\n proofFormat ?? DEFAULT_PROOF_FORMAT,\n context,\n listToUpdate,\n issuerString,\n id,\n expiresAt,\n keyRef,\n )\n\n return {\n encodedList,\n statusListCredential,\n oauthStatusList: {\n bitsPerStatus,\n expiresAt,\n },\n length: listToUpdate.statusList.length,\n type: StatusListType.OAuthStatusList,\n proofFormat: proofFormat ?? DEFAULT_PROOF_FORMAT,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n private buildContentType(proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor' | undefined) {\n return `application/statuslist+${proofFormat === 'cbor' ? 'cwt' : 'jwt'}`\n }\n\n async checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | StatusOAuth> {\n const { statusListCredential, statusListIndex } = args\n if (typeof statusListCredential !== 'string') {\n return Promise.reject('statusListCredential in neither JWT nor CWT')\n }\n\n const proofFormat = determineProofFormat(statusListCredential)\n const { statusList } = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential)\n\n const index = typeof statusListIndex === 'number' ? statusListIndex : parseInt(statusListIndex)\n if (index < 0 || index >= statusList.statusList.length) {\n throw new Error('Status list index out of bounds')\n }\n\n return statusList.getStatus(index)\n }\n\n async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {\n const { statusListPayload } = args as { statusListPayload: CompactJWT | CWT }\n const proofFormat = determineProofFormat(statusListPayload)\n const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload)\n const { statusList, issuer, id, exp } = decoded\n\n return {\n id,\n encodedList: statusList.compressStatusList(),\n issuer,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n length: statusList.statusList.length,\n statusListCredential: statusListPayload,\n statuslistContentType: this.buildContentType(proofFormat),\n oauthStatusList: {\n bitsPerStatus: statusList.getBitsPerStatus(),\n ...(exp && { expiresAt: new Date(exp * 1000) }),\n },\n ...(args.correlationId && { correlationId: args.correlationId }),\n ...(args.driverType && { driverType: args.driverType }),\n }\n }\n\n private async createSignedStatusList(\n proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor',\n context: IAgentContext<ICredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n ): Promise<SignedStatusListData> {\n switch (proofFormat) {\n case 'jwt': {\n return await createSignedJwt(context, statusList, issuerString, id, expiresAt, keyRef)\n }\n case 'cbor': {\n return await createSignedCbor(context, statusList, issuerString, id, expiresAt, keyRef)\n }\n default:\n throw new Error(`Invalid proof format '${proofFormat}' for OAuthStatusList`)\n }\n }\n}\n","import { CompactJWT, JoseSignatureAlgorithm } from '@sphereon/ssi-types'\nimport { createHeaderAndPayload, StatusList, StatusListJWTHeaderParameters, StatusListJWTPayload } from '@sd-jwt/jwt-status-list'\nimport base64url from 'base64url'\nimport { JWTPayload } from 'did-jwt'\nimport { IRequiredContext, SignedStatusListData } from '../../types'\nimport { DecodedStatusListPayload, resolveIdentifier } from './common'\nimport { TKeyType } from '@veramo/core'\nimport { ensureManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution'\n\nconst STATUS_LIST_JWT_TYP = 'statuslist+jwt'\n\nexport const createSignedJwt = async (\n context: IRequiredContext,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n): Promise<SignedStatusListData> => {\n const identifier = await resolveIdentifier(context, issuerString, keyRef)\n const resolution = await ensureManagedIdentifierResult(identifier, context)\n\n const payload: JWTPayload = {\n iss: issuerString,\n sub: id,\n iat: Math.floor(Date.now() / 1000),\n ...(expiresAt && { exp: Math.floor(expiresAt.getTime() / 1000) }),\n }\n\n const header: StatusListJWTHeaderParameters = {\n alg: getSigningAlgo(resolution.key.type),\n typ: STATUS_LIST_JWT_TYP,\n }\n const values = createHeaderAndPayload(statusList, payload, header)\n const signedJwt = await context.agent.jwtCreateJwsCompactSignature({\n issuer: { ...identifier, noIssPayloadUpdate: false },\n protectedHeader: values.header,\n payload: values.payload,\n })\n\n return {\n statusListCredential: signedJwt.jwt,\n encodedList: (values.payload as StatusListJWTPayload).status_list.lst,\n }\n}\n\nexport const decodeStatusListJWT = (jwt: CompactJWT): DecodedStatusListPayload => {\n const [, payloadBase64] = jwt.split('.')\n const payload = JSON.parse(base64url.decode(payloadBase64))\n\n if (!payload.iss || !payload.sub || !payload.status_list) {\n throw new Error('Missing required fields in JWT payload')\n }\n\n const statusList = StatusList.decompressStatusList(payload.status_list.lst, payload.status_list.bits)\n\n return {\n issuer: payload.iss,\n id: payload.sub,\n statusList,\n exp: payload.exp,\n ttl: payload.ttl,\n iat: payload.iat,\n }\n}\n\nexport const getSigningAlgo = (type: TKeyType): JoseSignatureAlgorithm => {\n switch (type) {\n case 'Ed25519':\n return JoseSignatureAlgorithm.EdDSA\n case 'Secp256k1':\n return JoseSignatureAlgorithm.ES256K\n case 'Secp256r1':\n return JoseSignatureAlgorithm.ES256\n case 'RSA':\n return JoseSignatureAlgorithm.RS256\n default:\n throw Error('Key type not yet supported')\n }\n}\n","import { IRequiredContext } from '../../types'\nimport { StatusList } from '@sd-jwt/jwt-status-list'\n\nexport interface DecodedStatusListPayload {\n issuer: string\n id: string\n statusList: StatusList\n exp?: number\n ttl?: number\n iat: number\n}\n\nexport const resolveIdentifier = async (context: IRequiredContext, issuer: string, keyRef?: string) => {\n return await context.agent.identifierManagedGet({\n identifier: issuer,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true,\n ...(keyRef && { kmsKeyRef: keyRef }), // TODO the getDid resolver should look at this ASAP\n })\n}\n","import { StatusList } from '@sd-jwt/jwt-status-list'\nimport { deflate, inflate } from 'pako'\nimport { com, kotlin } from '@sphereon/kmp-cbor'\nimport base64url from 'base64url'\nimport { IRequiredContext, SignedStatusListData } from '../../types'\nimport { DecodedStatusListPayload, resolveIdentifier } from './common'\nimport { BitsPerStatus } from '@sd-jwt/jwt-status-list'\n\nconst cbor = com.sphereon.cbor\nconst kmp = com.sphereon.kmp\nconst decompressRawStatusList = (StatusList as any).decodeStatusList.bind(StatusList)\n\nconst CWT_CLAIMS = {\n SUBJECT: 2,\n ISSUER: 1,\n ISSUED_AT: 6,\n EXPIRATION: 4,\n TIME_TO_LIVE: 65534,\n STATUS_LIST: 65533,\n} as const\n\nexport const createSignedCbor = async (\n context: IRequiredContext,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n): Promise<SignedStatusListData> => {\n const identifier = await resolveIdentifier(context, issuerString, keyRef)\n\n const encodeStatusList = statusList.encodeStatusList()\n const compressedList = deflate(encodeStatusList, { level: 9 })\n const compressedBytes = new Int8Array(compressedList)\n\n const statusListMap = new cbor.CborMap(\n kotlin.collections.KtMutableMap.fromJsMap(\n new Map<com.sphereon.cbor.CborString, com.sphereon.cbor.CborItem<any>>([\n [new cbor.CborString('bits'), new cbor.CborUInt(kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))],\n [new cbor.CborString('lst'), new cbor.CborByteString(compressedBytes)],\n ]),\n ),\n )\n\n const protectedHeader = new cbor.CborMap(\n kotlin.collections.KtMutableMap.fromJsMap(\n new Map([[new cbor.CborUInt(kmp.LongKMP.fromNumber(16)), new cbor.CborString('statuslist+cwt')]]), // \"type\"\n ),\n )\n const protectedHeaderEncoded = cbor.Cbor.encode(protectedHeader)\n const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt)\n const claimsEncoded: Int8Array = cbor.Cbor.encode(claimsMap)\n\n const signedCWT: string = await context.agent.keyManagerSign({\n keyRef: identifier.kmsKeyRef,\n data: base64url.encode(Buffer.from(claimsEncoded)), // TODO test on RN\n encoding: undefined,\n })\n\n const protectedHeaderEncodedInt8 = new Int8Array(protectedHeaderEncoded)\n const claimsEncodedInt8 = new Int8Array(claimsEncoded)\n const signatureBytes = base64url.decode(signedCWT)\n const signatureInt8 = new Int8Array(Buffer.from(signatureBytes))\n\n const cwtArrayElements: Array<com.sphereon.cbor.CborItem<any>> = [\n new cbor.CborByteString(protectedHeaderEncodedInt8),\n new cbor.CborByteString(claimsEncodedInt8),\n new cbor.CborByteString(signatureInt8),\n ]\n const cwtArray = new cbor.CborArray(kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements))\n const cwtEncoded = cbor.Cbor.encode(cwtArray)\n const cwtBuffer = Buffer.from(cwtEncoded)\n return {\n statusListCredential: base64url.encode(cwtBuffer),\n encodedList: base64url.encode(compressedList as Buffer), // JS in @sd-jwt/jwt-status-list drops it in like this, so keep the same method\n }\n}\n\nfunction buildClaimsMap(\n id: string,\n issuerString: string,\n statusListMap: com.sphereon.cbor.CborMap<com.sphereon.cbor.CborString, com.sphereon.cbor.CborItem<any>>,\n expiresAt?: Date,\n) {\n const ttl = 65535 // FIXME figure out what value should be / come from and what the difference is with exp\n const claimsEntries: Array<[com.sphereon.cbor.CborUInt, com.sphereon.cbor.CborItem<any>]> = [\n [new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)), new cbor.CborString(id)], // \"sub\"\n [new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)), new cbor.CborString(issuerString)], // \"iss\"\n [\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1000))), // \"iat\"\n ],\n ]\n\n if (expiresAt) {\n claimsEntries.push([\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1000))), // \"exp\"\n ])\n }\n\n if (ttl) {\n claimsEntries.push([\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(ttl)), // \"time to live\"\n ])\n }\n\n claimsEntries.push([new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)), statusListMap])\n\n const claimsMap = new cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)))\n return claimsMap\n}\n\nconst getCborValueFromMap = <T>(map: Map<com.sphereon.cbor.CborItem<any>, com.sphereon.cbor.CborItem<any>>, key: number): T => {\n const value = getCborOptionalValueFromMap<T>(map, key)\n if (value === undefined) {\n throw new Error(`Required claim ${key} not found`)\n }\n return value\n}\n\nconst getCborOptionalValueFromMap = <T>(\n map: Map<com.sphereon.cbor.CborItem<any>, com.sphereon.cbor.CborItem<any>>,\n key: number,\n): T | undefined | never => {\n const value = map.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)))\n if (!value) {\n return undefined\n }\n return value.value as T\n}\n\nexport const decodeStatusListCWT = (cwt: string): DecodedStatusListPayload => {\n const encodedCbor = base64url.toBuffer(cwt)\n const encodedCborArray = new Int8Array(encodedCbor)\n const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray)\n\n if (!(decodedCbor instanceof com.sphereon.cbor.CborArray)) {\n throw new Error('Invalid CWT format: Expected a CBOR array')\n }\n\n const [, payload] = decodedCbor.value.asJsArrayView()\n if (!(payload instanceof com.sphereon.cbor.CborByteString)) {\n throw new Error('Invalid payload format: Expected a CBOR ByteString')\n }\n\n const claims = com.sphereon.cbor.Cbor.decode(payload.value)\n if (!(claims instanceof com.sphereon.cbor.CborMap)) {\n throw new Error('Invalid claims format: Expected a CBOR map')\n }\n\n const claimsMap = claims.value.asJsMapView()\n\n const statusListMap = claimsMap.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView()\n\n const bits = Number(statusListMap.get(new com.sphereon.cbor.CborString('bits')).value) as BitsPerStatus\n const decoded = new Uint8Array(statusListMap.get(new com.sphereon.cbor.CborString('lst')).value)\n const uint8Array = inflate(decoded)\n const rawStatusList = decompressRawStatusList(uint8Array, bits)\n const statusList = new StatusList(rawStatusList, bits)\n\n return {\n issuer: getCborValueFromMap<string>(claimsMap, CWT_CLAIMS.ISSUER),\n id: getCborValueFromMap<string>(claimsMap, CWT_CLAIMS.SUBJECT),\n statusList,\n iat: Number(getCborValueFromMap<number>(claimsMap, CWT_CLAIMS.ISSUED_AT)),\n exp: getCborOptionalValueFromMap<number>(claimsMap, CWT_CLAIMS.EXPIRATION),\n ttl: getCborOptionalValueFromMap<number>(claimsMap, CWT_CLAIMS.TIME_TO_LIVE),\n }\n}\n","import { IStatusList } from './IStatusList'\nimport { StatusList2021Implementation } from './StatusList2021'\nimport { OAuthStatusListImplementation } from './OAuthStatusList'\nimport { StatusListType } from '@sphereon/ssi-types'\n\nexport class StatusListFactory {\n private static instance: StatusListFactory\n private implementations: Map<StatusListType, IStatusList>\n\n private constructor() {\n this.implementations = new Map()\n this.implementations.set(StatusListType.StatusList2021, new StatusList2021Implementation())\n this.implementations.set(StatusListType.OAuthStatusList, new OAuthStatusListImplementation())\n }\n\n public static getInstance(): StatusListFactory {\n if (!StatusListFactory.instance) {\n StatusListFactory.instance = new StatusListFactory()\n }\n return StatusListFactory.instance\n }\n\n public getByType(type: StatusListType): IStatusList {\n const statusList = this.implementations.get(type)\n if (!statusList) {\n throw new Error(`No implementation found for status list type: ${type}`)\n }\n return statusList\n }\n}\n\nexport function getStatusListImplementation(type: StatusListType): IStatusList {\n return StatusListFactory.getInstance().getByType(type)\n}\n"],"mappings":";;;;AA6BO,IAAKA,cAAAA,yBAAAA,cAAAA;;;;SAAAA;;AAML,IAAKC,aAAAA,yBAAAA,aAAAA;;;SAAAA;;;;AClCZ,SACEC,oBAAAA,mBACAC,kBAAAA,iBAIAC,kBAAAA,uBAEK;AAGP,SAASC,mBAAmB;;;ACZ5B,SACEC,kBAGAC,gBAGAC,sBACK;AACP,SAASC,iBAAiB;AAEnB,SAASC,0BAA0BC,MAAqB;AAC7D,QAAMC,eAAeD,QAAQE,eAAeC;AAC5C,MAAI,CAAC;IAACD,eAAeC;IAAgBD,eAAeE;IAAiBC,SAASJ,YAAAA,GAAe;AAC3F,UAAMK,MAAM,mBAAmBL,YAAAA,yBAAqC;EACtE;AACA,SAAOA;AACT;AANgBF;AAQT,SAASQ,iBAAoBC,MAAcC,OAAQ;AACxD,MAAIA,UAAUC,UAAaD,UAAU,MAAM;AACzC,UAAMH,MAAM,oBAAoBE,IAAAA,QAAY;EAC9C;AACA,SAA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AmBnD;IACnBoD,eAAezE,KAAKyE;IACpBC,YAAY1E,KAAK0E;EACnB,CAAA;AACF;AAnCsBtB;AAqCtB,eAAsBuB,qCACpB3E,MACAgD,SAAiE;AAEjE,QAAM,EAAEV,KAAI,IAAKpC,iBAAiB,QAAQF,IAAAA;AAC1C,QAAM4C,iBAAiBC,4BAA4BP,IAAAA;AACnD,SAAOM,eAAegC,gCAAgC5E,MAAMgD,OAAAA;AAC9D;AAPsB2B;AAStB,eAAsBE,qCACpB7E,MACAgD,SAAiE;AAEjE,QAAM,EAAE8B,QAAQC,IAAIzC,KAAI,IAAKW,kBAAkBjD,IAAAA;AAC/C,QAAMgF,aAAa,MAAMhC,QAAQiC,MAAMC,qBAAqB;IAC1DF,YAAY,OAAOF,WAAW,WAAWA,SAASA,OAAOC;IACzDI,gBAAgB;IAChBC,4BAA4B;EAC9B,CAAA;AACA,QAAMC,cAA2BrF,MAAMqF,eAAe;AACtDC,uBAAqBtB,gBAAeuB,gBAAgBF,WAAAA;AACpD,QAAMG,oBAAuCH;AAE7C,QAAMI,cAAcvF,iBAAiB,eAAeF,KAAKyF,WAAW;AACpE,QAAMC,gBAAgBxF,iBAAiB,iBAAiBF,KAAK0F,aAAa;AAC1E,QAAMrE,aAAa;IACjB,YAAY;MAAC;MAA0C;;IACvD0D;IACAD;;IAEAxC,MAAM;MAAC;MAAwB,GAAGA,IAAAA;;IAClCqD,mBAAmB;MACjBZ;MACAzC;MACAoD;MACAD;IACF;EACF;AAEA,QAAMG,uBAAuB,MAAM5C,QAAQiC,MAAMY,2BAA2B;IAC1ExE;IACAyE,QAAQd,WAAWe;IACnBV,aAAaG;IACbQ,qBAAqB;EACvB,CAAA;AAEA,SAAO9D,kBAAiB+D,8BAA8BL,oBAAAA,EAA8CM;AACtG;AAtCsBrB;","names":["StatusOAuth","Status2021","CredentialMapper","DocumentFormat","StatusListType","checkStatus","CredentialMapper","StatusListType","DocumentFormat","jwtDecode","getAssertedStatusListType","type","assertedType","StatusListType","StatusList2021","OAuthStatusList","includes","Error","getAssertedValue","name","value","undefined","getAssertedValues","args","id","issuer","getAssertedProperty","propertyName","obj","ValidProofTypeMap","Map","assertValidProofType","proofFormat","validProofTypes","get","determineStatusListType","credential","determineProofFormat","payload","jwtDecode","keys","Object","uniform","CredentialMapper","toUniformCredential","find","t","values","some","statusType","replace","detectDocumentType","DocumentFormat","JWT","MSO_MDOC","JSONLD","CredentialMapper","DocumentFormat","StatusListType","StatusList","DEFAULT_LIST_LENGTH","DEFAULT_PROOF_FORMAT","StatusList2021Implementation","createNewStatusList","args","context","length","proofFormat","assertValidProofType","StatusListType","StatusList2021","veramoProofFormat","issuer","id","correlationId","getAssertedValue","list","StatusList","encodedList","encode","statusPurpose","statusListCredential","createVerifiableCredential","statusList2021","indexingDirection","type","statuslistContentType","buildContentType","updateStatusListIndex","credential","uniform","CredentialMapper","toUniformCredential","credentialSubject","origEncodedList","getAssertedProperty","index","statusListIndex","parseInt","statusList","decode","setStatus","value","detectDocumentType","DocumentFormat","JWT","updatedCredential","updateStatusListFromEncodedList","Error","getAssertedValues","newEncodedList","keyRef","checkStatusIndex","status","getStatus","Status2021","Invalid","Valid","toStatusListDetails","statusListPayload","driverType","identifier","agent","identifierManagedGet","vmRelationship","offlineWhenNoDIDRegistered","verifiableCredential","kmsKeyRef","fetchRemoteContexts","toWrappedVerifiableCredential","original","StatusListType","StatusList","JoseSignatureAlgorithm","createHeaderAndPayload","StatusList","base64url","resolveIdentifier","context","issuer","keyRef","agent","identifierManagedGet","identifier","vmRelationship","offlineWhenNoDIDRegistered","kmsKeyRef","ensureManagedIdentifierResult","STATUS_LIST_JWT_TYP","createSignedJwt","context","statusList","issuerString","id","expiresAt","keyRef","identifier","resolveIdentifier","resolution","ensureManagedIdentifierResult","payload","iss","sub","iat","Math","floor","Date","now","exp","getTime","header","alg","getSigningAlgo","key","type","typ","values","createHeaderAndPayload","signedJwt","agent","jwtCreateJwsCompactSignature","issuer","noIssPayloadUpdate","protectedHeader","statusListCredential","jwt","encodedList","status_list","lst","decodeStatusListJWT","payloadBase64","split","JSON","parse","base64url","decode","Error","StatusList","decompressStatusList","bits","ttl","JoseSignatureAlgorithm","EdDSA","ES256K","ES256","RS256","StatusList","deflate","inflate","com","kotlin","base64url","cbor","com","sphereon","kmp","decompressRawStatusList","StatusList","decodeStatusList","bind","CWT_CLAIMS","SUBJECT","ISSUER","ISSUED_AT","EXPIRATION","TIME_TO_LIVE","STATUS_LIST","createSignedCbor","context","statusList","issuerString","id","expiresAt","keyRef","identifier","resolveIdentifier","encodeStatusList","compressedList","deflate","level","compressedBytes","Int8Array","statusListMap","CborMap","kotlin","collections","KtMutableMap","fromJsMap","Map","CborString","CborUInt","LongKMP","fromNumber","getBitsPerStatus","CborByteString","protectedHeader","protectedHeaderEncoded","Cbor","encode","claimsMap","buildClaimsMap","claimsEncoded","signedCWT","agent","keyManagerSign","kmsKeyRef","data","base64url","Buffer","from","encoding","undefined","protectedHeaderEncodedInt8","claimsEncodedInt8","signatureBytes","decode","signatureInt8","cwtArrayElements","cwtArray","CborArray","KtMutableList","fromJsArray","cwtEncoded","cwtBuffer","statusListCredential","encodedList","ttl","claimsEntries","Math","floor","Date","now","push","getTime","getCborValueFromMap","map","key","value","getCborOptionalValueFromMap","Error","get","decodeStatusListCWT","cwt","encodedCbor","toBuffer","encodedCborArray","decodedCbor","payload","asJsArrayView","claims","asJsMapView","bits","Number","decoded","Uint8Array","uint8Array","inflate","rawStatusList","issuer","iat","exp","DEFAULT_BITS_PER_STATUS","DEFAULT_LIST_LENGTH","DEFAULT_PROOF_FORMAT","OAuthStatusListImplementation","createNewStatusList","args","context","oauthStatusList","Error","proofFormat","issuer","id","keyRef","bitsPerStatus","expiresAt","length","issuerString","correlationId","getAssertedValue","statusList","StatusList","Array","fill","encodedList","compressStatusList","statusListCredential","createSignedStatusList","type","StatusListType","OAuthStatusList","statuslistContentType","buildContentType","updateStatusListIndex","value","Promise","reject","determineProofFormat","decoded","decodeStatusListJWT","decodeStatusListCWT","index","statusListIndex","parseInt","setStatus","signedCredential","getBitsPerStatus","updateStatusListFromEncodedList","getAssertedValues","listToUpdate","decompressStatusList","checkStatusIndex","getStatus","toStatusListDetails","statusListPayload","exp","Date","driverType","createSignedJwt","createSignedCbor","StatusListType","StatusListFactory","instance","implementations","Map","set","StatusListType","StatusList2021","StatusList2021Implementation","OAuthStatusList","OAuthStatusListImplementation","getInstance","getByType","type","statusList","get","Error","getStatusListImplementation","fetchStatusListCredential","args","url","getAssertedValue","statusListCredential","response","fetch","ok","Error","status","statusText","responseAsText","text","trim","startsWith","JSON","parse","error","console","message","stringify","statusPluginStatusFunction","credential","didDoc","result","checkStatusForCredential","documentLoader","errorUnknownListType","revoked","verified","vcLibCheckStatusFunction","mandatoryCredentialStatus","verifyStatusListCredential","verifyMatchingIssuers","uniform","CredentialMapper","toUniformCredential","credentialStatus","log","type","checkStatus","simpleCheckStatusFromStatusListUrl","checkStatusIndexFromStatusListCredential","statusListType","determineStatusListType","implementation","getStatusListImplementation","checkStatusIndex","createNewStatusList","context","getAssertedValues","updateStatusIndexFromStatusListCredential","updateStatusListIndex","statusListCredentialToDetails","documentFormat","detectDocumentType","DocumentFormat","JWT","header","split","decodedHeader","Buffer","from","toString","typ","StatusListType","OAuthStatusList","MSO_MDOC","find","t","includes","replace","toStatusListDetails","statusListPayload","correlationId","driverType","updateStatusListIndexFromEncodedList","updateStatusListFromEncodedList","statusList2021ToVerifiableCredential","issuer","id","identifier","agent","identifierManagedGet","vmRelationship","offlineWhenNoDIDRegistered","proofFormat","assertValidProofType","StatusList2021","veramoProofFormat","encodedList","statusPurpose","credentialSubject","verifiableCredential","createVerifiableCredential","keyRef","kmsKeyRef","fetchRemoteContexts","toWrappedVerifiableCredential","original"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/index.ts","../src/functions.ts","../src/utils.ts","../src/impl/StatusList2021.ts","../src/impl/OAuthStatusList.ts","../src/impl/encoding/jwt.ts","../src/impl/encoding/common.ts","../src/impl/encoding/cbor.ts","../src/impl/StatusListFactory.ts"],"sourcesContent":["import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport {\n ICredential,\n ICredentialStatus,\n IIssuer,\n IVerifiableCredential,\n OrPromise,\n ProofFormat,\n StatusListCredential,\n StatusListCredentialIdMode,\n StatusListDriverType,\n StatusListIndexingDirection,\n StatusListType,\n StatusPurpose2021,\n} from '@sphereon/ssi-types'\nimport {\n CredentialPayload,\n IAgentContext,\n ICredentialIssuer,\n ICredentialPlugin,\n ICredentialVerifier,\n IKeyManager,\n IPluginMethodMap,\n} from '@veramo/core'\nimport { DataSource } from 'typeorm'\nimport { BitsPerStatus } from '@sd-jwt/jwt-status-list'\nimport { SdJwtVcPayload } from '@sd-jwt/sd-jwt-vc'\nimport { StatusListOpts } from '@sphereon/oid4vci-common'\n\nexport enum StatusOAuth {\n Valid = 0,\n Invalid = 1,\n Suspended = 2,\n}\n\nexport enum Status2021 {\n Valid = 0,\n Invalid = 1,\n}\n\nexport type StatusList2021Args = {\n indexingDirection: StatusListIndexingDirection\n statusPurpose?: StatusPurpose2021\n // todo: validFrom and validUntil\n}\n\nexport type OAuthStatusListArgs = {\n bitsPerStatus?: BitsPerStatus\n expiresAt?: Date\n}\n\nexport type BaseCreateNewStatusListArgs = {\n type: StatusListType\n id: string\n issuer: string | IIssuer\n correlationId?: string\n length?: number\n proofFormat?: ProofFormat\n keyRef?: string\n statusList2021?: StatusList2021Args\n oauthStatusList?: OAuthStatusListArgs\n driverType?: StatusListDriverType\n}\n\nexport type UpdateStatusList2021Args = {\n statusPurpose: StatusPurpose2021\n}\n\nexport type UpdateOAuthStatusListArgs = {\n bitsPerStatus: BitsPerStatus\n expiresAt?: Date\n}\n\nexport interface UpdateStatusListFromEncodedListArgs {\n type?: StatusListType\n statusListIndex: number | string\n value: boolean\n proofFormat?: ProofFormat\n keyRef?: string\n correlationId?: string\n encodedList: string\n issuer: string | IIssuer\n id: string\n statusList2021?: UpdateStatusList2021Args\n oauthStatusList?: UpdateOAuthStatusListArgs\n}\n\nexport interface UpdateStatusListFromStatusListCredentialArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n keyRef?: string\n statusListIndex: number | string\n value: number | Status2021 | StatusOAuth\n}\n\nexport interface StatusListResult {\n encodedList: string\n statusListCredential: StatusListCredential\n length: number\n type: StatusListType\n proofFormat: ProofFormat\n id: string\n statuslistContentType: string\n issuer: string | IIssuer\n statusList2021?: StatusList2021Details\n oauthStatusList?: OAuthStatusDetails\n\n // These cannot be deduced from the VC, so they are present when callers pass in these values as params\n correlationId?: string\n driverType?: StatusListDriverType\n credentialIdMode?: StatusListCredentialIdMode\n}\n\ninterface StatusList2021Details {\n indexingDirection: StatusListIndexingDirection\n statusPurpose?: StatusPurpose2021\n}\n\ninterface OAuthStatusDetails {\n bitsPerStatus?: BitsPerStatus\n expiresAt?: Date\n}\n\nexport interface StatusList2021EntryCredentialStatus extends ICredentialStatus {\n type: 'StatusList2021Entry'\n statusPurpose: StatusPurpose2021\n statusListIndex: string\n statusListCredential: string\n}\n\nexport interface StatusListOAuthEntryCredentialStatus extends ICredentialStatus {\n type: 'OAuthStatusListEntry'\n bitsPerStatus: number\n statusListIndex: string\n statusListCredential: string\n expiresAt?: Date\n}\n\nexport interface StatusList2021ToVerifiableCredentialArgs {\n issuer: string | IIssuer\n id: string\n type?: StatusListType\n proofFormat?: ProofFormat\n keyRef?: string\n encodedList: string\n statusPurpose: StatusPurpose2021\n}\n\nexport interface CreateStatusListArgs {\n issuer: string | IIssuer\n id: string\n proofFormat?: ProofFormat\n keyRef?: string\n correlationId?: string\n length?: number\n statusList2021?: StatusList2021Args\n oauthStatusList?: OAuthStatusListArgs\n}\n\nexport interface UpdateStatusListIndexArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n statusListIndex: number | string\n value: number | Status2021 | StatusOAuth\n keyRef?: string\n expiresAt?: Date\n}\n\nexport interface CheckStatusIndexArgs {\n statusListCredential: StatusListCredential // | CompactJWT\n statusListIndex: string | number\n}\n\nexport interface ToStatusListDetailsArgs {\n statusListPayload: StatusListCredential\n correlationId?: string\n driverType?: StatusListDriverType\n}\n\n/**\n * The interface definition for a plugin that can add statuslist info to a credential\n *\n * @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}\n *\n * @beta This API is likely to change without a BREAKING CHANGE notice\n */\nexport interface IStatusListPlugin extends IPluginMethodMap {\n /**\n * Create a new status list\n *\n * @param args Status list information like type and size\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n *\n * @returns - The details of the newly created status list\n */\n slCreateStatusList(args: CreateNewStatusListArgs, context: IRequiredContext): Promise<StatusListResult>\n\n /**\n * Ensures status list info like index and list id is added to a credential\n *\n * @param args - Arguments necessary to add the statuslist info.\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n *\n * @returns - a promise that resolves to the credential now with status support\n *\n * @beta This API is likely to change without a BREAKING CHANGE notice\n */\n slAddStatusToCredential(args: IAddStatusToCredentialArgs, context: IRequiredContext): Promise<CredentialWithStatusSupport>\n\n slAddStatusToSdJwtCredential(args: IAddStatusToSdJwtCredentialArgs, context: IRequiredContext): Promise<SdJwtVcPayload>\n\n /**\n * Get the status list using the configured driver for the SL. Normally a correlationId or id should suffice. Optionally accepts a dbName/datasource\n * @param args\n * @param context\n */\n slGetStatusList(args: GetStatusListArgs, context: IRequiredContext): Promise<StatusListResult>\n\n /**\n * Import status lists when noy yet present\n *\n * @param imports Array of status list information like type and size\n * @param context - This reserved param is automatically added and handled by the framework, *do not override*\n */\n slImportStatusLists(imports: Array<CreateNewStatusListArgs>, context: IRequiredContext): Promise<boolean>\n}\n\nexport type CreateNewStatusListFuncArgs = BaseCreateNewStatusListArgs\n\nexport type CreateNewStatusListArgs = BaseCreateNewStatusListArgs & {\n dbName?: string\n dataSource?: OrPromise<DataSource>\n isDefault?: boolean\n}\n\nexport type IAddStatusToCredentialArgs = Omit<IIssueCredentialStatusOpts, 'dataSource'> & {\n credential: CredentialWithStatusSupport\n}\n\nexport type IAddStatusToSdJwtCredentialArgs = Omit<IIssueCredentialStatusOpts, 'dataSource'> & {\n credential: SdJwtVcPayload\n}\n\nexport interface IIssueCredentialStatusOpts {\n dataSource?: DataSource\n statusLists?: Array<StatusListOpts>\n credentialId?: string // An id to use for the credential. Normally should be set as the crdential.id value\n value?: string\n}\n\nexport type GetStatusListArgs = {\n id?: string\n correlationId?: string\n dataSource?: OrPromise<DataSource>\n dbName?: string\n}\n\nexport type CredentialWithStatusSupport = ICredential | CredentialPayload | IVerifiableCredential\n\nexport type SignedStatusListData = {\n statusListCredential: StatusListCredential\n encodedList: string\n}\n\nexport type IRequiredPlugins = ICredentialPlugin & IIdentifierResolution\nexport type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager & ICredentialPlugin>\n","import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport {\n CredentialMapper,\n DocumentFormat,\n ProofFormat,\n StatusListCredential,\n StatusListDriverType,\n StatusListType,\n StatusPurpose2021,\n} from '@sphereon/ssi-types'\nimport { CredentialStatus, DIDDocument, IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core'\n\nimport { checkStatus } from '@sphereon/vc-status-list'\n\n// @ts-ignore\nimport { CredentialJwtOrJSON, StatusMethod } from 'credential-status'\nimport {\n CreateNewStatusListFuncArgs,\n Status2021,\n StatusList2021ToVerifiableCredentialArgs,\n StatusListResult,\n StatusOAuth,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from './types'\nimport { assertValidProofType, determineStatusListType, getAssertedValue, getAssertedValues } from './utils'\nimport { getStatusListImplementation } from './impl/StatusListFactory'\n\nexport async function fetchStatusListCredential(args: { statusListCredential: string }): Promise<StatusListCredential> {\n const url = getAssertedValue('statusListCredential', args.statusListCredential)\n try {\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(`Fetching status list ${url} resulted in an error: ${response.status} : ${response.statusText}`)\n }\n const responseAsText = await response.text()\n if (responseAsText.trim().startsWith('{')) {\n return JSON.parse(responseAsText) as StatusListCredential\n }\n return responseAsText as StatusListCredential\n } catch (error) {\n console.error(`Fetching status list ${url} resulted in an unexpected error: ${error instanceof Error ? error.message : JSON.stringify(error)}`)\n throw error\n }\n}\n\nexport function statusPluginStatusFunction(args: {\n documentLoader: any\n suite: any\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}): StatusMethod {\n return async (credential: CredentialJwtOrJSON, didDoc: DIDDocument): Promise<CredentialStatus> => {\n const result = await checkStatusForCredential({\n ...args,\n documentLoader: args.documentLoader,\n credential: credential as StatusListCredential,\n errorUnknownListType: args.errorUnknownListType,\n })\n\n return {\n revoked: !result.verified || result.error,\n ...(result.error && { error: result.error }),\n }\n }\n}\n\n/**\n * Function that can be used together with @digitalbazar/vc and @digitialcredentials/vc\n * @param args\n */\nexport function vcLibCheckStatusFunction(args: {\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}) {\n const { mandatoryCredentialStatus, verifyStatusListCredential, verifyMatchingIssuers, errorUnknownListType } = args\n return (args: {\n credential: StatusListCredential\n documentLoader: any\n suite: any\n }): Promise<{\n verified: boolean\n error?: any\n }> => {\n return checkStatusForCredential({\n ...args,\n mandatoryCredentialStatus,\n verifyStatusListCredential,\n verifyMatchingIssuers,\n errorUnknownListType,\n })\n }\n}\n\nexport async function checkStatusForCredential(args: {\n credential: StatusListCredential\n documentLoader: any\n suite: any\n mandatoryCredentialStatus?: boolean\n verifyStatusListCredential?: boolean\n verifyMatchingIssuers?: boolean\n errorUnknownListType?: boolean\n}): Promise<{ verified: boolean; error?: any }> {\n const verifyStatusListCredential = args.verifyStatusListCredential ?? true\n const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true\n const uniform = CredentialMapper.toUniformCredential(args.credential)\n if (!('credentialStatus' in uniform) || !uniform.credentialStatus) {\n if (args.mandatoryCredentialStatus) {\n const error = 'No credential status object found in the Verifiable Credential and it is mandatory'\n console.log(error)\n return { verified: false, error }\n }\n return { verified: true }\n }\n if ('credentialStatus' in uniform && uniform.credentialStatus) {\n if (uniform.credentialStatus.type === 'StatusList2021Entry') {\n return checkStatus({ ...args, verifyStatusListCredential, verifyMatchingIssuers })\n } else if (args?.errorUnknownListType) {\n const error = `Credential status type ${uniform.credentialStatus.type} is not supported, and check status has been configured to not allow for that`\n console.log(error)\n return { verified: false, error }\n } else {\n console.log(`Skipped verification of status type ${uniform.credentialStatus.type} as we do not support it (yet)`)\n }\n }\n return { verified: true }\n}\n\nexport async function simpleCheckStatusFromStatusListUrl(args: {\n statusListCredential: string\n statusPurpose?: StatusPurpose2021\n type?: StatusListType | 'StatusList2021Entry'\n id?: string\n statusListIndex: string\n}): Promise<number | Status2021 | StatusOAuth> {\n return checkStatusIndexFromStatusListCredential({\n ...args,\n statusListCredential: await fetchStatusListCredential(args),\n })\n}\n\nexport async function checkStatusIndexFromStatusListCredential(args: {\n statusListCredential: StatusListCredential\n statusPurpose?: StatusPurpose2021\n type?: StatusListType | 'StatusList2021Entry'\n id?: string\n statusListIndex: string | number\n}): Promise<number | Status2021 | StatusOAuth> {\n const statusListType: StatusListType = determineStatusListType(args.statusListCredential)\n const implementation = getStatusListImplementation(statusListType)\n return implementation.checkStatusIndex(args)\n}\n\nexport async function createNewStatusList(\n args: CreateNewStatusListFuncArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const { type } = getAssertedValues(args)\n const implementation = getStatusListImplementation(type)\n return implementation.createNewStatusList(args, context)\n}\n\nexport async function updateStatusIndexFromStatusListCredential(\n args: UpdateStatusListIndexArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const credential = getAssertedValue('statusListCredential', args.statusListCredential)\n const statusListType: StatusListType = determineStatusListType(credential)\n const implementation = getStatusListImplementation(statusListType)\n return implementation.updateStatusListIndex(args, context)\n}\n\n// Keeping helper function for backward compatibility\nexport async function statusListCredentialToDetails(args: {\n statusListCredential: StatusListCredential\n correlationId?: string\n driverType?: StatusListDriverType\n}): Promise<StatusListResult> {\n const credential = getAssertedValue('statusListCredential', args.statusListCredential)\n\n let statusListType: StatusListType | undefined\n const documentFormat = CredentialMapper.detectDocumentType(credential)\n if (documentFormat === DocumentFormat.JWT) {\n const [header] = credential.split('.')\n const decodedHeader = JSON.parse(Buffer.from(header, 'base64').toString())\n\n if (decodedHeader.typ === 'statuslist+jwt') {\n statusListType = StatusListType.OAuthStatusList\n }\n } else if (documentFormat === DocumentFormat.MSO_MDOC) {\n statusListType = StatusListType.OAuthStatusList\n // TODO check CBOR content?\n }\n if (!statusListType) {\n const uniform = CredentialMapper.toUniformCredential(credential)\n const type = uniform.type.find((t) => t.includes('StatusList2021') || t.includes('OAuth2StatusList'))\n if (!type) {\n throw new Error('Invalid status list credential type')\n }\n statusListType = type.replace('Credential', '') as StatusListType\n }\n\n const implementation = getStatusListImplementation(statusListType)\n return await implementation.toStatusListDetails({\n statusListPayload: credential,\n correlationId: args.correlationId,\n driverType: args.driverType,\n })\n}\n\nexport async function updateStatusListIndexFromEncodedList(\n args: UpdateStatusListFromEncodedListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListResult> {\n const { type } = getAssertedValue('type', args)\n const implementation = getStatusListImplementation(type!)\n return implementation.updateStatusListFromEncodedList(args, context)\n}\n\nexport async function statusList2021ToVerifiableCredential(\n args: StatusList2021ToVerifiableCredentialArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n): Promise<StatusListCredential> {\n const { issuer, id, type } = getAssertedValues(args)\n const identifier = await context.agent.identifierManagedGet({\n identifier: typeof issuer === 'string' ? issuer : issuer.id,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true, // FIXME Fix identifier resolution for EBSI\n })\n const proofFormat: ProofFormat = args?.proofFormat ?? 'lds'\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const encodedList = getAssertedValue('encodedList', args.encodedList)\n const statusPurpose = getAssertedValue('statusPurpose', args.statusPurpose)\n const credential = {\n '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],\n id,\n issuer,\n // issuanceDate: \"2021-03-10T04:24:12.164Z\",\n type: ['VerifiableCredential', `${type}Credential`],\n credentialSubject: {\n id,\n type,\n statusPurpose,\n encodedList,\n },\n }\n // TODO copy statuslist schema to local and disable fetching remote contexts\n const verifiableCredential = await context.agent.createVerifiableCredential({\n credential,\n keyRef: identifier.kmsKeyRef,\n proofFormat: veramoProofFormat,\n fetchRemoteContexts: true,\n })\n\n return CredentialMapper.toWrappedVerifiableCredential(verifiableCredential as StatusListCredential).original as StatusListCredential\n}\n","import {\n CredentialMapper,\n IIssuer,\n ProofFormat,\n StatusListType,\n StatusListType as StatusListTypeW3C,\n StatusListCredential,\n DocumentFormat,\n} from '@sphereon/ssi-types'\nimport { jwtDecode } from 'jwt-decode'\n\nexport function getAssertedStatusListType(type?: StatusListType) {\n const assertedType = type ?? StatusListType.StatusList2021\n if (![StatusListType.StatusList2021, StatusListType.OAuthStatusList].includes(assertedType)) {\n throw Error(`StatusList type ${assertedType} is not supported (yet)`)\n }\n return assertedType\n}\n\nexport function getAssertedValue<T>(name: string, value: T): NonNullable<T> {\n if (value === undefined || value === null) {\n throw Error(`Missing required ${name} value`)\n }\n return value\n}\n\nexport function getAssertedValues(args: { issuer: string | IIssuer; id: string; type?: StatusListTypeW3C | StatusListType }) {\n const type = getAssertedStatusListType(args?.type)\n const id = getAssertedValue('id', args.id)\n const issuer = getAssertedValue('issuer', args.issuer)\n return { id, issuer, type }\n}\n\nexport function getAssertedProperty<T extends object>(propertyName: string, obj: T): NonNullable<any> {\n if (!(propertyName in obj)) {\n throw Error(`The input object does not contain required property: ${propertyName}`)\n }\n return getAssertedValue(propertyName, (obj as any)[propertyName])\n}\n\nconst ValidProofTypeMap = new Map<StatusListType, ProofFormat[]>([\n [StatusListType.StatusList2021, ['jwt', 'lds', 'EthereumEip712Signature2021']],\n [StatusListType.OAuthStatusList, ['jwt', 'cbor']],\n])\n\nexport function assertValidProofType(type: StatusListType, proofFormat: ProofFormat) {\n const validProofTypes = ValidProofTypeMap.get(type)\n if (!validProofTypes?.includes(proofFormat)) {\n throw Error(`Invalid proof format '${proofFormat}' for status list type ${type}`)\n }\n}\n\nexport function determineStatusListType(credential: StatusListCredential): StatusListType {\n const proofFormat = determineProofFormat(credential)\n switch (proofFormat) {\n case 'jwt':\n const payload: StatusListCredential = jwtDecode(credential as string)\n const keys = Object.keys(payload)\n if (keys.includes('status_list')) {\n return StatusListType.OAuthStatusList\n } else if (keys.includes('vc')) {\n return StatusListType.StatusList2021\n }\n break\n case 'lds':\n const uniform = CredentialMapper.toUniformCredential(credential)\n const type = uniform.type.find((t) => {\n return Object.values(StatusListType).some((statusType) => t.includes(statusType))\n })\n if (!type) {\n throw new Error('Invalid status list credential type')\n }\n return type.replace('Credential', '') as StatusListType\n\n case 'cbor':\n return StatusListType.OAuthStatusList\n }\n\n throw new Error('Cannot determine status list type from credential payload')\n}\n\nexport function determineProofFormat(credential: StatusListCredential): ProofFormat {\n const type: DocumentFormat = CredentialMapper.detectDocumentType(credential)\n switch (type) {\n case DocumentFormat.JWT:\n return 'jwt'\n case DocumentFormat.MSO_MDOC:\n // Not really mdoc, just assume Cbor for now, I'd need to decode at least the header to what type of Cbor we have\n return 'cbor'\n case DocumentFormat.JSONLD:\n return 'lds'\n default:\n throw Error('Cannot determine credential payload type')\n }\n}\n","import { IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core'\nimport { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport { CredentialMapper, DocumentFormat, IIssuer, ProofFormat, StatusListCredential, StatusListType } from '@sphereon/ssi-types'\n\nimport { StatusList } from '@sphereon/vc-status-list'\nimport { IStatusList } from './IStatusList'\nimport {\n CheckStatusIndexArgs,\n CreateStatusListArgs,\n Status2021,\n StatusListResult,\n ToStatusListDetailsArgs,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from '../types'\nimport { assertValidProofType, getAssertedProperty, getAssertedValue, getAssertedValues } from '../utils'\n\nexport const DEFAULT_LIST_LENGTH = 250000\nexport const DEFAULT_PROOF_FORMAT = 'lds' as VeramoProofFormat\n\nexport class StatusList2021Implementation implements IStatusList {\n async createNewStatusList(\n args: CreateStatusListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n const length = args?.length ?? DEFAULT_LIST_LENGTH\n const proofFormat: ProofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const { issuer, id } = args\n const correlationId = getAssertedValue('correlationId', args.correlationId)\n\n const list = new StatusList({ length })\n const encodedList = await list.encode()\n const statusPurpose = 'revocation'\n\n const statusListCredential = await this.createVerifiableCredential(\n {\n ...args,\n encodedList,\n proofFormat: veramoProofFormat,\n },\n context,\n )\n\n return {\n encodedList,\n statusListCredential: statusListCredential,\n statusList2021: {\n statusPurpose,\n indexingDirection: 'rightToLeft',\n },\n length,\n type: StatusListType.StatusList2021,\n proofFormat,\n id,\n correlationId,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListIndex(\n args: UpdateStatusListIndexArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n const credential = args.statusListCredential\n const uniform = CredentialMapper.toUniformCredential(credential)\n const { issuer, credentialSubject } = uniform\n const id = getAssertedValue('id', uniform.id)\n const origEncodedList = getAssertedProperty('encodedList', credentialSubject)\n\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n const statusList = await StatusList.decode({ encodedList: origEncodedList })\n statusList.setStatus(index, args.value != 0)\n const encodedList = await statusList.encode()\n\n const proofFormat = CredentialMapper.detectDocumentType(credential) === DocumentFormat.JWT ? 'jwt' : 'lds'\n const updatedCredential = await this.createVerifiableCredential(\n {\n ...args,\n id,\n issuer,\n encodedList,\n proofFormat: proofFormat,\n },\n context,\n )\n\n return {\n statusListCredential: updatedCredential,\n encodedList,\n statusList2021: {\n ...('statusPurpose' in credentialSubject ? { statusPurpose: credentialSubject.statusPurpose } : {}),\n indexingDirection: 'rightToLeft',\n },\n length: statusList.length - 1,\n type: StatusListType.StatusList2021,\n proofFormat: proofFormat,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListFromEncodedList(\n args: UpdateStatusListFromEncodedListArgs,\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListResult> {\n if (!args.statusList2021) {\n throw new Error('statusList2021 options required for type StatusList2021')\n }\n const proofFormat: ProofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n assertValidProofType(StatusListType.StatusList2021, proofFormat)\n const veramoProofFormat: VeramoProofFormat = proofFormat as VeramoProofFormat\n\n const { issuer, id } = getAssertedValues(args)\n const statusList = await StatusList.decode({ encodedList: args.encodedList })\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n statusList.setStatus(index, args.value)\n\n const newEncodedList = await statusList.encode()\n const credential = await this.createVerifiableCredential(\n {\n id,\n issuer,\n encodedList: newEncodedList,\n proofFormat: veramoProofFormat,\n keyRef: args.keyRef,\n },\n context,\n )\n\n return {\n type: StatusListType.StatusList2021,\n statusListCredential: credential,\n encodedList: newEncodedList,\n statusList2021: {\n statusPurpose: args.statusList2021.statusPurpose,\n indexingDirection: 'rightToLeft',\n },\n length: statusList.length,\n proofFormat: args.proofFormat ?? 'lds',\n id: id,\n issuer: issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | Status2021> {\n const uniform = CredentialMapper.toUniformCredential(args.statusListCredential)\n const { credentialSubject } = uniform\n const encodedList = getAssertedProperty('encodedList', credentialSubject)\n\n const statusList = await StatusList.decode({ encodedList })\n const status = statusList.getStatus(typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex))\n return status ? Status2021.Invalid : Status2021.Valid\n }\n\n async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {\n const { statusListPayload } = args\n const uniform = CredentialMapper.toUniformCredential(statusListPayload)\n const { issuer, credentialSubject } = uniform\n const id = getAssertedValue('id', uniform.id)\n const encodedList = getAssertedProperty('encodedList', credentialSubject)\n const proofFormat: ProofFormat = CredentialMapper.detectDocumentType(statusListPayload) === DocumentFormat.JWT ? 'jwt' : 'lds'\n\n const statusPurpose = getAssertedProperty('statusPurpose', credentialSubject)\n const list = await StatusList.decode({ encodedList })\n\n return {\n id,\n encodedList,\n issuer,\n type: StatusListType.StatusList2021,\n proofFormat,\n length: list.length,\n statusListCredential: statusListPayload,\n statuslistContentType: this.buildContentType(proofFormat),\n statusList2021: {\n indexingDirection: 'rightToLeft',\n statusPurpose,\n },\n ...(args.correlationId && { correlationId: args.correlationId }),\n ...(args.driverType && { driverType: args.driverType }),\n }\n }\n\n private async createVerifiableCredential(\n args: {\n id: string\n issuer: string | IIssuer\n encodedList: string\n proofFormat: VeramoProofFormat\n keyRef?: string\n },\n context: IAgentContext<ICredentialPlugin & IIdentifierResolution>,\n ): Promise<StatusListCredential> {\n const identifier = await context.agent.identifierManagedGet({\n identifier: typeof args.issuer === 'string' ? args.issuer : args.issuer.id,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true,\n })\n\n const credential = {\n '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],\n id: args.id,\n issuer: args.issuer,\n type: ['VerifiableCredential', 'StatusList2021Credential'],\n credentialSubject: {\n id: args.id,\n type: 'StatusList2021',\n statusPurpose: 'revocation',\n encodedList: args.encodedList,\n },\n }\n\n const verifiableCredential = await context.agent.createVerifiableCredential({\n credential,\n keyRef: args.keyRef ?? identifier.kmsKeyRef,\n proofFormat: args.proofFormat,\n fetchRemoteContexts: true,\n })\n\n return CredentialMapper.toWrappedVerifiableCredential(verifiableCredential as StatusListCredential).original as StatusListCredential\n }\n\n private buildContentType(proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor' | undefined) {\n switch (proofFormat) {\n case 'jwt':\n return `application/statuslist+jwt`\n case 'cbor':\n return `application/statuslist+cwt`\n case 'lds':\n return 'application/statuslist+ld+json'\n default:\n throw Error(`Unsupported content type '${proofFormat}' for status lists`)\n }\n }\n}\n","import { IAgentContext, ICredentialPlugin, IKeyManager } from '@veramo/core'\nimport { CompactJWT, CWT, ProofFormat, StatusListType } from '@sphereon/ssi-types'\nimport {\n CheckStatusIndexArgs,\n CreateStatusListArgs,\n SignedStatusListData,\n StatusListResult,\n StatusOAuth,\n ToStatusListDetailsArgs,\n UpdateStatusListFromEncodedListArgs,\n UpdateStatusListIndexArgs,\n} from '../types'\nimport { determineProofFormat, getAssertedValue, getAssertedValues } from '../utils'\nimport { IStatusList } from './IStatusList'\nimport { StatusList } from '@sd-jwt/jwt-status-list'\nimport { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'\nimport { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'\nimport { createSignedJwt, decodeStatusListJWT } from './encoding/jwt'\nimport { createSignedCbor, decodeStatusListCWT } from './encoding/cbor'\n\ntype IRequiredContext = IAgentContext<ICredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>\n\nexport const DEFAULT_BITS_PER_STATUS = 1 // 1 bit is sufficient for 0x00 - \"VALID\" 0x01 - \"INVALID\" saving space in the process\nexport const DEFAULT_LIST_LENGTH = 250000\nexport const DEFAULT_PROOF_FORMAT = 'jwt' as ProofFormat\n\nexport class OAuthStatusListImplementation implements IStatusList {\n async createNewStatusList(args: CreateStatusListArgs, context: IRequiredContext): Promise<StatusListResult> {\n if (!args.oauthStatusList) {\n throw new Error('OAuthStatusList options are required for type OAuthStatusList')\n }\n\n const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT\n const { issuer, id, oauthStatusList, keyRef } = args\n const { bitsPerStatus, expiresAt } = oauthStatusList\n const length = args.length ?? DEFAULT_LIST_LENGTH\n const issuerString = typeof issuer === 'string' ? issuer : issuer.id\n const correlationId = getAssertedValue('correlationId', args.correlationId)\n\n const statusList = new StatusList(new Array(length).fill(0), bitsPerStatus ?? DEFAULT_BITS_PER_STATUS)\n const encodedList = statusList.compressStatusList()\n const { statusListCredential } = await this.createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef)\n\n return {\n encodedList,\n statusListCredential,\n oauthStatusList: { bitsPerStatus },\n length,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n id,\n correlationId,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n async updateStatusListIndex(args: UpdateStatusListIndexArgs, context: IRequiredContext): Promise<StatusListResult> {\n const { statusListCredential, value, expiresAt, keyRef } = args\n if (typeof statusListCredential !== 'string') {\n return Promise.reject('statusListCredential in neither JWT nor CWT')\n }\n\n const proofFormat = determineProofFormat(statusListCredential)\n const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential)\n const { statusList, issuer, id } = decoded\n\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n if (index < 0 || index >= statusList.statusList.length) {\n throw new Error('Status list index out of bounds')\n }\n\n statusList.setStatus(index, value)\n const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(\n proofFormat,\n context,\n statusList,\n issuer,\n id,\n expiresAt,\n keyRef,\n )\n\n return {\n statusListCredential: signedCredential,\n encodedList,\n oauthStatusList: {\n bitsPerStatus: statusList.getBitsPerStatus(),\n },\n length: statusList.statusList.length,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n // FIXME: This still assumes only two values (boolean), whilst this list supports 8 bits max\n async updateStatusListFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IRequiredContext): Promise<StatusListResult> {\n if (!args.oauthStatusList) {\n throw new Error('OAuthStatusList options are required for type OAuthStatusList')\n }\n const { proofFormat, oauthStatusList, keyRef } = args\n const { bitsPerStatus, expiresAt } = oauthStatusList\n\n const { issuer, id } = getAssertedValues(args)\n const issuerString = typeof issuer === 'string' ? issuer : issuer.id\n\n const listToUpdate = StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS)\n const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex)\n // FIXME: See above.\n listToUpdate.setStatus(index, args.value ? 1 : 0)\n\n const { statusListCredential, encodedList } = await this.createSignedStatusList(\n proofFormat ?? DEFAULT_PROOF_FORMAT,\n context,\n listToUpdate,\n issuerString,\n id,\n expiresAt,\n keyRef,\n )\n\n return {\n encodedList,\n statusListCredential,\n oauthStatusList: {\n bitsPerStatus,\n expiresAt,\n },\n length: listToUpdate.statusList.length,\n type: StatusListType.OAuthStatusList,\n proofFormat: proofFormat ?? DEFAULT_PROOF_FORMAT,\n id,\n issuer,\n statuslistContentType: this.buildContentType(proofFormat),\n }\n }\n\n private buildContentType(proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor' | undefined) {\n return `application/statuslist+${proofFormat === 'cbor' ? 'cwt' : 'jwt'}`\n }\n\n async checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | StatusOAuth> {\n const { statusListCredential, statusListIndex } = args\n if (typeof statusListCredential !== 'string') {\n return Promise.reject('statusListCredential in neither JWT nor CWT')\n }\n\n const proofFormat = determineProofFormat(statusListCredential)\n const { statusList } = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential)\n\n const index = typeof statusListIndex === 'number' ? statusListIndex : parseInt(statusListIndex)\n if (index < 0 || index >= statusList.statusList.length) {\n throw new Error('Status list index out of bounds')\n }\n\n return statusList.getStatus(index)\n }\n\n async toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult> {\n const { statusListPayload } = args as { statusListPayload: CompactJWT | CWT }\n const proofFormat = determineProofFormat(statusListPayload)\n const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload)\n const { statusList, issuer, id, exp } = decoded\n\n return {\n id,\n encodedList: statusList.compressStatusList(),\n issuer,\n type: StatusListType.OAuthStatusList,\n proofFormat,\n length: statusList.statusList.length,\n statusListCredential: statusListPayload,\n statuslistContentType: this.buildContentType(proofFormat),\n oauthStatusList: {\n bitsPerStatus: statusList.getBitsPerStatus(),\n ...(exp && { expiresAt: new Date(exp * 1000) }),\n },\n ...(args.correlationId && { correlationId: args.correlationId }),\n ...(args.driverType && { driverType: args.driverType }),\n }\n }\n\n private async createSignedStatusList(\n proofFormat: 'jwt' | 'lds' | 'EthereumEip712Signature2021' | 'cbor',\n context: IAgentContext<ICredentialPlugin & IJwtService & IIdentifierResolution & IKeyManager>,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n ): Promise<SignedStatusListData> {\n switch (proofFormat) {\n case 'jwt': {\n return await createSignedJwt(context, statusList, issuerString, id, expiresAt, keyRef)\n }\n case 'cbor': {\n return await createSignedCbor(context, statusList, issuerString, id, expiresAt, keyRef)\n }\n default:\n throw new Error(`Invalid proof format '${proofFormat}' for OAuthStatusList`)\n }\n }\n}\n","import { CompactJWT, JoseSignatureAlgorithm } from '@sphereon/ssi-types'\nimport { createHeaderAndPayload, StatusList, StatusListJWTHeaderParameters, StatusListJWTPayload } from '@sd-jwt/jwt-status-list'\nimport base64url from 'base64url'\nimport { JWTPayload } from 'did-jwt'\nimport { IRequiredContext, SignedStatusListData } from '../../types'\nimport { DecodedStatusListPayload, resolveIdentifier } from './common'\nimport { TKeyType } from '@veramo/core'\nimport { ensureManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution'\n\nconst STATUS_LIST_JWT_TYP = 'statuslist+jwt'\n\nexport const createSignedJwt = async (\n context: IRequiredContext,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n): Promise<SignedStatusListData> => {\n const identifier = await resolveIdentifier(context, issuerString, keyRef)\n const resolution = await ensureManagedIdentifierResult(identifier, context)\n\n const payload: JWTPayload = {\n iss: issuerString,\n sub: id,\n iat: Math.floor(Date.now() / 1000),\n ...(expiresAt && { exp: Math.floor(expiresAt.getTime() / 1000) }),\n }\n\n const header: StatusListJWTHeaderParameters = {\n alg: getSigningAlgo(resolution.key.type),\n typ: STATUS_LIST_JWT_TYP,\n }\n const values = createHeaderAndPayload(statusList, payload, header)\n const signedJwt = await context.agent.jwtCreateJwsCompactSignature({\n issuer: { ...identifier, noIssPayloadUpdate: false },\n protectedHeader: values.header,\n payload: values.payload,\n })\n\n return {\n statusListCredential: signedJwt.jwt,\n encodedList: (values.payload as StatusListJWTPayload).status_list.lst,\n }\n}\n\nexport const decodeStatusListJWT = (jwt: CompactJWT): DecodedStatusListPayload => {\n const [, payloadBase64] = jwt.split('.')\n const payload = JSON.parse(base64url.decode(payloadBase64))\n\n if (!payload.iss || !payload.sub || !payload.status_list) {\n throw new Error('Missing required fields in JWT payload')\n }\n\n const statusList = StatusList.decompressStatusList(payload.status_list.lst, payload.status_list.bits)\n\n return {\n issuer: payload.iss,\n id: payload.sub,\n statusList,\n exp: payload.exp,\n ttl: payload.ttl,\n iat: payload.iat,\n }\n}\n\nexport const getSigningAlgo = (type: TKeyType): JoseSignatureAlgorithm => {\n switch (type) {\n case 'Ed25519':\n return JoseSignatureAlgorithm.EdDSA\n case 'Secp256k1':\n return JoseSignatureAlgorithm.ES256K\n case 'Secp256r1':\n return JoseSignatureAlgorithm.ES256\n case 'RSA':\n return JoseSignatureAlgorithm.RS256\n default:\n throw Error('Key type not yet supported')\n }\n}\n","import { IRequiredContext } from '../../types'\nimport { StatusList } from '@sd-jwt/jwt-status-list'\n\nexport interface DecodedStatusListPayload {\n issuer: string\n id: string\n statusList: StatusList\n exp?: number\n ttl?: number\n iat: number\n}\n\nexport const resolveIdentifier = async (context: IRequiredContext, issuer: string, keyRef?: string) => {\n return await context.agent.identifierManagedGet({\n identifier: issuer,\n vmRelationship: 'assertionMethod',\n offlineWhenNoDIDRegistered: true,\n ...(keyRef && { kmsKeyRef: keyRef }), // TODO the getDid resolver should look at this ASAP\n })\n}\n","import { StatusList } from '@sd-jwt/jwt-status-list'\nimport { deflate, inflate } from 'pako'\nimport * as cborpkg from '@sphereon/kmp-cbor'\nimport base64url from 'base64url'\nimport { IRequiredContext, SignedStatusListData } from '../../types'\nimport { DecodedStatusListPayload, resolveIdentifier } from './common'\nimport { BitsPerStatus } from '@sd-jwt/jwt-status-list'\n\nconst cbor = cborpkg.com.sphereon.cbor\nconst kmp = cborpkg.com.sphereon.kmp\nconst kotlin = cborpkg.kotlin\nconst decompressRawStatusList = (StatusList as any).decodeStatusList.bind(StatusList)\n\nconst CWT_CLAIMS = {\n SUBJECT: 2,\n ISSUER: 1,\n ISSUED_AT: 6,\n EXPIRATION: 4,\n TIME_TO_LIVE: 65534,\n STATUS_LIST: 65533,\n} as const\n\nexport const createSignedCbor = async (\n context: IRequiredContext,\n statusList: StatusList,\n issuerString: string,\n id: string,\n expiresAt?: Date,\n keyRef?: string,\n): Promise<SignedStatusListData> => {\n const identifier = await resolveIdentifier(context, issuerString, keyRef)\n\n const encodeStatusList = statusList.encodeStatusList()\n const compressedList = deflate(encodeStatusList, { level: 9 })\n const compressedBytes = new Int8Array(compressedList)\n\n const statusListMap = new cbor.CborMap(\n kotlin.collections.KtMutableMap.fromJsMap(\n new Map<cborpkg.com.sphereon.cbor.CborString, cborpkg.com.sphereon.cbor.CborItem<any>>([\n [new cbor.CborString('bits'), new cbor.CborUInt(kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))],\n [new cbor.CborString('lst'), new cbor.CborByteString(compressedBytes)],\n ]),\n ),\n )\n\n const protectedHeader = new cbor.CborMap(\n kotlin.collections.KtMutableMap.fromJsMap(\n new Map([[new cbor.CborUInt(kmp.LongKMP.fromNumber(16)), new cbor.CborString('statuslist+cwt')]]), // \"type\"\n ),\n )\n const protectedHeaderEncoded = cbor.Cbor.encode(protectedHeader)\n const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt)\n const claimsEncoded: Int8Array = cbor.Cbor.encode(claimsMap)\n\n const signedCWT: string = await context.agent.keyManagerSign({\n keyRef: identifier.kmsKeyRef,\n data: base64url.encode(Buffer.from(claimsEncoded)), // TODO test on RN\n encoding: undefined,\n })\n\n const protectedHeaderEncodedInt8 = new Int8Array(protectedHeaderEncoded)\n const claimsEncodedInt8 = new Int8Array(claimsEncoded)\n const signatureBytes = base64url.decode(signedCWT)\n const signatureInt8 = new Int8Array(Buffer.from(signatureBytes))\n\n const cwtArrayElements: Array<cborpkg.com.sphereon.cbor.CborItem<any>> = [\n new cbor.CborByteString(protectedHeaderEncodedInt8),\n new cbor.CborByteString(claimsEncodedInt8),\n new cbor.CborByteString(signatureInt8),\n ]\n const cwtArray = new cbor.CborArray(kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements))\n const cwtEncoded = cbor.Cbor.encode(cwtArray)\n const cwtBuffer = Buffer.from(cwtEncoded)\n return {\n statusListCredential: base64url.encode(cwtBuffer),\n encodedList: base64url.encode(compressedList as Buffer), // JS in @sd-jwt/jwt-status-list drops it in like this, so keep the same method\n }\n}\n\nfunction buildClaimsMap(\n id: string,\n issuerString: string,\n statusListMap: cborpkg.com.sphereon.cbor.CborMap<cborpkg.com.sphereon.cbor.CborString, cborpkg.com.sphereon.cbor.CborItem<any>>,\n expiresAt?: Date,\n) {\n const ttl = 65535 // FIXME figure out what value should be / come from and what the difference is with exp\n const claimsEntries: Array<[cborpkg.com.sphereon.cbor.CborUInt, cborpkg.com.sphereon.cbor.CborItem<any>]> = [\n [new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)), new cbor.CborString(id)], // \"sub\"\n [new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)), new cbor.CborString(issuerString)], // \"iss\"\n [\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1000))), // \"iat\"\n ],\n ]\n\n if (expiresAt) {\n claimsEntries.push([\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1000))), // \"exp\"\n ])\n }\n\n if (ttl) {\n claimsEntries.push([\n new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),\n new cbor.CborUInt(kmp.LongKMP.fromNumber(ttl)), // \"time to live\"\n ])\n }\n\n claimsEntries.push([new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)), statusListMap])\n\n const claimsMap = new cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)))\n return claimsMap\n}\n\nconst getCborValueFromMap = <T>(map: Map<cborpkg.com.sphereon.cbor.CborItem<any>, cborpkg.com.sphereon.cbor.CborItem<any>>, key: number): T => {\n const value = getCborOptionalValueFromMap<T>(map, key)\n if (value === undefined) {\n throw new Error(`Required claim ${key} not found`)\n }\n return value\n}\n\nconst getCborOptionalValueFromMap = <T>(\n map: Map<cborpkg.com.sphereon.cbor.CborItem<any>, cborpkg.com.sphereon.cbor.CborItem<any>>,\n key: number,\n): T | undefined | never => {\n const value = map.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)))\n if (!value) {\n return undefined\n }\n return value.value as T\n}\n\nexport const decodeStatusListCWT = (cwt: string): DecodedStatusListPayload => {\n const encodedCbor = base64url.toBuffer(cwt)\n const encodedCborArray = new Int8Array(encodedCbor)\n const decodedCbor = cborpkg.com.sphereon.cbor.Cbor.decode(encodedCborArray)\n\n if (!(decodedCbor instanceof cborpkg.com.sphereon.cbor.CborArray)) {\n throw new Error('Invalid CWT format: Expected a CBOR array')\n }\n\n const [, payload] = decodedCbor.value.asJsArrayView()\n if (!(payload instanceof cborpkg.com.sphereon.cbor.CborByteString)) {\n throw new Error('Invalid payload format: Expected a CBOR ByteString')\n }\n\n const claims = cborpkg.com.sphereon.cbor.Cbor.decode(payload.value)\n if (!(claims instanceof cborpkg.com.sphereon.cbor.CborMap)) {\n throw new Error('Invalid claims format: Expected a CBOR map')\n }\n\n const claimsMap = claims.value.asJsMapView()\n\n const statusListMap = claimsMap.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView()\n\n const bits = Number(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString('bits')).value) as BitsPerStatus\n const decoded = new Uint8Array(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString('lst')).value)\n const uint8Array = inflate(decoded)\n const rawStatusList = decompressRawStatusList(uint8Array, bits)\n const statusList = new StatusList(rawStatusList, bits)\n\n return {\n issuer: getCborValueFromMap<string>(claimsMap, CWT_CLAIMS.ISSUER),\n id: getCborValueFromMap<string>(claimsMap, CWT_CLAIMS.SUBJECT),\n statusList,\n iat: Number(getCborValueFromMap<number>(claimsMap, CWT_CLAIMS.ISSUED_AT)),\n exp: getCborOptionalValueFromMap<number>(claimsMap, CWT_CLAIMS.EXPIRATION),\n ttl: getCborOptionalValueFromMap<number>(claimsMap, CWT_CLAIMS.TIME_TO_LIVE),\n }\n}\n","import { IStatusList } from './IStatusList'\nimport { StatusList2021Implementation } from './StatusList2021'\nimport { OAuthStatusListImplementation } from './OAuthStatusList'\nimport { StatusListType } from '@sphereon/ssi-types'\n\nexport class StatusListFactory {\n private static instance: StatusListFactory\n private implementations: Map<StatusListType, IStatusList>\n\n private constructor() {\n this.implementations = new Map()\n this.implementations.set(StatusListType.StatusList2021, new StatusList2021Implementation())\n this.implementations.set(StatusListType.OAuthStatusList, new OAuthStatusListImplementation())\n }\n\n public static getInstance(): StatusListFactory {\n if (!StatusListFactory.instance) {\n StatusListFactory.instance = new StatusListFactory()\n }\n return StatusListFactory.instance\n }\n\n public getByType(type: StatusListType): IStatusList {\n const statusList = this.implementations.get(type)\n if (!statusList) {\n throw new Error(`No implementation found for status list type: ${type}`)\n }\n return statusList\n }\n}\n\nexport function getStatusListImplementation(type: StatusListType): IStatusList {\n return StatusListFactory.getInstance().getByType(type)\n}\n"],"mappings":";;;;AA6BO,IAAKA,cAAAA,yBAAAA,cAAAA;;;;SAAAA;;AAML,IAAKC,aAAAA,yBAAAA,aAAAA;;;SAAAA;;;;AClCZ,SACEC,oBAAAA,mBACAC,kBAAAA,iBAIAC,kBAAAA,uBAEK;AAGP,SAASC,mBAAmB;;;ACZ5B,SACEC,kBAGAC,gBAGAC,sBACK;AACP,SAASC,iBAAiB;AAEnB,SAASC,0BAA0BC,MAAqB;AAC7D,QAAMC,eAAeD,QAAQE,eAAeC;AAC5C,MAAI,CAAC;IAACD,eAAeC;IAAgBD,eAAeE;IAAiBC,SAASJ,YAAAA,GAAe;AAC3F,UAAMK,MAAM,mBAAmBL,YAAAA,yBAAqC;EACtE;AACA,SAAOA;AACT;AANgBF;AAQT,SAASQ,iBAAoBC,MAAcC,OAAQ;AACxD,MAAIA,UAAUC,UAAaD,UAAU,MAAM;AACzC,UAAMH,MAAM,oBAAoBE,IAAAA,QAAY;EAC9C;AACA,SAAOC;AACT;AALgBF;AAOT,SAASI,kBAAkBC,MAAyF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AezE,KAAKyE;IACpBC,YAAY1E,KAAK0E;EACnB,CAAA;AACF;AAnCsBtB;AAqCtB,eAAsBuB,qCACpB3E,MACAgD,SAAiE;AAEjE,QAAM,EAAEV,KAAI,IAAKpC,iBAAiB,QAAQF,IAAAA;AAC1C,QAAM4C,iBAAiBC,4BAA4BP,IAAAA;AACnD,SAAOM,eAAegC,gCAAgC5E,MAAMgD,OAAAA;AAC9D;AAPsB2B;AAStB,eAAsBE,qCACpB7E,MACAgD,SAAiE;AAEjE,QAAM,EAAE8B,QAAQC,IAAIzC,KAAI,IAAKW,kBAAkBjD,IAAAA;AAC/C,QAAMgF,aAAa,MAAMhC,QAAQiC,MAAMC,qBAAqB;IAC1DF,YAAY,OAAOF,WAAW,WAAWA,SAASA,OAAOC;IACzDI,gBAAgB;IAChBC,4BAA4B;EAC9B,CAAA;AACA,QAAMC,cAA2BrF,MAAMqF,eAAe;AACtDC,uBAAqBtB,gBAAeuB,gBAAgBF,WAAAA;AACpD,QAAMG,oBAAuCH;AAE7C,QAAMI,cAAcvF,iBAAiB,eAAeF,KAAKyF,WAAW;AACpE,QAAMC,gBAAgBxF,iBAAiB,iBAAiBF,KAAK0F,aAAa;AAC1E,QAAMrE,aAAa;IACjB,YAAY;MAAC;MAA0C;;IACvD0D;IACAD;;IAEAxC,MAAM;MAAC;MAAwB,GAAGA,IAAAA;;IAClCqD,mBAAmB;MACjBZ;MACAzC;MACAoD;MACAD;IACF;EACF;AAEA,QAAMG,uBAAuB,MAAM5C,QAAQiC,MAAMY,2BAA2B;IAC1ExE;IACAyE,QAAQd,WAAWe;IACnBV,aAAaG;IACbQ,qBAAqB;EACvB,CAAA;AAEA,SAAO9D,kBAAiB+D,8BAA8BL,oBAAAA,EAA8CM;AACtG;AAtCsBrB;","names":["StatusOAuth","Status2021","CredentialMapper","DocumentFormat","StatusListType","checkStatus","CredentialMapper","StatusListType","DocumentFormat","jwtDecode","getAssertedStatusListType","type","assertedType","StatusListType","StatusList2021","OAuthStatusList","includes","Error","getAssertedValue","name","value","undefined","getAssertedValues","args","id","issuer","getAssertedProperty","propertyName","obj","ValidProofTypeMap","Map","assertValidProofType","proofFormat","validProofTypes","get","determineStatusListType","credential","determineProofFormat","payload","jwtDecode","keys","Object","uniform","CredentialMapper","toUniformCredential","find","t","values","some","statusType","replace","detectDocumentType","DocumentFormat","JWT","MSO_MDOC","JSONLD","CredentialMapper","DocumentFormat","StatusListType","StatusList","DEFAULT_LIST_LENGTH","DEFAULT_PROOF_FORMAT","StatusList2021Implementation","createNewStatusList","args","context","length","proofFormat","assertValidProofType","StatusListType","StatusList2021","veramoProofFormat","issuer","id","correlationId","getAssertedValue","list","StatusList","encodedList","encode","statusPurpose","statusListCredential","createVerifiableCredential","statusList2021","indexingDirection","type","statuslistContentType","buildContentType","updateStatusListIndex","credential","uniform","CredentialMapper","toUniformCredential","credentialSubject","origEncodedList","getAssertedProperty","index","statusListIndex","parseInt","statusList","decode","setStatus","value","detectDocumentType","DocumentFormat","JWT","updatedCredential","updateStatusListFromEncodedList","Error","getAssertedValues","newEncodedList","keyRef","checkStatusIndex","status","getStatus","Status2021","Invalid","Valid","toStatusListDetails","statusListPayload","driverType","identifier","agent","identifierManagedGet","vmRelationship","offlineWhenNoDIDRegistered","verifiableCredential","kmsKeyRef","fetchRemoteContexts","toWrappedVerifiableCredential","original","StatusListType","StatusList","JoseSignatureAlgorithm","createHeaderAndPayload","StatusList","base64url","resolveIdentifier","context","issuer","keyRef","agent","identifierManagedGet","identifier","vmRelationship","offlineWhenNoDIDRegistered","kmsKeyRef","ensureManagedIdentifierResult","STATUS_LIST_JWT_TYP","createSignedJwt","context","statusList","issuerString","id","expiresAt","keyRef","identifier","resolveIdentifier","resolution","ensureManagedIdentifierResult","payload","iss","sub","iat","Math","floor","Date","now","exp","getTime","header","alg","getSigningAlgo","key","type","typ","values","createHeaderAndPayload","signedJwt","agent","jwtCreateJwsCompactSignature","issuer","noIssPayloadUpdate","protectedHeader","statusListCredential","jwt","encodedList","status_list","lst","decodeStatusListJWT","payloadBase64","split","JSON","parse","base64url","decode","Error","StatusList","decompressStatusList","bits","ttl","JoseSignatureAlgorithm","EdDSA","ES256K","ES256","RS256","StatusList","deflate","inflate","cborpkg","base64url","cbor","com","sphereon","kmp","kotlin","decompressRawStatusList","StatusList","decodeStatusList","bind","CWT_CLAIMS","SUBJECT","ISSUER","ISSUED_AT","EXPIRATION","TIME_TO_LIVE","STATUS_LIST","createSignedCbor","context","statusList","issuerString","id","expiresAt","keyRef","identifier","resolveIdentifier","encodeStatusList","compressedList","deflate","level","compressedBytes","Int8Array","statusListMap","CborMap","collections","KtMutableMap","fromJsMap","Map","CborString","CborUInt","LongKMP","fromNumber","getBitsPerStatus","CborByteString","protectedHeader","protectedHeaderEncoded","Cbor","encode","claimsMap","buildClaimsMap","claimsEncoded","signedCWT","agent","keyManagerSign","kmsKeyRef","data","base64url","Buffer","from","encoding","undefined","protectedHeaderEncodedInt8","claimsEncodedInt8","signatureBytes","decode","signatureInt8","cwtArrayElements","cwtArray","CborArray","KtMutableList","fromJsArray","cwtEncoded","cwtBuffer","statusListCredential","encodedList","ttl","claimsEntries","Math","floor","Date","now","push","getTime","getCborValueFromMap","map","key","value","getCborOptionalValueFromMap","Error","get","decodeStatusListCWT","cwt","encodedCbor","toBuffer","encodedCborArray","decodedCbor","payload","asJsArrayView","claims","asJsMapView","bits","Number","decoded","Uint8Array","uint8Array","inflate","rawStatusList","issuer","iat","exp","DEFAULT_BITS_PER_STATUS","DEFAULT_LIST_LENGTH","DEFAULT_PROOF_FORMAT","OAuthStatusListImplementation","createNewStatusList","args","context","oauthStatusList","Error","proofFormat","issuer","id","keyRef","bitsPerStatus","expiresAt","length","issuerString","correlationId","getAssertedValue","statusList","StatusList","Array","fill","encodedList","compressStatusList","statusListCredential","createSignedStatusList","type","StatusListType","OAuthStatusList","statuslistContentType","buildContentType","updateStatusListIndex","value","Promise","reject","determineProofFormat","decoded","decodeStatusListJWT","decodeStatusListCWT","index","statusListIndex","parseInt","setStatus","signedCredential","getBitsPerStatus","updateStatusListFromEncodedList","getAssertedValues","listToUpdate","decompressStatusList","checkStatusIndex","getStatus","toStatusListDetails","statusListPayload","exp","Date","driverType","createSignedJwt","createSignedCbor","StatusListType","StatusListFactory","instance","implementations","Map","set","StatusListType","StatusList2021","StatusList2021Implementation","OAuthStatusList","OAuthStatusListImplementation","getInstance","getByType","type","statusList","get","Error","getStatusListImplementation","fetchStatusListCredential","args","url","getAssertedValue","statusListCredential","response","fetch","ok","Error","status","statusText","responseAsText","text","trim","startsWith","JSON","parse","error","console","message","stringify","statusPluginStatusFunction","credential","didDoc","result","checkStatusForCredential","documentLoader","errorUnknownListType","revoked","verified","vcLibCheckStatusFunction","mandatoryCredentialStatus","verifyStatusListCredential","verifyMatchingIssuers","uniform","CredentialMapper","toUniformCredential","credentialStatus","log","type","checkStatus","simpleCheckStatusFromStatusListUrl","checkStatusIndexFromStatusListCredential","statusListType","determineStatusListType","implementation","getStatusListImplementation","checkStatusIndex","createNewStatusList","context","getAssertedValues","updateStatusIndexFromStatusListCredential","updateStatusListIndex","statusListCredentialToDetails","documentFormat","detectDocumentType","DocumentFormat","JWT","header","split","decodedHeader","Buffer","from","toString","typ","StatusListType","OAuthStatusList","MSO_MDOC","find","t","includes","replace","toStatusListDetails","statusListPayload","correlationId","driverType","updateStatusListIndexFromEncodedList","updateStatusListFromEncodedList","statusList2021ToVerifiableCredential","issuer","id","identifier","agent","identifierManagedGet","vmRelationship","offlineWhenNoDIDRegistered","proofFormat","assertValidProofType","StatusList2021","veramoProofFormat","encodedList","statusPurpose","credentialSubject","verifiableCredential","createVerifiableCredential","keyRef","kmsKeyRef","fetchRemoteContexts","toWrappedVerifiableCredential","original"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.vc-status-list",
|
|
3
3
|
"description": "Sphereon SSI-SDK plugin for Status List management, like StatusList2021.",
|
|
4
|
-
"version": "0.33.1-feature.vcdm2.tsup.
|
|
4
|
+
"version": "0.33.1-feature.vcdm2.tsup.41+4b691dc5",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@sphereon/ssi-sdk-ext.did-utils": "0.28.1-feature.esm.cjs.17",
|
|
31
31
|
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.28.1-feature.esm.cjs.17",
|
|
32
32
|
"@sphereon/ssi-sdk-ext.jwt-service": "0.28.1-feature.esm.cjs.17",
|
|
33
|
-
"@sphereon/ssi-types": "0.33.1-feature.vcdm2.tsup.
|
|
33
|
+
"@sphereon/ssi-types": "0.33.1-feature.vcdm2.tsup.41+4b691dc5",
|
|
34
34
|
"@sphereon/vc-status-list": "7.0.0-next.0",
|
|
35
35
|
"@veramo/core": "4.2.0",
|
|
36
36
|
"@veramo/credential-status": "4.2.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"SSI",
|
|
70
70
|
"StatusList2021"
|
|
71
71
|
],
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "4b691dc5852f18435f6b9031a62849a2cc6bb7e2"
|
|
73
73
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { StatusList } from '@sd-jwt/jwt-status-list'
|
|
2
2
|
import { deflate, inflate } from 'pako'
|
|
3
|
-
import
|
|
3
|
+
import * as cborpkg from '@sphereon/kmp-cbor'
|
|
4
4
|
import base64url from 'base64url'
|
|
5
5
|
import { IRequiredContext, SignedStatusListData } from '../../types'
|
|
6
6
|
import { DecodedStatusListPayload, resolveIdentifier } from './common'
|
|
7
7
|
import { BitsPerStatus } from '@sd-jwt/jwt-status-list'
|
|
8
8
|
|
|
9
|
-
const cbor = com.sphereon.cbor
|
|
10
|
-
const kmp = com.sphereon.kmp
|
|
9
|
+
const cbor = cborpkg.com.sphereon.cbor
|
|
10
|
+
const kmp = cborpkg.com.sphereon.kmp
|
|
11
|
+
const kotlin = cborpkg.kotlin
|
|
11
12
|
const decompressRawStatusList = (StatusList as any).decodeStatusList.bind(StatusList)
|
|
12
13
|
|
|
13
14
|
const CWT_CLAIMS = {
|
|
@@ -35,7 +36,7 @@ export const createSignedCbor = async (
|
|
|
35
36
|
|
|
36
37
|
const statusListMap = new cbor.CborMap(
|
|
37
38
|
kotlin.collections.KtMutableMap.fromJsMap(
|
|
38
|
-
new Map<com.sphereon.cbor.CborString, com.sphereon.cbor.CborItem<any>>([
|
|
39
|
+
new Map<cborpkg.com.sphereon.cbor.CborString, cborpkg.com.sphereon.cbor.CborItem<any>>([
|
|
39
40
|
[new cbor.CborString('bits'), new cbor.CborUInt(kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))],
|
|
40
41
|
[new cbor.CborString('lst'), new cbor.CborByteString(compressedBytes)],
|
|
41
42
|
]),
|
|
@@ -62,7 +63,7 @@ export const createSignedCbor = async (
|
|
|
62
63
|
const signatureBytes = base64url.decode(signedCWT)
|
|
63
64
|
const signatureInt8 = new Int8Array(Buffer.from(signatureBytes))
|
|
64
65
|
|
|
65
|
-
const cwtArrayElements: Array<com.sphereon.cbor.CborItem<any>> = [
|
|
66
|
+
const cwtArrayElements: Array<cborpkg.com.sphereon.cbor.CborItem<any>> = [
|
|
66
67
|
new cbor.CborByteString(protectedHeaderEncodedInt8),
|
|
67
68
|
new cbor.CborByteString(claimsEncodedInt8),
|
|
68
69
|
new cbor.CborByteString(signatureInt8),
|
|
@@ -79,11 +80,11 @@ export const createSignedCbor = async (
|
|
|
79
80
|
function buildClaimsMap(
|
|
80
81
|
id: string,
|
|
81
82
|
issuerString: string,
|
|
82
|
-
statusListMap: com.sphereon.cbor.CborMap<com.sphereon.cbor.CborString, com.sphereon.cbor.CborItem<any>>,
|
|
83
|
+
statusListMap: cborpkg.com.sphereon.cbor.CborMap<cborpkg.com.sphereon.cbor.CborString, cborpkg.com.sphereon.cbor.CborItem<any>>,
|
|
83
84
|
expiresAt?: Date,
|
|
84
85
|
) {
|
|
85
86
|
const ttl = 65535 // FIXME figure out what value should be / come from and what the difference is with exp
|
|
86
|
-
const claimsEntries: Array<[com.sphereon.cbor.CborUInt, com.sphereon.cbor.CborItem<any>]> = [
|
|
87
|
+
const claimsEntries: Array<[cborpkg.com.sphereon.cbor.CborUInt, cborpkg.com.sphereon.cbor.CborItem<any>]> = [
|
|
87
88
|
[new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)), new cbor.CborString(id)], // "sub"
|
|
88
89
|
[new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)), new cbor.CborString(issuerString)], // "iss"
|
|
89
90
|
[
|
|
@@ -112,7 +113,7 @@ function buildClaimsMap(
|
|
|
112
113
|
return claimsMap
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
const getCborValueFromMap = <T>(map: Map<com.sphereon.cbor.CborItem<any>, com.sphereon.cbor.CborItem<any>>, key: number): T => {
|
|
116
|
+
const getCborValueFromMap = <T>(map: Map<cborpkg.com.sphereon.cbor.CborItem<any>, cborpkg.com.sphereon.cbor.CborItem<any>>, key: number): T => {
|
|
116
117
|
const value = getCborOptionalValueFromMap<T>(map, key)
|
|
117
118
|
if (value === undefined) {
|
|
118
119
|
throw new Error(`Required claim ${key} not found`)
|
|
@@ -121,10 +122,10 @@ const getCborValueFromMap = <T>(map: Map<com.sphereon.cbor.CborItem<any>, com.sp
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
const getCborOptionalValueFromMap = <T>(
|
|
124
|
-
map: Map<com.sphereon.cbor.CborItem<any>, com.sphereon.cbor.CborItem<any>>,
|
|
125
|
+
map: Map<cborpkg.com.sphereon.cbor.CborItem<any>, cborpkg.com.sphereon.cbor.CborItem<any>>,
|
|
125
126
|
key: number,
|
|
126
127
|
): T | undefined | never => {
|
|
127
|
-
const value = map.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)))
|
|
128
|
+
const value = map.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)))
|
|
128
129
|
if (!value) {
|
|
129
130
|
return undefined
|
|
130
131
|
}
|
|
@@ -134,28 +135,28 @@ const getCborOptionalValueFromMap = <T>(
|
|
|
134
135
|
export const decodeStatusListCWT = (cwt: string): DecodedStatusListPayload => {
|
|
135
136
|
const encodedCbor = base64url.toBuffer(cwt)
|
|
136
137
|
const encodedCborArray = new Int8Array(encodedCbor)
|
|
137
|
-
const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray)
|
|
138
|
+
const decodedCbor = cborpkg.com.sphereon.cbor.Cbor.decode(encodedCborArray)
|
|
138
139
|
|
|
139
|
-
if (!(decodedCbor instanceof com.sphereon.cbor.CborArray)) {
|
|
140
|
+
if (!(decodedCbor instanceof cborpkg.com.sphereon.cbor.CborArray)) {
|
|
140
141
|
throw new Error('Invalid CWT format: Expected a CBOR array')
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
const [, payload] = decodedCbor.value.asJsArrayView()
|
|
144
|
-
if (!(payload instanceof com.sphereon.cbor.CborByteString)) {
|
|
145
|
+
if (!(payload instanceof cborpkg.com.sphereon.cbor.CborByteString)) {
|
|
145
146
|
throw new Error('Invalid payload format: Expected a CBOR ByteString')
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
const claims = com.sphereon.cbor.Cbor.decode(payload.value)
|
|
149
|
-
if (!(claims instanceof com.sphereon.cbor.CborMap)) {
|
|
149
|
+
const claims = cborpkg.com.sphereon.cbor.Cbor.decode(payload.value)
|
|
150
|
+
if (!(claims instanceof cborpkg.com.sphereon.cbor.CborMap)) {
|
|
150
151
|
throw new Error('Invalid claims format: Expected a CBOR map')
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
const claimsMap = claims.value.asJsMapView()
|
|
154
155
|
|
|
155
|
-
const statusListMap = claimsMap.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView()
|
|
156
|
+
const statusListMap = claimsMap.get(new cborpkg.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView()
|
|
156
157
|
|
|
157
|
-
const bits = Number(statusListMap.get(new com.sphereon.cbor.CborString('bits')).value) as BitsPerStatus
|
|
158
|
-
const decoded = new Uint8Array(statusListMap.get(new com.sphereon.cbor.CborString('lst')).value)
|
|
158
|
+
const bits = Number(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString('bits')).value) as BitsPerStatus
|
|
159
|
+
const decoded = new Uint8Array(statusListMap.get(new cborpkg.com.sphereon.cbor.CborString('lst')).value)
|
|
159
160
|
const uint8Array = inflate(decoded)
|
|
160
161
|
const rawStatusList = decompressRawStatusList(uint8Array, bits)
|
|
161
162
|
const statusList = new StatusList(rawStatusList, bits)
|