@sphereon/ssi-sdk-ext.did-provider-web 0.28.1-feature.esm.cjs.11 → 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.js +47 -16
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,24 +1,58 @@
|
|
|
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
|
+
WebDIDProvider: () => WebDIDProvider
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
3
37
|
|
|
4
38
|
// src/web-did-provider.ts
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var debug =
|
|
10
|
-
var WebDIDProvider = class extends
|
|
39
|
+
var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
40
|
+
var import_ssi_sdk_ext2 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
41
|
+
var import_did_manager = require("@veramo/did-manager");
|
|
42
|
+
var import_debug = __toESM(require("debug"));
|
|
43
|
+
var debug = (0, import_debug.default)("sphereon:web-did:identifier-provider");
|
|
44
|
+
var WebDIDProvider = class extends import_did_manager.AbstractIdentifierProvider {
|
|
11
45
|
static {
|
|
12
46
|
__name(this, "WebDIDProvider");
|
|
13
47
|
}
|
|
14
|
-
|
|
48
|
+
defaultKms;
|
|
15
49
|
constructor(options) {
|
|
16
50
|
super();
|
|
17
51
|
this.defaultKms = options.defaultKms;
|
|
18
52
|
}
|
|
19
53
|
async createIdentifier(args, context) {
|
|
20
54
|
const { kms, alias } = args;
|
|
21
|
-
const opts =
|
|
55
|
+
const opts = args.options ?? {};
|
|
22
56
|
if (!opts.keys || Array.isArray(opts.keys) && opts.keys.length === 0) {
|
|
23
57
|
opts.keys = [
|
|
24
58
|
{
|
|
@@ -30,17 +64,17 @@ var WebDIDProvider = class extends _didmanager.AbstractIdentifierProvider {
|
|
|
30
64
|
const keyOpts = Array.isArray(opts.keys) ? opts.keys : [
|
|
31
65
|
opts.keys
|
|
32
66
|
];
|
|
33
|
-
const keys = await Promise.all(keyOpts.map((keyOpt) =>
|
|
34
|
-
kms:
|
|
67
|
+
const keys = await Promise.all(keyOpts.map((keyOpt) => (0, import_ssi_sdk_ext2.importProvidedOrGeneratedKey)({
|
|
68
|
+
kms: kms ?? this.defaultKms,
|
|
35
69
|
options: keyOpt
|
|
36
70
|
}, context)));
|
|
37
71
|
const controllerIdx = keyOpts.findIndex((opt) => opt.isController);
|
|
38
72
|
const controllerKeyId = controllerIdx < 0 ? keys[0].kid : keys[controllerIdx].kid;
|
|
39
73
|
const identifier = {
|
|
40
|
-
did: await
|
|
74
|
+
did: await (0, import_ssi_sdk_ext.asDidWeb)(alias),
|
|
41
75
|
controllerKeyId,
|
|
42
76
|
keys,
|
|
43
|
-
services:
|
|
77
|
+
services: opts.services ?? []
|
|
44
78
|
};
|
|
45
79
|
debug("Created", identifier);
|
|
46
80
|
return identifier;
|
|
@@ -77,7 +111,4 @@ var WebDIDProvider = class extends _didmanager.AbstractIdentifierProvider {
|
|
|
77
111
|
};
|
|
78
112
|
}
|
|
79
113
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
exports.WebDIDProvider = WebDIDProvider;
|
|
83
114
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/web-did-provider.ts"],"sourcesContent":["/**\n * Provides `did:web` {@link @veramo/did-provider-web#WebDIDProvider | identifier provider } for the\n * {@link @veramo/did-manager#DIDManager}\n *\n * @packageDocumentation\n */\nexport * from './types'\nexport { WebDIDProvider } from './web-did-provider'\n","import { asDidWeb } from '@sphereon/ssi-sdk-ext.did-utils'\nimport { importProvidedOrGeneratedKey } from '@sphereon/ssi-sdk-ext.key-utils'\nimport { IAgentContext, IIdentifier, IKey, IKeyManager, IService } from '@veramo/core'\nimport { AbstractIdentifierProvider } from '@veramo/did-manager'\n\nimport Debug from 'debug'\nimport { ICreateIdentifierArgs, IKeyOpts } from './types'\n\nconst debug = Debug('sphereon:web-did:identifier-provider')\n\ntype IContext = IAgentContext<IKeyManager>\n\n/**\n * {@link @veramo/did-manager#DIDManager} identifier provider for `did:web` identifiers\n * @public\n */\nexport class WebDIDProvider extends AbstractIdentifierProvider {\n private readonly defaultKms: string\n\n constructor(options: { defaultKms: string }) {\n super()\n this.defaultKms = options.defaultKms\n }\n\n async createIdentifier(args: ICreateIdentifierArgs, context: IContext): Promise<Omit<IIdentifier, 'provider'>> {\n const { kms, alias } = args\n const opts = args.options ?? {}\n if (!opts.keys || (Array.isArray(opts.keys) && opts.keys.length === 0)) {\n // Let's generate a key as no import keys or types are provided\n opts.keys = [{ type: 'Secp256r1', isController: true }]\n }\n const keyOpts = Array.isArray(opts.keys) ? opts.keys : [opts.keys as IKeyOpts]\n const keys = await Promise.all(\n keyOpts.map((keyOpt: IKeyOpts) => importProvidedOrGeneratedKey({ kms: kms ?? this.defaultKms, options: keyOpt }, context))\n )\n\n const controllerIdx = keyOpts.findIndex((opt) => opt.isController)\n const controllerKeyId = controllerIdx < 0 ? keys[0].kid : keys[controllerIdx].kid\n const identifier: Omit<IIdentifier, 'provider'> = {\n did: await asDidWeb(alias),\n controllerKeyId,\n keys,\n services: opts.services ?? [],\n }\n debug('Created', identifier)\n return identifier\n }\n\n async updateIdentifier(\n args: {\n did: string\n kms?: string | undefined\n alias?: string | undefined\n options?: any\n },\n context: IAgentContext<IKeyManager>\n ): Promise<IIdentifier> {\n throw new Error('WebDIDProvider 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(\n {\n identifier,\n key,\n options,\n }: {\n identifier: IIdentifier\n key: IKey\n options?: any\n },\n context: IContext\n ): Promise<any> {\n return { success: true }\n }\n\n async addService(\n {\n identifier,\n service,\n options,\n }: {\n identifier: IIdentifier\n service: IService\n options?: any\n },\n context: IContext\n ): 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,yBAAyB;AACzB,IAAAA,sBAA6C;AAE7C,yBAA2C;AAE3C,mBAAkB;AAGlB,IAAMC,YAAQC,aAAAA,SAAM,sCAAA;AAQb,IAAMC,iBAAN,cAA6BC,8CAAAA;EAhBpC,OAgBoCA;;;EACjBC;EAEjBC,YAAYC,SAAiC;AAC3C,UAAK;AACL,SAAKF,aAAaE,QAAQF;EAC5B;EAEA,MAAMG,iBAAiBC,MAA6BC,SAA2D;AAC7G,UAAM,EAAEC,KAAKC,MAAK,IAAKH;AACvB,UAAMI,OAAOJ,KAAKF,WAAW,CAAC;AAC9B,QAAI,CAACM,KAAKC,QAASC,MAAMC,QAAQH,KAAKC,IAAI,KAAKD,KAAKC,KAAKG,WAAW,GAAI;AAEtEJ,WAAKC,OAAO;QAAC;UAAEI,MAAM;UAAaC,cAAc;QAAK;;IACvD;AACA,UAAMC,UAAUL,MAAMC,QAAQH,KAAKC,IAAI,IAAID,KAAKC,OAAO;MAACD,KAAKC;;AAC7D,UAAMA,OAAO,MAAMO,QAAQC,IACzBF,QAAQG,IAAI,CAACC,eAAqBC,kDAA6B;MAAEd,KAAKA,OAAO,KAAKN;MAAYE,SAASiB;IAAO,GAAGd,OAAAA,CAAAA,CAAAA;AAGnH,UAAMgB,gBAAgBN,QAAQO,UAAU,CAACC,QAAQA,IAAIT,YAAY;AACjE,UAAMU,kBAAkBH,gBAAgB,IAAIZ,KAAK,CAAA,EAAGgB,MAAMhB,KAAKY,aAAAA,EAAeI;AAC9E,UAAMC,aAA4C;MAChDC,KAAK,UAAMC,6BAASrB,KAAAA;MACpBiB;MACAf;MACAoB,UAAUrB,KAAKqB,YAAY,CAAA;IAC7B;AACAjC,UAAM,WAAW8B,UAAAA;AACjB,WAAOA;EACT;EAEA,MAAMI,iBACJ1B,MAMAC,SACsB;AACtB,UAAM,IAAI0B,MAAM,oDAAA;EAClB;EAEA,MAAMC,iBAAiBN,YAAyBrB,SAAqC;AACnF,eAAW,EAAEoB,IAAG,KAAMC,WAAWjB,MAAM;AACrC,YAAMJ,QAAQ4B,MAAMC,iBAAiB;QAAET;MAAI,CAAA;IAC7C;AACA,WAAO;EACT;EAEA,MAAMU,OACJ,EACET,YACAU,KACAlC,QAAO,GAMTG,SACc;AACd,WAAO;MAAEgC,SAAS;IAAK;EACzB;EAEA,MAAMC,WACJ,EACEZ,YACAa,SACArC,QAAO,GAMTG,SACc;AACd,WAAO;MAAEgC,SAAS;IAAK;EACzB;EAEA,MAAMG,UAAUpC,MAA+DC,SAAiC;AAC9G,WAAO;MAAEgC,SAAS;IAAK;EACzB;EAEA,MAAMI,cAAcrC,MAA8DC,SAAiC;AACjH,WAAO;MAAEgC,SAAS;IAAK;EACzB;AACF;","names":["import_ssi_sdk_ext","debug","Debug","WebDIDProvider","AbstractIdentifierProvider","defaultKms","constructor","options","createIdentifier","args","context","kms","alias","opts","keys","Array","isArray","length","type","isController","keyOpts","Promise","all","map","keyOpt","importProvidedOrGeneratedKey","controllerIdx","findIndex","opt","controllerKeyId","kid","identifier","did","asDidWeb","services","updateIdentifier","Error","deleteIdentifier","agent","keyManagerDelete","addKey","key","success","addService","service","removeKey","removeService"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk-ext.did-provider-web",
|
|
3
3
|
"description": "plugin that can enable creation and control of did:web identifiers.",
|
|
4
|
-
"version": "0.28.1-feature.esm.cjs.
|
|
4
|
+
"version": "0.28.1-feature.esm.cjs.13+24ca549",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@sphereon/ssi-sdk-ext.did-utils": "^0.28.1-feature.esm.cjs.
|
|
13
|
-
"@sphereon/ssi-sdk-ext.key-utils": "^0.28.1-feature.esm.cjs.
|
|
12
|
+
"@sphereon/ssi-sdk-ext.did-utils": "^0.28.1-feature.esm.cjs.13+24ca549",
|
|
13
|
+
"@sphereon/ssi-sdk-ext.key-utils": "^0.28.1-feature.esm.cjs.13+24ca549",
|
|
14
14
|
"@veramo/core": "4.2.0",
|
|
15
15
|
"@veramo/did-manager": "4.2.0",
|
|
16
16
|
"debug": "^4.3.4"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"secp256r1",
|
|
45
45
|
"RSA"
|
|
46
46
|
],
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "24ca549841533d8ae29184b42dc92a416bdb246d"
|
|
48
48
|
}
|