@sphereon/did-provider-oyd 0.28.0 → 0.28.1-feature.esm.cjs.13
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 +193 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{oyd-did-provider.d.ts → index.d.cts} +39 -5
- package/dist/index.d.ts +79 -7
- package/dist/index.js +159 -26
- package/dist/index.js.map +1 -1
- package/package.json +22 -15
- package/dist/index.d.ts.map +0 -1
- package/dist/oyd-did-provider.d.ts.map +0 -1
- package/dist/oyd-did-provider.js +0 -131
- package/dist/oyd-did-provider.js.map +0 -1
- package/dist/resolver.d.ts +0 -10
- package/dist/resolver.d.ts.map +0 -1
- package/dist/resolver.js +0 -44
- package/dist/resolver.js.map +0 -1
- package/dist/tsdoc-metadata.json +0 -11
- package/dist/types/oyd-provider-types.d.ts +0 -25
- package/dist/types/oyd-provider-types.d.ts.map +0 -1
- package/dist/types/oyd-provider-types.js +0 -11
- package/dist/types/oyd-provider-types.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
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;
|
|
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
|
+
OydDIDProvider: () => OydDIDProvider,
|
|
35
|
+
SupportedKeyTypes: () => SupportedKeyTypes,
|
|
36
|
+
getDidOydResolver: () => getDidOydResolver
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
|
|
40
|
+
// src/oyd-did-provider.ts
|
|
41
|
+
var import_did_manager = require("@veramo/did-manager");
|
|
42
|
+
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
43
|
+
var import_debug = __toESM(require("debug"), 1);
|
|
44
|
+
var debug = (0, import_debug.default)("veramo:oyd-did:identifier-provider");
|
|
45
|
+
var OydDIDProvider = class extends import_did_manager.AbstractIdentifierProvider {
|
|
46
|
+
static {
|
|
47
|
+
__name(this, "OydDIDProvider");
|
|
48
|
+
}
|
|
49
|
+
defaultKms;
|
|
50
|
+
constructor(options) {
|
|
51
|
+
super();
|
|
52
|
+
this.defaultKms = options.defaultKms;
|
|
53
|
+
}
|
|
54
|
+
async createIdentifier({ kms, options }, context) {
|
|
55
|
+
const body = {
|
|
56
|
+
options
|
|
57
|
+
};
|
|
58
|
+
const url = "https://oydid-registrar.data-container.net/1.0/createIdentifier";
|
|
59
|
+
let didDoc;
|
|
60
|
+
try {
|
|
61
|
+
const response = await (0, import_cross_fetch.default)(url, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: {
|
|
64
|
+
"Content-Type": "application/json"
|
|
65
|
+
},
|
|
66
|
+
body: JSON.stringify(body)
|
|
67
|
+
});
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
throw new Error("Network response was not ok: " + response.statusText);
|
|
70
|
+
}
|
|
71
|
+
didDoc = await response.json();
|
|
72
|
+
} catch (error) {
|
|
73
|
+
throw new Error("There has been a problem with the fetch operation: " + error.toString());
|
|
74
|
+
}
|
|
75
|
+
const keyType = options?.keyType || "Ed25519";
|
|
76
|
+
const key = await this.holdKeys({
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
kms: kms || this.defaultKms,
|
|
79
|
+
options: {
|
|
80
|
+
keyType,
|
|
81
|
+
kid: didDoc.did + "#key-doc",
|
|
82
|
+
publicKeyHex: didDoc.keys[0].publicKeyHex,
|
|
83
|
+
privateKeyHex: didDoc.keys[0].privateKeyHex
|
|
84
|
+
}
|
|
85
|
+
}, context);
|
|
86
|
+
const identifier = {
|
|
87
|
+
did: didDoc.did,
|
|
88
|
+
controllerKeyId: key.kid,
|
|
89
|
+
keys: [
|
|
90
|
+
key
|
|
91
|
+
],
|
|
92
|
+
services: []
|
|
93
|
+
};
|
|
94
|
+
debug("Created", identifier.did);
|
|
95
|
+
return identifier;
|
|
96
|
+
}
|
|
97
|
+
async updateIdentifier(args, context) {
|
|
98
|
+
throw new Error("OydDIDProvider updateIdentifier not supported yet.");
|
|
99
|
+
}
|
|
100
|
+
async deleteIdentifier(identifier, context) {
|
|
101
|
+
for (const { kid } of identifier.keys) {
|
|
102
|
+
await context.agent.keyManagerDelete({
|
|
103
|
+
kid
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
async addKey({ identifier, key, options }, context) {
|
|
109
|
+
return {
|
|
110
|
+
success: true
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async addService({ identifier, service, options }, context) {
|
|
114
|
+
return {
|
|
115
|
+
success: true
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async removeKey(args, context) {
|
|
119
|
+
return {
|
|
120
|
+
success: true
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async removeService(args, context) {
|
|
124
|
+
return {
|
|
125
|
+
success: true
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async holdKeys(args, context) {
|
|
129
|
+
if (args.options.privateKeyHex) {
|
|
130
|
+
return context.agent.keyManagerImport({
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
kms: args.kms || this.defaultKms,
|
|
133
|
+
type: args.options.keyType,
|
|
134
|
+
kid: args.options.kid,
|
|
135
|
+
privateKeyHex: args.options.privateKeyHex,
|
|
136
|
+
meta: {
|
|
137
|
+
algorithms: [
|
|
138
|
+
"Ed25519"
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return context.agent.keyManagerCreate({
|
|
144
|
+
type: args.options.keyType,
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
kms: args.kms || this.defaultKms,
|
|
147
|
+
meta: {
|
|
148
|
+
algorithms: [
|
|
149
|
+
"Ed25519"
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// src/resolver.ts
|
|
157
|
+
var import_cross_fetch2 = __toESM(require("cross-fetch"), 1);
|
|
158
|
+
var resolveDidOyd = /* @__PURE__ */ __name(async (didUrl, _parsed, _resolver, options) => {
|
|
159
|
+
try {
|
|
160
|
+
const baseUrl = "https://oydid-resolver.data-container.net";
|
|
161
|
+
const response = await (0, import_cross_fetch2.default)(`${baseUrl}/1.0/identifiers/${didUrl}`);
|
|
162
|
+
if (!response.ok) {
|
|
163
|
+
throw new Error("Network response was not ok: " + response.statusText);
|
|
164
|
+
}
|
|
165
|
+
const didDoc = await response.json();
|
|
166
|
+
return didDoc;
|
|
167
|
+
} catch (err) {
|
|
168
|
+
return {
|
|
169
|
+
didDocumentMetadata: {},
|
|
170
|
+
didResolutionMetadata: {
|
|
171
|
+
error: "invalidDid",
|
|
172
|
+
message: err.toString()
|
|
173
|
+
},
|
|
174
|
+
didDocument: null
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}, "resolveDidOyd");
|
|
178
|
+
function getDidOydResolver() {
|
|
179
|
+
return {
|
|
180
|
+
oyd: resolveDidOyd
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
__name(getDidOydResolver, "getDidOydResolver");
|
|
184
|
+
|
|
185
|
+
// src/types/oyd-provider-types.ts
|
|
186
|
+
var SupportedKeyTypes = /* @__PURE__ */ function(SupportedKeyTypes2) {
|
|
187
|
+
SupportedKeyTypes2["Secp256r1"] = "Secp256r1";
|
|
188
|
+
SupportedKeyTypes2["Secp256k1"] = "Secp256k1";
|
|
189
|
+
SupportedKeyTypes2["Ed25519"] = "Ed25519";
|
|
190
|
+
SupportedKeyTypes2["X25519"] = "X25519";
|
|
191
|
+
return SupportedKeyTypes2;
|
|
192
|
+
}({});
|
|
193
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/oyd-did-provider.ts","../src/resolver.ts","../src/types/oyd-provider-types.ts"],"sourcesContent":["/**\n * Provides `did:oyd` {@link @ownyourdata/did-provider-oyd#OydDIDProvider | identifier provider } for the\n * {@link @veramo/did-manager#DIDManager}\n *\n * @packageDocumentation\n */\nexport { OydDIDProvider } from './oyd-did-provider.js'\nexport { getDidOydResolver } from './resolver.js'\nexport * from './types/oyd-provider-types.js'\n","import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core'\nimport { AbstractIdentifierProvider } from '@veramo/did-manager'\nimport type { OydCreateIdentifierOptions, OydDidHoldKeysArgs, OydDidSupportedKeyTypes } from './types/oyd-provider-types.js'\nimport fetch from 'cross-fetch'\n\nimport Debug from 'debug'\nconst debug = Debug('veramo:oyd-did:identifier-provider')\n\ntype IContext = IAgentContext<IKeyManager>\n\n/**\n * {@link @veramo/did-manager#DIDManager} identifier provider for `did:oyd` identifiers\n * @public\n */\nexport class OydDIDProvider extends AbstractIdentifierProvider {\n private defaultKms?: string\n\n constructor(options: { defaultKms?: string }) {\n super()\n this.defaultKms = options.defaultKms\n }\n\n async createIdentifier(\n { kms, options }: { kms?: string; options: OydCreateIdentifierOptions },\n context: IContext\n ): Promise<Omit<IIdentifier, 'provider'>> {\n const body = { options }\n const url = 'https://oydid-registrar.data-container.net/1.0/createIdentifier'\n\n let didDoc: any | undefined\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n })\n if (!response.ok) {\n throw new Error('Network response was not ok: ' + response.statusText)\n }\n didDoc = await response.json()\n } catch (error) {\n // @ts-ignore\n throw new Error('There has been a problem with the fetch operation: ' + error.toString())\n }\n\n const keyType: OydDidSupportedKeyTypes = options?.keyType || 'Ed25519'\n const key = await this.holdKeys(\n {\n // @ts-ignore\n kms: kms || this.defaultKms,\n options: {\n keyType,\n kid: didDoc.did + '#key-doc',\n publicKeyHex: didDoc.keys[0].publicKeyHex,\n privateKeyHex: didDoc.keys[0].privateKeyHex,\n },\n },\n context\n )\n\n const identifier: Omit<IIdentifier, 'provider'> = {\n did: didDoc.did,\n controllerKeyId: key.kid,\n keys: [key],\n services: [],\n }\n debug('Created', identifier.did)\n return identifier\n }\n\n async updateIdentifier(\n args: { did: string; kms?: string | undefined; alias?: string | undefined; options?: any },\n context: IAgentContext<IKeyManager>\n ): Promise<IIdentifier> {\n throw new Error('OydDIDProvider updateIdentifier not supported yet.')\n }\n\n async deleteIdentifier(identifier: IIdentifier, context: IContext): Promise<boolean> {\n for (const { kid } of identifier.keys) {\n await context.agent.keyManagerDelete({ kid })\n }\n return true\n }\n\n async addKey({ identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any }, context: IContext): Promise<any> {\n return { success: true }\n }\n\n async addService({ identifier, service, options }: { identifier: IIdentifier; service: IService; options?: any }, context: IContext): Promise<any> {\n return { success: true }\n }\n\n async removeKey(args: { identifier: IIdentifier; kid: string; options?: any }, context: IContext): Promise<any> {\n return { success: true }\n }\n\n async removeService(args: { identifier: IIdentifier; id: string; options?: any }, context: IContext): Promise<any> {\n return { success: true }\n }\n\n private async holdKeys(args: OydDidHoldKeysArgs, context: IContext): Promise<IKey> {\n if (args.options.privateKeyHex) {\n return context.agent.keyManagerImport({\n // @ts-ignore\n kms: args.kms || this.defaultKms,\n type: args.options.keyType,\n kid: args.options.kid,\n privateKeyHex: args.options.privateKeyHex,\n meta: {\n algorithms: ['Ed25519'],\n },\n })\n }\n return context.agent.keyManagerCreate({\n type: args.options.keyType,\n // @ts-ignore\n kms: args.kms || this.defaultKms,\n meta: {\n algorithms: ['Ed25519'],\n },\n })\n }\n}\n","import { DIDResolutionOptions, DIDResolutionResult, DIDResolver, ParsedDID, Resolvable } from 'did-resolver'\nimport fetch from 'cross-fetch'\n\nconst resolveDidOyd: DIDResolver = async (\n didUrl: string,\n _parsed: ParsedDID,\n _resolver: Resolvable,\n options: DIDResolutionOptions\n): Promise<DIDResolutionResult> => {\n try {\n const baseUrl: string = 'https://oydid-resolver.data-container.net'\n // const didDoc = await axios.get(`${baseUrl}/1.0/identifiers/${didUrl}`);\n const response = await fetch(`${baseUrl}/1.0/identifiers/${didUrl}`)\n if (!response.ok) {\n throw new Error('Network response was not ok: ' + response.statusText)\n }\n const didDoc = await response.json()\n return didDoc as DIDResolutionResult\n } catch (err: any) {\n return {\n didDocumentMetadata: {},\n didResolutionMetadata: { error: 'invalidDid', message: err.toString() },\n didDocument: null,\n }\n }\n}\n\n/**\n * Provides a mapping to a did:oyd resolver, usable by {@link did-resolver#Resolver}.\n *\n * @public\n */\nexport function getDidOydResolver() {\n return { oyd: resolveDidOyd }\n}\n","export type OydCreateIdentifierOptions = {\n keyType?: OydDidSupportedKeyTypes\n privateKeyHex?: string\n keyUse?: KeyUse\n}\n\nexport type OydDidHoldKeysArgs = {\n kms: string\n options: HoldKeysOpts\n}\n\ntype HoldKeysOpts = {\n keyType: OydDidSupportedKeyTypes\n kid: string\n publicKeyHex?: string\n privateKeyHex?: string\n}\n\nexport enum SupportedKeyTypes {\n Secp256r1 = 'Secp256r1',\n Secp256k1 = 'Secp256k1',\n Ed25519 = 'Ed25519',\n X25519 = 'X25519',\n}\n\nexport type OydDidSupportedKeyTypes = keyof typeof SupportedKeyTypes\n\nexport type KeyUse = 'sig' | 'enc'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACCA,yBAA2C;AAE3C,yBAAkB;AAElB,mBAAkB;AAClB,IAAMA,YAAQC,aAAAA,SAAM,oCAAA;AAQb,IAAMC,iBAAN,cAA6BC,8CAAAA;EAbpC,OAaoCA;;;EAC1BC;EAERC,YAAYC,SAAkC;AAC5C,UAAK;AACL,SAAKF,aAAaE,QAAQF;EAC5B;EAEA,MAAMG,iBACJ,EAAEC,KAAKF,QAAO,GACdG,SACwC;AACxC,UAAMC,OAAO;MAAEJ;IAAQ;AACvB,UAAMK,MAAM;AAEZ,QAAIC;AACJ,QAAI;AACF,YAAMC,WAAW,UAAMC,mBAAAA,SAAMH,KAAK;QAChCI,QAAQ;QACRC,SAAS;UACP,gBAAgB;QAClB;QACAN,MAAMO,KAAKC,UAAUR,IAAAA;MACvB,CAAA;AACA,UAAI,CAACG,SAASM,IAAI;AAChB,cAAM,IAAIC,MAAM,kCAAkCP,SAASQ,UAAU;MACvE;AACAT,eAAS,MAAMC,SAASS,KAAI;IA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QAEpCvC,KAAK6B,KAAK7B,OAAO,KAAKJ;QACtB4C,MAAMX,KAAK/B,QAAQmB;QACnBG,KAAKS,KAAK/B,QAAQsB;QAClBI,eAAeK,KAAK/B,QAAQ0B;QAC5BiB,MAAM;UACJC,YAAY;YAAC;;QACf;MACF,CAAA;IACF;AACA,WAAOzC,QAAQ8B,MAAMY,iBAAiB;MACpCH,MAAMX,KAAK/B,QAAQmB;;MAEnBjB,KAAK6B,KAAK7B,OAAO,KAAKJ;MACtB6C,MAAM;QACJC,YAAY;UAAC;;MACf;IACF,CAAA;EACF;AACF;;;AC3HA,IAAAE,sBAAkB;AAElB,IAAMC,gBAA6B,8BACjCC,QACAC,SACAC,WACAC,YAAAA;AAEA,MAAI;AACF,UAAMC,UAAkB;AAExB,UAAMC,WAAW,UAAMC,oBAAAA,SAAM,GAAGF,OAAAA,oBAA2BJ,MAAAA,EAAQ;AACnE,QAAI,CAACK,SAASE,IAAI;AAChB,YAAM,IAAIC,MAAM,kCAAkCH,SAASI,UAAU;IACvE;AACA,UAAMC,SAAS,MAAML,SAASM,KAAI;AAClC,WAAOD;EACT,SAASE,KAAU;AACjB,WAAO;MACLC,qBAAqB,CAAC;MACtBC,uBAAuB;QAAEC,OAAO;QAAcC,SAASJ,IAAIK,SAAQ;MAAG;MACtEC,aAAa;IACf;EACF;AACF,GAtBmC;AA6B5B,SAASC,oBAAAA;AACd,SAAO;IAAEC,KAAKrB;EAAc;AAC9B;AAFgBoB;;;ACdT,IAAKE,oBAAAA,yBAAAA,oBAAAA;;;;;SAAAA;;","names":["debug","Debug","OydDIDProvider","AbstractIdentifierProvider","defaultKms","constructor","options","createIdentifier","kms","context","body","url","didDoc","response","fetch","method","headers","JSON","stringify","ok","Error","statusText","json","error","toString","keyType","key","holdKeys","kid","did","publicKeyHex","keys","privateKeyHex","identifier","controllerKeyId","services","updateIdentifier","args","deleteIdentifier","agent","keyManagerDelete","addKey","success","addService","service","removeKey","removeService","keyManagerImport","type","meta","algorithms","keyManagerCreate","import_cross_fetch","resolveDidOyd","didUrl","_parsed","_resolver","options","baseUrl","response","fetch","ok","Error","statusText","didDoc","json","err","didDocumentMetadata","didResolutionMetadata","error","message","toString","didDocument","getDidOydResolver","oyd","SupportedKeyTypes"]}
|
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAgentContext, IKeyManager, IIdentifier, IKey, IService } from '@veramo/core';
|
|
2
2
|
import { AbstractIdentifierProvider } from '@veramo/did-manager';
|
|
3
|
-
import
|
|
3
|
+
import { DIDResolver } from 'did-resolver';
|
|
4
|
+
|
|
5
|
+
type OydCreateIdentifierOptions = {
|
|
6
|
+
keyType?: OydDidSupportedKeyTypes;
|
|
7
|
+
privateKeyHex?: string;
|
|
8
|
+
keyUse?: KeyUse;
|
|
9
|
+
};
|
|
10
|
+
type OydDidHoldKeysArgs = {
|
|
11
|
+
kms: string;
|
|
12
|
+
options: HoldKeysOpts;
|
|
13
|
+
};
|
|
14
|
+
type HoldKeysOpts = {
|
|
15
|
+
keyType: OydDidSupportedKeyTypes;
|
|
16
|
+
kid: string;
|
|
17
|
+
publicKeyHex?: string;
|
|
18
|
+
privateKeyHex?: string;
|
|
19
|
+
};
|
|
20
|
+
declare enum SupportedKeyTypes {
|
|
21
|
+
Secp256r1 = "Secp256r1",
|
|
22
|
+
Secp256k1 = "Secp256k1",
|
|
23
|
+
Ed25519 = "Ed25519",
|
|
24
|
+
X25519 = "X25519"
|
|
25
|
+
}
|
|
26
|
+
type OydDidSupportedKeyTypes = keyof typeof SupportedKeyTypes;
|
|
27
|
+
type KeyUse = 'sig' | 'enc';
|
|
28
|
+
|
|
4
29
|
type IContext = IAgentContext<IKeyManager>;
|
|
5
30
|
/**
|
|
6
31
|
* {@link @veramo/did-manager#DIDManager} identifier provider for `did:oyd` identifiers
|
|
7
32
|
* @public
|
|
8
33
|
*/
|
|
9
|
-
|
|
34
|
+
declare class OydDIDProvider extends AbstractIdentifierProvider {
|
|
10
35
|
private defaultKms?;
|
|
11
36
|
constructor(options: {
|
|
12
37
|
defaultKms?: string;
|
|
@@ -44,5 +69,14 @@ export declare class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
44
69
|
}, context: IContext): Promise<any>;
|
|
45
70
|
private holdKeys;
|
|
46
71
|
}
|
|
47
|
-
|
|
48
|
-
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Provides a mapping to a did:oyd resolver, usable by {@link did-resolver#Resolver}.
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
declare function getDidOydResolver(): {
|
|
79
|
+
oyd: DIDResolver;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { type KeyUse, type OydCreateIdentifierOptions, OydDIDProvider, type OydDidHoldKeysArgs, type OydDidSupportedKeyTypes, SupportedKeyTypes, getDidOydResolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,82 @@
|
|
|
1
|
+
import { IAgentContext, IKeyManager, IIdentifier, IKey, IService } from '@veramo/core';
|
|
2
|
+
import { AbstractIdentifierProvider } from '@veramo/did-manager';
|
|
3
|
+
import { DIDResolver } from 'did-resolver';
|
|
4
|
+
|
|
5
|
+
type OydCreateIdentifierOptions = {
|
|
6
|
+
keyType?: OydDidSupportedKeyTypes;
|
|
7
|
+
privateKeyHex?: string;
|
|
8
|
+
keyUse?: KeyUse;
|
|
9
|
+
};
|
|
10
|
+
type OydDidHoldKeysArgs = {
|
|
11
|
+
kms: string;
|
|
12
|
+
options: HoldKeysOpts;
|
|
13
|
+
};
|
|
14
|
+
type HoldKeysOpts = {
|
|
15
|
+
keyType: OydDidSupportedKeyTypes;
|
|
16
|
+
kid: string;
|
|
17
|
+
publicKeyHex?: string;
|
|
18
|
+
privateKeyHex?: string;
|
|
19
|
+
};
|
|
20
|
+
declare enum SupportedKeyTypes {
|
|
21
|
+
Secp256r1 = "Secp256r1",
|
|
22
|
+
Secp256k1 = "Secp256k1",
|
|
23
|
+
Ed25519 = "Ed25519",
|
|
24
|
+
X25519 = "X25519"
|
|
25
|
+
}
|
|
26
|
+
type OydDidSupportedKeyTypes = keyof typeof SupportedKeyTypes;
|
|
27
|
+
type KeyUse = 'sig' | 'enc';
|
|
28
|
+
|
|
29
|
+
type IContext = IAgentContext<IKeyManager>;
|
|
1
30
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
31
|
+
* {@link @veramo/did-manager#DIDManager} identifier provider for `did:oyd` identifiers
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
declare class OydDIDProvider extends AbstractIdentifierProvider {
|
|
35
|
+
private defaultKms?;
|
|
36
|
+
constructor(options: {
|
|
37
|
+
defaultKms?: string;
|
|
38
|
+
});
|
|
39
|
+
createIdentifier({ kms, options }: {
|
|
40
|
+
kms?: string;
|
|
41
|
+
options: OydCreateIdentifierOptions;
|
|
42
|
+
}, context: IContext): Promise<Omit<IIdentifier, 'provider'>>;
|
|
43
|
+
updateIdentifier(args: {
|
|
44
|
+
did: string;
|
|
45
|
+
kms?: string | undefined;
|
|
46
|
+
alias?: string | undefined;
|
|
47
|
+
options?: any;
|
|
48
|
+
}, context: IAgentContext<IKeyManager>): Promise<IIdentifier>;
|
|
49
|
+
deleteIdentifier(identifier: IIdentifier, context: IContext): Promise<boolean>;
|
|
50
|
+
addKey({ identifier, key, options }: {
|
|
51
|
+
identifier: IIdentifier;
|
|
52
|
+
key: IKey;
|
|
53
|
+
options?: any;
|
|
54
|
+
}, context: IContext): Promise<any>;
|
|
55
|
+
addService({ identifier, service, options }: {
|
|
56
|
+
identifier: IIdentifier;
|
|
57
|
+
service: IService;
|
|
58
|
+
options?: any;
|
|
59
|
+
}, context: IContext): Promise<any>;
|
|
60
|
+
removeKey(args: {
|
|
61
|
+
identifier: IIdentifier;
|
|
62
|
+
kid: string;
|
|
63
|
+
options?: any;
|
|
64
|
+
}, context: IContext): Promise<any>;
|
|
65
|
+
removeService(args: {
|
|
66
|
+
identifier: IIdentifier;
|
|
67
|
+
id: string;
|
|
68
|
+
options?: any;
|
|
69
|
+
}, context: IContext): Promise<any>;
|
|
70
|
+
private holdKeys;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Provides a mapping to a did:oyd resolver, usable by {@link did-resolver#Resolver}.
|
|
4
75
|
*
|
|
5
|
-
* @
|
|
76
|
+
* @public
|
|
6
77
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
78
|
+
declare function getDidOydResolver(): {
|
|
79
|
+
oyd: DIDResolver;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { type KeyUse, type OydCreateIdentifierOptions, OydDIDProvider, type OydDidHoldKeysArgs, type OydDidSupportedKeyTypes, SupportedKeyTypes, getDidOydResolver };
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,162 @@
|
|
|
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/oyd-did-provider.ts
|
|
5
|
+
import { AbstractIdentifierProvider } from "@veramo/did-manager";
|
|
6
|
+
import fetch from "cross-fetch";
|
|
7
|
+
import Debug from "debug";
|
|
8
|
+
var debug = Debug("veramo:oyd-did:identifier-provider");
|
|
9
|
+
var OydDIDProvider = class extends AbstractIdentifierProvider {
|
|
10
|
+
static {
|
|
11
|
+
__name(this, "OydDIDProvider");
|
|
12
|
+
}
|
|
13
|
+
defaultKms;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super();
|
|
16
|
+
this.defaultKms = options.defaultKms;
|
|
17
|
+
}
|
|
18
|
+
async createIdentifier({ kms, options }, context) {
|
|
19
|
+
const body = {
|
|
20
|
+
options
|
|
21
|
+
};
|
|
22
|
+
const url = "https://oydid-registrar.data-container.net/1.0/createIdentifier";
|
|
23
|
+
let didDoc;
|
|
24
|
+
try {
|
|
25
|
+
const response = await fetch(url, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
headers: {
|
|
28
|
+
"Content-Type": "application/json"
|
|
29
|
+
},
|
|
30
|
+
body: JSON.stringify(body)
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw new Error("Network response was not ok: " + response.statusText);
|
|
34
|
+
}
|
|
35
|
+
didDoc = await response.json();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
throw new Error("There has been a problem with the fetch operation: " + error.toString());
|
|
7
38
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
39
|
+
const keyType = options?.keyType || "Ed25519";
|
|
40
|
+
const key = await this.holdKeys({
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
kms: kms || this.defaultKms,
|
|
43
|
+
options: {
|
|
44
|
+
keyType,
|
|
45
|
+
kid: didDoc.did + "#key-doc",
|
|
46
|
+
publicKeyHex: didDoc.keys[0].publicKeyHex,
|
|
47
|
+
privateKeyHex: didDoc.keys[0].privateKeyHex
|
|
48
|
+
}
|
|
49
|
+
}, context);
|
|
50
|
+
const identifier = {
|
|
51
|
+
did: didDoc.did,
|
|
52
|
+
controllerKeyId: key.kid,
|
|
53
|
+
keys: [
|
|
54
|
+
key
|
|
55
|
+
],
|
|
56
|
+
services: []
|
|
57
|
+
};
|
|
58
|
+
debug("Created", identifier.did);
|
|
59
|
+
return identifier;
|
|
60
|
+
}
|
|
61
|
+
async updateIdentifier(args, context) {
|
|
62
|
+
throw new Error("OydDIDProvider updateIdentifier not supported yet.");
|
|
63
|
+
}
|
|
64
|
+
async deleteIdentifier(identifier, context) {
|
|
65
|
+
for (const { kid } of identifier.keys) {
|
|
66
|
+
await context.agent.keyManagerDelete({
|
|
67
|
+
kid
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
async addKey({ identifier, key, options }, context) {
|
|
73
|
+
return {
|
|
74
|
+
success: true
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async addService({ identifier, service, options }, context) {
|
|
78
|
+
return {
|
|
79
|
+
success: true
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
async removeKey(args, context) {
|
|
83
|
+
return {
|
|
84
|
+
success: true
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
async removeService(args, context) {
|
|
88
|
+
return {
|
|
89
|
+
success: true
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async holdKeys(args, context) {
|
|
93
|
+
if (args.options.privateKeyHex) {
|
|
94
|
+
return context.agent.keyManagerImport({
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
kms: args.kms || this.defaultKms,
|
|
97
|
+
type: args.options.keyType,
|
|
98
|
+
kid: args.options.kid,
|
|
99
|
+
privateKeyHex: args.options.privateKeyHex,
|
|
100
|
+
meta: {
|
|
101
|
+
algorithms: [
|
|
102
|
+
"Ed25519"
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return context.agent.keyManagerCreate({
|
|
108
|
+
type: args.options.keyType,
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
kms: args.kms || this.defaultKms,
|
|
111
|
+
meta: {
|
|
112
|
+
algorithms: [
|
|
113
|
+
"Ed25519"
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/resolver.ts
|
|
121
|
+
import fetch2 from "cross-fetch";
|
|
122
|
+
var resolveDidOyd = /* @__PURE__ */ __name(async (didUrl, _parsed, _resolver, options) => {
|
|
123
|
+
try {
|
|
124
|
+
const baseUrl = "https://oydid-resolver.data-container.net";
|
|
125
|
+
const response = await fetch2(`${baseUrl}/1.0/identifiers/${didUrl}`);
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
throw new Error("Network response was not ok: " + response.statusText);
|
|
128
|
+
}
|
|
129
|
+
const didDoc = await response.json();
|
|
130
|
+
return didDoc;
|
|
131
|
+
} catch (err) {
|
|
132
|
+
return {
|
|
133
|
+
didDocumentMetadata: {},
|
|
134
|
+
didResolutionMetadata: {
|
|
135
|
+
error: "invalidDid",
|
|
136
|
+
message: err.toString()
|
|
137
|
+
},
|
|
138
|
+
didDocument: null
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}, "resolveDidOyd");
|
|
142
|
+
function getDidOydResolver() {
|
|
143
|
+
return {
|
|
144
|
+
oyd: resolveDidOyd
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
__name(getDidOydResolver, "getDidOydResolver");
|
|
148
|
+
|
|
149
|
+
// src/types/oyd-provider-types.ts
|
|
150
|
+
var SupportedKeyTypes = /* @__PURE__ */ function(SupportedKeyTypes2) {
|
|
151
|
+
SupportedKeyTypes2["Secp256r1"] = "Secp256r1";
|
|
152
|
+
SupportedKeyTypes2["Secp256k1"] = "Secp256k1";
|
|
153
|
+
SupportedKeyTypes2["Ed25519"] = "Ed25519";
|
|
154
|
+
SupportedKeyTypes2["X25519"] = "X25519";
|
|
155
|
+
return SupportedKeyTypes2;
|
|
156
|
+
}({});
|
|
157
|
+
export {
|
|
158
|
+
OydDIDProvider,
|
|
159
|
+
SupportedKeyTypes,
|
|
160
|
+
getDidOydResolver
|
|
15
161
|
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getDidOydResolver = exports.OydDIDProvider = void 0;
|
|
18
|
-
/**
|
|
19
|
-
* Provides `did:oyd` {@link @ownyourdata/did-provider-oyd#OydDIDProvider | identifier provider } for the
|
|
20
|
-
* {@link @veramo/did-manager#DIDManager}
|
|
21
|
-
*
|
|
22
|
-
* @packageDocumentation
|
|
23
|
-
*/
|
|
24
|
-
var oyd_did_provider_js_1 = require("./oyd-did-provider.js");
|
|
25
|
-
Object.defineProperty(exports, "OydDIDProvider", { enumerable: true, get: function () { return oyd_did_provider_js_1.OydDIDProvider; } });
|
|
26
|
-
var resolver_js_1 = require("./resolver.js");
|
|
27
|
-
Object.defineProperty(exports, "getDidOydResolver", { enumerable: true, get: function () { return resolver_js_1.getDidOydResolver; } });
|
|
28
|
-
__exportStar(require("./types/oyd-provider-types.js"), exports);
|
|
29
162
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/oyd-did-provider.ts","../src/resolver.ts","../src/types/oyd-provider-types.ts"],"sourcesContent":["import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core'\nimport { AbstractIdentifierProvider } from '@veramo/did-manager'\nimport type { OydCreateIdentifierOptions, OydDidHoldKeysArgs, OydDidSupportedKeyTypes } from './types/oyd-provider-types.js'\nimport fetch from 'cross-fetch'\n\nimport Debug from 'debug'\nconst debug = Debug('veramo:oyd-did:identifier-provider')\n\ntype IContext = IAgentContext<IKeyManager>\n\n/**\n * {@link @veramo/did-manager#DIDManager} identifier provider for `did:oyd` identifiers\n * @public\n */\nexport class OydDIDProvider extends AbstractIdentifierProvider {\n private defaultKms?: string\n\n constructor(options: { defaultKms?: string }) {\n super()\n this.defaultKms = options.defaultKms\n }\n\n async createIdentifier(\n { kms, options }: { kms?: string; options: OydCreateIdentifierOptions },\n context: IContext\n ): Promise<Omit<IIdentifier, 'provider'>> {\n const body = { options }\n const url = 'https://oydid-registrar.data-container.net/1.0/createIdentifier'\n\n let didDoc: any | undefined\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n })\n if (!response.ok) {\n throw new Error('Network response was not ok: ' + response.statusText)\n }\n didDoc = await response.json()\n } catch (error) {\n // @ts-ignore\n throw new Error('There has been a problem with the fetch operation: ' + error.toString())\n }\n\n const keyType: OydDidSupportedKeyTypes = options?.keyType || 'Ed25519'\n const key = await this.holdKeys(\n {\n // @ts-ignore\n kms: kms || this.defaultKms,\n options: {\n keyType,\n kid: didDoc.did + '#key-doc',\n publicKeyHex: didDoc.keys[0].publicKeyHex,\n privateKeyHex: didDoc.keys[0].privateKeyHex,\n },\n },\n context\n )\n\n const identifier: Omit<IIdentifier, 'provider'> = {\n did: didDoc.did,\n controllerKeyId: key.kid,\n keys: [key],\n services: [],\n }\n debug('Created', identifier.did)\n return identifier\n }\n\n async updateIdentifier(\n args: { did: string; kms?: string | undefined; alias?: string | undefined; options?: any },\n context: IAgentContext<IKeyManager>\n ): Promise<IIdentifier> {\n throw new Error('OydDIDProvider updateIdentifier not supported yet.')\n }\n\n async deleteIdentifier(identifier: IIdentifier, context: IContext): Promise<boolean> {\n for (const { kid } of identifier.keys) {\n await context.agent.keyManagerDelete({ kid })\n }\n return true\n }\n\n async addKey({ identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any }, context: IContext): Promise<any> {\n return { success: true }\n }\n\n async addService({ identifier, service, options }: { identifier: IIdentifier; service: IService; options?: any }, context: IContext): Promise<any> {\n return { success: true }\n }\n\n async removeKey(args: { identifier: IIdentifier; kid: string; options?: any }, context: IContext): Promise<any> {\n return { success: true }\n }\n\n async removeService(args: { identifier: IIdentifier; id: string; options?: any }, context: IContext): Promise<any> {\n return { success: true }\n }\n\n private async holdKeys(args: OydDidHoldKeysArgs, context: IContext): Promise<IKey> {\n if (args.options.privateKeyHex) {\n return context.agent.keyManagerImport({\n // @ts-ignore\n kms: args.kms || this.defaultKms,\n type: args.options.keyType,\n kid: args.options.kid,\n privateKeyHex: args.options.privateKeyHex,\n meta: {\n algorithms: ['Ed25519'],\n },\n })\n }\n return context.agent.keyManagerCreate({\n type: args.options.keyType,\n // @ts-ignore\n kms: args.kms || this.defaultKms,\n meta: {\n algorithms: ['Ed25519'],\n },\n })\n }\n}\n","import { DIDResolutionOptions, DIDResolutionResult, DIDResolver, ParsedDID, Resolvable } from 'did-resolver'\nimport fetch from 'cross-fetch'\n\nconst resolveDidOyd: DIDResolver = async (\n didUrl: string,\n _parsed: ParsedDID,\n _resolver: Resolvable,\n options: DIDResolutionOptions\n): Promise<DIDResolutionResult> => {\n try {\n const baseUrl: string = 'https://oydid-resolver.data-container.net'\n // const didDoc = await axios.get(`${baseUrl}/1.0/identifiers/${didUrl}`);\n const response = await fetch(`${baseUrl}/1.0/identifiers/${didUrl}`)\n if (!response.ok) {\n throw new Error('Network response was not ok: ' + response.statusText)\n }\n const didDoc = await response.json()\n return didDoc as DIDResolutionResult\n } catch (err: any) {\n return {\n didDocumentMetadata: {},\n didResolutionMetadata: { error: 'invalidDid', message: err.toString() },\n didDocument: null,\n }\n }\n}\n\n/**\n * Provides a mapping to a did:oyd resolver, usable by {@link did-resolver#Resolver}.\n *\n * @public\n */\nexport function getDidOydResolver() {\n return { oyd: resolveDidOyd }\n}\n","export type OydCreateIdentifierOptions = {\n keyType?: OydDidSupportedKeyTypes\n privateKeyHex?: string\n keyUse?: KeyUse\n}\n\nexport type OydDidHoldKeysArgs = {\n kms: string\n options: HoldKeysOpts\n}\n\ntype HoldKeysOpts = {\n keyType: OydDidSupportedKeyTypes\n kid: string\n publicKeyHex?: string\n privateKeyHex?: string\n}\n\nexport enum SupportedKeyTypes {\n Secp256r1 = 'Secp256r1',\n Secp256k1 = 'Secp256k1',\n Ed25519 = 'Ed25519',\n X25519 = 'X25519',\n}\n\nexport type OydDidSupportedKeyTypes = keyof typeof SupportedKeyTypes\n\nexport type KeyUse = 'sig' | 'enc'\n"],"mappings":";;;;AACA,SAASA,kCAAkC;AAE3C,OAAOC,WAAW;AAElB,OAAOC,WAAW;AAClB,IAAMC,QAAQC,MAAM,oCAAA;AAQb,IAAMC,iBAAN,cAA6BC,2BAAAA;EAbpC,OAaoCA;;;EAC1BC;EAERC,YAAYC,SAAkC;AAC5C,UAAK;AACL,SAAKF,aAAaE,QAAQF;EAC5B;EAEA,MAAMG,iBACJ,EAAEC,KAAK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AC9B;AAFgBoB;;;ACdT,IAAKE,oBAAAA,yBAAAA,oBAAAA;;;;;SAAAA;;","names":["AbstractIdentifierProvider","fetch","Debug","debug","Debug","OydDIDProvider","AbstractIdentifierProvider","defaultKms","constructor","options","createIdentifier","kms","context","body","url","didDoc","response","fetch","method","headers","JSON","stringify","ok","Error","statusText","json","error","toString","keyType","key","holdKeys","kid","did","publicKeyHex","keys","privateKeyHex","identifier","controllerKeyId","services","updateIdentifier","args","deleteIdentifier","agent","keyManagerDelete","addKey","success","addService","service","removeKey","removeService","keyManagerImport","type","meta","algorithms","keyManagerCreate","fetch","resolveDidOyd","didUrl","_parsed","_resolver","options","baseUrl","response","fetch","ok","Error","statusText","didDoc","json","err","didDocumentMetadata","didResolutionMetadata","error","message","toString","didDocument","getDidOydResolver","oyd","SupportedKeyTypes"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/did-provider-oyd",
|
|
3
3
|
"description": "OwnYourData plugin that can enable creation and control of did:oyd identifiers.",
|
|
4
|
-
"version": "0.28.
|
|
5
|
-
"source": "src/index.ts",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
4
|
+
"version": "0.28.1-feature.esm.cjs.13+24ca549",
|
|
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": "
|
|
21
|
+
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json",
|
|
10
22
|
"extract-api": "sphereon dev extract-api"
|
|
11
23
|
},
|
|
12
24
|
"dependencies": {
|
|
@@ -17,15 +29,15 @@
|
|
|
17
29
|
"did-resolver": "^4.1.0"
|
|
18
30
|
},
|
|
19
31
|
"devDependencies": {
|
|
20
|
-
"@sphereon/ssi-sdk.dev": "0.
|
|
32
|
+
"@sphereon/ssi-sdk.dev": "0.33.1-feature.vcdm2.tsup.25",
|
|
21
33
|
"@types/debug": "4.1.8",
|
|
22
34
|
"inquirer": "^9.1.4",
|
|
23
35
|
"inquirer-autocomplete-prompt": "^3.0.0",
|
|
24
|
-
"typescript": "5.
|
|
36
|
+
"typescript": "5.8.3"
|
|
25
37
|
},
|
|
26
38
|
"files": [
|
|
27
|
-
"dist
|
|
28
|
-
"src
|
|
39
|
+
"dist",
|
|
40
|
+
"src",
|
|
29
41
|
"README.md",
|
|
30
42
|
"LICENSE"
|
|
31
43
|
],
|
|
@@ -36,10 +48,5 @@
|
|
|
36
48
|
"author": "Christoph Fabianek <christoph@ownyourdata.eu>",
|
|
37
49
|
"keywords": [],
|
|
38
50
|
"license": "MIT",
|
|
39
|
-
"
|
|
40
|
-
"moduleDirectories": [
|
|
41
|
-
"node_modules",
|
|
42
|
-
"src"
|
|
43
|
-
],
|
|
44
|
-
"gitHead": "ba773b2ba53f4a9b96bf4356789a0e68bf666816"
|
|
51
|
+
"gitHead": "24ca549841533d8ae29184b42dc92a416bdb246d"
|
|
45
52
|
}
|
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,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,cAAc,+BAA+B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oyd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AAE,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAI5H,UAAU,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QAAE,UAAU,EAAE,WAAW,CAAC;QAAC,OAAO,EAAE,QAAQ,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAI5I,SAAS,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,WAAW,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAIzG,aAAa,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,WAAW,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;YAIpG,QAAQ;CAsBvB"}
|
package/dist/oyd-did-provider.js
DELETED
|
@@ -1,131 +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.OydDIDProvider = void 0;
|
|
16
|
-
const did_manager_1 = require("@veramo/did-manager");
|
|
17
|
-
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
18
|
-
const debug_1 = __importDefault(require("debug"));
|
|
19
|
-
const debug = (0, debug_1.default)('veramo:oyd-did:identifier-provider');
|
|
20
|
-
/**
|
|
21
|
-
* {@link @veramo/did-manager#DIDManager} identifier provider for `did:oyd` identifiers
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
class OydDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
25
|
-
constructor(options) {
|
|
26
|
-
super();
|
|
27
|
-
this.defaultKms = options.defaultKms;
|
|
28
|
-
}
|
|
29
|
-
createIdentifier(_a, context_1) {
|
|
30
|
-
return __awaiter(this, arguments, void 0, function* ({ kms, options }, context) {
|
|
31
|
-
const body = { options };
|
|
32
|
-
const url = 'https://oydid-registrar.data-container.net/1.0/createIdentifier';
|
|
33
|
-
let didDoc;
|
|
34
|
-
try {
|
|
35
|
-
const response = yield (0, cross_fetch_1.default)(url, {
|
|
36
|
-
method: 'POST',
|
|
37
|
-
headers: {
|
|
38
|
-
'Content-Type': 'application/json',
|
|
39
|
-
},
|
|
40
|
-
body: JSON.stringify(body),
|
|
41
|
-
});
|
|
42
|
-
if (!response.ok) {
|
|
43
|
-
throw new Error('Network response was not ok: ' + response.statusText);
|
|
44
|
-
}
|
|
45
|
-
didDoc = yield response.json();
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
throw new Error('There has been a problem with the fetch operation: ' + error.toString());
|
|
50
|
-
}
|
|
51
|
-
const keyType = (options === null || options === void 0 ? void 0 : options.keyType) || 'Ed25519';
|
|
52
|
-
const key = yield this.holdKeys({
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
kms: kms || this.defaultKms,
|
|
55
|
-
options: {
|
|
56
|
-
keyType,
|
|
57
|
-
kid: didDoc.did + '#key-doc',
|
|
58
|
-
publicKeyHex: didDoc.keys[0].publicKeyHex,
|
|
59
|
-
privateKeyHex: didDoc.keys[0].privateKeyHex,
|
|
60
|
-
},
|
|
61
|
-
}, context);
|
|
62
|
-
const identifier = {
|
|
63
|
-
did: didDoc.did,
|
|
64
|
-
controllerKeyId: key.kid,
|
|
65
|
-
keys: [key],
|
|
66
|
-
services: [],
|
|
67
|
-
};
|
|
68
|
-
debug('Created', identifier.did);
|
|
69
|
-
return identifier;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
updateIdentifier(args, context) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
throw new Error('OydDIDProvider updateIdentifier not supported yet.');
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
deleteIdentifier(identifier, context) {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
for (const { kid } of identifier.keys) {
|
|
80
|
-
yield context.agent.keyManagerDelete({ kid });
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
addKey(_a, context_1) {
|
|
86
|
-
return __awaiter(this, arguments, void 0, function* ({ identifier, key, options }, context) {
|
|
87
|
-
return { success: true };
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
addService(_a, context_1) {
|
|
91
|
-
return __awaiter(this, arguments, void 0, function* ({ identifier, service, options }, context) {
|
|
92
|
-
return { success: true };
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
removeKey(args, context) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
return { success: true };
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
removeService(args, context) {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
return { success: true };
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
holdKeys(args, context) {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
if (args.options.privateKeyHex) {
|
|
108
|
-
return context.agent.keyManagerImport({
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
kms: args.kms || this.defaultKms,
|
|
111
|
-
type: args.options.keyType,
|
|
112
|
-
kid: args.options.kid,
|
|
113
|
-
privateKeyHex: args.options.privateKeyHex,
|
|
114
|
-
meta: {
|
|
115
|
-
algorithms: ['Ed25519'],
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return context.agent.keyManagerCreate({
|
|
120
|
-
type: args.options.keyType,
|
|
121
|
-
// @ts-ignore
|
|
122
|
-
kms: args.kms || this.defaultKms,
|
|
123
|
-
meta: {
|
|
124
|
-
algorithms: ['Ed25519'],
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
exports.OydDIDProvider = OydDIDProvider;
|
|
131
|
-
//# sourceMappingURL=oyd-did-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oyd-did-provider.js","sourceRoot":"","sources":["../src/oyd-did-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,qDAAgE;AAEhE,8DAA+B;AAE/B,kDAAyB;AACzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,oCAAoC,CAAC,CAAA;AAIzD;;;GAGG;AACH,MAAa,cAAe,SAAQ,wCAA0B;IAG5D,YAAY,OAAgC;QAC1C,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;IACtC,CAAC;IAEK,gBAAgB;6DACpB,EAAE,GAAG,EAAE,OAAO,EAAyD,EACvE,OAAiB;YAEjB,MAAM,IAAI,GAAG,EAAE,OAAO,EAAE,CAAA;YACxB,MAAM,GAAG,GAAG,iEAAiE,CAAA;YAE7E,IAA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C1B,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;oBACrB,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa;oBACzC,IAAI,EAAE;wBACJ,UAAU,EAAE,CAAC,SAAS,CAAC;qBACxB;iBACF,CAAC,CAAA;YACJ,CAAC;YACD,OAAO,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC;gBACpC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;gBAC1B,aAAa;gBACb,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,UAAU;gBAChC,IAAI,EAAE;oBACJ,UAAU,EAAE,CAAC,SAAS,CAAC;iBACxB;aACF,CAAC,CAAA;QACJ,CAAC;KAAA;CACF;AA9GD,wCA8GC"}
|
package/dist/resolver.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { DIDResolver } from 'did-resolver';
|
|
2
|
-
/**
|
|
3
|
-
* Provides a mapping to a did:oyd resolver, usable by {@link did-resolver#Resolver}.
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export declare function getDidOydResolver(): {
|
|
8
|
-
oyd: DIDResolver;
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=resolver.d.ts.map
|
package/dist/resolver.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6C,WAAW,EAAyB,MAAM,cAAc,CAAA;AA2B5G;;;;GAIG;AACH,wBAAgB,iBAAiB;;EAEhC"}
|
package/dist/resolver.js
DELETED
|
@@ -1,44 +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.getDidOydResolver = getDidOydResolver;
|
|
16
|
-
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
17
|
-
const resolveDidOyd = (didUrl, _parsed, _resolver, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
try {
|
|
19
|
-
const baseUrl = 'https://oydid-resolver.data-container.net';
|
|
20
|
-
// const didDoc = await axios.get(`${baseUrl}/1.0/identifiers/${didUrl}`);
|
|
21
|
-
const response = yield (0, cross_fetch_1.default)(`${baseUrl}/1.0/identifiers/${didUrl}`);
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
throw new Error('Network response was not ok: ' + response.statusText);
|
|
24
|
-
}
|
|
25
|
-
const didDoc = yield response.json();
|
|
26
|
-
return didDoc;
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
return {
|
|
30
|
-
didDocumentMetadata: {},
|
|
31
|
-
didResolutionMetadata: { error: 'invalidDid', message: err.toString() },
|
|
32
|
-
didDocument: null,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
/**
|
|
37
|
-
* Provides a mapping to a did:oyd resolver, usable by {@link did-resolver#Resolver}.
|
|
38
|
-
*
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
|
-
function getDidOydResolver() {
|
|
42
|
-
return { oyd: resolveDidOyd };
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=resolver.js.map
|
package/dist/resolver.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAgCA,8CAEC;AAjCD,8DAA+B;AAE/B,MAAM,aAAa,GAAgB,CACjC,MAAc,EACd,OAAkB,EAClB,SAAqB,EACrB,OAA6B,EACC,EAAE;IAChC,IAAI,CAAC;QACH,MAAM,OAAO,GAAW,2CAA2C,CAAA;QACnE,0EAA0E;QAC1E,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAK,EAAC,GAAG,OAAO,oBAAoB,MAAM,EAAE,CAAC,CAAA;QACpE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAA;QACxE,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QACpC,OAAO,MAA6B,CAAA;IACtC,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO;YACL,mBAAmB,EAAE,EAAE;YACvB,qBAAqB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE;YACvE,WAAW,EAAE,IAAI;SAClB,CAAA;IACH,CAAC;AACH,CAAC,CAAA,CAAA;AAED;;;;GAIG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,CAAA;AAC/B,CAAC"}
|
package/dist/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.47.11"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type OydCreateIdentifierOptions = {
|
|
2
|
-
keyType?: OydDidSupportedKeyTypes;
|
|
3
|
-
privateKeyHex?: string;
|
|
4
|
-
keyUse?: KeyUse;
|
|
5
|
-
};
|
|
6
|
-
export type OydDidHoldKeysArgs = {
|
|
7
|
-
kms: string;
|
|
8
|
-
options: HoldKeysOpts;
|
|
9
|
-
};
|
|
10
|
-
type HoldKeysOpts = {
|
|
11
|
-
keyType: OydDidSupportedKeyTypes;
|
|
12
|
-
kid: string;
|
|
13
|
-
publicKeyHex?: string;
|
|
14
|
-
privateKeyHex?: string;
|
|
15
|
-
};
|
|
16
|
-
export declare enum SupportedKeyTypes {
|
|
17
|
-
Secp256r1 = "Secp256r1",
|
|
18
|
-
Secp256k1 = "Secp256k1",
|
|
19
|
-
Ed25519 = "Ed25519",
|
|
20
|
-
X25519 = "X25519"
|
|
21
|
-
}
|
|
22
|
-
export type OydDidSupportedKeyTypes = keyof typeof SupportedKeyTypes;
|
|
23
|
-
export type KeyUse = 'sig' | 'enc';
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=oyd-provider-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oyd-provider-types.d.ts","sourceRoot":"","sources":["../../src/types/oyd-provider-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,CAAC,EAAE,uBAAuB,CAAA;IACjC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,uBAAuB,CAAA;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,oBAAY,iBAAiB;IAC3B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,OAAO,iBAAiB,CAAA;AAEpE,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SupportedKeyTypes = void 0;
|
|
4
|
-
var SupportedKeyTypes;
|
|
5
|
-
(function (SupportedKeyTypes) {
|
|
6
|
-
SupportedKeyTypes["Secp256r1"] = "Secp256r1";
|
|
7
|
-
SupportedKeyTypes["Secp256k1"] = "Secp256k1";
|
|
8
|
-
SupportedKeyTypes["Ed25519"] = "Ed25519";
|
|
9
|
-
SupportedKeyTypes["X25519"] = "X25519";
|
|
10
|
-
})(SupportedKeyTypes || (exports.SupportedKeyTypes = SupportedKeyTypes = {}));
|
|
11
|
-
//# sourceMappingURL=oyd-provider-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oyd-provider-types.js","sourceRoot":"","sources":["../../src/types/oyd-provider-types.ts"],"names":[],"mappings":";;;AAkBA,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,4CAAuB,CAAA;IACvB,4CAAuB,CAAA;IACvB,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;AACnB,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B"}
|