@sphereon/ssi-sdk-ext.did-resolver-jwk 0.28.0 → 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 +160 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -9
- package/dist/index.js +157 -24
- package/dist/index.js.map +1 -1
- package/package.json +22 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/jwk-did-resolver.d.ts +0 -6
- package/dist/jwk-did-resolver.d.ts.map +0 -1
- package/dist/jwk-did-resolver.js +0 -84
- package/dist/jwk-did-resolver.js.map +0 -1
- package/dist/types/jwk-resolver-types.d.ts +0 -25
- package/dist/types/jwk-resolver-types.d.ts.map +0 -1
- package/dist/types/jwk-resolver-types.js +0 -36
- package/dist/types/jwk-resolver-types.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/jwk-did-resolver.ts
|
|
5
|
+
var _ssitypes = require('@sphereon/ssi-types');
|
|
6
|
+
var _base64url = require('base64url'); var _base64url2 = _interopRequireDefault(_base64url);
|
|
7
|
+
|
|
8
|
+
// src/types/jwk-resolver-types.ts
|
|
9
|
+
var Key = /* @__PURE__ */ function(Key2) {
|
|
10
|
+
Key2["Ed25519"] = "Ed25519";
|
|
11
|
+
Key2["Secp256k1"] = "Secp256k1";
|
|
12
|
+
Key2["Secp256r1"] = "Secp256r1";
|
|
13
|
+
return Key2;
|
|
14
|
+
}({});
|
|
15
|
+
var KeyUse = /* @__PURE__ */ function(KeyUse2) {
|
|
16
|
+
KeyUse2["Encryption"] = "enc";
|
|
17
|
+
KeyUse2["Signature"] = "sig";
|
|
18
|
+
return KeyUse2;
|
|
19
|
+
}({});
|
|
20
|
+
var KeyType = /* @__PURE__ */ function(KeyType2) {
|
|
21
|
+
KeyType2["EC"] = "EC";
|
|
22
|
+
KeyType2["OKP"] = "OKP";
|
|
23
|
+
return KeyType2;
|
|
24
|
+
}({});
|
|
25
|
+
var VerificationType = /* @__PURE__ */ function(VerificationType2) {
|
|
26
|
+
VerificationType2["JsonWebKey2020"] = "JsonWebKey2020";
|
|
27
|
+
return VerificationType2;
|
|
28
|
+
}({});
|
|
29
|
+
var SIG_KEY_ALGS = [
|
|
30
|
+
"ES256",
|
|
31
|
+
"ES384",
|
|
32
|
+
"ES512",
|
|
33
|
+
"EdDSA",
|
|
34
|
+
"ES256K",
|
|
35
|
+
"Ed25519",
|
|
36
|
+
"Secp256k1",
|
|
37
|
+
"Secp256r1",
|
|
38
|
+
"Bls12381G1",
|
|
39
|
+
"Bls12381G2"
|
|
40
|
+
];
|
|
41
|
+
var ENC_KEY_ALGS = [
|
|
42
|
+
"X25519",
|
|
43
|
+
"ECDH_ES_A256KW",
|
|
44
|
+
"RSA_OAEP_256"
|
|
45
|
+
];
|
|
46
|
+
var VocabType = /* @__PURE__ */ function(VocabType2) {
|
|
47
|
+
VocabType2["Jose"] = "https://www.iana.org/assignments/jose#";
|
|
48
|
+
return VocabType2;
|
|
49
|
+
}({});
|
|
50
|
+
var ContextType = /* @__PURE__ */ function(ContextType2) {
|
|
51
|
+
ContextType2["DidDocument"] = "https://www.w3.org/ns/did/v1";
|
|
52
|
+
return ContextType2;
|
|
53
|
+
}({});
|
|
54
|
+
|
|
55
|
+
// src/jwk-did-resolver.ts
|
|
56
|
+
var resolveDidJwk = /* @__PURE__ */ __name(async (didUrl, options) => {
|
|
57
|
+
return resolve(didUrl, options);
|
|
58
|
+
}, "resolveDidJwk");
|
|
59
|
+
var resolve = /* @__PURE__ */ __name(async (didUrl, _options) => {
|
|
60
|
+
let parsedDid;
|
|
61
|
+
try {
|
|
62
|
+
parsedDid = _ssitypes.parseDid.call(void 0, didUrl);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return errorResponseFrom("invalidDid");
|
|
65
|
+
}
|
|
66
|
+
if (parsedDid.method !== "jwk") {
|
|
67
|
+
return errorResponseFrom("unsupportedDidMethod");
|
|
68
|
+
}
|
|
69
|
+
let jwk;
|
|
70
|
+
try {
|
|
71
|
+
jwk = JSON.parse(_base64url2.default.decode(parsedDid.id, "UTF-8"));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return errorResponseFrom("invalidDid");
|
|
74
|
+
}
|
|
75
|
+
const context = [
|
|
76
|
+
ContextType.DidDocument,
|
|
77
|
+
{
|
|
78
|
+
"@vocab": VocabType.Jose
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
const enc = jwk.use && jwk.use === KeyUse.Encryption || jwk.alg && ENC_KEY_ALGS.includes(jwk.alg);
|
|
82
|
+
const sig = jwk.use && jwk.use === KeyUse.Signature || jwk.alg && SIG_KEY_ALGS.includes(jwk.alg);
|
|
83
|
+
const didResolution = {
|
|
84
|
+
didResolutionMetadata: {
|
|
85
|
+
contentType: "application/did+ld+json",
|
|
86
|
+
pattern: "^(did:jwk:.+)$",
|
|
87
|
+
did: {
|
|
88
|
+
didString: parsedDid.did,
|
|
89
|
+
methodSpecificId: parsedDid.id,
|
|
90
|
+
method: "jwk"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
didDocument: {
|
|
94
|
+
"@context": context,
|
|
95
|
+
id: parsedDid.did,
|
|
96
|
+
verificationMethod: [
|
|
97
|
+
{
|
|
98
|
+
id: `${parsedDid.did}#0`,
|
|
99
|
+
type: VerificationType.JsonWebKey2020,
|
|
100
|
+
controller: parsedDid.did,
|
|
101
|
+
publicKeyJwk: jwk
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
...sig && {
|
|
105
|
+
assertionMethod: [
|
|
106
|
+
`${parsedDid.did}#0`
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
...sig && {
|
|
110
|
+
authentication: [
|
|
111
|
+
`${parsedDid.did}#0`
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
...sig && {
|
|
115
|
+
capabilityInvocation: [
|
|
116
|
+
`${parsedDid.did}#0`
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
...sig && {
|
|
120
|
+
capabilityDelegation: [
|
|
121
|
+
`${parsedDid.did}#0`
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
...enc && {
|
|
125
|
+
keyAgreement: [
|
|
126
|
+
`${parsedDid.did}#0`
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
didDocumentMetadata: {}
|
|
131
|
+
};
|
|
132
|
+
return didResolution;
|
|
133
|
+
}, "resolve");
|
|
134
|
+
var errorResponseFrom = /* @__PURE__ */ __name(async (error) => {
|
|
135
|
+
return {
|
|
136
|
+
didResolutionMetadata: {
|
|
137
|
+
error
|
|
138
|
+
},
|
|
139
|
+
didDocument: null,
|
|
140
|
+
didDocumentMetadata: {}
|
|
141
|
+
};
|
|
142
|
+
}, "errorResponseFrom");
|
|
143
|
+
function getDidJwkResolver() {
|
|
144
|
+
return {
|
|
145
|
+
jwk: resolveDidJwk
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
__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
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/SSI-SDK-crypto-extensions/SSI-SDK-crypto-extensions/packages/did-resolver-jwk/dist/index.cjs","../src/jwk-did-resolver.ts","../src/types/jwk-resolver-types.ts"],"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","DidDocument","Jose","enc","use","Encryption","alg","includes","sig","Signature","didResolution","didResolutionMetadata","contentType","pattern","did","didString","methodSpecificId","didDocument","verificationMethod","type","controller","publicKeyJwk","assertionMethod","authentication","capabilityInvocation","capabilityDelegation","keyAgreement","didDocumentMetadata","getDidJwkResolver"],"mappings":"AAAA,6KAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;AACxF;AACA;ACHA,+CAAqC;AACrC,4FAAsB;ADKtB;AACA;AEPO,IAAKA,IAAAA,kBAAAA,QAAAA,CAAAA,IAAAA,EAAAA;AFSZ,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,SAAS;AAC7B,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,WAAW;AACjC,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,WAAW;AACjC,EAAE,OEZUA,IAAAA;AFaZ,CAAC,CAAC,CAAC,CAAC,CAAC;AEPE,IAAKC,OAAAA,kBAAAA,QAAAA,CAAAA,OAAAA,EAAAA;AFSZ,EAAE,OAAO,CAAC,YAAY,EAAE,EAAE,KAAK;AAC/B,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK;AAC9B,EAAE,OEXUA,OAAAA;AFYZ,CAAC,CAAC,CAAC,CAA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lB;AACG,EAAA;AACLmB,IAAAA;AACEpB,MAAAA;AACF,IAAA;AACA0B,IAAAA;AACAU,IAAAA;AACF,EAAA;AAPwB;AAUVC;AACP,EAAA;AAAO5C,IAAAA;AAAc,EAAA;AAC9B;AAFgB4C;ADkED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/SSI-SDK-crypto-extensions/SSI-SDK-crypto-extensions/packages/did-resolver-jwk/dist/index.cjs","sourcesContent":[null,"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"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DIDResolver } from 'did-resolver';
|
|
2
|
+
|
|
3
|
+
declare function getDidJwkResolver(): {
|
|
4
|
+
jwk: DIDResolver;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
declare enum Key {
|
|
8
|
+
Ed25519 = "Ed25519",
|
|
9
|
+
Secp256k1 = "Secp256k1",
|
|
10
|
+
Secp256r1 = "Secp256r1"
|
|
11
|
+
}
|
|
12
|
+
declare enum KeyUse {
|
|
13
|
+
Encryption = "enc",
|
|
14
|
+
Signature = "sig"
|
|
15
|
+
}
|
|
16
|
+
declare enum KeyType {
|
|
17
|
+
EC = "EC",
|
|
18
|
+
OKP = "OKP"
|
|
19
|
+
}
|
|
20
|
+
declare enum VerificationType {
|
|
21
|
+
JsonWebKey2020 = "JsonWebKey2020"
|
|
22
|
+
}
|
|
23
|
+
declare const SIG_KEY_ALGS: string[];
|
|
24
|
+
declare const ENC_KEY_ALGS: string[];
|
|
25
|
+
declare enum VocabType {
|
|
26
|
+
Jose = "https://www.iana.org/assignments/jose#"
|
|
27
|
+
}
|
|
28
|
+
declare enum ContextType {
|
|
29
|
+
DidDocument = "https://www.w3.org/ns/did/v1"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { ContextType, ENC_KEY_ALGS, Key, KeyType, KeyUse, SIG_KEY_ALGS, VerificationType, VocabType, getDidJwkResolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { DIDResolver } from 'did-resolver';
|
|
2
|
+
|
|
3
|
+
declare function getDidJwkResolver(): {
|
|
4
|
+
jwk: DIDResolver;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
declare enum Key {
|
|
8
|
+
Ed25519 = "Ed25519",
|
|
9
|
+
Secp256k1 = "Secp256k1",
|
|
10
|
+
Secp256r1 = "Secp256r1"
|
|
11
|
+
}
|
|
12
|
+
declare enum KeyUse {
|
|
13
|
+
Encryption = "enc",
|
|
14
|
+
Signature = "sig"
|
|
15
|
+
}
|
|
16
|
+
declare enum KeyType {
|
|
17
|
+
EC = "EC",
|
|
18
|
+
OKP = "OKP"
|
|
19
|
+
}
|
|
20
|
+
declare enum VerificationType {
|
|
21
|
+
JsonWebKey2020 = "JsonWebKey2020"
|
|
22
|
+
}
|
|
23
|
+
declare const SIG_KEY_ALGS: string[];
|
|
24
|
+
declare const ENC_KEY_ALGS: string[];
|
|
25
|
+
declare enum VocabType {
|
|
26
|
+
Jose = "https://www.iana.org/assignments/jose#"
|
|
27
|
+
}
|
|
28
|
+
declare enum ContextType {
|
|
29
|
+
DidDocument = "https://www.w3.org/ns/did/v1"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { ContextType, ENC_KEY_ALGS, Key, KeyType, KeyUse, SIG_KEY_ALGS, VerificationType, VocabType, getDidJwkResolver };
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/jwk-did-resolver.ts
|
|
5
|
+
import { parseDid } from "@sphereon/ssi-types";
|
|
6
|
+
import base64url from "base64url";
|
|
7
|
+
|
|
8
|
+
// src/types/jwk-resolver-types.ts
|
|
9
|
+
var Key = /* @__PURE__ */ function(Key2) {
|
|
10
|
+
Key2["Ed25519"] = "Ed25519";
|
|
11
|
+
Key2["Secp256k1"] = "Secp256k1";
|
|
12
|
+
Key2["Secp256r1"] = "Secp256r1";
|
|
13
|
+
return Key2;
|
|
14
|
+
}({});
|
|
15
|
+
var KeyUse = /* @__PURE__ */ function(KeyUse2) {
|
|
16
|
+
KeyUse2["Encryption"] = "enc";
|
|
17
|
+
KeyUse2["Signature"] = "sig";
|
|
18
|
+
return KeyUse2;
|
|
19
|
+
}({});
|
|
20
|
+
var KeyType = /* @__PURE__ */ function(KeyType2) {
|
|
21
|
+
KeyType2["EC"] = "EC";
|
|
22
|
+
KeyType2["OKP"] = "OKP";
|
|
23
|
+
return KeyType2;
|
|
24
|
+
}({});
|
|
25
|
+
var VerificationType = /* @__PURE__ */ function(VerificationType2) {
|
|
26
|
+
VerificationType2["JsonWebKey2020"] = "JsonWebKey2020";
|
|
27
|
+
return VerificationType2;
|
|
28
|
+
}({});
|
|
29
|
+
var SIG_KEY_ALGS = [
|
|
30
|
+
"ES256",
|
|
31
|
+
"ES384",
|
|
32
|
+
"ES512",
|
|
33
|
+
"EdDSA",
|
|
34
|
+
"ES256K",
|
|
35
|
+
"Ed25519",
|
|
36
|
+
"Secp256k1",
|
|
37
|
+
"Secp256r1",
|
|
38
|
+
"Bls12381G1",
|
|
39
|
+
"Bls12381G2"
|
|
40
|
+
];
|
|
41
|
+
var ENC_KEY_ALGS = [
|
|
42
|
+
"X25519",
|
|
43
|
+
"ECDH_ES_A256KW",
|
|
44
|
+
"RSA_OAEP_256"
|
|
45
|
+
];
|
|
46
|
+
var VocabType = /* @__PURE__ */ function(VocabType2) {
|
|
47
|
+
VocabType2["Jose"] = "https://www.iana.org/assignments/jose#";
|
|
48
|
+
return VocabType2;
|
|
49
|
+
}({});
|
|
50
|
+
var ContextType = /* @__PURE__ */ function(ContextType2) {
|
|
51
|
+
ContextType2["DidDocument"] = "https://www.w3.org/ns/did/v1";
|
|
52
|
+
return ContextType2;
|
|
53
|
+
}({});
|
|
54
|
+
|
|
55
|
+
// src/jwk-did-resolver.ts
|
|
56
|
+
var resolveDidJwk = /* @__PURE__ */ __name(async (didUrl, options) => {
|
|
57
|
+
return resolve(didUrl, options);
|
|
58
|
+
}, "resolveDidJwk");
|
|
59
|
+
var resolve = /* @__PURE__ */ __name(async (didUrl, _options) => {
|
|
60
|
+
let parsedDid;
|
|
61
|
+
try {
|
|
62
|
+
parsedDid = parseDid(didUrl);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return errorResponseFrom("invalidDid");
|
|
65
|
+
}
|
|
66
|
+
if (parsedDid.method !== "jwk") {
|
|
67
|
+
return errorResponseFrom("unsupportedDidMethod");
|
|
68
|
+
}
|
|
69
|
+
let jwk;
|
|
70
|
+
try {
|
|
71
|
+
jwk = JSON.parse(base64url.decode(parsedDid.id, "UTF-8"));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return errorResponseFrom("invalidDid");
|
|
74
|
+
}
|
|
75
|
+
const context = [
|
|
76
|
+
ContextType.DidDocument,
|
|
77
|
+
{
|
|
78
|
+
"@vocab": VocabType.Jose
|
|
7
79
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
80
|
+
];
|
|
81
|
+
const enc = jwk.use && jwk.use === KeyUse.Encryption || jwk.alg && ENC_KEY_ALGS.includes(jwk.alg);
|
|
82
|
+
const sig = jwk.use && jwk.use === KeyUse.Signature || jwk.alg && SIG_KEY_ALGS.includes(jwk.alg);
|
|
83
|
+
const didResolution = {
|
|
84
|
+
didResolutionMetadata: {
|
|
85
|
+
contentType: "application/did+ld+json",
|
|
86
|
+
pattern: "^(did:jwk:.+)$",
|
|
87
|
+
did: {
|
|
88
|
+
didString: parsedDid.did,
|
|
89
|
+
methodSpecificId: parsedDid.id,
|
|
90
|
+
method: "jwk"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
didDocument: {
|
|
94
|
+
"@context": context,
|
|
95
|
+
id: parsedDid.did,
|
|
96
|
+
verificationMethod: [
|
|
97
|
+
{
|
|
98
|
+
id: `${parsedDid.did}#0`,
|
|
99
|
+
type: VerificationType.JsonWebKey2020,
|
|
100
|
+
controller: parsedDid.did,
|
|
101
|
+
publicKeyJwk: jwk
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
...sig && {
|
|
105
|
+
assertionMethod: [
|
|
106
|
+
`${parsedDid.did}#0`
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
...sig && {
|
|
110
|
+
authentication: [
|
|
111
|
+
`${parsedDid.did}#0`
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
...sig && {
|
|
115
|
+
capabilityInvocation: [
|
|
116
|
+
`${parsedDid.did}#0`
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
...sig && {
|
|
120
|
+
capabilityDelegation: [
|
|
121
|
+
`${parsedDid.did}#0`
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
...enc && {
|
|
125
|
+
keyAgreement: [
|
|
126
|
+
`${parsedDid.did}#0`
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
didDocumentMetadata: {}
|
|
131
|
+
};
|
|
132
|
+
return didResolution;
|
|
133
|
+
}, "resolve");
|
|
134
|
+
var errorResponseFrom = /* @__PURE__ */ __name(async (error) => {
|
|
135
|
+
return {
|
|
136
|
+
didResolutionMetadata: {
|
|
137
|
+
error
|
|
138
|
+
},
|
|
139
|
+
didDocument: null,
|
|
140
|
+
didDocumentMetadata: {}
|
|
141
|
+
};
|
|
142
|
+
}, "errorResponseFrom");
|
|
143
|
+
function getDidJwkResolver() {
|
|
144
|
+
return {
|
|
145
|
+
jwk: resolveDidJwk
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
__name(getDidJwkResolver, "getDidJwkResolver");
|
|
149
|
+
export {
|
|
150
|
+
ContextType,
|
|
151
|
+
ENC_KEY_ALGS,
|
|
152
|
+
Key,
|
|
153
|
+
KeyType,
|
|
154
|
+
KeyUse,
|
|
155
|
+
SIG_KEY_ALGS,
|
|
156
|
+
VerificationType,
|
|
157
|
+
VocabType,
|
|
158
|
+
getDidJwkResolver
|
|
15
159
|
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getDidJwkResolver = void 0;
|
|
18
|
-
/**
|
|
19
|
-
* Provides `did:jwk` {@link @veramo/did-provider-jwk#JwkDIDProvider | identifier provider }
|
|
20
|
-
* for the {@link @veramo/did-manager#DIDManager}
|
|
21
|
-
*
|
|
22
|
-
* @packageDocumentation
|
|
23
|
-
*/
|
|
24
|
-
var jwk_did_resolver_1 = require("./jwk-did-resolver");
|
|
25
|
-
Object.defineProperty(exports, "getDidJwkResolver", { enumerable: true, get: function () { return jwk_did_resolver_1.getDidJwkResolver; } });
|
|
26
|
-
__exportStar(require("./types/jwk-resolver-types"), exports);
|
|
27
160
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/jwk-did-resolver.ts","../src/types/jwk-resolver-types.ts"],"sourcesContent":["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,SAAqBA,gBAAgB;AACrC,OAAOC,eAAe;;;ACDf,IAAKC,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;AAI1C,IAAMC,UAAU,8BAAOF,QAAgBG,aAAAA;AACrC,MAAIC;AACJ,MAAI;AACFA,gBAAYC,SAASL,MAAAA;EACvB,SAASM,OAAgB;AAEvB,WAAOC,kBAAkB,YAAA;EAC3B;AAEA,MAAIH,UAAUI,WAAW,OAAO;AAE9B,WAAOD,kBAAkB,sBAAA;EAC3B;AAEA,MAAIE;AACJ,MAAI;AACFA,UAAMC,KAAKC,MAAMC,UAAUC,OAAOT,UAAUU,IAAI,OAAA,CAAA;EAClD,SAASR,OAAgB;AAEvB,WAAOC,kBAAkB,YA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B;AAFgBmD;","names":["parseDid","base64url","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,20 +1,31 @@
|
|
|
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.
|
|
5
|
-
"source": "src/index.ts",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
4
|
+
"version": "0.28.1-feature.esm.cjs.9+71682ea",
|
|
5
|
+
"source": "./src/index.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
8
20
|
"scripts": {
|
|
9
|
-
"build": "
|
|
10
|
-
"build:clean": "tsc --build --clean && tsc --build"
|
|
21
|
+
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
11
22
|
},
|
|
12
23
|
"dependencies": {
|
|
13
|
-
"@sphereon/ssi-types": "0.
|
|
24
|
+
"@sphereon/ssi-types": " ^0.33",
|
|
14
25
|
"base64url": "^3.0.1",
|
|
15
26
|
"debug": "^4.3.4",
|
|
16
27
|
"did-resolver": "^4.1.0",
|
|
17
|
-
"uint8arrays": "
|
|
28
|
+
"uint8arrays": " 3.1.1"
|
|
18
29
|
},
|
|
19
30
|
"devDependencies": {
|
|
20
31
|
"@or13/did-jwk": "^0.0.4",
|
|
@@ -23,8 +34,8 @@
|
|
|
23
34
|
"jose": "^4.14.6"
|
|
24
35
|
},
|
|
25
36
|
"files": [
|
|
26
|
-
"dist
|
|
27
|
-
"src
|
|
37
|
+
"dist",
|
|
38
|
+
"src",
|
|
28
39
|
"README.md",
|
|
29
40
|
"LICENSE"
|
|
30
41
|
],
|
|
@@ -40,5 +51,5 @@
|
|
|
40
51
|
"DID",
|
|
41
52
|
"Veramo"
|
|
42
53
|
],
|
|
43
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "71682ea0c528f5b32c421245c253b3bc9d6296a0"
|
|
44
55
|
}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,cAAc,4BAA4B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwk-did-resolver.d.ts","sourceRoot":"","sources":["../src/jwk-did-resolver.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6C,WAAW,EAAc,MAAM,cAAc,CAAA;AAGjG,eAAO,MAAM,aAAa,EAAE,WAE3B,CAAA;AA2ED,wBAAgB,iBAAiB;;EAEhC"}
|
package/dist/jwk-did-resolver.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
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.resolveDidJwk = void 0;
|
|
16
|
-
exports.getDidJwkResolver = getDidJwkResolver;
|
|
17
|
-
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
18
|
-
const base64url_1 = __importDefault(require("base64url"));
|
|
19
|
-
const jwk_resolver_types_1 = require("./types/jwk-resolver-types");
|
|
20
|
-
const resolveDidJwk = (didUrl, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
return resolve(didUrl, options);
|
|
22
|
-
});
|
|
23
|
-
exports.resolveDidJwk = resolveDidJwk;
|
|
24
|
-
const resolve = (didUrl, _options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
let parsedDid;
|
|
26
|
-
try {
|
|
27
|
-
parsedDid = (0, ssi_types_1.parseDid)(didUrl);
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
// Error from did resolution spec
|
|
31
|
-
return errorResponseFrom('invalidDid');
|
|
32
|
-
}
|
|
33
|
-
if (parsedDid.method !== 'jwk') {
|
|
34
|
-
// Error from did resolution spec
|
|
35
|
-
return errorResponseFrom('unsupportedDidMethod');
|
|
36
|
-
}
|
|
37
|
-
let jwk;
|
|
38
|
-
try {
|
|
39
|
-
jwk = JSON.parse(base64url_1.default.decode(parsedDid.id, 'UTF-8'));
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
// Error from did resolution spec
|
|
43
|
-
return errorResponseFrom('invalidDid');
|
|
44
|
-
}
|
|
45
|
-
// We need this since DIDResolutionResult does not allow for an object in the array
|
|
46
|
-
const context = [jwk_resolver_types_1.ContextType.DidDocument, { '@vocab': jwk_resolver_types_1.VocabType.Jose }];
|
|
47
|
-
// We add the alg check to ensure max compatibility with implementations that do not export the use property
|
|
48
|
-
const enc = (jwk.use && jwk.use === jwk_resolver_types_1.KeyUse.Encryption) || (jwk.alg && jwk_resolver_types_1.ENC_KEY_ALGS.includes(jwk.alg));
|
|
49
|
-
const sig = (jwk.use && jwk.use === jwk_resolver_types_1.KeyUse.Signature) || (jwk.alg && jwk_resolver_types_1.SIG_KEY_ALGS.includes(jwk.alg));
|
|
50
|
-
const didResolution = {
|
|
51
|
-
didResolutionMetadata: {
|
|
52
|
-
contentType: 'application/did+ld+json',
|
|
53
|
-
pattern: '^(did:jwk:.+)$',
|
|
54
|
-
did: {
|
|
55
|
-
didString: parsedDid.did,
|
|
56
|
-
methodSpecificId: parsedDid.id,
|
|
57
|
-
method: 'jwk',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
didDocument: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ '@context': context, id: parsedDid.did, verificationMethod: [
|
|
61
|
-
{
|
|
62
|
-
id: `${parsedDid.did}#0`,
|
|
63
|
-
type: jwk_resolver_types_1.VerificationType.JsonWebKey2020,
|
|
64
|
-
controller: parsedDid.did,
|
|
65
|
-
publicKeyJwk: jwk,
|
|
66
|
-
},
|
|
67
|
-
] }, (sig && { assertionMethod: [`${parsedDid.did}#0`] })), (sig && { authentication: [`${parsedDid.did}#0`] })), (sig && { capabilityInvocation: [`${parsedDid.did}#0`] })), (sig && { capabilityDelegation: [`${parsedDid.did}#0`] })), (enc && { keyAgreement: [`${parsedDid.did}#0`] })),
|
|
68
|
-
didDocumentMetadata: {},
|
|
69
|
-
};
|
|
70
|
-
return didResolution;
|
|
71
|
-
});
|
|
72
|
-
const errorResponseFrom = (error) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
-
return {
|
|
74
|
-
didResolutionMetadata: {
|
|
75
|
-
error,
|
|
76
|
-
},
|
|
77
|
-
didDocument: null,
|
|
78
|
-
didDocumentMetadata: {},
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
function getDidJwkResolver() {
|
|
82
|
-
return { jwk: exports.resolveDidJwk };
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=jwk-did-resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwk-did-resolver.js","sourceRoot":"","sources":["../src/jwk-did-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAkFA,8CAEC;AApFD,mDAA0D;AAC1D,0DAAiC;AAEjC,mEAAyH;AAElH,MAAM,aAAa,GAAgB,CAAO,MAAc,EAAE,OAA8B,EAAgC,EAAE;IAC/H,OAAO,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC,CAAA,CAAA;AAFY,QAAA,aAAa,iBAEzB;AAED,MAAM,OAAO,GAAG,CAAO,MAAc,EAAE,QAA+B,EAAgC,EAAE;IACtG,IAAI,SAAqB,CAAA;IACzB,IAAI,CAAC;QACH,SAAS,GAAG,IAAA,oBAAQ,EAAC,MAAM,CAAC,CAAA;IAC9B,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,iCAAiC;QACjC,OAAO,iBAAiB,CAAC,YAAY,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QAC/B,iCAAiC;QACjC,OAAO,iBAAiB,CAAC,sBAAsB,CAAC,CAAA;IAClD,CAAC;IAED,IAAI,GAAe,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E,SAAS,CAAC,GAAG;oBACzB,YAAY,EAAE,GAAG;iBAClB;aACF,IACE,CAAC,GAAG,IAAI,EAAE,eAAe,EAAE,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GACpD,CAAC,GAAG,IAAI,EAAE,cAAc,EAAE,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GACnD,CAAC,GAAG,IAAI,EAAE,oBAAoB,EAAE,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GACzD,CAAC,GAAG,IAAI,EAAE,oBAAoB,EAAE,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GACzD,CAAC,GAAG,IAAI,EAAE,YAAY,EAAE,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CACrD;QACD,mBAAmB,EAAE,EAAE;KACxB,CAAA;IAED,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAO,KAAa,EAAgC,EAAE;IAC9E,OAAO;QACL,qBAAqB,EAAE;YACrB,KAAK;SACN;QACD,WAAW,EAAE,IAAI;QACjB,mBAAmB,EAAE,EAAE;KACxB,CAAA;AACH,CAAC,CAAA,CAAA;AAED,SAAgB,iBAAiB;IAC/B,OAAO,EAAE,GAAG,EAAE,qBAAa,EAAE,CAAA;AAC/B,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export declare enum Key {
|
|
2
|
-
Ed25519 = "Ed25519",
|
|
3
|
-
Secp256k1 = "Secp256k1",
|
|
4
|
-
Secp256r1 = "Secp256r1"
|
|
5
|
-
}
|
|
6
|
-
export declare enum KeyUse {
|
|
7
|
-
Encryption = "enc",
|
|
8
|
-
Signature = "sig"
|
|
9
|
-
}
|
|
10
|
-
export declare enum KeyType {
|
|
11
|
-
EC = "EC",
|
|
12
|
-
OKP = "OKP"
|
|
13
|
-
}
|
|
14
|
-
export declare enum VerificationType {
|
|
15
|
-
JsonWebKey2020 = "JsonWebKey2020"
|
|
16
|
-
}
|
|
17
|
-
export declare const SIG_KEY_ALGS: string[];
|
|
18
|
-
export declare const ENC_KEY_ALGS: string[];
|
|
19
|
-
export declare enum VocabType {
|
|
20
|
-
Jose = "https://www.iana.org/assignments/jose#"
|
|
21
|
-
}
|
|
22
|
-
export declare enum ContextType {
|
|
23
|
-
DidDocument = "https://www.w3.org/ns/did/v1"
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=jwk-resolver-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwk-resolver-types.d.ts","sourceRoot":"","sources":["../../src/types/jwk-resolver-types.ts"],"names":[],"mappings":"AAAA,oBAAY,GAAG;IACb,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,SAAS,cAAc;CACxB;AAED,oBAAY,MAAM;IAChB,UAAU,QAAQ;IAClB,SAAS,QAAQ;CAClB;AAED,oBAAY,OAAO;IACjB,EAAE,OAAO;IACT,GAAG,QAAQ;CACZ;AAED,oBAAY,gBAAgB;IAC1B,cAAc,mBAAmB;CAClC;AACD,eAAO,MAAM,YAAY,UAAkH,CAAA;AAC3I,eAAO,MAAM,YAAY,UAA+C,CAAA;AAIxE,oBAAY,SAAS;IACnB,IAAI,2CAA2C;CAChD;AAED,oBAAY,WAAW;IACrB,WAAW,iCAAiC;CAC7C"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContextType = exports.VocabType = exports.ENC_KEY_ALGS = exports.SIG_KEY_ALGS = exports.VerificationType = exports.KeyType = exports.KeyUse = exports.Key = void 0;
|
|
4
|
-
var Key;
|
|
5
|
-
(function (Key) {
|
|
6
|
-
Key["Ed25519"] = "Ed25519";
|
|
7
|
-
Key["Secp256k1"] = "Secp256k1";
|
|
8
|
-
Key["Secp256r1"] = "Secp256r1";
|
|
9
|
-
})(Key || (exports.Key = Key = {}));
|
|
10
|
-
var KeyUse;
|
|
11
|
-
(function (KeyUse) {
|
|
12
|
-
KeyUse["Encryption"] = "enc";
|
|
13
|
-
KeyUse["Signature"] = "sig";
|
|
14
|
-
})(KeyUse || (exports.KeyUse = KeyUse = {}));
|
|
15
|
-
var KeyType;
|
|
16
|
-
(function (KeyType) {
|
|
17
|
-
KeyType["EC"] = "EC";
|
|
18
|
-
KeyType["OKP"] = "OKP";
|
|
19
|
-
})(KeyType || (exports.KeyType = KeyType = {}));
|
|
20
|
-
var VerificationType;
|
|
21
|
-
(function (VerificationType) {
|
|
22
|
-
VerificationType["JsonWebKey2020"] = "JsonWebKey2020";
|
|
23
|
-
})(VerificationType || (exports.VerificationType = VerificationType = {}));
|
|
24
|
-
exports.SIG_KEY_ALGS = ['ES256', 'ES384', 'ES512', 'EdDSA', 'ES256K', 'Ed25519', 'Secp256k1', 'Secp256r1', 'Bls12381G1', 'Bls12381G2'];
|
|
25
|
-
exports.ENC_KEY_ALGS = ['X25519', 'ECDH_ES_A256KW', 'RSA_OAEP_256'];
|
|
26
|
-
// https://datatracker.ietf.org/doc/html/rfc8812#section-3
|
|
27
|
-
// https://datatracker.ietf.org/doc/html/rfc8812#section-4
|
|
28
|
-
var VocabType;
|
|
29
|
-
(function (VocabType) {
|
|
30
|
-
VocabType["Jose"] = "https://www.iana.org/assignments/jose#";
|
|
31
|
-
})(VocabType || (exports.VocabType = VocabType = {}));
|
|
32
|
-
var ContextType;
|
|
33
|
-
(function (ContextType) {
|
|
34
|
-
ContextType["DidDocument"] = "https://www.w3.org/ns/did/v1";
|
|
35
|
-
})(ContextType || (exports.ContextType = ContextType = {}));
|
|
36
|
-
//# sourceMappingURL=jwk-resolver-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwk-resolver-types.js","sourceRoot":"","sources":["../../src/types/jwk-resolver-types.ts"],"names":[],"mappings":";;;AAAA,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,0BAAmB,CAAA;IACnB,8BAAuB,CAAA;IACvB,8BAAuB,CAAA;AACzB,CAAC,EAJW,GAAG,mBAAH,GAAG,QAId;AAED,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,4BAAkB,CAAA;IAClB,2BAAiB,CAAA;AACnB,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB;AAED,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,oBAAS,CAAA;IACT,sBAAW,CAAA;AACb,CAAC,EAHW,OAAO,uBAAP,OAAO,QAGlB;AAED,IAAY,gBAEX;AAFD,WAAY,gBAAgB;IAC1B,qDAAiC,CAAA;AACnC,CAAC,EAFW,gBAAgB,gCAAhB,gBAAgB,QAE3B;AACY,QAAA,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;AAC9H,QAAA,YAAY,GAAG,CAAC,QAAQ,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAA;AAExE,0DAA0D;AAC1D,0DAA0D;AAC1D,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,4DAA+C,CAAA;AACjD,CAAC,EAFW,SAAS,yBAAT,SAAS,QAEpB;AAED,IAAY,WAEX;AAFD,WAAY,WAAW;IACrB,2DAA4C,CAAA;AAC9C,CAAC,EAFW,WAAW,2BAAX,WAAW,QAEtB"}
|