@sphereon/ssi-sdk-ext.did-provider-web 0.28.1-feature.esm.cjs.9 → 0.28.1-feature.jose.vcdm.20
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 +114 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/package.json +20 -7
- package/dist/index.mjs +0 -83
- package/dist/index.mjs.map +0 -1
- /package/dist/{index.d.mts → index.d.cts} +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
WebDIDProvider: () => WebDIDProvider
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// src/web-did-provider.ts
|
|
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"), 1);
|
|
43
|
+
var debug = (0, import_debug.default)("sphereon:web-did:identifier-provider");
|
|
44
|
+
var WebDIDProvider = class extends import_did_manager.AbstractIdentifierProvider {
|
|
45
|
+
static {
|
|
46
|
+
__name(this, "WebDIDProvider");
|
|
47
|
+
}
|
|
48
|
+
defaultKms;
|
|
49
|
+
constructor(options) {
|
|
50
|
+
super();
|
|
51
|
+
this.defaultKms = options.defaultKms;
|
|
52
|
+
}
|
|
53
|
+
async createIdentifier(args, context) {
|
|
54
|
+
const { kms, alias } = args;
|
|
55
|
+
const opts = args.options ?? {};
|
|
56
|
+
if (!opts.keys || Array.isArray(opts.keys) && opts.keys.length === 0) {
|
|
57
|
+
opts.keys = [
|
|
58
|
+
{
|
|
59
|
+
type: "Secp256r1",
|
|
60
|
+
isController: true
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
const keyOpts = Array.isArray(opts.keys) ? opts.keys : [
|
|
65
|
+
opts.keys
|
|
66
|
+
];
|
|
67
|
+
const keys = await Promise.all(keyOpts.map((keyOpt) => (0, import_ssi_sdk_ext2.importProvidedOrGeneratedKey)({
|
|
68
|
+
kms: kms ?? this.defaultKms,
|
|
69
|
+
options: keyOpt
|
|
70
|
+
}, context)));
|
|
71
|
+
const controllerIdx = keyOpts.findIndex((opt) => opt.isController);
|
|
72
|
+
const controllerKeyId = controllerIdx < 0 ? keys[0].kid : keys[controllerIdx].kid;
|
|
73
|
+
const identifier = {
|
|
74
|
+
did: await (0, import_ssi_sdk_ext.asDidWeb)(alias),
|
|
75
|
+
controllerKeyId,
|
|
76
|
+
keys,
|
|
77
|
+
services: opts.services ?? []
|
|
78
|
+
};
|
|
79
|
+
debug("Created", identifier);
|
|
80
|
+
return identifier;
|
|
81
|
+
}
|
|
82
|
+
async updateIdentifier(args, context) {
|
|
83
|
+
throw new Error("WebDIDProvider updateIdentifier not supported yet.");
|
|
84
|
+
}
|
|
85
|
+
async deleteIdentifier(identifier, context) {
|
|
86
|
+
for (const { kid } of identifier.keys) {
|
|
87
|
+
await context.agent.keyManagerDelete({
|
|
88
|
+
kid
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
async addKey({ identifier, key, options }, context) {
|
|
94
|
+
return {
|
|
95
|
+
success: true
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async addService({ identifier, service, options }, context) {
|
|
99
|
+
return {
|
|
100
|
+
success: true
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async removeKey(args, context) {
|
|
104
|
+
return {
|
|
105
|
+
success: true
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async removeService(args, context) {
|
|
109
|
+
return {
|
|
110
|
+
success: true
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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/dist/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/web-did-provider.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var debug =
|
|
10
|
-
var WebDIDProvider = class extends
|
|
5
|
+
import { asDidWeb } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
6
|
+
import { importProvidedOrGeneratedKey } from "@sphereon/ssi-sdk-ext.key-utils";
|
|
7
|
+
import { AbstractIdentifierProvider } from "@veramo/did-manager";
|
|
8
|
+
import Debug from "debug";
|
|
9
|
+
var debug = Debug("sphereon:web-did:identifier-provider");
|
|
10
|
+
var WebDIDProvider = class extends AbstractIdentifierProvider {
|
|
11
11
|
static {
|
|
12
12
|
__name(this, "WebDIDProvider");
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
defaultKms;
|
|
15
15
|
constructor(options) {
|
|
16
16
|
super();
|
|
17
17
|
this.defaultKms = options.defaultKms;
|
|
18
18
|
}
|
|
19
19
|
async createIdentifier(args, context) {
|
|
20
20
|
const { kms, alias } = args;
|
|
21
|
-
const opts =
|
|
21
|
+
const opts = args.options ?? {};
|
|
22
22
|
if (!opts.keys || Array.isArray(opts.keys) && opts.keys.length === 0) {
|
|
23
23
|
opts.keys = [
|
|
24
24
|
{
|
|
@@ -30,17 +30,17 @@ var WebDIDProvider = class extends _didmanager.AbstractIdentifierProvider {
|
|
|
30
30
|
const keyOpts = Array.isArray(opts.keys) ? opts.keys : [
|
|
31
31
|
opts.keys
|
|
32
32
|
];
|
|
33
|
-
const keys = await Promise.all(keyOpts.map((keyOpt) =>
|
|
34
|
-
kms:
|
|
33
|
+
const keys = await Promise.all(keyOpts.map((keyOpt) => importProvidedOrGeneratedKey({
|
|
34
|
+
kms: kms ?? this.defaultKms,
|
|
35
35
|
options: keyOpt
|
|
36
36
|
}, context)));
|
|
37
37
|
const controllerIdx = keyOpts.findIndex((opt) => opt.isController);
|
|
38
38
|
const controllerKeyId = controllerIdx < 0 ? keys[0].kid : keys[controllerIdx].kid;
|
|
39
39
|
const identifier = {
|
|
40
|
-
did: await
|
|
40
|
+
did: await asDidWeb(alias),
|
|
41
41
|
controllerKeyId,
|
|
42
42
|
keys,
|
|
43
|
-
services:
|
|
43
|
+
services: opts.services ?? []
|
|
44
44
|
};
|
|
45
45
|
debug("Created", identifier);
|
|
46
46
|
return identifier;
|
|
@@ -77,7 +77,7 @@ var WebDIDProvider = class extends _didmanager.AbstractIdentifierProvider {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
export {
|
|
81
|
+
WebDIDProvider
|
|
82
|
+
};
|
|
83
83
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../src/web-did-provider.ts"],"sourcesContent":["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,SAASA,gBAA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M;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":["asDidWeb","importProvidedOrGeneratedKey","AbstractIdentifierProvider","Debug","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,16 +1,29 @@
|
|
|
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.
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
4
|
+
"version": "0.28.1-feature.jose.vcdm.20+0d68761",
|
|
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
|
+
"react-native": "./dist/index.js",
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"require": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
8
21
|
"scripts": {
|
|
9
22
|
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
10
23
|
},
|
|
11
24
|
"dependencies": {
|
|
12
|
-
"@sphereon/ssi-sdk-ext.did-utils": "
|
|
13
|
-
"@sphereon/ssi-sdk-ext.key-utils": "
|
|
25
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.28.1-feature.jose.vcdm.20+0d68761",
|
|
26
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.28.1-feature.jose.vcdm.20+0d68761",
|
|
14
27
|
"@veramo/core": "4.2.0",
|
|
15
28
|
"@veramo/did-manager": "4.2.0",
|
|
16
29
|
"debug": "^4.3.4"
|
|
@@ -44,5 +57,5 @@
|
|
|
44
57
|
"secp256r1",
|
|
45
58
|
"RSA"
|
|
46
59
|
],
|
|
47
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "0d68761c4490c4759a24780bdb9e29046145549d"
|
|
48
61
|
}
|
package/dist/index.mjs
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/web-did-provider.ts
|
|
5
|
-
import { asDidWeb } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
6
|
-
import { importProvidedOrGeneratedKey } from "@sphereon/ssi-sdk-ext.key-utils";
|
|
7
|
-
import { AbstractIdentifierProvider } from "@veramo/did-manager";
|
|
8
|
-
import Debug from "debug";
|
|
9
|
-
var debug = Debug("sphereon:web-did:identifier-provider");
|
|
10
|
-
var WebDIDProvider = class extends AbstractIdentifierProvider {
|
|
11
|
-
static {
|
|
12
|
-
__name(this, "WebDIDProvider");
|
|
13
|
-
}
|
|
14
|
-
defaultKms;
|
|
15
|
-
constructor(options) {
|
|
16
|
-
super();
|
|
17
|
-
this.defaultKms = options.defaultKms;
|
|
18
|
-
}
|
|
19
|
-
async createIdentifier(args, context) {
|
|
20
|
-
const { kms, alias } = args;
|
|
21
|
-
const opts = args.options ?? {};
|
|
22
|
-
if (!opts.keys || Array.isArray(opts.keys) && opts.keys.length === 0) {
|
|
23
|
-
opts.keys = [
|
|
24
|
-
{
|
|
25
|
-
type: "Secp256r1",
|
|
26
|
-
isController: true
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
const keyOpts = Array.isArray(opts.keys) ? opts.keys : [
|
|
31
|
-
opts.keys
|
|
32
|
-
];
|
|
33
|
-
const keys = await Promise.all(keyOpts.map((keyOpt) => importProvidedOrGeneratedKey({
|
|
34
|
-
kms: kms ?? this.defaultKms,
|
|
35
|
-
options: keyOpt
|
|
36
|
-
}, context)));
|
|
37
|
-
const controllerIdx = keyOpts.findIndex((opt) => opt.isController);
|
|
38
|
-
const controllerKeyId = controllerIdx < 0 ? keys[0].kid : keys[controllerIdx].kid;
|
|
39
|
-
const identifier = {
|
|
40
|
-
did: await asDidWeb(alias),
|
|
41
|
-
controllerKeyId,
|
|
42
|
-
keys,
|
|
43
|
-
services: opts.services ?? []
|
|
44
|
-
};
|
|
45
|
-
debug("Created", identifier);
|
|
46
|
-
return identifier;
|
|
47
|
-
}
|
|
48
|
-
async updateIdentifier(args, context) {
|
|
49
|
-
throw new Error("WebDIDProvider updateIdentifier not supported yet.");
|
|
50
|
-
}
|
|
51
|
-
async deleteIdentifier(identifier, context) {
|
|
52
|
-
for (const { kid } of identifier.keys) {
|
|
53
|
-
await context.agent.keyManagerDelete({
|
|
54
|
-
kid
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
async addKey({ identifier, key, options }, context) {
|
|
60
|
-
return {
|
|
61
|
-
success: true
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
async addService({ identifier, service, options }, context) {
|
|
65
|
-
return {
|
|
66
|
-
success: true
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
async removeKey(args, context) {
|
|
70
|
-
return {
|
|
71
|
-
success: true
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
async removeService(args, context) {
|
|
75
|
-
return {
|
|
76
|
-
success: true
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
export {
|
|
81
|
-
WebDIDProvider
|
|
82
|
-
};
|
|
83
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/web-did-provider.ts"],"sourcesContent":["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,SAASA,gBAAgB;AACzB,SAASC,oCAAoC;AAE7C,SAASC,kCAAkC;AAE3C,OAAOC,WAAW;AAGlB,IAAMC,QAAQC,MAAM,sCAAA;AAQb,IAAMC,iBAAN,cAA6BC,2BAAAA;EAhBpC,OAgBoCA;;;EACjBC;EAEjBC,YAAYC,SAAiC;AAC3C,UAAK;AACL,SAAKF,aAAaE,QAAQF;EAC5B;EAEA,MAAMG,iBAAiBC,MAA6BC,SAA2D;AAC7G,UAAM,EAA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MAA+DC,SAAiC;AAC9G,WAAO;MAAEgC,SAAS;IAAK;EACzB;EAEA,MAAMI,cAAcrC,MAA8DC,SAAiC;AACjH,WAAO;MAAEgC,SAAS;IAAK;EACzB;AACF;","names":["asDidWeb","importProvidedOrGeneratedKey","AbstractIdentifierProvider","Debug","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"]}
|
|
File without changes
|