@sphereon/ssi-sdk.vc-status-list 0.32.1-next.54 → 0.33.1-feature.vcdm2.4
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/functions.d.ts +13 -13
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +141 -225
- package/dist/functions.js.map +1 -1
- package/dist/impl/IStatusList.d.ts +26 -0
- package/dist/impl/IStatusList.d.ts.map +1 -0
- package/dist/impl/IStatusList.js +2 -0
- package/dist/impl/IStatusList.js.map +1 -0
- package/dist/impl/OAuthStatusList.d.ts +21 -0
- package/dist/impl/OAuthStatusList.d.ts.map +1 -0
- package/dist/impl/OAuthStatusList.js +144 -0
- package/dist/impl/OAuthStatusList.js.map +1 -0
- package/dist/impl/StatusList2021.d.ts +16 -0
- package/dist/impl/StatusList2021.d.ts.map +1 -0
- package/dist/impl/StatusList2021.js +179 -0
- package/dist/impl/StatusList2021.js.map +1 -0
- package/dist/impl/StatusListFactory.d.ts +11 -0
- package/dist/impl/StatusListFactory.d.ts.map +1 -0
- package/dist/impl/StatusListFactory.js +29 -0
- package/dist/impl/StatusListFactory.js.map +1 -0
- package/dist/impl/encoding/cbor.d.ts +6 -0
- package/dist/impl/encoding/cbor.d.ts.map +1 -0
- package/dist/impl/encoding/cbor.js +123 -0
- package/dist/impl/encoding/cbor.js.map +1 -0
- package/dist/impl/encoding/common.d.ts +12 -0
- package/dist/impl/encoding/common.d.ts.map +1 -0
- package/dist/impl/encoding/common.js +9 -0
- package/dist/impl/encoding/common.js.map +1 -0
- package/dist/impl/encoding/jwt.d.ts +9 -0
- package/dist/impl/encoding/jwt.d.ts.map +1 -0
- package/dist/impl/encoding/jwt.js +61 -0
- package/dist/impl/encoding/jwt.js.map +1 -0
- package/dist/index.js +2 -18
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +131 -33
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +11 -2
- package/dist/types/index.js.map +1 -1
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +79 -0
- package/dist/utils.js.map +1 -0
- package/package.json +17 -6
- package/src/functions.ts +73 -159
- package/src/impl/IStatusList.ts +42 -0
- package/src/impl/OAuthStatusList.ts +206 -0
- package/src/impl/StatusList2021.ts +241 -0
- package/src/impl/StatusListFactory.ts +34 -0
- package/src/impl/encoding/cbor.ts +171 -0
- package/src/impl/encoding/common.ts +20 -0
- package/src/impl/encoding/jwt.ts +80 -0
- package/src/types/index.ts +151 -37
- package/src/utils.ts +95 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { StatusListType } from '@sphereon/ssi-types';
|
|
2
|
+
import { determineProofFormat, getAssertedValue, getAssertedValues } from '../utils';
|
|
3
|
+
import { StatusList } from '@sd-jwt/jwt-status-list';
|
|
4
|
+
import { createSignedJwt, decodeStatusListJWT } from './encoding/jwt';
|
|
5
|
+
import { createSignedCbor, decodeStatusListCWT } from './encoding/cbor';
|
|
6
|
+
export const DEFAULT_BITS_PER_STATUS = 1; // 1 bit is sufficient for 0x00 - "VALID" 0x01 - "INVALID" saving space in the process
|
|
7
|
+
export const DEFAULT_LIST_LENGTH = 250000;
|
|
8
|
+
export const DEFAULT_PROOF_FORMAT = 'jwt';
|
|
9
|
+
export class OAuthStatusListImplementation {
|
|
10
|
+
async createNewStatusList(args, context) {
|
|
11
|
+
if (!args.oauthStatusList) {
|
|
12
|
+
throw new Error('OAuthStatusList options are required for type OAuthStatusList');
|
|
13
|
+
}
|
|
14
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT;
|
|
15
|
+
const { issuer, id, oauthStatusList, keyRef } = args;
|
|
16
|
+
const { bitsPerStatus, expiresAt } = oauthStatusList;
|
|
17
|
+
const length = args.length ?? DEFAULT_LIST_LENGTH;
|
|
18
|
+
const issuerString = typeof issuer === 'string' ? issuer : issuer.id;
|
|
19
|
+
const correlationId = getAssertedValue('correlationId', args.correlationId);
|
|
20
|
+
const statusList = new StatusList(new Array(length).fill(0), bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
21
|
+
const encodedList = statusList.compressStatusList();
|
|
22
|
+
const { statusListCredential } = await this.createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef);
|
|
23
|
+
return {
|
|
24
|
+
encodedList,
|
|
25
|
+
statusListCredential,
|
|
26
|
+
oauthStatusList: { bitsPerStatus },
|
|
27
|
+
length,
|
|
28
|
+
type: StatusListType.OAuthStatusList,
|
|
29
|
+
proofFormat,
|
|
30
|
+
id,
|
|
31
|
+
correlationId,
|
|
32
|
+
issuer,
|
|
33
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async updateStatusListIndex(args, context) {
|
|
37
|
+
const { statusListCredential, value, expiresAt, keyRef } = args;
|
|
38
|
+
if (typeof statusListCredential !== 'string') {
|
|
39
|
+
return Promise.reject('statusListCredential in neither JWT nor CWT');
|
|
40
|
+
}
|
|
41
|
+
const proofFormat = determineProofFormat(statusListCredential);
|
|
42
|
+
const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
43
|
+
const { statusList, issuer, id } = decoded;
|
|
44
|
+
const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
45
|
+
if (index < 0 || index >= statusList.statusList.length) {
|
|
46
|
+
throw new Error('Status list index out of bounds');
|
|
47
|
+
}
|
|
48
|
+
statusList.setStatus(index, value);
|
|
49
|
+
const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
|
|
50
|
+
return {
|
|
51
|
+
statusListCredential: signedCredential,
|
|
52
|
+
encodedList,
|
|
53
|
+
oauthStatusList: {
|
|
54
|
+
bitsPerStatus: statusList.getBitsPerStatus(),
|
|
55
|
+
},
|
|
56
|
+
length: statusList.statusList.length,
|
|
57
|
+
type: StatusListType.OAuthStatusList,
|
|
58
|
+
proofFormat,
|
|
59
|
+
id,
|
|
60
|
+
issuer,
|
|
61
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// FIXME: This still assumes only two values (boolean), whilst this list supports 8 bits max
|
|
65
|
+
async updateStatusListFromEncodedList(args, context) {
|
|
66
|
+
if (!args.oauthStatusList) {
|
|
67
|
+
throw new Error('OAuthStatusList options are required for type OAuthStatusList');
|
|
68
|
+
}
|
|
69
|
+
const { proofFormat, oauthStatusList, keyRef } = args;
|
|
70
|
+
const { bitsPerStatus, expiresAt } = oauthStatusList;
|
|
71
|
+
const { issuer, id } = getAssertedValues(args);
|
|
72
|
+
const issuerString = typeof issuer === 'string' ? issuer : issuer.id;
|
|
73
|
+
const listToUpdate = StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
74
|
+
const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
75
|
+
// FIXME: See above.
|
|
76
|
+
listToUpdate.setStatus(index, args.value ? 1 : 0);
|
|
77
|
+
const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT, context, listToUpdate, issuerString, id, expiresAt, keyRef);
|
|
78
|
+
return {
|
|
79
|
+
encodedList,
|
|
80
|
+
statusListCredential,
|
|
81
|
+
oauthStatusList: {
|
|
82
|
+
bitsPerStatus,
|
|
83
|
+
expiresAt,
|
|
84
|
+
},
|
|
85
|
+
length: listToUpdate.statusList.length,
|
|
86
|
+
type: StatusListType.OAuthStatusList,
|
|
87
|
+
proofFormat: proofFormat ?? DEFAULT_PROOF_FORMAT,
|
|
88
|
+
id,
|
|
89
|
+
issuer,
|
|
90
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
buildContentType(proofFormat) {
|
|
94
|
+
return `application/statuslist+${proofFormat === 'cbor' ? 'cwt' : 'jwt'}`;
|
|
95
|
+
}
|
|
96
|
+
async checkStatusIndex(args) {
|
|
97
|
+
const { statusListCredential, statusListIndex } = args;
|
|
98
|
+
if (typeof statusListCredential !== 'string') {
|
|
99
|
+
return Promise.reject('statusListCredential in neither JWT nor CWT');
|
|
100
|
+
}
|
|
101
|
+
const proofFormat = determineProofFormat(statusListCredential);
|
|
102
|
+
const { statusList } = proofFormat === 'jwt' ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
103
|
+
const index = typeof statusListIndex === 'number' ? statusListIndex : parseInt(statusListIndex);
|
|
104
|
+
if (index < 0 || index >= statusList.statusList.length) {
|
|
105
|
+
throw new Error('Status list index out of bounds');
|
|
106
|
+
}
|
|
107
|
+
return statusList.getStatus(index);
|
|
108
|
+
}
|
|
109
|
+
async toStatusListDetails(args) {
|
|
110
|
+
const { statusListPayload } = args;
|
|
111
|
+
const proofFormat = determineProofFormat(statusListPayload);
|
|
112
|
+
const decoded = proofFormat === 'jwt' ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload);
|
|
113
|
+
const { statusList, issuer, id, exp } = decoded;
|
|
114
|
+
return {
|
|
115
|
+
id,
|
|
116
|
+
encodedList: statusList.compressStatusList(),
|
|
117
|
+
issuer,
|
|
118
|
+
type: StatusListType.OAuthStatusList,
|
|
119
|
+
proofFormat,
|
|
120
|
+
length: statusList.statusList.length,
|
|
121
|
+
statusListCredential: statusListPayload,
|
|
122
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
123
|
+
oauthStatusList: {
|
|
124
|
+
bitsPerStatus: statusList.getBitsPerStatus(),
|
|
125
|
+
...(exp && { expiresAt: new Date(exp * 1000) }),
|
|
126
|
+
},
|
|
127
|
+
...(args.correlationId && { correlationId: args.correlationId }),
|
|
128
|
+
...(args.driverType && { driverType: args.driverType }),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
async createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef) {
|
|
132
|
+
switch (proofFormat) {
|
|
133
|
+
case 'jwt': {
|
|
134
|
+
return await createSignedJwt(context, statusList, issuerString, id, expiresAt, keyRef);
|
|
135
|
+
}
|
|
136
|
+
case 'cbor': {
|
|
137
|
+
return await createSignedCbor(context, statusList, issuerString, id, expiresAt, keyRef);
|
|
138
|
+
}
|
|
139
|
+
default:
|
|
140
|
+
throw new Error(`Invalid proof format '${proofFormat}' for OAuthStatusList`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=OAuthStatusList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuthStatusList.js","sourceRoot":"","sources":["../../src/impl/OAuthStatusList.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAWlF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEpF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAGpD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAIvE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAA,CAAC,uFAAuF;AAChI,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAA;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAoB,CAAA;AAExD,MAAM,OAAO,6BAA6B;IACxC,KAAK,CAAC,mBAAmB,CAAC,IAA0B,EAAE,OAAyB;QAC7E,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;QAClF,CAAC;QAED,MAAM,WAAW,GAAG,IAAI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AC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;YACzF,CAAC;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,uBAAuB,CAAC,CAAA;QAChF,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IAgentContext, ICredentialPlugin, ProofFormat as VeramoProofFormat } from '@veramo/core';
|
|
2
|
+
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
3
|
+
import { IStatusList } from './IStatusList';
|
|
4
|
+
import { CheckStatusIndexArgs, CreateStatusListArgs, Status2021, StatusListResult, ToStatusListDetailsArgs, UpdateStatusListFromEncodedListArgs, UpdateStatusListIndexArgs } from '../types';
|
|
5
|
+
export declare const DEFAULT_LIST_LENGTH = 250000;
|
|
6
|
+
export declare const DEFAULT_PROOF_FORMAT: VeramoProofFormat;
|
|
7
|
+
export declare class StatusList2021Implementation implements IStatusList {
|
|
8
|
+
createNewStatusList(args: CreateStatusListArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
9
|
+
updateStatusListIndex(args: UpdateStatusListIndexArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
10
|
+
updateStatusListFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
11
|
+
checkStatusIndex(args: CheckStatusIndexArgs): Promise<number | Status2021>;
|
|
12
|
+
toStatusListDetails(args: ToStatusListDetailsArgs): Promise<StatusListResult>;
|
|
13
|
+
private createVerifiableCredential;
|
|
14
|
+
private buildContentType;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=StatusList2021.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusList2021.d.ts","sourceRoot":"","sources":["../../src/impl/StatusList2021.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AAInF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,mCAAmC,EACnC,yBAAyB,EAC1B,MAAM,UAAU,CAAA;AAGjB,eAAO,MAAM,mBAAmB,SAAS,CAAA;AACzC,eAAO,MAAM,oBAAoB,EAAY,iBAAiB,CAAA;AAE9D,qBAAa,4BAA6B,YAAW,WAAW;IACxD,mBAAmB,CACvB,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,aAAa,CAAC,iBAAiB,GAAG,qBAAqB,CAAC,GAChE,OAAO,CAAC,gBAAgB,CAAC;IAuCtB,qBAAqB,CACzB,IAAI,EAAE,yBAAyB,EAC/B,OAAO,EAAE,aAAa,CAAC,iBAAiB,GAAG,qBAAqB,CAAC,GAChE,OAAO,CAAC,gBAAgB,CAAC;IAwCtB,+BAA+B,CACnC,IAAI,EAAE,mCAAmC,EACzC,OAAO,EAAE,aAAa,CAAC,iBAAiB,GAAG,qBAAqB,CAAC,GAChE,OAAO,CAAC,gBAAgB,CAAC;IAyCtB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC;IAU1E,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;YA6BrE,0BAA0B;IAuCxC,OAAO,CAAC,gBAAgB;CAYzB"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { CredentialMapper, StatusListType } from '@sphereon/ssi-types';
|
|
2
|
+
import { StatusList } from '@sphereon/vc-status-list';
|
|
3
|
+
import { Status2021, } from '../types';
|
|
4
|
+
import { assertValidProofType, getAssertedProperty, getAssertedValue, getAssertedValues } from '../utils';
|
|
5
|
+
export const DEFAULT_LIST_LENGTH = 250000;
|
|
6
|
+
export const DEFAULT_PROOF_FORMAT = 'lds';
|
|
7
|
+
export class StatusList2021Implementation {
|
|
8
|
+
async createNewStatusList(args, context) {
|
|
9
|
+
const length = args?.length ?? DEFAULT_LIST_LENGTH;
|
|
10
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT;
|
|
11
|
+
assertValidProofType(StatusListType.StatusList2021, proofFormat);
|
|
12
|
+
const veramoProofFormat = proofFormat;
|
|
13
|
+
const { issuer, id } = args;
|
|
14
|
+
const correlationId = getAssertedValue('correlationId', args.correlationId);
|
|
15
|
+
const list = new StatusList({ length });
|
|
16
|
+
const encodedList = await list.encode();
|
|
17
|
+
const statusPurpose = 'revocation';
|
|
18
|
+
const statusListCredential = await this.createVerifiableCredential({
|
|
19
|
+
...args,
|
|
20
|
+
encodedList,
|
|
21
|
+
proofFormat: veramoProofFormat,
|
|
22
|
+
}, context);
|
|
23
|
+
return {
|
|
24
|
+
encodedList,
|
|
25
|
+
statusListCredential: statusListCredential,
|
|
26
|
+
statusList2021: {
|
|
27
|
+
statusPurpose,
|
|
28
|
+
indexingDirection: 'rightToLeft',
|
|
29
|
+
},
|
|
30
|
+
length,
|
|
31
|
+
type: StatusListType.StatusList2021,
|
|
32
|
+
proofFormat,
|
|
33
|
+
id,
|
|
34
|
+
correlationId,
|
|
35
|
+
issuer,
|
|
36
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async updateStatusListIndex(args, context) {
|
|
40
|
+
const credential = args.statusListCredential;
|
|
41
|
+
const uniform = CredentialMapper.toUniformCredential(credential);
|
|
42
|
+
const { issuer, credentialSubject } = uniform;
|
|
43
|
+
const id = getAssertedValue('id', uniform.id);
|
|
44
|
+
const origEncodedList = getAssertedProperty('encodedList', credentialSubject);
|
|
45
|
+
const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
46
|
+
const statusList = await StatusList.decode({ encodedList: origEncodedList });
|
|
47
|
+
statusList.setStatus(index, args.value != 0);
|
|
48
|
+
const encodedList = await statusList.encode();
|
|
49
|
+
const proofFormat = CredentialMapper.detectDocumentType(credential) === 0 /* DocumentFormat.JWT */ ? 'jwt' : 'lds';
|
|
50
|
+
const updatedCredential = await this.createVerifiableCredential({
|
|
51
|
+
...args,
|
|
52
|
+
id,
|
|
53
|
+
issuer,
|
|
54
|
+
encodedList,
|
|
55
|
+
proofFormat: proofFormat,
|
|
56
|
+
}, context);
|
|
57
|
+
return {
|
|
58
|
+
statusListCredential: updatedCredential,
|
|
59
|
+
encodedList,
|
|
60
|
+
statusList2021: {
|
|
61
|
+
...('statusPurpose' in credentialSubject ? { statusPurpose: credentialSubject.statusPurpose } : {}),
|
|
62
|
+
indexingDirection: 'rightToLeft',
|
|
63
|
+
},
|
|
64
|
+
length: statusList.length - 1,
|
|
65
|
+
type: StatusListType.StatusList2021,
|
|
66
|
+
proofFormat: proofFormat,
|
|
67
|
+
id,
|
|
68
|
+
issuer,
|
|
69
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async updateStatusListFromEncodedList(args, context) {
|
|
73
|
+
if (!args.statusList2021) {
|
|
74
|
+
throw new Error('statusList2021 options required for type StatusList2021');
|
|
75
|
+
}
|
|
76
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT;
|
|
77
|
+
assertValidProofType(StatusListType.StatusList2021, proofFormat);
|
|
78
|
+
const veramoProofFormat = proofFormat;
|
|
79
|
+
const { issuer, id } = getAssertedValues(args);
|
|
80
|
+
const statusList = await StatusList.decode({ encodedList: args.encodedList });
|
|
81
|
+
const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
82
|
+
statusList.setStatus(index, args.value);
|
|
83
|
+
const newEncodedList = await statusList.encode();
|
|
84
|
+
const credential = await this.createVerifiableCredential({
|
|
85
|
+
id,
|
|
86
|
+
issuer,
|
|
87
|
+
encodedList: newEncodedList,
|
|
88
|
+
proofFormat: veramoProofFormat,
|
|
89
|
+
keyRef: args.keyRef,
|
|
90
|
+
}, context);
|
|
91
|
+
return {
|
|
92
|
+
type: StatusListType.StatusList2021,
|
|
93
|
+
statusListCredential: credential,
|
|
94
|
+
encodedList: newEncodedList,
|
|
95
|
+
statusList2021: {
|
|
96
|
+
statusPurpose: args.statusList2021.statusPurpose,
|
|
97
|
+
indexingDirection: 'rightToLeft',
|
|
98
|
+
},
|
|
99
|
+
length: statusList.length,
|
|
100
|
+
proofFormat: args.proofFormat ?? 'lds',
|
|
101
|
+
id: id,
|
|
102
|
+
issuer: issuer,
|
|
103
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async checkStatusIndex(args) {
|
|
107
|
+
const uniform = CredentialMapper.toUniformCredential(args.statusListCredential);
|
|
108
|
+
const { credentialSubject } = uniform;
|
|
109
|
+
const encodedList = getAssertedProperty('encodedList', credentialSubject);
|
|
110
|
+
const statusList = await StatusList.decode({ encodedList });
|
|
111
|
+
const status = statusList.getStatus(typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex));
|
|
112
|
+
return status ? Status2021.Invalid : Status2021.Valid;
|
|
113
|
+
}
|
|
114
|
+
async toStatusListDetails(args) {
|
|
115
|
+
const { statusListPayload } = args;
|
|
116
|
+
const uniform = CredentialMapper.toUniformCredential(statusListPayload);
|
|
117
|
+
const { issuer, credentialSubject } = uniform;
|
|
118
|
+
const id = getAssertedValue('id', uniform.id);
|
|
119
|
+
const encodedList = getAssertedProperty('encodedList', credentialSubject);
|
|
120
|
+
const proofFormat = CredentialMapper.detectDocumentType(statusListPayload) === 0 /* DocumentFormat.JWT */ ? 'jwt' : 'lds';
|
|
121
|
+
const statusPurpose = getAssertedProperty('statusPurpose', credentialSubject);
|
|
122
|
+
const list = await StatusList.decode({ encodedList });
|
|
123
|
+
return {
|
|
124
|
+
id,
|
|
125
|
+
encodedList,
|
|
126
|
+
issuer,
|
|
127
|
+
type: StatusListType.StatusList2021,
|
|
128
|
+
proofFormat,
|
|
129
|
+
length: list.length,
|
|
130
|
+
statusListCredential: statusListPayload,
|
|
131
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
132
|
+
statusList2021: {
|
|
133
|
+
indexingDirection: 'rightToLeft',
|
|
134
|
+
statusPurpose,
|
|
135
|
+
},
|
|
136
|
+
...(args.correlationId && { correlationId: args.correlationId }),
|
|
137
|
+
...(args.driverType && { driverType: args.driverType }),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async createVerifiableCredential(args, context) {
|
|
141
|
+
const identifier = await context.agent.identifierManagedGet({
|
|
142
|
+
identifier: typeof args.issuer === 'string' ? args.issuer : args.issuer.id,
|
|
143
|
+
vmRelationship: 'assertionMethod',
|
|
144
|
+
offlineWhenNoDIDRegistered: true,
|
|
145
|
+
});
|
|
146
|
+
const credential = {
|
|
147
|
+
'@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],
|
|
148
|
+
id: args.id,
|
|
149
|
+
issuer: args.issuer,
|
|
150
|
+
type: ['VerifiableCredential', 'StatusList2021Credential'],
|
|
151
|
+
credentialSubject: {
|
|
152
|
+
id: args.id,
|
|
153
|
+
type: 'StatusList2021',
|
|
154
|
+
statusPurpose: 'revocation',
|
|
155
|
+
encodedList: args.encodedList,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
159
|
+
credential,
|
|
160
|
+
keyRef: args.keyRef ?? identifier.kmsKeyRef,
|
|
161
|
+
proofFormat: args.proofFormat,
|
|
162
|
+
fetchRemoteContexts: true,
|
|
163
|
+
});
|
|
164
|
+
return CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
165
|
+
}
|
|
166
|
+
buildContentType(proofFormat) {
|
|
167
|
+
switch (proofFormat) {
|
|
168
|
+
case 'jwt':
|
|
169
|
+
return `application/statuslist+jwt`;
|
|
170
|
+
case 'cbor':
|
|
171
|
+
return `application/statuslist+cwt`;
|
|
172
|
+
case 'lds':
|
|
173
|
+
return 'application/statuslist+ld+json';
|
|
174
|
+
default:
|
|
175
|
+
throw Error(`Unsupported content type '${proofFormat}' for status lists`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=StatusList2021.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusList2021.js","sourceRoot":"","sources":["../../src/impl/StatusList2021.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAA8D,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAElI,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAErD,OAAO,EAGL,UAAU,GAKX,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEzG,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAA;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAA0B,CAAA;AAE9D,MAAM,OAAO,4BAA4B;IACvC,KAAK,CAAC,mBAAmB,CACvB,IAA0B,EAC1B,OAAiE;QAEjE,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,mBAAmB,CAAA;QAClD,MAAM,WAAW,GAAgB,IAAI,EAAE,WAAW,IAAI,oBAAoB,CAAA;QAC1E,oBAAoB,CAAC,cAAc,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;QAChE,MAAM,iBAAiB,GAAsB,WAAgC,CAAA;QAE7E,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GA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AO,CAAC,KAAK,CAAC,0BAA0B,CAAC;YAC1E,UAAU;YACV,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,SAAS;YAC3C,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,mBAAmB,EAAE,IAAI;SAC1B,CAAC,CAAA;QAEF,OAAO,gBAAgB,CAAC,6BAA6B,CAAC,oBAA4C,CAAC,CAAC,QAAgC,CAAA;IACtI,CAAC;IAEO,gBAAgB,CAAC,WAA+E;QACtG,QAAQ,WAAW,EAAE,CAAC;YACpB,KAAK,KAAK;gBACR,OAAO,4BAA4B,CAAA;YACrC,KAAK,MAAM;gBACT,OAAO,4BAA4B,CAAA;YACrC,KAAK,KAAK;gBACR,OAAO,gCAAgC,CAAA;YACzC;gBACE,MAAM,KAAK,CAAC,6BAA6B,WAAW,oBAAoB,CAAC,CAAA;QAC7E,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IStatusList } from './IStatusList';
|
|
2
|
+
import { StatusListType } from '@sphereon/ssi-types';
|
|
3
|
+
export declare class StatusListFactory {
|
|
4
|
+
private static instance;
|
|
5
|
+
private implementations;
|
|
6
|
+
private constructor();
|
|
7
|
+
static getInstance(): StatusListFactory;
|
|
8
|
+
getByType(type: StatusListType): IStatusList;
|
|
9
|
+
}
|
|
10
|
+
export declare function getStatusListImplementation(type: StatusListType): IStatusList;
|
|
11
|
+
//# sourceMappingURL=StatusListFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusListFactory.d.ts","sourceRoot":"","sources":["../../src/impl/StatusListFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAmB;IAC1C,OAAO,CAAC,eAAe,CAAkC;IAEzD,OAAO;WAMO,WAAW,IAAI,iBAAiB;IAOvC,SAAS,CAAC,IAAI,EAAE,cAAc,GAAG,WAAW;CAOpD;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,cAAc,GAAG,WAAW,CAE7E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { StatusList2021Implementation } from './StatusList2021';
|
|
2
|
+
import { OAuthStatusListImplementation } from './OAuthStatusList';
|
|
3
|
+
import { StatusListType } from '@sphereon/ssi-types';
|
|
4
|
+
export class StatusListFactory {
|
|
5
|
+
static instance;
|
|
6
|
+
implementations;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.implementations = new Map();
|
|
9
|
+
this.implementations.set(StatusListType.StatusList2021, new StatusList2021Implementation());
|
|
10
|
+
this.implementations.set(StatusListType.OAuthStatusList, new OAuthStatusListImplementation());
|
|
11
|
+
}
|
|
12
|
+
static getInstance() {
|
|
13
|
+
if (!StatusListFactory.instance) {
|
|
14
|
+
StatusListFactory.instance = new StatusListFactory();
|
|
15
|
+
}
|
|
16
|
+
return StatusListFactory.instance;
|
|
17
|
+
}
|
|
18
|
+
getByType(type) {
|
|
19
|
+
const statusList = this.implementations.get(type);
|
|
20
|
+
if (!statusList) {
|
|
21
|
+
throw new Error(`No implementation found for status list type: ${type}`);
|
|
22
|
+
}
|
|
23
|
+
return statusList;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function getStatusListImplementation(type) {
|
|
27
|
+
return StatusListFactory.getInstance().getByType(type);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=StatusListFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusListFactory.js","sourceRoot":"","sources":["../../src/impl/StatusListFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,MAAM,OAAO,iBAAiB;IACpB,MAAM,CAAC,QAAQ,CAAmB;IAClC,eAAe,CAAkC;IAEzD;QACE,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAA;QAChC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,4BAA4B,EAAE,CAAC,CAAA;QAC3F,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,6BAA6B,EAAE,CAAC,CAAA;IAC/F,CAAC;IAEM,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;YAChC,iBAAiB,CAAC,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAA;QACtD,CAAC;QACD,OAAO,iBAAiB,CAAC,QAAQ,CAAA;IACnC,CAAC;IAEM,SAAS,CAAC,IAAoB;QACnC,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,iDAAiD,IAAI,EAAE,CAAC,CAAA;QAC1E,CAAC;QACD,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AAED,MAAM,UAAU,2BAA2B,CAAC,IAAoB;IAC9D,OAAO,iBAAiB,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AACxD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StatusList } from '@sd-jwt/jwt-status-list';
|
|
2
|
+
import { IRequiredContext, SignedStatusListData } from '../../types';
|
|
3
|
+
import { DecodedStatusListPayload } from './common';
|
|
4
|
+
export declare const createSignedCbor: (context: IRequiredContext, statusList: StatusList, issuerString: string, id: string, expiresAt?: Date, keyRef?: string) => Promise<SignedStatusListData>;
|
|
5
|
+
export declare const decodeStatusListCWT: (cwt: string) => DecodedStatusListPayload;
|
|
6
|
+
//# sourceMappingURL=cbor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cbor.d.ts","sourceRoot":"","sources":["../../../src/impl/encoding/cbor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAIpD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAqB,MAAM,UAAU,CAAA;AAgBtE,eAAO,MAAM,gBAAgB,YAClB,gBAAgB,cACb,UAAU,gBACR,MAAM,MAChB,MAAM,cACE,IAAI,WACP,MAAM,KACd,OAAO,CAAC,oBAAoB,CAgD9B,CAAA;AAyDD,eAAO,MAAM,mBAAmB,QAAS,MAAM,KAAG,wBAqCjD,CAAA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { StatusList } from '@sd-jwt/jwt-status-list';
|
|
2
|
+
import { deflate, inflate } from 'pako';
|
|
3
|
+
import { com, kotlin } from '@sphereon/kmp-cbor';
|
|
4
|
+
import base64url from 'base64url';
|
|
5
|
+
import { resolveIdentifier } from './common';
|
|
6
|
+
const cbor = com.sphereon.cbor;
|
|
7
|
+
const kmp = com.sphereon.kmp;
|
|
8
|
+
const decompressRawStatusList = StatusList.decodeStatusList.bind(StatusList);
|
|
9
|
+
const CWT_CLAIMS = {
|
|
10
|
+
SUBJECT: 2,
|
|
11
|
+
ISSUER: 1,
|
|
12
|
+
ISSUED_AT: 6,
|
|
13
|
+
EXPIRATION: 4,
|
|
14
|
+
TIME_TO_LIVE: 65534,
|
|
15
|
+
STATUS_LIST: 65533,
|
|
16
|
+
};
|
|
17
|
+
export const createSignedCbor = async (context, statusList, issuerString, id, expiresAt, keyRef) => {
|
|
18
|
+
const identifier = await resolveIdentifier(context, issuerString, keyRef);
|
|
19
|
+
const encodeStatusList = statusList.encodeStatusList();
|
|
20
|
+
const compressedList = deflate(encodeStatusList, { level: 9 });
|
|
21
|
+
const compressedBytes = new Int8Array(compressedList);
|
|
22
|
+
const statusListMap = new cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map([
|
|
23
|
+
[new cbor.CborString('bits'), new cbor.CborUInt(kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))],
|
|
24
|
+
[new cbor.CborString('lst'), new cbor.CborByteString(compressedBytes)],
|
|
25
|
+
])));
|
|
26
|
+
const protectedHeader = new cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map([[new cbor.CborUInt(kmp.LongKMP.fromNumber(16)), new cbor.CborString('statuslist+cwt')]])));
|
|
27
|
+
const protectedHeaderEncoded = cbor.Cbor.encode(protectedHeader);
|
|
28
|
+
const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt);
|
|
29
|
+
const claimsEncoded = cbor.Cbor.encode(claimsMap);
|
|
30
|
+
const signedCWT = await context.agent.keyManagerSign({
|
|
31
|
+
keyRef: identifier.kmsKeyRef,
|
|
32
|
+
data: base64url.encode(Buffer.from(claimsEncoded)), // TODO test on RN
|
|
33
|
+
encoding: undefined,
|
|
34
|
+
});
|
|
35
|
+
const protectedHeaderEncodedInt8 = new Int8Array(protectedHeaderEncoded);
|
|
36
|
+
const claimsEncodedInt8 = new Int8Array(claimsEncoded);
|
|
37
|
+
const signatureBytes = base64url.decode(signedCWT);
|
|
38
|
+
const signatureInt8 = new Int8Array(Buffer.from(signatureBytes));
|
|
39
|
+
const cwtArrayElements = [
|
|
40
|
+
new cbor.CborByteString(protectedHeaderEncodedInt8),
|
|
41
|
+
new cbor.CborByteString(claimsEncodedInt8),
|
|
42
|
+
new cbor.CborByteString(signatureInt8),
|
|
43
|
+
];
|
|
44
|
+
const cwtArray = new cbor.CborArray(kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements));
|
|
45
|
+
const cwtEncoded = cbor.Cbor.encode(cwtArray);
|
|
46
|
+
const cwtBuffer = Buffer.from(cwtEncoded);
|
|
47
|
+
return {
|
|
48
|
+
statusListCredential: base64url.encode(cwtBuffer),
|
|
49
|
+
encodedList: base64url.encode(compressedList), // JS in @sd-jwt/jwt-status-list drops it in like this, so keep the same method
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
function buildClaimsMap(id, issuerString, statusListMap, expiresAt) {
|
|
53
|
+
const ttl = 65535; // FIXME figure out what value should be / come from and what the difference is with exp
|
|
54
|
+
const claimsEntries = [
|
|
55
|
+
[new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)), new cbor.CborString(id)], // "sub"
|
|
56
|
+
[new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)), new cbor.CborString(issuerString)], // "iss"
|
|
57
|
+
[
|
|
58
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),
|
|
59
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1000))), // "iat"
|
|
60
|
+
],
|
|
61
|
+
];
|
|
62
|
+
if (expiresAt) {
|
|
63
|
+
claimsEntries.push([
|
|
64
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),
|
|
65
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1000))), // "exp"
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
if (ttl) {
|
|
69
|
+
claimsEntries.push([
|
|
70
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),
|
|
71
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(ttl)), // "time to live"
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
claimsEntries.push([new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)), statusListMap]);
|
|
75
|
+
const claimsMap = new cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)));
|
|
76
|
+
return claimsMap;
|
|
77
|
+
}
|
|
78
|
+
const getCborValueFromMap = (map, key) => {
|
|
79
|
+
const value = getCborOptionalValueFromMap(map, key);
|
|
80
|
+
if (value === undefined) {
|
|
81
|
+
throw new Error(`Required claim ${key} not found`);
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
};
|
|
85
|
+
const getCborOptionalValueFromMap = (map, key) => {
|
|
86
|
+
const value = map.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)));
|
|
87
|
+
if (!value) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
return value.value;
|
|
91
|
+
};
|
|
92
|
+
export const decodeStatusListCWT = (cwt) => {
|
|
93
|
+
const encodedCbor = base64url.toBuffer(cwt);
|
|
94
|
+
const encodedCborArray = new Int8Array(encodedCbor);
|
|
95
|
+
const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray);
|
|
96
|
+
if (!(decodedCbor instanceof com.sphereon.cbor.CborArray)) {
|
|
97
|
+
throw new Error('Invalid CWT format: Expected a CBOR array');
|
|
98
|
+
}
|
|
99
|
+
const [, payload] = decodedCbor.value.asJsArrayView();
|
|
100
|
+
if (!(payload instanceof com.sphereon.cbor.CborByteString)) {
|
|
101
|
+
throw new Error('Invalid payload format: Expected a CBOR ByteString');
|
|
102
|
+
}
|
|
103
|
+
const claims = com.sphereon.cbor.Cbor.decode(payload.value);
|
|
104
|
+
if (!(claims instanceof com.sphereon.cbor.CborMap)) {
|
|
105
|
+
throw new Error('Invalid claims format: Expected a CBOR map');
|
|
106
|
+
}
|
|
107
|
+
const claimsMap = claims.value.asJsMapView();
|
|
108
|
+
const statusListMap = claimsMap.get(new com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView();
|
|
109
|
+
const bits = Number(statusListMap.get(new com.sphereon.cbor.CborString('bits')).value);
|
|
110
|
+
const decoded = new Uint8Array(statusListMap.get(new com.sphereon.cbor.CborString('lst')).value);
|
|
111
|
+
const uint8Array = inflate(decoded);
|
|
112
|
+
const rawStatusList = decompressRawStatusList(uint8Array, bits);
|
|
113
|
+
const statusList = new StatusList(rawStatusList, bits);
|
|
114
|
+
return {
|
|
115
|
+
issuer: getCborValueFromMap(claimsMap, CWT_CLAIMS.ISSUER),
|
|
116
|
+
id: getCborValueFromMap(claimsMap, CWT_CLAIMS.SUBJECT),
|
|
117
|
+
statusList,
|
|
118
|
+
iat: Number(getCborValueFromMap(claimsMap, CWT_CLAIMS.ISSUED_AT)),
|
|
119
|
+
exp: getCborOptionalValueFromMap(claimsMap, CWT_CLAIMS.EXPIRATION),
|
|
120
|
+
ttl: getCborOptionalValueFromMap(claimsMap, CWT_CLAIMS.TIME_TO_LIVE),
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=cbor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cbor.js","sourceRoot":"","sources":["../../../src/impl/encoding/cbor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,EAA4B,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAGtE,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAA;AAC9B,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAA;AAC5B,MAAM,uBAAuB,GAAI,UAAkB,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AAErF,MAAM,UAAU,GAAG;IACjB,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,C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+
import { StatusList } from '@sd-jwt/jwt-status-list';
|
|
3
|
+
export interface DecodedStatusListPayload {
|
|
4
|
+
issuer: string;
|
|
5
|
+
id: string;
|
|
6
|
+
statusList: StatusList;
|
|
7
|
+
exp?: number;
|
|
8
|
+
ttl?: number;
|
|
9
|
+
iat: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const resolveIdentifier: (context: IRequiredContext, issuer: string, keyRef?: string) => Promise<import("@sphereon/ssi-sdk-ext.identifier-resolution").ManagedIdentifierResult>;
|
|
12
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/impl/encoding/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,eAAO,MAAM,iBAAiB,YAAmB,gBAAgB,UAAU,MAAM,WAAW,MAAM,2FAOjG,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const resolveIdentifier = async (context, issuer, keyRef) => {
|
|
2
|
+
return await context.agent.identifierManagedGet({
|
|
3
|
+
identifier: issuer,
|
|
4
|
+
vmRelationship: 'assertionMethod',
|
|
5
|
+
offlineWhenNoDIDRegistered: true,
|
|
6
|
+
...(keyRef && { kmsKeyRef: keyRef }), // TODO the getDid resolver should look at this ASAP
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/impl/encoding/common.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAyB,EAAE,MAAc,EAAE,MAAe,EAAE,EAAE;IACpG,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC;QAC9C,UAAU,EAAE,MAAM;QAClB,cAAc,EAAE,iBAAiB;QACjC,0BAA0B,EAAE,IAAI;QAChC,GAAG,CAAC,MAAM,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,oDAAoD;KAC3F,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CompactJWT, JoseSignatureAlgorithm } from '@sphereon/ssi-types';
|
|
2
|
+
import { StatusList } from '@sd-jwt/jwt-status-list';
|
|
3
|
+
import { IRequiredContext, SignedStatusListData } from '../../types';
|
|
4
|
+
import { DecodedStatusListPayload } from './common';
|
|
5
|
+
import { TKeyType } from '@veramo/core';
|
|
6
|
+
export declare const createSignedJwt: (context: IRequiredContext, statusList: StatusList, issuerString: string, id: string, expiresAt?: Date, keyRef?: string) => Promise<SignedStatusListData>;
|
|
7
|
+
export declare const decodeStatusListJWT: (jwt: CompactJWT) => DecodedStatusListPayload;
|
|
8
|
+
export declare const getSigningAlgo: (type: TKeyType) => JoseSignatureAlgorithm;
|
|
9
|
+
//# sourceMappingURL=jwt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../../src/impl/encoding/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAA0B,UAAU,EAAuD,MAAM,yBAAyB,CAAA;AAGjI,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAqB,MAAM,UAAU,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAKvC,eAAO,MAAM,eAAe,YACjB,gBAAgB,cACb,UAAU,gBACR,MAAM,MAChB,MAAM,cACE,IAAI,WACP,MAAM,KACd,OAAO,CAAC,oBAAoB,CA0B9B,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAS,UAAU,KAAG,wBAkBrD,CAAA;AAED,eAAO,MAAM,cAAc,SAAU,QAAQ,KAAG,sBAa/C,CAAA"}
|