@sphereon/ssi-sdk-ext.did-resolver-jwk 0.28.1-feature.esm.cjs.11 → 0.28.1-feature.esm.cjs.14
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 +47 -16
- package/dist/index.cjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var index_exports = {};
|
|
33
|
+
__export(index_exports, {
|
|
34
|
+
ContextType: () => ContextType,
|
|
35
|
+
ENC_KEY_ALGS: () => ENC_KEY_ALGS,
|
|
36
|
+
Key: () => Key,
|
|
37
|
+
KeyType: () => KeyType,
|
|
38
|
+
KeyUse: () => KeyUse,
|
|
39
|
+
SIG_KEY_ALGS: () => SIG_KEY_ALGS,
|
|
40
|
+
VerificationType: () => VerificationType,
|
|
41
|
+
VocabType: () => VocabType,
|
|
42
|
+
getDidJwkResolver: () => getDidJwkResolver
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(index_exports);
|
|
3
45
|
|
|
4
46
|
// src/jwk-did-resolver.ts
|
|
5
|
-
var
|
|
6
|
-
var
|
|
47
|
+
var import_ssi_types = require("@sphereon/ssi-types");
|
|
48
|
+
var import_base64url = __toESM(require("base64url"), 1);
|
|
7
49
|
|
|
8
50
|
// src/types/jwk-resolver-types.ts
|
|
9
51
|
var Key = /* @__PURE__ */ function(Key2) {
|
|
@@ -59,7 +101,7 @@ var resolveDidJwk = /* @__PURE__ */ __name(async (didUrl, options) => {
|
|
|
59
101
|
var resolve = /* @__PURE__ */ __name(async (didUrl, _options) => {
|
|
60
102
|
let parsedDid;
|
|
61
103
|
try {
|
|
62
|
-
parsedDid =
|
|
104
|
+
parsedDid = (0, import_ssi_types.parseDid)(didUrl);
|
|
63
105
|
} catch (error) {
|
|
64
106
|
return errorResponseFrom("invalidDid");
|
|
65
107
|
}
|
|
@@ -68,7 +110,7 @@ var resolve = /* @__PURE__ */ __name(async (didUrl, _options) => {
|
|
|
68
110
|
}
|
|
69
111
|
let jwk;
|
|
70
112
|
try {
|
|
71
|
-
jwk = JSON.parse(
|
|
113
|
+
jwk = JSON.parse(import_base64url.default.decode(parsedDid.id, "UTF-8"));
|
|
72
114
|
} catch (error) {
|
|
73
115
|
return errorResponseFrom("invalidDid");
|
|
74
116
|
}
|
|
@@ -146,15 +188,4 @@ function getDidJwkResolver() {
|
|
|
146
188
|
};
|
|
147
189
|
}
|
|
148
190
|
__name(getDidJwkResolver, "getDidJwkResolver");
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
exports.ContextType = ContextType; exports.ENC_KEY_ALGS = ENC_KEY_ALGS; exports.Key = Key; exports.KeyType = KeyType; exports.KeyUse = KeyUse; exports.SIG_KEY_ALGS = SIG_KEY_ALGS; exports.VerificationType = VerificationType; exports.VocabType = VocabType; exports.getDidJwkResolver = getDidJwkResolver;
|
|
160
191
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/jwk-did-resolver.ts","../src/types/jwk-resolver-types.ts"],"sourcesContent":["/**\n * Provides `did:jwk` {@link @veramo/did-provider-jwk#JwkDIDProvider | identifier provider }\n * for the {@link @veramo/did-manager#DIDManager}\n *\n * @packageDocumentation\n */\nexport { getDidJwkResolver } from './jwk-did-resolver'\nexport * from './types/jwk-resolver-types'\n","import { IParsedDID, parseDid } from '@sphereon/ssi-types'\nimport base64url from 'base64url'\nimport { DIDResolutionOptions, DIDResolutionResult, DIDResolver, JsonWebKey } from 'did-resolver'\nimport { ContextType, ENC_KEY_ALGS, KeyUse, SIG_KEY_ALGS, VerificationType, VocabType } from './types/jwk-resolver-types'\n\nexport const resolveDidJwk: DIDResolver = async (didUrl: string, options?: DIDResolutionOptions): Promise<DIDResolutionResult> => {\n return resolve(didUrl, options)\n}\n\nconst resolve = async (didUrl: string, _options?: DIDResolutionOptions): Promise<DIDResolutionResult> => {\n let parsedDid: IParsedDID\n try {\n parsedDid = parseDid(didUrl)\n } catch (error: unknown) {\n // Error from did resolution spec\n return errorResponseFrom('invalidDid')\n }\n\n if (parsedDid.method !== 'jwk') {\n // Error from did resolution spec\n return errorResponseFrom('unsupportedDidMethod')\n }\n\n let jwk: JsonWebKey\n try {\n jwk = JSON.parse(base64url.decode(parsedDid.id, 'UTF-8'))\n } catch (error: unknown) {\n // Error from did resolution spec\n return errorResponseFrom('invalidDid')\n }\n\n // We need this since DIDResolutionResult does not allow for an object in the array\n const context = [ContextType.DidDocument, { '@vocab': VocabType.Jose }] as never\n\n // We add the alg check to ensure max compatibility with implementations that do not export the use property\n const enc = (jwk.use && jwk.use === KeyUse.Encryption) || (jwk.alg && ENC_KEY_ALGS.includes(jwk.alg))\n const sig = (jwk.use && jwk.use === KeyUse.Signature) || (jwk.alg && SIG_KEY_ALGS.includes(jwk.alg))\n\n const didResolution: DIDResolutionResult = {\n didResolutionMetadata: {\n contentType: 'application/did+ld+json',\n pattern: '^(did:jwk:.+)$',\n did: {\n didString: parsedDid.did,\n methodSpecificId: parsedDid.id,\n method: 'jwk',\n },\n },\n\n didDocument: {\n '@context': context,\n id: parsedDid.did,\n verificationMethod: [\n {\n id: `${parsedDid.did}#0`,\n type: VerificationType.JsonWebKey2020,\n controller: parsedDid.did,\n publicKeyJwk: jwk,\n },\n ],\n ...(sig && { assertionMethod: [`${parsedDid.did}#0`] }),\n ...(sig && { authentication: [`${parsedDid.did}#0`] }),\n ...(sig && { capabilityInvocation: [`${parsedDid.did}#0`] }),\n ...(sig && { capabilityDelegation: [`${parsedDid.did}#0`] }),\n ...(enc && { keyAgreement: [`${parsedDid.did}#0`] }),\n },\n didDocumentMetadata: {},\n }\n\n return didResolution\n}\n\nconst errorResponseFrom = async (error: string): Promise<DIDResolutionResult> => {\n return {\n didResolutionMetadata: {\n error,\n },\n didDocument: null,\n didDocumentMetadata: {},\n }\n}\n\nexport function getDidJwkResolver() {\n return { jwk: resolveDidJwk }\n}\n","export enum Key {\n Ed25519 = 'Ed25519',\n Secp256k1 = 'Secp256k1',\n Secp256r1 = 'Secp256r1',\n}\n\nexport enum KeyUse {\n Encryption = 'enc',\n Signature = 'sig',\n}\n\nexport enum KeyType {\n EC = 'EC',\n OKP = 'OKP',\n}\n\nexport enum VerificationType {\n JsonWebKey2020 = 'JsonWebKey2020',\n}\nexport const SIG_KEY_ALGS = ['ES256', 'ES384', 'ES512', 'EdDSA', 'ES256K', 'Ed25519', 'Secp256k1', 'Secp256r1', 'Bls12381G1', 'Bls12381G2']\nexport const ENC_KEY_ALGS = ['X25519', 'ECDH_ES_A256KW', 'RSA_OAEP_256']\n\n// https://datatracker.ietf.org/doc/html/rfc8812#section-3\n// https://datatracker.ietf.org/doc/html/rfc8812#section-4\nexport enum VocabType {\n Jose = 'https://www.iana.org/assignments/jose#',\n}\n\nexport enum ContextType {\n DidDocument = 'https://www.w3.org/ns/did/v1',\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;ACAA,uBAAqC;AACrC,uBAAsB;;;ACDf,IAAKA,MAAAA,yBAAAA,MAAAA;;;;SAAAA;;AAML,IAAKC,SAAAA,yBAAAA,SAAAA;;;SAAAA;;AAKL,IAAKC,UAAAA,yBAAAA,UAAAA;;;SAAAA;;AAKL,IAAKC,mBAAAA,yBAAAA,mBAAAA;;SAAAA;;AAGL,IAAMC,eAAe;EAAC;EAAS;EAAS;EAAS;EAAS;EAAU;EAAW;EAAa;EAAa;EAAc;;AACvH,IAAMC,eAAe;EAAC;EAAU;EAAkB;;AAIlD,IAAKC,YAAAA,yBAAAA,YAAAA;;SAAAA;;AAIL,IAAKC,cAAAA,yBAAAA,cAAAA;;SAAAA;;;;ADvBL,IAAMC,gBAA6B,8BAAOC,QAAgBC,YAAAA;AAC/D,SAAOC,QAAQF,QAAQC,OAAAA;AACzB,GAF0C;AAI1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AsB;UAAC,GAAG3C,UAAU8B,GAAG;;MAAM;MAC1D,GAAId,OAAO;QAAE4B,cAAc;UAAC,GAAG5C,UAAU8B,GAAG;;MAAM;IACpD;IACAe,qBAAqB,CAAC;EACxB;AAEA,SAAOnB;AACT,GA7DgB;AA+DhB,IAAMvB,oBAAoB,8BAAOD,UAAAA;AAC/B,SAAO;IACLyB,uBAAuB;MACrBzB;IACF;IACA+B,aAAa;IACbY,qBAAqB,CAAC;EACxB;AACF,GAR0B;AAUnB,SAASC,oBAAAA;AACd,SAAO;IAAEzC,KAAKV;EAAc;AAC9B;AAFgBmD;","names":["Key","KeyUse","KeyType","VerificationType","SIG_KEY_ALGS","ENC_KEY_ALGS","VocabType","ContextType","resolveDidJwk","didUrl","options","resolve","_options","parsedDid","parseDid","error","errorResponseFrom","method","jwk","JSON","parse","base64url","decode","id","context","ContextType","DidDocument","VocabType","Jose","enc","use","KeyUse","Encryption","alg","ENC_KEY_ALGS","includes","sig","Signature","SIG_KEY_ALGS","didResolution","didResolutionMetadata","contentType","pattern","did","didString","methodSpecificId","didDocument","verificationMethod","type","VerificationType","JsonWebKey2020","controller","publicKeyJwk","assertionMethod","authentication","capabilityInvocation","capabilityDelegation","keyAgreement","didDocumentMetadata","getDidJwkResolver"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk-ext.did-resolver-jwk",
|
|
3
3
|
"description": "DIF resolver for resolution of did:jwk identifiers.",
|
|
4
|
-
"version": "0.28.1-feature.esm.cjs.
|
|
4
|
+
"version": "0.28.1-feature.esm.cjs.14+b36311c",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@sphereon/ssi-types": "
|
|
24
|
+
"@sphereon/ssi-types": "0.33.1-feature.vcdm2.tsup.26",
|
|
25
25
|
"base64url": "^3.0.1",
|
|
26
26
|
"debug": "^4.3.4",
|
|
27
27
|
"did-resolver": "^4.1.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"DID",
|
|
52
52
|
"Veramo"
|
|
53
53
|
],
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "b36311cef728bb778039501d6671890fdbdf9334"
|
|
55
55
|
}
|