@sphereon/ssi-sdk-ext.jwt-service 0.28.1-feature.oyd.cmsm.improv.21 → 0.28.1-next.53
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 +37739 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +278 -0
- package/dist/index.d.ts +273 -8
- package/dist/index.js +37709 -30
- package/dist/index.js.map +1 -1
- package/package.json +38 -23
- package/plugin.schema.json +35838 -4811
- package/src/agent/JwtService.ts +21 -18
- package/src/functions/JWE.ts +18 -14
- package/src/functions/index.ts +36 -21
- package/src/types/IJwtService.ts +4 -4
- package/dist/agent/JwtService.d.ts +0 -17
- package/dist/agent/JwtService.d.ts.map +0 -1
- package/dist/agent/JwtService.js +0 -137
- package/dist/agent/JwtService.js.map +0 -1
- package/dist/functions/JWE.d.ts +0 -75
- package/dist/functions/JWE.d.ts.map +0 -1
- package/dist/functions/JWE.js +0 -280
- package/dist/functions/JWE.js.map +0 -1
- package/dist/functions/index.d.ts +0 -35
- package/dist/functions/index.d.ts.map +0 -1
- package/dist/functions/index.js +0 -385
- package/dist/functions/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types/IJwtService.d.ts +0 -222
- package/dist/types/IJwtService.d.ts.map +0 -1
- package/dist/types/IJwtService.js +0 -75
- package/dist/types/IJwtService.js.map +0 -1
package/dist/functions/JWE.js
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.CompactJwtEncrypter = exports.generateContentEncryptionKey = void 0;
|
|
36
|
-
exports.createJwe = createJwe;
|
|
37
|
-
exports.jweMergeHeaders = jweMergeHeaders;
|
|
38
|
-
exports.decryptJwe = decryptJwe;
|
|
39
|
-
exports.toWebCryptoCiphertext = toWebCryptoCiphertext;
|
|
40
|
-
const random_1 = require("@stablelib/random");
|
|
41
|
-
const utils_1 = require("@veramo/utils");
|
|
42
|
-
const jose = __importStar(require("jose"));
|
|
43
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
44
|
-
const IJwtService_1 = require("../types/IJwtService");
|
|
45
|
-
const generateContentEncryptionKey = (_a) => __awaiter(void 0, [_a], void 0, function* ({ alg, randomSource = random_1.defaultRandomSource, }) {
|
|
46
|
-
let length;
|
|
47
|
-
switch (alg) {
|
|
48
|
-
case 'A128GCM':
|
|
49
|
-
length = 16;
|
|
50
|
-
break;
|
|
51
|
-
case 'A192GCM':
|
|
52
|
-
length = 24;
|
|
53
|
-
break;
|
|
54
|
-
case 'A128CBC-HS256':
|
|
55
|
-
case 'A256GCM':
|
|
56
|
-
length = 32;
|
|
57
|
-
break;
|
|
58
|
-
case 'A192CBC-HS384':
|
|
59
|
-
length = 48;
|
|
60
|
-
break;
|
|
61
|
-
case 'A256CBC-HS512':
|
|
62
|
-
length = 64;
|
|
63
|
-
break;
|
|
64
|
-
default:
|
|
65
|
-
length = 32;
|
|
66
|
-
}
|
|
67
|
-
return (0, random_1.randomBytes)(length, randomSource);
|
|
68
|
-
});
|
|
69
|
-
exports.generateContentEncryptionKey = generateContentEncryptionKey;
|
|
70
|
-
function jweAssertValid(jwe) {
|
|
71
|
-
if (!(jwe.protected && jwe.iv && jwe.ciphertext && jwe.tag)) {
|
|
72
|
-
throw Error('JWE is missing properties: protected, iv, ciphertext and/or tag');
|
|
73
|
-
}
|
|
74
|
-
if (jwe.recipients) {
|
|
75
|
-
jwe.recipients.map((recipient) => {
|
|
76
|
-
if (!(recipient.header && recipient.encrypted_key)) {
|
|
77
|
-
throw Error('Malformed JWE recipients; no header and encrypted key present');
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function jweEncode({ ciphertext, tag, iv, protectedHeader, recipients, aad, unprotected, }) {
|
|
83
|
-
if (!recipients || recipients.length === 0) {
|
|
84
|
-
throw Error(`No recipient found`);
|
|
85
|
-
}
|
|
86
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (unprotected && { unprotected })), { protected: protectedHeader, iv: (0, utils_1.bytesToBase64url)(iv), ciphertext: (0, utils_1.bytesToBase64url)(ciphertext) }), (tag && { tag: (0, utils_1.bytesToBase64url)(tag) })), (aad && { aad: (0, utils_1.bytesToBase64url)(aad) })), { recipients });
|
|
87
|
-
}
|
|
88
|
-
class CompactJwtEncrypter {
|
|
89
|
-
constructor(args) {
|
|
90
|
-
if (args === null || args === void 0 ? void 0 : args.alg) {
|
|
91
|
-
this._alg = args.alg;
|
|
92
|
-
}
|
|
93
|
-
if (args === null || args === void 0 ? void 0 : args.enc) {
|
|
94
|
-
this._enc = args.enc;
|
|
95
|
-
}
|
|
96
|
-
this._keyManagementParams = args.keyManagementParams;
|
|
97
|
-
this.recipientKey = args.key;
|
|
98
|
-
this.expirationTime = args.expirationTime;
|
|
99
|
-
this.issuer = args.issuer;
|
|
100
|
-
this.audience = args.audience;
|
|
101
|
-
}
|
|
102
|
-
get enc() {
|
|
103
|
-
if (!this._enc) {
|
|
104
|
-
throw Error(`enc not set`);
|
|
105
|
-
}
|
|
106
|
-
return this._enc;
|
|
107
|
-
}
|
|
108
|
-
set enc(value) {
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
if (!IJwtService_1.JweEncs.includes(value)) {
|
|
111
|
-
throw Error(`invalid JWE enc value ${value}`);
|
|
112
|
-
}
|
|
113
|
-
this._enc = value;
|
|
114
|
-
}
|
|
115
|
-
get alg() {
|
|
116
|
-
if (!this._alg) {
|
|
117
|
-
throw Error(`alg not set`);
|
|
118
|
-
}
|
|
119
|
-
return this._alg;
|
|
120
|
-
}
|
|
121
|
-
set alg(value) {
|
|
122
|
-
// @ts-ignore
|
|
123
|
-
if (!IJwtService_1.JweAlgs.includes(value)) {
|
|
124
|
-
throw Error(`invalid JWE alg value ${value}`);
|
|
125
|
-
}
|
|
126
|
-
this._alg = value;
|
|
127
|
-
}
|
|
128
|
-
encryptCompactJWT(payload, jweProtectedHeader, aad) {
|
|
129
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
var _a, _b;
|
|
131
|
-
const protectedHeader = Object.assign(Object.assign({}, jweProtectedHeader), { alg: (_a = jweProtectedHeader.alg) !== null && _a !== void 0 ? _a : this._alg, enc: (_b = jweProtectedHeader.enc) !== null && _b !== void 0 ? _b : this._enc });
|
|
132
|
-
if (!protectedHeader.alg || !protectedHeader.enc) {
|
|
133
|
-
return Promise.reject(Error(`no 'alg' or 'enc' value set for the protected JWE header!`));
|
|
134
|
-
}
|
|
135
|
-
this.enc = protectedHeader.enc;
|
|
136
|
-
this.alg = protectedHeader.alg;
|
|
137
|
-
if (payload.exp) {
|
|
138
|
-
this.expirationTime = payload.exp;
|
|
139
|
-
}
|
|
140
|
-
if (payload.iss) {
|
|
141
|
-
this.issuer = payload.iss;
|
|
142
|
-
}
|
|
143
|
-
if (payload.aud) {
|
|
144
|
-
this.audience = payload.aud;
|
|
145
|
-
}
|
|
146
|
-
const encrypt = new jose.EncryptJWT(payload).setProtectedHeader(Object.assign(Object.assign({}, protectedHeader), { alg: this.alg, enc: this.enc }));
|
|
147
|
-
if (this._alg.startsWith('ECDH')) {
|
|
148
|
-
if (!this._keyManagementParams) {
|
|
149
|
-
return Promise.reject(Error(`ECDH requires key management params`));
|
|
150
|
-
}
|
|
151
|
-
encrypt.setKeyManagementParameters(this._keyManagementParams);
|
|
152
|
-
}
|
|
153
|
-
if (this.expirationTime !== undefined) {
|
|
154
|
-
encrypt.setExpirationTime(this.expirationTime);
|
|
155
|
-
}
|
|
156
|
-
if (this.issuer) {
|
|
157
|
-
encrypt.setIssuer(this.issuer);
|
|
158
|
-
}
|
|
159
|
-
if (this.audience) {
|
|
160
|
-
encrypt.setAudience(this.audience);
|
|
161
|
-
}
|
|
162
|
-
return yield encrypt.encrypt(this.recipientKey);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
static decryptCompactJWT(jwt, key, options) {
|
|
166
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
return yield jose.jwtDecrypt(jwt, key, options);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
encrypt(payload, jweProtectedHeader, aad) {
|
|
171
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
const jwt = yield this.encryptCompactJWT(JSON.parse(u8a.toString(payload)), jweProtectedHeader, aad);
|
|
173
|
-
const [protectedHeader, encryptedKey, ivB64, payloadB64, tagB64] = jwt.split('.');
|
|
174
|
-
//[jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.');
|
|
175
|
-
console.log(`FIXME: TO EncryptionResult`);
|
|
176
|
-
return {
|
|
177
|
-
protectedHeader,
|
|
178
|
-
tag: (0, utils_1.base64ToBytes)(tagB64),
|
|
179
|
-
ciphertext: (0, utils_1.base64ToBytes)(payloadB64),
|
|
180
|
-
iv: (0, utils_1.base64ToBytes)(ivB64),
|
|
181
|
-
recipients: [
|
|
182
|
-
Object.assign({}, (encryptedKey && { encrypted_key: encryptedKey })),
|
|
183
|
-
],
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
exports.CompactJwtEncrypter = CompactJwtEncrypter;
|
|
189
|
-
function createJwe(cleartext, encrypters, protectedHeader, aad) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
var _a, _b;
|
|
192
|
-
if (encrypters.length === 0) {
|
|
193
|
-
throw Error('JWE needs at least 1 encryptor');
|
|
194
|
-
}
|
|
195
|
-
if (encrypters.find((enc) => enc.alg === 'dir' || enc.alg === 'ECDH-ES')) {
|
|
196
|
-
if (encrypters.length !== 1) {
|
|
197
|
-
throw Error(`JWE can only do "dir" or "ECDH-ES" encryption with one key. ${encrypters.length} supplied`);
|
|
198
|
-
}
|
|
199
|
-
const encryptionResult = yield encrypters[0].encrypt(cleartext, protectedHeader, aad);
|
|
200
|
-
return jweEncode(Object.assign(Object.assign({}, encryptionResult), { aad }));
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
const tmpEnc = encrypters[0].enc;
|
|
204
|
-
if (!encrypters.reduce((acc, encrypter) => acc && encrypter.enc === tmpEnc, true)) {
|
|
205
|
-
throw new Error('invalid_argument: Incompatible encrypters passed');
|
|
206
|
-
}
|
|
207
|
-
let cek = undefined;
|
|
208
|
-
let jwe = undefined;
|
|
209
|
-
for (const encrypter of encrypters) {
|
|
210
|
-
if (!cek) {
|
|
211
|
-
const encryptionResult = yield encrypter.encrypt(cleartext, protectedHeader, aad);
|
|
212
|
-
cek = encryptionResult.cek;
|
|
213
|
-
jwe = jweEncode(Object.assign(Object.assign({}, encryptionResult), { aad }));
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
const recipient = yield ((_a = encrypter.encryptCek) === null || _a === void 0 ? void 0 : _a.call(encrypter, cek));
|
|
217
|
-
if (recipient) {
|
|
218
|
-
(_b = jwe === null || jwe === void 0 ? void 0 : jwe.recipients) === null || _b === void 0 ? void 0 : _b.push(recipient);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
if (!jwe) {
|
|
223
|
-
throw Error(`No JWE constructed`);
|
|
224
|
-
}
|
|
225
|
-
return jwe;
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Merges all headers, so we get a unified header.
|
|
231
|
-
*
|
|
232
|
-
* @param protectedHeader
|
|
233
|
-
* @param unprotectedHeader
|
|
234
|
-
* @param recipientUnprotectedHeader
|
|
235
|
-
*/
|
|
236
|
-
function jweMergeHeaders({ protectedHeader, unprotectedHeader, recipientUnprotectedHeader, }) {
|
|
237
|
-
// TODO: Check that all headers/params are disjoint!
|
|
238
|
-
const header = Object.assign(Object.assign(Object.assign({}, protectedHeader), unprotectedHeader), recipientUnprotectedHeader);
|
|
239
|
-
if (!header.alg || !header.enc) {
|
|
240
|
-
throw Error(`Either 'alg' or 'enc' are missing from the headers`);
|
|
241
|
-
}
|
|
242
|
-
return header;
|
|
243
|
-
}
|
|
244
|
-
function decryptJwe(jwe, decrypter) {
|
|
245
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
-
jweAssertValid(jwe);
|
|
247
|
-
const protectedHeader = JSON.parse((0, utils_1.decodeBase64url)(jwe.protected));
|
|
248
|
-
if ((protectedHeader === null || protectedHeader === void 0 ? void 0 : protectedHeader.enc) !== decrypter.enc) {
|
|
249
|
-
return Promise.reject(Error(`Decrypter enc '${decrypter.enc}' does not support header enc '${protectedHeader.enc}'`));
|
|
250
|
-
}
|
|
251
|
-
else if (!jwe.tag) {
|
|
252
|
-
return Promise.reject(Error(`Decrypter enc '${decrypter.enc}' does not support header enc '${protectedHeader.enc}'`));
|
|
253
|
-
}
|
|
254
|
-
const sealed = toWebCryptoCiphertext(jwe.ciphertext, jwe.tag);
|
|
255
|
-
const aad = u8a.fromString(jwe.aad ? `${jwe.protected}.${jwe.aad}` : jwe.protected);
|
|
256
|
-
let cleartext = null;
|
|
257
|
-
if (protectedHeader.alg === 'dir' && decrypter.alg === 'dir') {
|
|
258
|
-
cleartext = yield decrypter.decrypt(sealed, (0, utils_1.base64ToBytes)(jwe.iv), aad);
|
|
259
|
-
}
|
|
260
|
-
else if (!jwe.recipients || jwe.recipients.length === 0) {
|
|
261
|
-
throw Error('missing recipients for JWE');
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
for (let i = 0; !cleartext && i < jwe.recipients.length; i++) {
|
|
265
|
-
const recipient = jwe.recipients[i];
|
|
266
|
-
recipient.header = Object.assign(Object.assign({}, recipient.header), protectedHeader);
|
|
267
|
-
if (recipient.header.alg === decrypter.alg) {
|
|
268
|
-
cleartext = yield decrypter.decrypt(sealed, (0, utils_1.base64ToBytes)(jwe.iv), aad, recipient);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if (cleartext === null)
|
|
273
|
-
throw new Error('failure: Failed to decrypt');
|
|
274
|
-
return cleartext;
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
function toWebCryptoCiphertext(ciphertext, tag) {
|
|
278
|
-
return u8a.concat([(0, utils_1.base64ToBytes)(ciphertext), (0, utils_1.base64ToBytes)(tag)]);
|
|
279
|
-
}
|
|
280
|
-
//# sourceMappingURL=JWE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JWE.js","sourceRoot":"","sources":["../../src/functions/JWE.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsQA,8BAuCC;AASD,0CAgBC;AAED,gCA0BC;AAED,sDAEC;AAtWD,8CAAkF;AAClF,yCAAgF;AAChF,2CAA4B;AAG5B,iDAAkC;AAClC,sDAW6B;AAWtB,MAAM,4BAA4B,GAAG,KAMpB,EAAE,4CANyB,EACjD,GAAG,EACH,YAAY,GAAG,4BAAmB,GAInC;IACC,IAAI,MAAc,CAAA;IAClB,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,SAAS;YACZ,MAAM,GAAG,EAAE,CAAA;YACX,MAAK;QACP,KAAK,SAAS;YACZ,MAAM,GAAG,EAAE,CAAA;YACX,MAAK;QACP,KAAK,eAAe,CAAC;QACrB,KAAK,SAAS;YACZ,MAAM,GAAG,EAAE,CAAA;YACX,MAAK;QACP,KAAK,eAAe;YAClB,MAAM,GAAG,EAAE,CAAA;YACX,MAAK;QACP,KAAK,eAAe;YAClB,MAAM,GAAG,EAAE,CAAA;YACX,MAAK;QACP;YACE,MAAM,GAAG,EAAE,CAAA;IACf,CAAC;IACD,OAAO,IAAA,oBAAW,EAAC,MAAM,EAAE,YAAY,CAAC,CAAA;AAC1C,CAAC,CAAA,CAAA;AA7BY,QAAA,4BAA4B,gCA6BxC;AAiCD,SAAS,cAAc,CAAC,GAAmB;IACzC,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAA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AAC,EAAE,EAAE,CAAC;gBAC7D,MAAM,SAAS,GAAiB,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;gBACjD,SAAS,CAAC,MAAM,GAAG,gCAAK,SAAS,CAAC,MAAM,GAAK,eAAe,CAAmC,CAAA;gBAC/F,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK,SAAS,CAAC,GAAG,EAAE,CAAC;oBAC3C,SAAS,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAA,qBAAa,EAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAA;gBACpF,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,SAAS,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QACrE,OAAO,SAAS,CAAA;IAClB,CAAC;CAAA;AAED,SAAgB,qBAAqB,CAAC,UAAkB,EAAE,GAAW;IACnE,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,IAAA,qBAAa,EAAC,UAAU,CAAC,EAAE,IAAA,qBAAa,EAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ExternalIdentifierDidOpts, ExternalIdentifierX5cOpts, IIdentifierResolution, ManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
|
-
import { JWK } from '@sphereon/ssi-types';
|
|
3
|
-
import { IAgentContext } from '@veramo/core';
|
|
4
|
-
import { CreateJwsCompactArgs, CreateJwsFlattenedArgs, CreateJwsJsonArgs, IJwsValidationResult, IRequiredContext, Jws, JwsCompact, JwsHeader, JwsIdentifierMode, JwsJsonFlattened, JwsJsonGeneral, JwsJsonGeneralWithIdentifiers, PreparedJwsObject, VerifyJwsArgs } from '../types/IJwtService';
|
|
5
|
-
export declare const prepareJwsObject: (args: CreateJwsJsonArgs, context: IRequiredContext) => Promise<PreparedJwsObject>;
|
|
6
|
-
export declare const createJwsCompact: (args: CreateJwsCompactArgs, context: IRequiredContext) => Promise<JwsCompact>;
|
|
7
|
-
export declare const createJwsJsonFlattened: (args: CreateJwsFlattenedArgs, context: IRequiredContext) => Promise<JwsJsonFlattened>;
|
|
8
|
-
export declare const createJwsJsonGeneral: (args: CreateJwsJsonArgs, context: IRequiredContext) => Promise<JwsJsonGeneral>;
|
|
9
|
-
/**
|
|
10
|
-
* Updates the JWT header to include x5c, kid, jwk objects using the supplied issuer identifier that will be used to sign. If not present will automatically make the header objects available
|
|
11
|
-
* @param mode The type of header to check or include
|
|
12
|
-
* @param identifier The identifier of the signer. This identifier will be used later to sign
|
|
13
|
-
* @param header The JWT header
|
|
14
|
-
* @param noIdentifierInHeader
|
|
15
|
-
* @param context
|
|
16
|
-
*/
|
|
17
|
-
export declare const checkAndUpdateJwsHeader: ({ mode, identifier, header, noIdentifierInHeader, }: {
|
|
18
|
-
mode?: JwsIdentifierMode;
|
|
19
|
-
identifier: ManagedIdentifierResult;
|
|
20
|
-
noIdentifierInHeader?: boolean;
|
|
21
|
-
header: JwsHeader;
|
|
22
|
-
}, context: IRequiredContext) => Promise<undefined>;
|
|
23
|
-
export declare const verifyJws: (args: VerifyJwsArgs, context: IAgentContext<IIdentifierResolution>) => Promise<IJwsValidationResult>;
|
|
24
|
-
export declare const toJwsJsonGeneral: ({ jws }: {
|
|
25
|
-
jws: Jws;
|
|
26
|
-
}, context: IAgentContext<any>) => Promise<JwsJsonGeneral>;
|
|
27
|
-
export declare const toJwsJsonGeneralWithIdentifiers: (args: {
|
|
28
|
-
jws: Jws;
|
|
29
|
-
jwk?: JWK;
|
|
30
|
-
opts?: {
|
|
31
|
-
x5c?: Omit<ExternalIdentifierX5cOpts, "identifier">;
|
|
32
|
-
did?: Omit<ExternalIdentifierDidOpts, "identifier">;
|
|
33
|
-
};
|
|
34
|
-
}, context: IAgentContext<IIdentifierResolution>) => Promise<JwsJsonGeneralWithIdentifiers>;
|
|
35
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EAIrB,uBAAuB,EAExB,MAAM,6CAA6C,CAAA;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAG5C,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAKhB,GAAG,EACH,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,6BAA6B,EAI7B,iBAAiB,EACjB,aAAa,EACd,MAAM,sBAAsB,CAAA;AAQ7B,eAAO,MAAM,gBAAgB,SAAgB,iBAAiB,WAAW,gBAAgB,KAAG,OAAO,CAAC,iBAAiB,CAoCpH,CAAA;AAED,eAAO,MAAM,gBAAgB,SAAgB,oBAAoB,WAAW,gBAAgB,KAAG,OAAO,CAAC,UAAU,CAGhH,CAAA;AAED,eAAO,MAAM,sBAAsB,SAAgB,sBAAsB,WAAW,gBAAgB,KAAG,OAAO,CAAC,gBAAgB,CAS9H,CAAA;AAED,eAAO,MAAM,oBAAoB,SAAgB,iBAAiB,WAAW,gBAAgB,KAAG,OAAO,CAAC,cAAc,CA4BrH,CAAA;AAED;;;;;;;GAOG;AAEH,eAAO,MAAM,uBAAuB,wDAM/B;IACD,IAAI,CAAC,EAAE,iBAAiB,CAAA;IACxB,UAAU,EAAE,uBAAuB,CAAA;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,MAAM,EAAE,SAAS,CAAA;CAClB,WACQ,gBAAgB,uBAqB1B,CAAA;AAoID,eAAO,MAAM,SAAS,SAAgB,aAAa,WAAW,aAAa,CAAC,qBAAqB,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