@sphereon/ssi-sdk-ext.jwt-service 0.28.1-feature.esm.cjs.8 → 0.28.1-feature.esm.cjs.9
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 +93 -121
- package/dist/index.cjs.map +1 -1
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -1,40 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
|
|
5
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
4
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
5
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
6
|
};
|
|
12
|
-
var __export = (target, all) => {
|
|
13
|
-
for (var name in all)
|
|
14
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
32
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
7
|
|
|
34
8
|
// plugin.schema.json
|
|
35
9
|
var require_plugin_schema = __commonJS({
|
|
36
|
-
"plugin.schema.json"(exports,
|
|
37
|
-
|
|
10
|
+
"plugin.schema.json"(exports, module) {
|
|
11
|
+
module.exports = {
|
|
38
12
|
IJwtService: {
|
|
39
13
|
components: {
|
|
40
14
|
schemas: {
|
|
@@ -14131,50 +14105,20 @@ var require_plugin_schema = __commonJS({
|
|
|
14131
14105
|
});
|
|
14132
14106
|
|
|
14133
14107
|
// src/index.ts
|
|
14134
|
-
var
|
|
14135
|
-
__export(index_exports, {
|
|
14136
|
-
COMPACT_JWE_REGEX: () => COMPACT_JWE_REGEX,
|
|
14137
|
-
COMPACT_JWS_REGEX: () => COMPACT_JWS_REGEX,
|
|
14138
|
-
JweAlgs: () => JweAlgs,
|
|
14139
|
-
JweEncs: () => JweEncs,
|
|
14140
|
-
JwtLogger: () => JwtLogger,
|
|
14141
|
-
JwtService: () => JwtService,
|
|
14142
|
-
checkAndUpdateJwsHeader: () => checkAndUpdateJwsHeader,
|
|
14143
|
-
createJwsCompact: () => createJwsCompact,
|
|
14144
|
-
createJwsJsonFlattened: () => createJwsJsonFlattened,
|
|
14145
|
-
createJwsJsonGeneral: () => createJwsJsonGeneral,
|
|
14146
|
-
isJweCompact: () => isJweCompact,
|
|
14147
|
-
isJweHeader: () => isJweHeader,
|
|
14148
|
-
isJweJsonFlattened: () => isJweJsonFlattened,
|
|
14149
|
-
isJweJsonGeneral: () => isJweJsonGeneral,
|
|
14150
|
-
isJwsCompact: () => isJwsCompact,
|
|
14151
|
-
isJwsHeader: () => isJwsHeader,
|
|
14152
|
-
isJwsJsonFlattened: () => isJwsJsonFlattened,
|
|
14153
|
-
isJwsJsonGeneral: () => isJwsJsonGeneral,
|
|
14154
|
-
jweAlg: () => jweAlg,
|
|
14155
|
-
jweEnc: () => jweEnc,
|
|
14156
|
-
jwtServiceContextMethods: () => jwtServiceContextMethods,
|
|
14157
|
-
prepareJwsObject: () => prepareJwsObject,
|
|
14158
|
-
schema: () => schema,
|
|
14159
|
-
toJwsJsonGeneral: () => toJwsJsonGeneral,
|
|
14160
|
-
toJwsJsonGeneralWithIdentifiers: () => toJwsJsonGeneralWithIdentifiers,
|
|
14161
|
-
verifyJws: () => verifyJws
|
|
14162
|
-
});
|
|
14163
|
-
module.exports = __toCommonJS(index_exports);
|
|
14164
|
-
var import_ssi_types = require("@sphereon/ssi-types");
|
|
14108
|
+
var _ssitypes = require('@sphereon/ssi-types');
|
|
14165
14109
|
|
|
14166
14110
|
// src/agent/JwtService.ts
|
|
14167
|
-
var
|
|
14168
|
-
var
|
|
14169
|
-
var
|
|
14111
|
+
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14112
|
+
var _jose = require('jose'); var jose = _interopRequireWildcard(_jose);
|
|
14113
|
+
var _fromstring = require('uint8arrays/from-string');
|
|
14170
14114
|
|
|
14171
14115
|
// src/functions/JWE.ts
|
|
14172
|
-
var
|
|
14173
|
-
var
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
var
|
|
14177
|
-
var
|
|
14116
|
+
var _random = require('@stablelib/random');
|
|
14117
|
+
var _utils = require('@veramo/utils');
|
|
14118
|
+
|
|
14119
|
+
|
|
14120
|
+
var _tostring = require('uint8arrays/to-string');
|
|
14121
|
+
var _concat = require('uint8arrays/concat');
|
|
14178
14122
|
|
|
14179
14123
|
// src/types/IJwtService.ts
|
|
14180
14124
|
var jwtServiceContextMethods = [
|
|
@@ -14262,18 +14206,18 @@ var CompactJwtEncrypter = class {
|
|
|
14262
14206
|
static {
|
|
14263
14207
|
__name(this, "CompactJwtEncrypter");
|
|
14264
14208
|
}
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14209
|
+
|
|
14210
|
+
|
|
14211
|
+
|
|
14212
|
+
|
|
14213
|
+
|
|
14214
|
+
|
|
14215
|
+
|
|
14272
14216
|
constructor(args) {
|
|
14273
|
-
if (args
|
|
14217
|
+
if (_optionalChain([args, 'optionalAccess', _ => _.alg])) {
|
|
14274
14218
|
this._alg = args.alg;
|
|
14275
14219
|
}
|
|
14276
|
-
if (args
|
|
14220
|
+
if (_optionalChain([args, 'optionalAccess', _2 => _2.enc])) {
|
|
14277
14221
|
this._enc = args.enc;
|
|
14278
14222
|
}
|
|
14279
14223
|
this._keyManagementParams = args.keyManagementParams;
|
|
@@ -14309,8 +14253,8 @@ var CompactJwtEncrypter = class {
|
|
|
14309
14253
|
async encryptCompactJWT(payload, jweProtectedHeader, aad) {
|
|
14310
14254
|
const protectedHeader = {
|
|
14311
14255
|
...jweProtectedHeader,
|
|
14312
|
-
alg: jweProtectedHeader.alg
|
|
14313
|
-
enc: jweProtectedHeader.enc
|
|
14256
|
+
alg: _nullishCoalesce(jweProtectedHeader.alg, () => ( this._alg)),
|
|
14257
|
+
enc: _nullishCoalesce(jweProtectedHeader.enc, () => ( this._enc))
|
|
14314
14258
|
};
|
|
14315
14259
|
if (!protectedHeader.alg || !protectedHeader.enc) {
|
|
14316
14260
|
return Promise.reject(Error(`no 'alg' or 'enc' value set for the protected JWE header!`));
|
|
@@ -14352,14 +14296,14 @@ var CompactJwtEncrypter = class {
|
|
|
14352
14296
|
return await jose.jwtDecrypt(jwt, key, options);
|
|
14353
14297
|
}
|
|
14354
14298
|
async encrypt(payload, jweProtectedHeader, aad) {
|
|
14355
|
-
const jwt = await this.encryptCompactJWT(JSON.parse((0,
|
|
14299
|
+
const jwt = await this.encryptCompactJWT(JSON.parse(_tostring.toString.call(void 0, payload)), jweProtectedHeader, aad);
|
|
14356
14300
|
const [protectedHeader, encryptedKey, ivB64, payloadB64, tagB64] = jwt.split(".");
|
|
14357
14301
|
console.log(`FIXME: TO EncryptionResult`);
|
|
14358
14302
|
return {
|
|
14359
14303
|
protectedHeader,
|
|
14360
|
-
tag: (0,
|
|
14361
|
-
ciphertext: (0,
|
|
14362
|
-
iv: (0,
|
|
14304
|
+
tag: _utils.base64ToBytes.call(void 0, tagB64),
|
|
14305
|
+
ciphertext: _utils.base64ToBytes.call(void 0, payloadB64),
|
|
14306
|
+
iv: _utils.base64ToBytes.call(void 0, ivB64),
|
|
14363
14307
|
recipients: [
|
|
14364
14308
|
{
|
|
14365
14309
|
//fixme
|
|
@@ -14374,12 +14318,12 @@ var CompactJwtEncrypter = class {
|
|
|
14374
14318
|
};
|
|
14375
14319
|
|
|
14376
14320
|
// src/agent/JwtService.ts
|
|
14377
|
-
var JwtService = class {
|
|
14321
|
+
var JwtService = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
|
|
14378
14322
|
static {
|
|
14379
14323
|
__name(this, "JwtService");
|
|
14380
14324
|
}
|
|
14381
|
-
schema = schema.IJwtService
|
|
14382
|
-
methods = {
|
|
14325
|
+
__init() {this.schema = exports.schema = schema.IJwtService}
|
|
14326
|
+
__init2() {this.methods = {
|
|
14383
14327
|
jwtPrepareJws: this.jwtPrepareJws.bind(this),
|
|
14384
14328
|
jwtCreateJwsJsonGeneralSignature: this.jwtCreateJwsJsonGeneralSignature.bind(this),
|
|
14385
14329
|
jwtCreateJwsJsonFlattenedSignature: this.jwtCreateJwsJsonFlattenedSignature.bind(this),
|
|
@@ -14387,7 +14331,7 @@ var JwtService = class {
|
|
|
14387
14331
|
jwtVerifyJwsSignature: this.jwtVerifyJwsSignature.bind(this),
|
|
14388
14332
|
jwtEncryptJweCompactJwt: this.jwtEncryptJweCompactJwt.bind(this),
|
|
14389
14333
|
jwtDecryptJweCompactJwt: this.jwtDecryptJweCompactJwt.bind(this)
|
|
14390
|
-
}
|
|
14334
|
+
}}
|
|
14391
14335
|
async jwtPrepareJws(args, context) {
|
|
14392
14336
|
return await prepareJwsObject(args, context);
|
|
14393
14337
|
}
|
|
@@ -14411,9 +14355,9 @@ var JwtService = class {
|
|
|
14411
14355
|
enc: args.enc
|
|
14412
14356
|
}, recipientKey, issuer, expirationTime, audience } = args;
|
|
14413
14357
|
try {
|
|
14414
|
-
(0,
|
|
14415
|
-
const alg = jweAlg(args.alg)
|
|
14416
|
-
const enc = jweEnc(args.enc)
|
|
14358
|
+
_debug2.default.call(void 0, `JWE Encrypt: ${JSON.stringify(args, null, 2)}`);
|
|
14359
|
+
const alg = _nullishCoalesce(_nullishCoalesce(jweAlg(args.alg), () => ( jweAlg(protectedHeader.alg))), () => ( "ECDH-ES"));
|
|
14360
|
+
const enc = _nullishCoalesce(_nullishCoalesce(jweEnc(args.enc), () => ( jweEnc(protectedHeader.enc))), () => ( "A256GCM"));
|
|
14417
14361
|
const encJwks = recipientKey.jwks.length === 1 ? [
|
|
14418
14362
|
recipientKey.jwks[0]
|
|
14419
14363
|
] : recipientKey.jwks.filter((jwk) => jwk.kid && (jwk.kid === jwk.jwk.kid || jwk.kid === jwk.jwkThumbprint) || jwk.jwk.use === "enc");
|
|
@@ -14424,14 +14368,14 @@ var JwtService = class {
|
|
|
14424
14368
|
if (encJwks.length > 0) {
|
|
14425
14369
|
JwtLogger.warning(`More than one JWK with 'enc' usage found. Selected the first one as no 'kid' was provided`, encJwks);
|
|
14426
14370
|
}
|
|
14427
|
-
if (jwkInfo.jwk.kty
|
|
14371
|
+
if (_optionalChain([jwkInfo, 'access', _3 => _3.jwk, 'access', _4 => _4.kty, 'optionalAccess', _5 => _5.startsWith, 'call', _6 => _6("EC")]) !== true || !alg.startsWith("ECDH")) {
|
|
14428
14372
|
return Promise.reject(Error(`Currently only ECDH-ES is supported for encryption. JWK alg ${jwkInfo.jwk.kty}, header alg ${alg}`));
|
|
14429
14373
|
}
|
|
14430
|
-
const apuVal = protectedHeader.apu
|
|
14431
|
-
const apu = apuVal ? (0,
|
|
14432
|
-
const apvVal = protectedHeader.apv
|
|
14433
|
-
const apv = apvVal ? (0,
|
|
14434
|
-
const pubKey = await (0,
|
|
14374
|
+
const apuVal = _nullishCoalesce(protectedHeader.apu, () => ( args.apu));
|
|
14375
|
+
const apu = apuVal ? _fromstring.fromString.call(void 0, apuVal, "base64url") : void 0;
|
|
14376
|
+
const apvVal = _nullishCoalesce(protectedHeader.apv, () => ( args.apv));
|
|
14377
|
+
const apv = apvVal ? _fromstring.fromString.call(void 0, apvVal, "base64url") : void 0;
|
|
14378
|
+
const pubKey = await _jose.importJWK.call(void 0, jwkInfo.jwk);
|
|
14435
14379
|
const encrypter = new CompactJwtEncrypter({
|
|
14436
14380
|
enc,
|
|
14437
14381
|
alg,
|
|
@@ -14458,22 +14402,22 @@ var JwtService = class {
|
|
|
14458
14402
|
jwt: "FIXME"
|
|
14459
14403
|
};
|
|
14460
14404
|
}
|
|
14461
|
-
};
|
|
14405
|
+
}, _class);
|
|
14462
14406
|
|
|
14463
14407
|
// src/functions/index.ts
|
|
14464
|
-
var
|
|
14465
|
-
var
|
|
14466
|
-
|
|
14467
|
-
|
|
14408
|
+
var _ssisdkextidentifierresolution = require('@sphereon/ssi-sdk-ext.identifier-resolution');
|
|
14409
|
+
var _ssisdkextkeyutils = require('@sphereon/ssi-sdk-ext.key-utils');
|
|
14410
|
+
|
|
14411
|
+
|
|
14468
14412
|
var payloadToBytes = /* @__PURE__ */ __name((payload) => {
|
|
14469
14413
|
const isBytes = payload instanceof Uint8Array;
|
|
14470
14414
|
const isString = typeof payload === "string";
|
|
14471
|
-
return isBytes ? payload : isString ? (0,
|
|
14415
|
+
return isBytes ? payload : isString ? _fromstring.fromString.call(void 0, payload, "base64url") : _fromstring.fromString.call(void 0, JSON.stringify(payload), "utf-8");
|
|
14472
14416
|
}, "payloadToBytes");
|
|
14473
14417
|
var prepareJwsObject = /* @__PURE__ */ __name(async (args, context) => {
|
|
14474
14418
|
const { existingSignatures, protectedHeader, unprotectedHeader, issuer, payload, mode = "auto", clientId, clientIdScheme } = args;
|
|
14475
14419
|
const { noIdentifierInHeader = false } = issuer;
|
|
14476
|
-
const identifier = await (0,
|
|
14420
|
+
const identifier = await _ssisdkextidentifierresolution.ensureManagedIdentifierResult.call(void 0, issuer, context);
|
|
14477
14421
|
await checkAndUpdateJwsHeader({
|
|
14478
14422
|
mode,
|
|
14479
14423
|
identifier,
|
|
@@ -14494,8 +14438,8 @@ var prepareJwsObject = /* @__PURE__ */ __name(async (args, context) => {
|
|
|
14494
14438
|
}
|
|
14495
14439
|
}
|
|
14496
14440
|
const payloadBytes = payloadToBytes(payload);
|
|
14497
|
-
const base64urlHeader = (0,
|
|
14498
|
-
const base64urlPayload = (0,
|
|
14441
|
+
const base64urlHeader = _utils.encodeJoseBlob.call(void 0, protectedHeader);
|
|
14442
|
+
const base64urlPayload = _utils.bytesToBase64url.call(void 0, payloadBytes);
|
|
14499
14443
|
return {
|
|
14500
14444
|
jws: {
|
|
14501
14445
|
unprotectedHeader,
|
|
@@ -14547,7 +14491,7 @@ var createJwsJsonGeneral = /* @__PURE__ */ __name(async (args, context) => {
|
|
|
14547
14491
|
return {
|
|
14548
14492
|
payload: b64.payload,
|
|
14549
14493
|
signatures: [
|
|
14550
|
-
...existingSignatures
|
|
14494
|
+
..._nullishCoalesce(existingSignatures, () => ( [])),
|
|
14551
14495
|
jsonSignature
|
|
14552
14496
|
]
|
|
14553
14497
|
};
|
|
@@ -14591,7 +14535,7 @@ var checkAndUpdateX5cHeader = /* @__PURE__ */ __name(async ({ header, identifier
|
|
|
14591
14535
|
return Promise.reject(Error(`An x5c header was present, but its issuer public key did not match the provided signing public key!`));
|
|
14592
14536
|
}
|
|
14593
14537
|
} else if (!noIdentifierInHeader) {
|
|
14594
|
-
if (!(0,
|
|
14538
|
+
if (!_ssisdkextidentifierresolution.isManagedIdentifierX5cResult.call(void 0, identifier)) {
|
|
14595
14539
|
return Promise.reject(Error("No x5c header in the JWT, but mode was x5c and also no x5x identifier was provided!"));
|
|
14596
14540
|
} else if (header.jwk || header.kid) {
|
|
14597
14541
|
return Promise.reject(Error("x5c mode was choosen, but jwk or kid headers were provided. These cannot be used together!"));
|
|
@@ -14609,7 +14553,7 @@ var checkAndUpdateDidHeader = /* @__PURE__ */ __name(async ({ header, identifier
|
|
|
14609
14553
|
return Promise.reject(Error(`A kid header was present, but its value did not match the provided signing kid!`));
|
|
14610
14554
|
}
|
|
14611
14555
|
} else if (!noIdentifierInHeader) {
|
|
14612
|
-
if (!(0,
|
|
14556
|
+
if (!_ssisdkextidentifierresolution.isManagedIdentifierDidResult.call(void 0, identifier)) {
|
|
14613
14557
|
return Promise.reject(Error("No kid header in the JWT, but mode was did and also no DID identifier was provided!"));
|
|
14614
14558
|
} else if (header.jwk || header.x5c) {
|
|
14615
14559
|
return Promise.reject(Error("did mode was chosen, but jwk or x5c headers were provided. These cannot be used together!"));
|
|
@@ -14668,10 +14612,10 @@ var verifyJws = /* @__PURE__ */ __name(async (args, context) => {
|
|
|
14668
14612
|
await Promise.all(jws.signatures.map(async (sigWithId) => {
|
|
14669
14613
|
index++;
|
|
14670
14614
|
let valid;
|
|
14671
|
-
const data = (0,
|
|
14615
|
+
const data = _fromstring.fromString.call(void 0, `${sigWithId.protected}.${jws.payload}`, "utf-8");
|
|
14672
14616
|
const jwkInfo = sigWithId.identifier.jwks[0];
|
|
14673
|
-
const signature = (0,
|
|
14674
|
-
valid = await (0,
|
|
14617
|
+
const signature = _utils.base64ToBytes.call(void 0, sigWithId.signature);
|
|
14618
|
+
valid = await _ssisdkextkeyutils.verifyRawSignature.call(void 0, {
|
|
14675
14619
|
data,
|
|
14676
14620
|
signature,
|
|
14677
14621
|
key: jwkInfo.jwk
|
|
@@ -14731,7 +14675,7 @@ async function resolveExternalIdentifierFromJwsHeader(protectedHeader, context,
|
|
|
14731
14675
|
if (protectedHeader.x5c) {
|
|
14732
14676
|
const x5c = protectedHeader.x5c;
|
|
14733
14677
|
return await context.agent.identifierExternalResolveByX5c({
|
|
14734
|
-
...args.opts
|
|
14678
|
+
..._optionalChain([args, 'access', _7 => _7.opts, 'optionalAccess', _8 => _8.x5c]),
|
|
14735
14679
|
identifier: x5c,
|
|
14736
14680
|
verify: true
|
|
14737
14681
|
});
|
|
@@ -14742,14 +14686,14 @@ async function resolveExternalIdentifierFromJwsHeader(protectedHeader, context,
|
|
|
14742
14686
|
identifier: protectedHeader.jwk,
|
|
14743
14687
|
...x5c && {
|
|
14744
14688
|
x5c: {
|
|
14745
|
-
...args
|
|
14689
|
+
..._optionalChain([args, 'optionalAccess', _9 => _9.opts, 'optionalAccess', _10 => _10.x5c]),
|
|
14746
14690
|
identifier: x5c
|
|
14747
14691
|
}
|
|
14748
14692
|
}
|
|
14749
14693
|
});
|
|
14750
14694
|
} else if (protectedHeader.kid && protectedHeader.kid.startsWith("did:")) {
|
|
14751
14695
|
return await context.agent.identifierExternalResolveByDid({
|
|
14752
|
-
...args
|
|
14696
|
+
..._optionalChain([args, 'optionalAccess', _11 => _11.opts, 'optionalAccess', _12 => _12.did]),
|
|
14753
14697
|
identifier: protectedHeader.kid
|
|
14754
14698
|
});
|
|
14755
14699
|
} else if (protectedHeader.alg === "none") {
|
|
@@ -14763,9 +14707,9 @@ function loadJWK(providedJwk, protectedHeader, jws) {
|
|
|
14763
14707
|
if (providedJwk) {
|
|
14764
14708
|
return providedJwk;
|
|
14765
14709
|
}
|
|
14766
|
-
if (protectedHeader
|
|
14767
|
-
const payload = (0,
|
|
14768
|
-
if (!payload
|
|
14710
|
+
if (_optionalChain([protectedHeader, 'optionalAccess', _13 => _13.typ]) === "entity-statement+jwt") {
|
|
14711
|
+
const payload = _utils.decodeJoseBlob.call(void 0, jws.payload);
|
|
14712
|
+
if (!_optionalChain([payload, 'optionalAccess', _14 => _14.jwks, 'optionalAccess', _15 => _15.keys, 'optionalAccess', _16 => _16[0]])) {
|
|
14769
14713
|
throw new Error("Missing or invalid JWK in payload");
|
|
14770
14714
|
}
|
|
14771
14715
|
return payload.jwks.keys[0];
|
|
@@ -14776,9 +14720,9 @@ __name(loadJWK, "loadJWK");
|
|
|
14776
14720
|
var toJwsJsonGeneralWithIdentifiers = /* @__PURE__ */ __name(async (args, context) => {
|
|
14777
14721
|
const jws = await toJwsJsonGeneral(args, context);
|
|
14778
14722
|
const signatures = await Promise.all(jws.signatures.map(async (signature) => {
|
|
14779
|
-
const protectedHeader = (0,
|
|
14723
|
+
const protectedHeader = _utils.decodeJoseBlob.call(void 0, signature.protected);
|
|
14780
14724
|
const jwk = loadJWK(args.jwk, protectedHeader, jws);
|
|
14781
|
-
const identifier = jwk ? await (0,
|
|
14725
|
+
const identifier = jwk ? await _ssisdkextidentifierresolution.resolveExternalJwkIdentifier.call(void 0, {
|
|
14782
14726
|
identifier: jwk,
|
|
14783
14727
|
method: "jwk"
|
|
14784
14728
|
}, context) : await resolveExternalIdentifierFromJwsHeader(protectedHeader, context, args);
|
|
@@ -14798,5 +14742,33 @@ var toJwsJsonGeneralWithIdentifiers = /* @__PURE__ */ __name(async (args, contex
|
|
|
14798
14742
|
|
|
14799
14743
|
// src/index.ts
|
|
14800
14744
|
var schema = require_plugin_schema();
|
|
14801
|
-
var JwtLogger =
|
|
14745
|
+
var JwtLogger = _ssitypes.Loggers.DEFAULT.get("sphereon:sdk:jwt");
|
|
14746
|
+
|
|
14747
|
+
|
|
14748
|
+
|
|
14749
|
+
|
|
14750
|
+
|
|
14751
|
+
|
|
14752
|
+
|
|
14753
|
+
|
|
14754
|
+
|
|
14755
|
+
|
|
14756
|
+
|
|
14757
|
+
|
|
14758
|
+
|
|
14759
|
+
|
|
14760
|
+
|
|
14761
|
+
|
|
14762
|
+
|
|
14763
|
+
|
|
14764
|
+
|
|
14765
|
+
|
|
14766
|
+
|
|
14767
|
+
|
|
14768
|
+
|
|
14769
|
+
|
|
14770
|
+
|
|
14771
|
+
|
|
14772
|
+
|
|
14773
|
+
exports.COMPACT_JWE_REGEX = COMPACT_JWE_REGEX; exports.COMPACT_JWS_REGEX = COMPACT_JWS_REGEX; exports.JweAlgs = JweAlgs; exports.JweEncs = JweEncs; exports.JwtLogger = JwtLogger; exports.JwtService = JwtService; exports.checkAndUpdateJwsHeader = checkAndUpdateJwsHeader; exports.createJwsCompact = createJwsCompact; exports.createJwsJsonFlattened = createJwsJsonFlattened; exports.createJwsJsonGeneral = createJwsJsonGeneral; exports.isJweCompact = isJweCompact; exports.isJweHeader = isJweHeader; exports.isJweJsonFlattened = isJweJsonFlattened; exports.isJweJsonGeneral = isJweJsonGeneral; exports.isJwsCompact = isJwsCompact; exports.isJwsHeader = isJwsHeader; exports.isJwsJsonFlattened = isJwsJsonFlattened; exports.isJwsJsonGeneral = isJwsJsonGeneral; exports.jweAlg = jweAlg; exports.jweEnc = jweEnc; exports.jwtServiceContextMethods = jwtServiceContextMethods; exports.prepareJwsObject = prepareJwsObject; exports.schema = schema; exports.toJwsJsonGeneral = toJwsJsonGeneral; exports.toJwsJsonGeneralWithIdentifiers = toJwsJsonGeneralWithIdentifiers; exports.verifyJws = verifyJws;
|
|
14802
14774
|
//# sourceMappingURL=index.cjs.map
|