@sphereon/ssi-sdk.vc-status-list 0.33.1-feature.vcdm2.tsup.31 → 0.33.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions.d.ts +69 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +200 -0
- package/dist/functions.js.map +1 -0
- package/dist/impl/IStatusList.d.ts +26 -0
- package/dist/impl/IStatusList.d.ts.map +1 -0
- package/dist/impl/IStatusList.js +3 -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 +155 -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 +186 -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 +32 -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 +140 -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 +17 -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 +74 -0
- package/dist/impl/encoding/jwt.js.map +1 -0
- package/dist/index.d.ts +3 -273
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -944
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +209 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +15 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +88 -0
- package/dist/utils.js.map +1 -0
- package/package.json +16 -26
- package/src/functions.ts +0 -2
- package/src/impl/encoding/cbor.ts +1 -1
- package/src/types/index.ts +1 -1
- package/dist/index.cjs +0 -977
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -275
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.StatusList2021Implementation = exports.DEFAULT_PROOF_FORMAT = exports.DEFAULT_LIST_LENGTH = void 0;
|
|
13
|
+
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
14
|
+
const vc_status_list_1 = require("@sphereon/vc-status-list");
|
|
15
|
+
const types_1 = require("../types");
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
exports.DEFAULT_LIST_LENGTH = 250000;
|
|
18
|
+
exports.DEFAULT_PROOF_FORMAT = 'lds';
|
|
19
|
+
class StatusList2021Implementation {
|
|
20
|
+
createNewStatusList(args, context) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const length = (_a = args === null || args === void 0 ? void 0 : args.length) !== null && _a !== void 0 ? _a : exports.DEFAULT_LIST_LENGTH;
|
|
24
|
+
const proofFormat = (_b = args === null || args === void 0 ? void 0 : args.proofFormat) !== null && _b !== void 0 ? _b : exports.DEFAULT_PROOF_FORMAT;
|
|
25
|
+
(0, utils_1.assertValidProofType)(ssi_types_1.StatusListType.StatusList2021, proofFormat);
|
|
26
|
+
const veramoProofFormat = proofFormat;
|
|
27
|
+
const { issuer, id } = args;
|
|
28
|
+
const correlationId = (0, utils_1.getAssertedValue)('correlationId', args.correlationId);
|
|
29
|
+
const list = new vc_status_list_1.StatusList({ length });
|
|
30
|
+
const encodedList = yield list.encode();
|
|
31
|
+
const statusPurpose = 'revocation';
|
|
32
|
+
const statusListCredential = yield this.createVerifiableCredential(Object.assign(Object.assign({}, args), { encodedList, proofFormat: veramoProofFormat }), context);
|
|
33
|
+
return {
|
|
34
|
+
encodedList,
|
|
35
|
+
statusListCredential: statusListCredential,
|
|
36
|
+
statusList2021: {
|
|
37
|
+
statusPurpose,
|
|
38
|
+
indexingDirection: 'rightToLeft',
|
|
39
|
+
},
|
|
40
|
+
length,
|
|
41
|
+
type: ssi_types_1.StatusListType.StatusList2021,
|
|
42
|
+
proofFormat,
|
|
43
|
+
id,
|
|
44
|
+
correlationId,
|
|
45
|
+
issuer,
|
|
46
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
updateStatusListIndex(args, context) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const credential = args.statusListCredential;
|
|
53
|
+
const uniform = ssi_types_1.CredentialMapper.toUniformCredential(credential);
|
|
54
|
+
const { issuer, credentialSubject } = uniform;
|
|
55
|
+
const id = (0, utils_1.getAssertedValue)('id', uniform.id);
|
|
56
|
+
const origEncodedList = (0, utils_1.getAssertedProperty)('encodedList', credentialSubject);
|
|
57
|
+
const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
58
|
+
const statusList = yield vc_status_list_1.StatusList.decode({ encodedList: origEncodedList });
|
|
59
|
+
statusList.setStatus(index, args.value != 0);
|
|
60
|
+
const encodedList = yield statusList.encode();
|
|
61
|
+
const proofFormat = ssi_types_1.CredentialMapper.detectDocumentType(credential) === 0 /* DocumentFormat.JWT */ ? 'jwt' : 'lds';
|
|
62
|
+
const updatedCredential = yield this.createVerifiableCredential(Object.assign(Object.assign({}, args), { id,
|
|
63
|
+
issuer,
|
|
64
|
+
encodedList, proofFormat: proofFormat }), context);
|
|
65
|
+
return {
|
|
66
|
+
statusListCredential: updatedCredential,
|
|
67
|
+
encodedList,
|
|
68
|
+
statusList2021: Object.assign(Object.assign({}, ('statusPurpose' in credentialSubject ? { statusPurpose: credentialSubject.statusPurpose } : {})), { indexingDirection: 'rightToLeft' }),
|
|
69
|
+
length: statusList.length - 1,
|
|
70
|
+
type: ssi_types_1.StatusListType.StatusList2021,
|
|
71
|
+
proofFormat: proofFormat,
|
|
72
|
+
id,
|
|
73
|
+
issuer,
|
|
74
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
updateStatusListFromEncodedList(args, context) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
if (!args.statusList2021) {
|
|
82
|
+
throw new Error('statusList2021 options required for type StatusList2021');
|
|
83
|
+
}
|
|
84
|
+
const proofFormat = (_a = args === null || args === void 0 ? void 0 : args.proofFormat) !== null && _a !== void 0 ? _a : exports.DEFAULT_PROOF_FORMAT;
|
|
85
|
+
(0, utils_1.assertValidProofType)(ssi_types_1.StatusListType.StatusList2021, proofFormat);
|
|
86
|
+
const veramoProofFormat = proofFormat;
|
|
87
|
+
const { issuer, id } = (0, utils_1.getAssertedValues)(args);
|
|
88
|
+
const statusList = yield vc_status_list_1.StatusList.decode({ encodedList: args.encodedList });
|
|
89
|
+
const index = typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
90
|
+
statusList.setStatus(index, args.value);
|
|
91
|
+
const newEncodedList = yield statusList.encode();
|
|
92
|
+
const credential = yield this.createVerifiableCredential({
|
|
93
|
+
id,
|
|
94
|
+
issuer,
|
|
95
|
+
encodedList: newEncodedList,
|
|
96
|
+
proofFormat: veramoProofFormat,
|
|
97
|
+
keyRef: args.keyRef,
|
|
98
|
+
}, context);
|
|
99
|
+
return {
|
|
100
|
+
type: ssi_types_1.StatusListType.StatusList2021,
|
|
101
|
+
statusListCredential: credential,
|
|
102
|
+
encodedList: newEncodedList,
|
|
103
|
+
statusList2021: {
|
|
104
|
+
statusPurpose: args.statusList2021.statusPurpose,
|
|
105
|
+
indexingDirection: 'rightToLeft',
|
|
106
|
+
},
|
|
107
|
+
length: statusList.length,
|
|
108
|
+
proofFormat: (_b = args.proofFormat) !== null && _b !== void 0 ? _b : 'lds',
|
|
109
|
+
id: id,
|
|
110
|
+
issuer: issuer,
|
|
111
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
checkStatusIndex(args) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const uniform = ssi_types_1.CredentialMapper.toUniformCredential(args.statusListCredential);
|
|
118
|
+
const { credentialSubject } = uniform;
|
|
119
|
+
const encodedList = (0, utils_1.getAssertedProperty)('encodedList', credentialSubject);
|
|
120
|
+
const statusList = yield vc_status_list_1.StatusList.decode({ encodedList });
|
|
121
|
+
const status = statusList.getStatus(typeof args.statusListIndex === 'number' ? args.statusListIndex : parseInt(args.statusListIndex));
|
|
122
|
+
return status ? types_1.Status2021.Invalid : types_1.Status2021.Valid;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
toStatusListDetails(args) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const { statusListPayload } = args;
|
|
128
|
+
const uniform = ssi_types_1.CredentialMapper.toUniformCredential(statusListPayload);
|
|
129
|
+
const { issuer, credentialSubject } = uniform;
|
|
130
|
+
const id = (0, utils_1.getAssertedValue)('id', uniform.id);
|
|
131
|
+
const encodedList = (0, utils_1.getAssertedProperty)('encodedList', credentialSubject);
|
|
132
|
+
const proofFormat = ssi_types_1.CredentialMapper.detectDocumentType(statusListPayload) === 0 /* DocumentFormat.JWT */ ? 'jwt' : 'lds';
|
|
133
|
+
const statusPurpose = (0, utils_1.getAssertedProperty)('statusPurpose', credentialSubject);
|
|
134
|
+
const list = yield vc_status_list_1.StatusList.decode({ encodedList });
|
|
135
|
+
return Object.assign(Object.assign({ id,
|
|
136
|
+
encodedList,
|
|
137
|
+
issuer, type: ssi_types_1.StatusListType.StatusList2021, proofFormat, length: list.length, statusListCredential: statusListPayload, statuslistContentType: this.buildContentType(proofFormat), statusList2021: {
|
|
138
|
+
indexingDirection: 'rightToLeft',
|
|
139
|
+
statusPurpose,
|
|
140
|
+
} }, (args.correlationId && { correlationId: args.correlationId })), (args.driverType && { driverType: args.driverType }));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
createVerifiableCredential(args, context) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
var _a;
|
|
146
|
+
const identifier = yield context.agent.identifierManagedGet({
|
|
147
|
+
identifier: typeof args.issuer === 'string' ? args.issuer : args.issuer.id,
|
|
148
|
+
vmRelationship: 'assertionMethod',
|
|
149
|
+
offlineWhenNoDIDRegistered: true,
|
|
150
|
+
});
|
|
151
|
+
const credential = {
|
|
152
|
+
'@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/vc/status-list/2021/v1'],
|
|
153
|
+
id: args.id,
|
|
154
|
+
issuer: args.issuer,
|
|
155
|
+
type: ['VerifiableCredential', 'StatusList2021Credential'],
|
|
156
|
+
credentialSubject: {
|
|
157
|
+
id: args.id,
|
|
158
|
+
type: 'StatusList2021',
|
|
159
|
+
statusPurpose: 'revocation',
|
|
160
|
+
encodedList: args.encodedList,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
const verifiableCredential = yield context.agent.createVerifiableCredential({
|
|
164
|
+
credential,
|
|
165
|
+
keyRef: (_a = args.keyRef) !== null && _a !== void 0 ? _a : identifier.kmsKeyRef,
|
|
166
|
+
proofFormat: args.proofFormat,
|
|
167
|
+
fetchRemoteContexts: true,
|
|
168
|
+
});
|
|
169
|
+
return ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
buildContentType(proofFormat) {
|
|
173
|
+
switch (proofFormat) {
|
|
174
|
+
case 'jwt':
|
|
175
|
+
return `application/statuslist+jwt`;
|
|
176
|
+
case 'cbor':
|
|
177
|
+
return `application/statuslist+cwt`;
|
|
178
|
+
case 'lds':
|
|
179
|
+
return 'application/statuslist+ld+json';
|
|
180
|
+
default:
|
|
181
|
+
throw Error(`Unsupported content type '${proofFormat}' for status lists`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.StatusList2021Implementation = StatusList2021Implementation;
|
|
186
|
+
//# sourceMappingURL=StatusList2021.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusList2021.js","sourceRoot":"","sources":["../../src/impl/StatusList2021.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,mDAAkI;AAElI,6DAAqD;AAErD,oCAQiB;AACjB,oCAAyG;AAE5F,QAAA,mBAAmB,GAAG,MAAM,CAAA;AAC5B,QAAA,oBAAoB,GAAG,KAA0B,CAAA;AAE9D,MAAa,4BAA4B;IACjC,mBAAmB,CACvB,IAA0B,EAC1B,OAAiE;;;YAEjE,MAAM,MAAM,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,mCAAI,2BAAmB,CAAA;YAClD,MAAM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CAAC;gBACjG,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,IAAI,EAAE,CAAC,sBAAsB,EAAE,0BAA0B,CAAC;gBAC1D,iBAAiB,EAAE;oBACjB,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,IAAI,EAAE,gBAAgB;oBACtB,aAAa,EAAE,YAAY;oBAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;iBAC9B;aACF,CAAA;YAED,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC;gBAC1E,UAAU;gBACV,MAAM,EAAE,MAAA,IAAI,CAAC,MAAM,mCAAI,UAAU,CAAC,SAAS;gBAC3C,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,mBAAmB,EAAE,IAAI;aAC1B,CAAC,CAAA;YAEF,OAAO,4BAAgB,CAAC,6BAA6B,CAAC,oBAA4C,CAAC,CAAC,QAAgC,CAAA;QACtI,CAAC;KAAA;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;AA5ND,oEA4NC"}
|
|
@@ -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,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatusListFactory = void 0;
|
|
4
|
+
exports.getStatusListImplementation = getStatusListImplementation;
|
|
5
|
+
const StatusList2021_1 = require("./StatusList2021");
|
|
6
|
+
const OAuthStatusList_1 = require("./OAuthStatusList");
|
|
7
|
+
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
8
|
+
class StatusListFactory {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.implementations = new Map();
|
|
11
|
+
this.implementations.set(ssi_types_1.StatusListType.StatusList2021, new StatusList2021_1.StatusList2021Implementation());
|
|
12
|
+
this.implementations.set(ssi_types_1.StatusListType.OAuthStatusList, new OAuthStatusList_1.OAuthStatusListImplementation());
|
|
13
|
+
}
|
|
14
|
+
static getInstance() {
|
|
15
|
+
if (!StatusListFactory.instance) {
|
|
16
|
+
StatusListFactory.instance = new StatusListFactory();
|
|
17
|
+
}
|
|
18
|
+
return StatusListFactory.instance;
|
|
19
|
+
}
|
|
20
|
+
getByType(type) {
|
|
21
|
+
const statusList = this.implementations.get(type);
|
|
22
|
+
if (!statusList) {
|
|
23
|
+
throw new Error(`No implementation found for status list type: ${type}`);
|
|
24
|
+
}
|
|
25
|
+
return statusList;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.StatusListFactory = StatusListFactory;
|
|
29
|
+
function getStatusListImplementation(type) {
|
|
30
|
+
return StatusListFactory.getInstance().getByType(type);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=StatusListFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusListFactory.js","sourceRoot":"","sources":["../../src/impl/StatusListFactory.ts"],"names":[],"mappings":";;;AA+BA,kEAEC;AAhCD,qDAA+D;AAC/D,uDAAiE;AACjE,mDAAoD;AAEpD,MAAa,iBAAiB;IAI5B;QACE,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAA;QAChC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,0BAAc,CAAC,cAAc,EAAE,IAAI,6CAA4B,EAAE,CAAC,CAAA;QAC3F,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,0BAAc,CAAC,eAAe,EAAE,IAAI,+CAA6B,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;AAxBD,8CAwBC;AAED,SAAgB,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,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.decodeStatusListCWT = exports.createSignedCbor = void 0;
|
|
16
|
+
const jwt_status_list_1 = require("@sd-jwt/jwt-status-list");
|
|
17
|
+
const pako_1 = require("pako");
|
|
18
|
+
const kmp_cbor_1 = require("@sphereon/kmp-cbor");
|
|
19
|
+
const base64url_1 = __importDefault(require("base64url"));
|
|
20
|
+
const common_1 = require("./common");
|
|
21
|
+
const cbor = kmp_cbor_1.com.sphereon.cbor;
|
|
22
|
+
const kmp = kmp_cbor_1.com.sphereon.kmp;
|
|
23
|
+
const decompressRawStatusList = jwt_status_list_1.StatusList.decodeStatusList.bind(jwt_status_list_1.StatusList);
|
|
24
|
+
const CWT_CLAIMS = {
|
|
25
|
+
SUBJECT: 2,
|
|
26
|
+
ISSUER: 1,
|
|
27
|
+
ISSUED_AT: 6,
|
|
28
|
+
EXPIRATION: 4,
|
|
29
|
+
TIME_TO_LIVE: 65534,
|
|
30
|
+
STATUS_LIST: 65533,
|
|
31
|
+
};
|
|
32
|
+
const createSignedCbor = (context, statusList, issuerString, id, expiresAt, keyRef) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const identifier = yield (0, common_1.resolveIdentifier)(context, issuerString, keyRef);
|
|
34
|
+
const encodeStatusList = statusList.encodeStatusList();
|
|
35
|
+
const compressedList = (0, pako_1.deflate)(encodeStatusList, { level: 9 });
|
|
36
|
+
const compressedBytes = new Int8Array(compressedList);
|
|
37
|
+
const statusListMap = new cbor.CborMap(kmp_cbor_1.kotlin.collections.KtMutableMap.fromJsMap(new Map([
|
|
38
|
+
[new cbor.CborString('bits'), new cbor.CborUInt(kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))],
|
|
39
|
+
[new cbor.CborString('lst'), new cbor.CborByteString(compressedBytes)],
|
|
40
|
+
])));
|
|
41
|
+
const protectedHeader = new cbor.CborMap(kmp_cbor_1.kotlin.collections.KtMutableMap.fromJsMap(new Map([[new cbor.CborUInt(kmp.LongKMP.fromNumber(16)), new cbor.CborString('statuslist+cwt')]])));
|
|
42
|
+
const protectedHeaderEncoded = cbor.Cbor.encode(protectedHeader);
|
|
43
|
+
const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt);
|
|
44
|
+
const claimsEncoded = cbor.Cbor.encode(claimsMap);
|
|
45
|
+
const signedCWT = yield context.agent.keyManagerSign({
|
|
46
|
+
keyRef: identifier.kmsKeyRef,
|
|
47
|
+
data: base64url_1.default.encode(Buffer.from(claimsEncoded)), // TODO test on RN
|
|
48
|
+
encoding: undefined,
|
|
49
|
+
});
|
|
50
|
+
const protectedHeaderEncodedInt8 = new Int8Array(protectedHeaderEncoded);
|
|
51
|
+
const claimsEncodedInt8 = new Int8Array(claimsEncoded);
|
|
52
|
+
const signatureBytes = base64url_1.default.decode(signedCWT);
|
|
53
|
+
const signatureInt8 = new Int8Array(Buffer.from(signatureBytes));
|
|
54
|
+
const cwtArrayElements = [
|
|
55
|
+
new cbor.CborByteString(protectedHeaderEncodedInt8),
|
|
56
|
+
new cbor.CborByteString(claimsEncodedInt8),
|
|
57
|
+
new cbor.CborByteString(signatureInt8),
|
|
58
|
+
];
|
|
59
|
+
const cwtArray = new cbor.CborArray(kmp_cbor_1.kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements));
|
|
60
|
+
const cwtEncoded = cbor.Cbor.encode(cwtArray);
|
|
61
|
+
const cwtBuffer = Buffer.from(cwtEncoded);
|
|
62
|
+
return {
|
|
63
|
+
statusListCredential: base64url_1.default.encode(cwtBuffer),
|
|
64
|
+
encodedList: base64url_1.default.encode(compressedList), // JS in @sd-jwt/jwt-status-list drops it in like this, so keep the same method
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
exports.createSignedCbor = createSignedCbor;
|
|
68
|
+
function buildClaimsMap(id, issuerString, statusListMap, expiresAt) {
|
|
69
|
+
const ttl = 65535; // FIXME figure out what value should be / come from and what the difference is with exp
|
|
70
|
+
const claimsEntries = [
|
|
71
|
+
[new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)), new cbor.CborString(id)], // "sub"
|
|
72
|
+
[new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)), new cbor.CborString(issuerString)], // "iss"
|
|
73
|
+
[
|
|
74
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),
|
|
75
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1000))), // "iat"
|
|
76
|
+
],
|
|
77
|
+
];
|
|
78
|
+
if (expiresAt) {
|
|
79
|
+
claimsEntries.push([
|
|
80
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),
|
|
81
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1000))), // "exp"
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
if (ttl) {
|
|
85
|
+
claimsEntries.push([
|
|
86
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),
|
|
87
|
+
new cbor.CborUInt(kmp.LongKMP.fromNumber(ttl)), // "time to live"
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
claimsEntries.push([new cbor.CborUInt(kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)), statusListMap]);
|
|
91
|
+
const claimsMap = new cbor.CborMap(kmp_cbor_1.kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)));
|
|
92
|
+
return claimsMap;
|
|
93
|
+
}
|
|
94
|
+
const getCborValueFromMap = (map, key) => {
|
|
95
|
+
const value = getCborOptionalValueFromMap(map, key);
|
|
96
|
+
if (value === undefined) {
|
|
97
|
+
throw new Error(`Required claim ${key} not found`);
|
|
98
|
+
}
|
|
99
|
+
return value;
|
|
100
|
+
};
|
|
101
|
+
const getCborOptionalValueFromMap = (map, key) => {
|
|
102
|
+
const value = map.get(new kmp_cbor_1.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(key)));
|
|
103
|
+
if (!value) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
return value.value;
|
|
107
|
+
};
|
|
108
|
+
const decodeStatusListCWT = (cwt) => {
|
|
109
|
+
const encodedCbor = base64url_1.default.toBuffer(cwt);
|
|
110
|
+
const encodedCborArray = new Int8Array(encodedCbor);
|
|
111
|
+
const decodedCbor = kmp_cbor_1.com.sphereon.cbor.Cbor.decode(encodedCborArray);
|
|
112
|
+
if (!(decodedCbor instanceof kmp_cbor_1.com.sphereon.cbor.CborArray)) {
|
|
113
|
+
throw new Error('Invalid CWT format: Expected a CBOR array');
|
|
114
|
+
}
|
|
115
|
+
const [, payload] = decodedCbor.value.asJsArrayView();
|
|
116
|
+
if (!(payload instanceof kmp_cbor_1.com.sphereon.cbor.CborByteString)) {
|
|
117
|
+
throw new Error('Invalid payload format: Expected a CBOR ByteString');
|
|
118
|
+
}
|
|
119
|
+
const claims = kmp_cbor_1.com.sphereon.cbor.Cbor.decode(payload.value);
|
|
120
|
+
if (!(claims instanceof kmp_cbor_1.com.sphereon.cbor.CborMap)) {
|
|
121
|
+
throw new Error('Invalid claims format: Expected a CBOR map');
|
|
122
|
+
}
|
|
123
|
+
const claimsMap = claims.value.asJsMapView();
|
|
124
|
+
const statusListMap = claimsMap.get(new kmp_cbor_1.com.sphereon.cbor.CborUInt(kmp.LongKMP.fromNumber(65533))).value.asJsMapView();
|
|
125
|
+
const bits = Number(statusListMap.get(new kmp_cbor_1.com.sphereon.cbor.CborString('bits')).value);
|
|
126
|
+
const decoded = new Uint8Array(statusListMap.get(new kmp_cbor_1.com.sphereon.cbor.CborString('lst')).value);
|
|
127
|
+
const uint8Array = (0, pako_1.inflate)(decoded);
|
|
128
|
+
const rawStatusList = decompressRawStatusList(uint8Array, bits);
|
|
129
|
+
const statusList = new jwt_status_list_1.StatusList(rawStatusList, bits);
|
|
130
|
+
return {
|
|
131
|
+
issuer: getCborValueFromMap(claimsMap, CWT_CLAIMS.ISSUER),
|
|
132
|
+
id: getCborValueFromMap(claimsMap, CWT_CLAIMS.SUBJECT),
|
|
133
|
+
statusList,
|
|
134
|
+
iat: Number(getCborValueFromMap(claimsMap, CWT_CLAIMS.ISSUED_AT)),
|
|
135
|
+
exp: getCborOptionalValueFromMap(claimsMap, CWT_CLAIMS.EXPIRATION),
|
|
136
|
+
ttl: getCborOptionalValueFromMap(claimsMap, CWT_CLAIMS.TIME_TO_LIVE),
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
exports.decodeStatusListCWT = decodeStatusListCWT;
|
|
140
|
+
//# sourceMappingURL=cbor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cbor.js","sourceRoot":"","sources":["../../../src/impl/encoding/cbor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAoD;AACpD,+BAAuC;AACvC,iDAAgD;AAChD,0DAAiC;AAEjC,qCAAsE;AAGtE,MAAM,IAAI,GAAG,cAAG,CAAC,QAAQ,CAAC,IAAI,CAAA;AAC9B,MAAM,GAAG,GAAG,cAAG,CAAC,QAAQ,CAAC,GAAG,CAAA;AAC5B,MAAM,uBAAuB,GAAI,4BAAkB,CAAC,gBAAgB,CAAC,IAAI,CAAC,4BAAU,CAAC,CAAA;AAErF,MAAM,UAAU,GAAG;IACjB,OAAO,EAAE,CAAC;IACV,MAAM,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qC/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IRequiredContext } from '../../types';
|
|
2
|
+
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,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.resolveIdentifier = void 0;
|
|
13
|
+
const resolveIdentifier = (context, issuer, keyRef) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
return yield context.agent.identifierManagedGet(Object.assign({ identifier: issuer, vmRelationship: 'assertionMethod', offlineWhenNoDIDRegistered: true }, (keyRef && { kmsKeyRef: keyRef })));
|
|
15
|
+
});
|
|
16
|
+
exports.resolveIdentifier = resolveIdentifier;
|
|
17
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/impl/encoding/common.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYO,MAAM,iBAAiB,GAAG,CAAO,OAAyB,EAAE,MAAc,EAAE,MAAe,EAAE,EAAE;IACpG,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,oBAAoB,iBAC7C,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,iBAAiB,EACjC,0BAA0B,EAAE,IAAI,IAC7B,CAAC,MAAM,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EACpC,CAAA;AACJ,CAAC,CAAA,CAAA;AAPY,QAAA,iBAAiB,qBAO7B"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getSigningAlgo = exports.decodeStatusListJWT = exports.createSignedJwt = void 0;
|
|
16
|
+
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
17
|
+
const jwt_status_list_1 = require("@sd-jwt/jwt-status-list");
|
|
18
|
+
const base64url_1 = __importDefault(require("base64url"));
|
|
19
|
+
const common_1 = require("./common");
|
|
20
|
+
const ssi_sdk_ext_identifier_resolution_1 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
|
|
21
|
+
const STATUS_LIST_JWT_TYP = 'statuslist+jwt';
|
|
22
|
+
const createSignedJwt = (context, statusList, issuerString, id, expiresAt, keyRef) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const identifier = yield (0, common_1.resolveIdentifier)(context, issuerString, keyRef);
|
|
24
|
+
const resolution = yield (0, ssi_sdk_ext_identifier_resolution_1.ensureManagedIdentifierResult)(identifier, context);
|
|
25
|
+
const payload = Object.assign({ iss: issuerString, sub: id, iat: Math.floor(Date.now() / 1000) }, (expiresAt && { exp: Math.floor(expiresAt.getTime() / 1000) }));
|
|
26
|
+
const header = {
|
|
27
|
+
alg: (0, exports.getSigningAlgo)(resolution.key.type),
|
|
28
|
+
typ: STATUS_LIST_JWT_TYP,
|
|
29
|
+
};
|
|
30
|
+
const values = (0, jwt_status_list_1.createHeaderAndPayload)(statusList, payload, header);
|
|
31
|
+
const signedJwt = yield context.agent.jwtCreateJwsCompactSignature({
|
|
32
|
+
issuer: Object.assign(Object.assign({}, identifier), { noIssPayloadUpdate: false }),
|
|
33
|
+
protectedHeader: values.header,
|
|
34
|
+
payload: values.payload,
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
statusListCredential: signedJwt.jwt,
|
|
38
|
+
encodedList: values.payload.status_list.lst,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
exports.createSignedJwt = createSignedJwt;
|
|
42
|
+
const decodeStatusListJWT = (jwt) => {
|
|
43
|
+
const [, payloadBase64] = jwt.split('.');
|
|
44
|
+
const payload = JSON.parse(base64url_1.default.decode(payloadBase64));
|
|
45
|
+
if (!payload.iss || !payload.sub || !payload.status_list) {
|
|
46
|
+
throw new Error('Missing required fields in JWT payload');
|
|
47
|
+
}
|
|
48
|
+
const statusList = jwt_status_list_1.StatusList.decompressStatusList(payload.status_list.lst, payload.status_list.bits);
|
|
49
|
+
return {
|
|
50
|
+
issuer: payload.iss,
|
|
51
|
+
id: payload.sub,
|
|
52
|
+
statusList,
|
|
53
|
+
exp: payload.exp,
|
|
54
|
+
ttl: payload.ttl,
|
|
55
|
+
iat: payload.iat,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
exports.decodeStatusListJWT = decodeStatusListJWT;
|
|
59
|
+
const getSigningAlgo = (type) => {
|
|
60
|
+
switch (type) {
|
|
61
|
+
case 'Ed25519':
|
|
62
|
+
return ssi_types_1.JoseSignatureAlgorithm.EdDSA;
|
|
63
|
+
case 'Secp256k1':
|
|
64
|
+
return ssi_types_1.JoseSignatureAlgorithm.ES256K;
|
|
65
|
+
case 'Secp256r1':
|
|
66
|
+
return ssi_types_1.JoseSignatureAlgorithm.ES256;
|
|
67
|
+
case 'RSA':
|
|
68
|
+
return ssi_types_1.JoseSignatureAlgorithm.RS256;
|
|
69
|
+
default:
|
|
70
|
+
throw Error('Key type not yet supported');
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.getSigningAlgo = getSigningAlgo;
|
|
74
|
+
//# sourceMappingURL=jwt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.js","sourceRoot":"","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