@sphereon/did-provider-oyd 0.28.1-feature.oyd.cmsm.improv.16 → 0.28.1-feature.oyd.cmsm.improv.21
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/oyd-did-provider.d.ts +4 -4
- package/dist/oyd-did-provider.d.ts.map +1 -1
- package/dist/oyd-did-provider.js +85 -52
- package/dist/oyd-did-provider.js.map +1 -1
- package/dist/types/oyd-provider-types.d.ts +2 -1
- package/dist/types/oyd-provider-types.d.ts.map +1 -1
- package/dist/types/oyd-provider-types.js.map +1 -1
- package/package.json +9 -5
- package/src/oyd-did-provider.ts +77 -58
- package/src/types/oyd-provider-types.ts +4 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IIdentifier, IKey,
|
|
1
|
+
import { IAgentContext, IIdentifier, IKey, IKeyManager, IService, TKeyType } from '@veramo/core';
|
|
2
2
|
import { AbstractIdentifierProvider } from '@veramo/did-manager';
|
|
3
3
|
import { KeyManager } from '@veramo/key-manager';
|
|
4
|
-
import type {
|
|
4
|
+
import type { CMSMCallbackOpts, OydConstructorOptions, OydCreateIdentifierOptions } from './types/oyd-provider-types.js';
|
|
5
5
|
type IContext = IAgentContext<IKeyManager>;
|
|
6
6
|
/**
|
|
7
7
|
* {@link @veramo/did-manager#DIDManager} identifier provider for `did:oyd` identifiers
|
|
@@ -12,8 +12,9 @@ export declare class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
12
12
|
private readonly cmsmCallbackOpts?;
|
|
13
13
|
constructor(options?: OydConstructorOptions);
|
|
14
14
|
private assertedKms;
|
|
15
|
-
createIdentifier({ kms, options }: {
|
|
15
|
+
createIdentifier({ kms, alias, options }: {
|
|
16
16
|
kms?: string;
|
|
17
|
+
alias?: string;
|
|
17
18
|
options: OydCreateIdentifierOptions;
|
|
18
19
|
}, context: IContext): Promise<Omit<IIdentifier, 'provider'>>;
|
|
19
20
|
createIdentifierWithCMSM({ kms, options }: {
|
|
@@ -47,7 +48,6 @@ export declare class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
47
48
|
id: string;
|
|
48
49
|
options?: any;
|
|
49
50
|
}, context: IContext): Promise<any>;
|
|
50
|
-
private importOrCreateKey;
|
|
51
51
|
}
|
|
52
52
|
export declare function defaultOydCmsmPublicKeyCallback(keyManager: KeyManager): (kid: string, kms?: string, create?: boolean, createKeyType?: TKeyType) => Promise<IKey>;
|
|
53
53
|
export declare function defaultOydCmsmSignCallback(keyManager: KeyManager): (kid: string, data: string) => Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oyd-did-provider.d.ts","sourceRoot":"","sources":["../src/oyd-did-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oyd-did-provider.d.ts","sourceRoot":"","sources":["../src/oyd-did-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAChG,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAQhD,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAG3B,MAAM,+BAA+B,CAAA;AAKtC,KAAK,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;AAE1C;;;GAGG;AACH,qBAAa,cAAe,SAAQ,0BAA0B;IAC5D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAQ;IACpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAkB;gBAExC,OAAO,CAAC,EAAE,qBAAqB;YAM7B,WAAW;IAWnB,gBAAgB,CACpB,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAA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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;CAGnH;AAqBD,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,UAAU,GACrB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAoC1F;AAED,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAIjH;AAED,qBAAa,uBAAwB,YAAW,gBAAgB;IAClD,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAE1C,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAE1G;IAED,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAA8C;CAC5G"}
|
package/dist/oyd-did-provider.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -15,8 +38,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
38
|
exports.DefaultOydCmsmCallbacks = exports.OydDIDProvider = void 0;
|
|
16
39
|
exports.defaultOydCmsmPublicKeyCallback = defaultOydCmsmPublicKeyCallback;
|
|
17
40
|
exports.defaultOydCmsmSignCallback = defaultOydCmsmSignCallback;
|
|
41
|
+
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
18
42
|
const did_manager_1 = require("@veramo/did-manager");
|
|
19
43
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
44
|
+
const multibase_1 = __importDefault(require("multibase"));
|
|
45
|
+
const multicodec_1 = __importDefault(require("multicodec"));
|
|
46
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
20
47
|
const debug_1 = __importDefault(require("debug"));
|
|
21
48
|
const debug = (0, debug_1.default)('veramo:oyd-did:identifier-provider');
|
|
22
49
|
const OYDID_REGISTRAR_URL = 'https://oydid-registrar.data-container.net/1.0/createIdentifier';
|
|
@@ -43,8 +70,8 @@ class OydDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
43
70
|
});
|
|
44
71
|
}
|
|
45
72
|
createIdentifier(_a, context_1) {
|
|
46
|
-
return __awaiter(this, arguments, void 0, function* ({ kms, options }, context) {
|
|
47
|
-
var _b, _c;
|
|
73
|
+
return __awaiter(this, arguments, void 0, function* ({ kms, alias, options }, context) {
|
|
74
|
+
var _b, _c, _d, _e;
|
|
48
75
|
const resolvedKms = yield this.assertedKms(kms, this.defaultKms);
|
|
49
76
|
if ((this.cmsmCallbackOpts && !options.cmsm) || (options.cmsm && options.cmsm.enabled !== false)) {
|
|
50
77
|
if (!this.cmsmCallbackOpts) {
|
|
@@ -55,7 +82,7 @@ class OydDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
55
82
|
const body = {
|
|
56
83
|
options: {
|
|
57
84
|
cmsm: false,
|
|
58
|
-
key_type: (_b = options.
|
|
85
|
+
key_type: (_b = options.type) !== null && _b !== void 0 ? _b : 'Secp256r1',
|
|
59
86
|
},
|
|
60
87
|
};
|
|
61
88
|
let didDoc;
|
|
@@ -77,14 +104,17 @@ class OydDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
77
104
|
debug('Unexpected error from OydDID Registrar: ', error);
|
|
78
105
|
return Promise.reject(Error('There has been a problem with the fetch operation: ' + error.toString()));
|
|
79
106
|
}
|
|
80
|
-
const keyType = (_c = options === null || options === void 0 ? void 0 : options.
|
|
81
|
-
const key = yield
|
|
107
|
+
const keyType = (_c = options === null || options === void 0 ? void 0 : options.type) !== null && _c !== void 0 ? _c : 'Secp256r1';
|
|
108
|
+
const key = yield (0, ssi_sdk_ext_key_utils_1.importProvidedOrGeneratedKey)({
|
|
82
109
|
kms: resolvedKms,
|
|
110
|
+
alias: (_e = (_d = alias !== null && alias !== void 0 ? alias : options.alias) !== null && _d !== void 0 ? _d : options.kid) !== null && _e !== void 0 ? _e : `${didDoc.did}#key-doc`,
|
|
83
111
|
options: {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
112
|
+
key: {
|
|
113
|
+
kid: `${didDoc.did}#key-doc`,
|
|
114
|
+
type: keyType,
|
|
115
|
+
publicKeyHex: didDoc.keys[0].publicKeyHex,
|
|
116
|
+
privateKeyHex: didDoc.keys[0].privateKeyHex,
|
|
117
|
+
},
|
|
88
118
|
},
|
|
89
119
|
}, context);
|
|
90
120
|
const identifier = {
|
|
@@ -105,19 +135,22 @@ class OydDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
105
135
|
return Promise.reject(Error('did:oyd: no cmsm options defined!'));
|
|
106
136
|
}
|
|
107
137
|
const assertedKms = yield this.assertedKms(kms, this.defaultKms);
|
|
108
|
-
const pubKey = (_b = options.key) !== null && _b !== void 0 ? _b : (yield cmsmCallbackOpts.publicKeyCallback((_c = options.kid) !== null && _c !== void 0 ? _c : 'default', assertedKms, ((_d = options.cmsm) === null || _d === void 0 ? void 0 : _d.create) !== false, options.
|
|
138
|
+
const pubKey = (_b = options.key) !== null && _b !== void 0 ? _b : (yield cmsmCallbackOpts.publicKeyCallback((_c = options.kid) !== null && _c !== void 0 ? _c : 'default', assertedKms, ((_d = options.cmsm) === null || _d === void 0 ? void 0 : _d.create) !== false, options.type)); // "default" is probably not right, TODO!!
|
|
109
139
|
const kid = pubKey.kid;
|
|
110
140
|
const keyType = pubKey.type;
|
|
141
|
+
const key = base58btc({ publicKeyHex: pubKey.publicKeyHex, keyType });
|
|
142
|
+
console.log(`Bae58 pubkey key: ${key}`);
|
|
111
143
|
let signValue; // do the request
|
|
112
144
|
try {
|
|
113
145
|
const body_create = {
|
|
114
146
|
// specify the Identifier options for the registrar
|
|
115
|
-
key:
|
|
147
|
+
key: key,
|
|
116
148
|
options: {
|
|
117
149
|
cmsm: true,
|
|
118
150
|
key_type: keyType,
|
|
119
151
|
},
|
|
120
152
|
};
|
|
153
|
+
console.log(`Create request:\n${JSON.stringify(body_create, null, 2)}\n`);
|
|
121
154
|
const response = yield (0, cross_fetch_1.default)(OYDID_REGISTRAR_URL, {
|
|
122
155
|
method: 'POST',
|
|
123
156
|
headers: {
|
|
@@ -130,22 +163,26 @@ class OydDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
130
163
|
return Promise.reject(Error('Network response was not ok: ' + response.statusText));
|
|
131
164
|
}
|
|
132
165
|
signValue = yield response.json();
|
|
166
|
+
console.log(`Create response:\n${JSON.stringify(signValue, null, 2)}\n`);
|
|
133
167
|
}
|
|
134
168
|
catch (error) {
|
|
135
|
-
|
|
169
|
+
console.log('Unexpected error from OydDID Registrar: ', error);
|
|
136
170
|
return Promise.reject(Error('There has been a problem with the fetch operation: ' + error.toString()));
|
|
137
171
|
}
|
|
138
172
|
// we received our value to sign, now we sign it!
|
|
139
173
|
const { sign } = signValue;
|
|
140
174
|
const signature = yield cmsmCallbackOpts.signCallback(kid, sign);
|
|
175
|
+
console.log(`Signature: ${signature}`);
|
|
141
176
|
const body_signed = {
|
|
142
|
-
key
|
|
177
|
+
key,
|
|
143
178
|
options: {
|
|
144
179
|
cmsm: true,
|
|
180
|
+
key_type: keyType,
|
|
145
181
|
sig: signature,
|
|
146
182
|
},
|
|
147
183
|
};
|
|
148
|
-
|
|
184
|
+
console.log(`Signed request:\n${JSON.stringify(body_signed, null, 2)}\n`);
|
|
185
|
+
// Object.assign(body_signed.options, options)
|
|
149
186
|
let didDoc; // do the request
|
|
150
187
|
try {
|
|
151
188
|
const response = yield (0, cross_fetch_1.default)(OYDID_REGISTRAR_URL, {
|
|
@@ -156,6 +193,7 @@ class OydDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
156
193
|
body: JSON.stringify(body_signed),
|
|
157
194
|
});
|
|
158
195
|
if (!response.ok) {
|
|
196
|
+
console.log(`Error response from OydDID Registrar: ${JSON.stringify(response.text)}${response.statusText}`, response);
|
|
159
197
|
debug('Error response from OydDID Registrar: ', response);
|
|
160
198
|
return Promise.reject(Error('Network response was not ok: ' + response.statusText));
|
|
161
199
|
}
|
|
@@ -165,19 +203,6 @@ class OydDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
165
203
|
debug('Unexpected error from OydDID Registrar: ', error);
|
|
166
204
|
return Promise.reject(Error('There has been a problem with the fetch operation: ' + error.toString()));
|
|
167
205
|
}
|
|
168
|
-
/* let oydKeyType: OydDidSupportedKeyTypes = "Secp256r1";
|
|
169
|
-
|
|
170
|
-
const key = await this.holdKeys(
|
|
171
|
-
{
|
|
172
|
-
kms: assertedKms,
|
|
173
|
-
options: {
|
|
174
|
-
keyType: oydKeyType,
|
|
175
|
-
kid: kid,
|
|
176
|
-
publicKeyHex: pubKey.publicKeyHex,
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
context
|
|
180
|
-
);*/
|
|
181
206
|
const identifier = {
|
|
182
207
|
did: didDoc.did,
|
|
183
208
|
controllerKeyId: pubKey.kid,
|
|
@@ -221,31 +246,24 @@ class OydDIDProvider extends did_manager_1.AbstractIdentifierProvider {
|
|
|
221
246
|
return { success: true };
|
|
222
247
|
});
|
|
223
248
|
}
|
|
224
|
-
importOrCreateKey(args, context) {
|
|
225
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
-
const kms = yield this.assertedKms(args.kms, this.defaultKms);
|
|
227
|
-
if (args.options.privateKeyHex) {
|
|
228
|
-
return context.agent.keyManagerImport({
|
|
229
|
-
kms,
|
|
230
|
-
type: args.options.keyType,
|
|
231
|
-
kid: args.options.kid,
|
|
232
|
-
privateKeyHex: args.options.privateKeyHex,
|
|
233
|
-
/*meta: {
|
|
234
|
-
algorithms: ['Secp256r1'],
|
|
235
|
-
},*/
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
return context.agent.keyManagerCreate({
|
|
239
|
-
type: args.options.keyType,
|
|
240
|
-
kms,
|
|
241
|
-
meta: {
|
|
242
|
-
algorithms: ['Secp256r1'],
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
249
|
}
|
|
248
250
|
exports.OydDIDProvider = OydDIDProvider;
|
|
251
|
+
const keyCodecs = {
|
|
252
|
+
RSA: 'rsa-pub',
|
|
253
|
+
Ed25519: 'ed25519-pub',
|
|
254
|
+
X25519: 'x25519-pub',
|
|
255
|
+
Secp256k1: 'secp256k1-pub',
|
|
256
|
+
Secp256r1: 'p256-pub',
|
|
257
|
+
Bls12381G1: 'bls12_381-g1-pub',
|
|
258
|
+
Bls12381G2: 'bls12_381-g2-pub',
|
|
259
|
+
};
|
|
260
|
+
const base58btc = ({ publicKeyHex, keyType = 'Secp256r1' }) => {
|
|
261
|
+
const codecName = keyCodecs[keyType];
|
|
262
|
+
// methodSpecificId = bytesToMultibase({bytes: u8a.fromString(key.publicKeyHex, 'hex'), codecName})
|
|
263
|
+
return u8a
|
|
264
|
+
.toString(multibase_1.default.encode('base58btc', multicodec_1.default.addPrefix(codecName, u8a.fromString(publicKeyHex, 'hex'))))
|
|
265
|
+
.toString();
|
|
266
|
+
};
|
|
249
267
|
function defaultOydCmsmPublicKeyCallback(keyManager) {
|
|
250
268
|
return (kid, kms, create, createKeyType) => __awaiter(this, void 0, void 0, function* () {
|
|
251
269
|
try {
|
|
@@ -259,14 +277,29 @@ function defaultOydCmsmPublicKeyCallback(keyManager) {
|
|
|
259
277
|
if (!kms) {
|
|
260
278
|
return Promise.reject(Error('No KMS provided, whilst creating a new key!'));
|
|
261
279
|
}
|
|
262
|
-
|
|
280
|
+
const alias = kid !== null && kid !== void 0 ? kid : `oyd-${new Date().toISOString()}`;
|
|
281
|
+
const agent = keyManager;
|
|
282
|
+
const key = yield (0, ssi_sdk_ext_key_utils_1.importProvidedOrGeneratedKey)({
|
|
283
|
+
kms,
|
|
284
|
+
alias,
|
|
285
|
+
options: {
|
|
286
|
+
key: {
|
|
287
|
+
type: createKeyType !== null && createKeyType !== void 0 ? createKeyType : 'Secp256r1',
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
}, {
|
|
291
|
+
//@ts-ignore
|
|
292
|
+
agent
|
|
293
|
+
});
|
|
294
|
+
return key;
|
|
295
|
+
// return await keyManager.keyManagerCreate({ kms, type: createKeyType ?? 'Secp256r1' })
|
|
263
296
|
}
|
|
264
297
|
return Promise.reject(Error('No existing key found, and create is false!'));
|
|
265
298
|
});
|
|
266
299
|
}
|
|
267
300
|
function defaultOydCmsmSignCallback(keyManager) {
|
|
268
301
|
return (kid, data) => __awaiter(this, void 0, void 0, function* () {
|
|
269
|
-
return keyManager.keyManagerSign({ keyRef: kid, data, encoding: '
|
|
302
|
+
return keyManager.keyManagerSign({ keyRef: kid, data, encoding: 'utf-8' });
|
|
270
303
|
});
|
|
271
304
|
}
|
|
272
305
|
class DefaultOydCmsmCallbacks {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oyd-did-provider.js","sourceRoot":"","sources":["../src/oyd-did-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oyd-did-provider.js","sourceRoot":"","sources":["../src/oyd-did-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkQA,0EAsCC;AAED,gEAIC;AA9SD,2EAA8E;AAE9E,qDAAgE;AAEhE,8DAA+B;AAC/B,0DAAiC;AACjC,4DAAmC;AAEnC,iDAAkC;AAElC,kDAAyB;AASzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,oCAAoC,CAAC,CAAA;AACzD,MAAM,mBAAmB,GAAG,iEAAiE,CAAA;AA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agedSecretMode?: CMSMCallbackOpts;
|
|
5
5
|
};
|
|
6
6
|
export type OydCreateIdentifierOptions = {
|
|
7
|
-
|
|
7
|
+
type?: OydDidSupportedKeyTypes;
|
|
8
8
|
privateKeyHex?: string;
|
|
9
9
|
kid?: string;
|
|
10
|
+
alias?: string;
|
|
10
11
|
keyUse?: KeyUse;
|
|
11
12
|
cmsm?: CmsmOptions;
|
|
12
13
|
key?: IKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oyd-provider-types.d.ts","sourceRoot":"","sources":["../../src/types/oyd-provider-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"oyd-provider-types.d.ts","sourceRoot":"","sources":["../../src/types/oyd-provider-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,uBAAuB,CAAC,EAAE,gBAAgB,CAAA;CAC3C,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,CAAC,EAAE,uBAAuB,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,GAAG,CAAC,EAAE,IAAI,CAAA;CACX,CAAA;AAGD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,uBAAuB,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5G,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/D,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,CAAC;AAErE,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oyd-provider-types.js","sourceRoot":"","sources":["../../src/types/oyd-provider-types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"oyd-provider-types.js","sourceRoot":"","sources":["../../src/types/oyd-provider-types.ts"],"names":[],"mappings":";;;AAwCA,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,4CAAuB,CAAA;IACvB,4CAAuB,CAAA;IACvB,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;AACnB,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.1-feature.oyd.cmsm.improv.
|
|
4
|
+
"version": "0.28.1-feature.oyd.cmsm.improv.21+d4f5d24",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -10,15 +10,19 @@
|
|
|
10
10
|
"extract-api": "sphereon dev extract-api"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.28.1-feature.oyd.cmsm.improv.21+d4f5d24",
|
|
13
14
|
"@veramo/core": "4.2.0",
|
|
14
15
|
"@veramo/did-manager": "4.2.0",
|
|
15
16
|
"cross-fetch": "^4.0.0",
|
|
16
17
|
"debug": "^4.3.3",
|
|
17
|
-
"did-resolver": "^4.1.0"
|
|
18
|
+
"did-resolver": "^4.1.0",
|
|
19
|
+
"multibase": "^4.0.6",
|
|
20
|
+
"multicodec": "^3.2.1",
|
|
21
|
+
"uint8arrays": "^3.1.1"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"@sphereon/ssi-sdk-ext.key-manager": "0.28.1-feature.oyd.cmsm.improv.
|
|
21
|
-
"@sphereon/ssi-sdk-ext.kms-local": "0.28.1-feature.oyd.cmsm.improv.
|
|
24
|
+
"@sphereon/ssi-sdk-ext.key-manager": "0.28.1-feature.oyd.cmsm.improv.21+d4f5d24",
|
|
25
|
+
"@sphereon/ssi-sdk-ext.kms-local": "0.28.1-feature.oyd.cmsm.improv.21+d4f5d24",
|
|
22
26
|
"@sphereon/ssi-sdk.dev": "0.30.2-feature.SDK.41.oidf.support.286",
|
|
23
27
|
"@types/debug": "4.1.12",
|
|
24
28
|
"@veramo/key-manager": "4.2.0",
|
|
@@ -44,5 +48,5 @@
|
|
|
44
48
|
"node_modules",
|
|
45
49
|
"src"
|
|
46
50
|
],
|
|
47
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "d4f5d24390370292662bf168c8b6f9c1f6e69269"
|
|
48
52
|
}
|
package/src/oyd-did-provider.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { importProvidedOrGeneratedKey } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
2
|
+
import { IAgentContext, IIdentifier, IKey, IKeyManager, IService, TKeyType } from '@veramo/core'
|
|
2
3
|
import { AbstractIdentifierProvider } from '@veramo/did-manager'
|
|
3
4
|
import { KeyManager } from '@veramo/key-manager'
|
|
5
|
+
import fetch from 'cross-fetch'
|
|
6
|
+
import Multibase from 'multibase'
|
|
7
|
+
import Multicodec from 'multicodec'
|
|
8
|
+
|
|
9
|
+
import * as u8a from 'uint8arrays'
|
|
10
|
+
|
|
11
|
+
import Debug from 'debug'
|
|
4
12
|
import type {
|
|
5
|
-
OydCreateIdentifierOptions,
|
|
6
|
-
OydDidHoldKeysArgs,
|
|
7
|
-
OydDidSupportedKeyTypes,
|
|
8
13
|
CMSMCallbackOpts,
|
|
9
14
|
OydConstructorOptions,
|
|
15
|
+
OydCreateIdentifierOptions,
|
|
16
|
+
// OydDidHoldKeysArgs,
|
|
17
|
+
OydDidSupportedKeyTypes,
|
|
10
18
|
} from './types/oyd-provider-types.js'
|
|
11
|
-
import fetch from 'cross-fetch'
|
|
12
|
-
|
|
13
|
-
import Debug from 'debug'
|
|
14
19
|
|
|
15
20
|
const debug = Debug('veramo:oyd-did:identifier-provider')
|
|
16
21
|
const OYDID_REGISTRAR_URL = 'https://oydid-registrar.data-container.net/1.0/createIdentifier'
|
|
@@ -43,7 +48,7 @@ export class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
async createIdentifier(
|
|
46
|
-
{ kms, options }: { kms?: string; options: OydCreateIdentifierOptions },
|
|
51
|
+
{ kms, alias, options }: { kms?: string; alias?: string; options: OydCreateIdentifierOptions },
|
|
47
52
|
context: IContext
|
|
48
53
|
): Promise<Omit<IIdentifier, 'provider'>> {
|
|
49
54
|
const resolvedKms = await this.assertedKms(kms, this.defaultKms)
|
|
@@ -58,7 +63,7 @@ export class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
58
63
|
const body = {
|
|
59
64
|
options: {
|
|
60
65
|
cmsm: false,
|
|
61
|
-
key_type: options.
|
|
66
|
+
key_type: options.type ?? 'Secp256r1',
|
|
62
67
|
},
|
|
63
68
|
}
|
|
64
69
|
let didDoc: any | undefined
|
|
@@ -80,15 +85,18 @@ export class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
80
85
|
return Promise.reject(Error('There has been a problem with the fetch operation: ' + error.toString()))
|
|
81
86
|
}
|
|
82
87
|
|
|
83
|
-
const keyType: OydDidSupportedKeyTypes = options?.
|
|
84
|
-
const key = await
|
|
88
|
+
const keyType: OydDidSupportedKeyTypes = options?.type ?? 'Secp256r1'
|
|
89
|
+
const key = await importProvidedOrGeneratedKey(
|
|
85
90
|
{
|
|
86
91
|
kms: resolvedKms,
|
|
92
|
+
alias: alias ?? options.alias ?? options.kid ?? `${didDoc.did}#key-doc`,
|
|
87
93
|
options: {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
key: {
|
|
95
|
+
kid: `${didDoc.did}#key-doc`,
|
|
96
|
+
type: keyType,
|
|
97
|
+
publicKeyHex: didDoc.keys[0].publicKeyHex,
|
|
98
|
+
privateKeyHex: didDoc.keys[0].privateKeyHex,
|
|
99
|
+
},
|
|
92
100
|
},
|
|
93
101
|
},
|
|
94
102
|
context
|
|
@@ -115,21 +123,23 @@ export class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
115
123
|
|
|
116
124
|
const assertedKms = await this.assertedKms(kms, this.defaultKms)
|
|
117
125
|
const pubKey =
|
|
118
|
-
options.key ??
|
|
119
|
-
(await cmsmCallbackOpts.publicKeyCallback(options.kid ?? 'default', assertedKms, options.cmsm?.create !== false, options.keyType)) // "default" is probably not right, TODO!!
|
|
126
|
+
options.key ?? (await cmsmCallbackOpts.publicKeyCallback(options.kid ?? 'default', assertedKms, options.cmsm?.create !== false, options.type)) // "default" is probably not right, TODO!!
|
|
120
127
|
const kid = pubKey.kid
|
|
121
128
|
const keyType = pubKey.type
|
|
129
|
+
const key = base58btc({ publicKeyHex: pubKey.publicKeyHex, keyType })
|
|
122
130
|
|
|
131
|
+
console.log(`Bae58 pubkey key: ${key}`)
|
|
123
132
|
let signValue: any | undefined // do the request
|
|
124
133
|
try {
|
|
125
134
|
const body_create = {
|
|
126
135
|
// specify the Identifier options for the registrar
|
|
127
|
-
key:
|
|
136
|
+
key: key,
|
|
128
137
|
options: {
|
|
129
138
|
cmsm: true,
|
|
130
139
|
key_type: keyType,
|
|
131
140
|
},
|
|
132
141
|
}
|
|
142
|
+
console.log(`Create request:\n${JSON.stringify(body_create, null, 2)}\n`)
|
|
133
143
|
const response = await fetch(OYDID_REGISTRAR_URL, {
|
|
134
144
|
method: 'POST',
|
|
135
145
|
headers: {
|
|
@@ -142,8 +152,9 @@ export class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
142
152
|
return Promise.reject(Error('Network response was not ok: ' + response.statusText))
|
|
143
153
|
}
|
|
144
154
|
signValue = await response.json()
|
|
155
|
+
console.log(`Create response:\n${JSON.stringify(signValue, null, 2)}\n`)
|
|
145
156
|
} catch (error: any) {
|
|
146
|
-
|
|
157
|
+
console.log('Unexpected error from OydDID Registrar: ', error)
|
|
147
158
|
return Promise.reject(Error('There has been a problem with the fetch operation: ' + error.toString()))
|
|
148
159
|
}
|
|
149
160
|
|
|
@@ -151,15 +162,19 @@ export class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
151
162
|
const { sign } = signValue
|
|
152
163
|
const signature = await cmsmCallbackOpts.signCallback(kid, sign)
|
|
153
164
|
|
|
165
|
+
console.log(`Signature: ${signature}`)
|
|
166
|
+
|
|
154
167
|
const body_signed = {
|
|
155
|
-
key
|
|
168
|
+
key,
|
|
156
169
|
options: {
|
|
157
170
|
cmsm: true,
|
|
171
|
+
key_type: keyType,
|
|
158
172
|
sig: signature,
|
|
159
173
|
},
|
|
160
174
|
}
|
|
175
|
+
console.log(`Signed request:\n${JSON.stringify(body_signed, null, 2)}\n`)
|
|
161
176
|
|
|
162
|
-
Object.assign(body_signed.options, options)
|
|
177
|
+
// Object.assign(body_signed.options, options)
|
|
163
178
|
|
|
164
179
|
let didDoc: any | undefined // do the request
|
|
165
180
|
try {
|
|
@@ -171,6 +186,7 @@ export class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
171
186
|
body: JSON.stringify(body_signed),
|
|
172
187
|
})
|
|
173
188
|
if (!response.ok) {
|
|
189
|
+
console.log(`Error response from OydDID Registrar: ${JSON.stringify(response.text)}${response.statusText}`, response)
|
|
174
190
|
debug('Error response from OydDID Registrar: ', response)
|
|
175
191
|
return Promise.reject(Error('Network response was not ok: ' + response.statusText))
|
|
176
192
|
}
|
|
@@ -180,20 +196,6 @@ export class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
180
196
|
return Promise.reject(Error('There has been a problem with the fetch operation: ' + error.toString()))
|
|
181
197
|
}
|
|
182
198
|
|
|
183
|
-
/* let oydKeyType: OydDidSupportedKeyTypes = "Secp256r1";
|
|
184
|
-
|
|
185
|
-
const key = await this.holdKeys(
|
|
186
|
-
{
|
|
187
|
-
kms: assertedKms,
|
|
188
|
-
options: {
|
|
189
|
-
keyType: oydKeyType,
|
|
190
|
-
kid: kid,
|
|
191
|
-
publicKeyHex: pubKey.publicKeyHex,
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
context
|
|
195
|
-
);*/
|
|
196
|
-
|
|
197
199
|
const identifier: Omit<IIdentifier, 'provider'> = {
|
|
198
200
|
did: didDoc.did,
|
|
199
201
|
controllerKeyId: pubKey.kid,
|
|
@@ -233,28 +235,25 @@ export class OydDIDProvider extends AbstractIdentifierProvider {
|
|
|
233
235
|
async removeService(args: { identifier: IIdentifier; id: string; options?: any }, context: IContext): Promise<any> {
|
|
234
236
|
return { success: true }
|
|
235
237
|
}
|
|
238
|
+
}
|
|
236
239
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
algorithms: ['Secp256r1'],
|
|
255
|
-
},
|
|
256
|
-
})
|
|
257
|
-
}
|
|
240
|
+
const keyCodecs = {
|
|
241
|
+
RSA: 'rsa-pub',
|
|
242
|
+
Ed25519: 'ed25519-pub',
|
|
243
|
+
X25519: 'x25519-pub',
|
|
244
|
+
Secp256k1: 'secp256k1-pub',
|
|
245
|
+
Secp256r1: 'p256-pub',
|
|
246
|
+
Bls12381G1: 'bls12_381-g1-pub',
|
|
247
|
+
Bls12381G2: 'bls12_381-g2-pub',
|
|
248
|
+
} as const
|
|
249
|
+
|
|
250
|
+
const base58btc = ({ publicKeyHex, keyType = 'Secp256r1' }: { publicKeyHex: string; keyType?: TKeyType }): string => {
|
|
251
|
+
const codecName = keyCodecs[keyType]
|
|
252
|
+
|
|
253
|
+
// methodSpecificId = bytesToMultibase({bytes: u8a.fromString(key.publicKeyHex, 'hex'), codecName})
|
|
254
|
+
return u8a
|
|
255
|
+
.toString(Multibase.encode('base58btc', Multicodec.addPrefix(codecName as Multicodec.CodecName, u8a.fromString(publicKeyHex, 'hex'))))
|
|
256
|
+
.toString()
|
|
258
257
|
}
|
|
259
258
|
|
|
260
259
|
export function defaultOydCmsmPublicKeyCallback(
|
|
@@ -271,7 +270,27 @@ export function defaultOydCmsmPublicKeyCallback(
|
|
|
271
270
|
if (!kms) {
|
|
272
271
|
return Promise.reject(Error('No KMS provided, whilst creating a new key!'))
|
|
273
272
|
}
|
|
274
|
-
|
|
273
|
+
const alias = kid ?? `oyd-${new Date().toISOString()}`
|
|
274
|
+
|
|
275
|
+
const agent = keyManager
|
|
276
|
+
const key = await importProvidedOrGeneratedKey(
|
|
277
|
+
{
|
|
278
|
+
kms,
|
|
279
|
+
alias,
|
|
280
|
+
options: {
|
|
281
|
+
key: {
|
|
282
|
+
type: createKeyType ?? 'Secp256r1',
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
//@ts-ignore
|
|
288
|
+
agent
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
return key
|
|
292
|
+
|
|
293
|
+
// return await keyManager.keyManagerCreate({ kms, type: createKeyType ?? 'Secp256r1' })
|
|
275
294
|
}
|
|
276
295
|
return Promise.reject(Error('No existing key found, and create is false!'))
|
|
277
296
|
}
|
|
@@ -279,7 +298,7 @@ export function defaultOydCmsmPublicKeyCallback(
|
|
|
279
298
|
|
|
280
299
|
export function defaultOydCmsmSignCallback(keyManager: KeyManager): (kid: string, data: string) => Promise<string> {
|
|
281
300
|
return async (kid: string, data: string): Promise<string> => {
|
|
282
|
-
return keyManager.keyManagerSign({ keyRef: kid, data, encoding: '
|
|
301
|
+
return keyManager.keyManagerSign({ keyRef: kid, data, encoding: 'utf-8' })
|
|
283
302
|
}
|
|
284
303
|
}
|
|
285
304
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { IKey, TKeyType } from '@veramo/core'
|
|
2
2
|
|
|
3
3
|
export type OydConstructorOptions = {
|
|
4
|
-
defaultKms?: string
|
|
5
|
-
clientManagedSecretMode?: CMSMCallbackOpts
|
|
4
|
+
defaultKms?: string
|
|
5
|
+
clientManagedSecretMode?: CMSMCallbackOpts
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export type OydCreateIdentifierOptions = {
|
|
9
|
-
|
|
9
|
+
type?: OydDidSupportedKeyTypes;
|
|
10
10
|
privateKeyHex?: string;
|
|
11
11
|
kid?: string;
|
|
12
|
+
alias?: string;
|
|
12
13
|
keyUse?: KeyUse;
|
|
13
14
|
cmsm?: CmsmOptions;
|
|
14
15
|
key?: IKey // Use the supplied key instead of looking it up in the KMS or creating a new one
|