@sphereon/ssi-sdk-ext.key-manager 0.28.1-feature.jose.vcdm.52 → 0.28.1-feature.oyd.cmsm.improv.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/agent/SphereonKeyManager.d.ts +27 -0
- package/dist/agent/SphereonKeyManager.d.ts.map +1 -0
- package/dist/agent/SphereonKeyManager.js +190 -0
- package/dist/agent/SphereonKeyManager.js.map +1 -0
- package/dist/index.d.ts +5 -136
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -582
- package/dist/index.js.map +1 -1
- package/dist/{index.d.cts → ssi-sdk-ext.key-manager.d.ts} +159 -137
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/ISphereonKeyManager.d.ts +107 -0
- package/dist/types/ISphereonKeyManager.d.ts.map +1 -0
- package/dist/types/ISphereonKeyManager.js +10 -0
- package/dist/types/ISphereonKeyManager.js.map +1 -0
- package/package.json +12 -25
- package/plugin.schema.json +62 -12
- package/src/__tests__/SphereonKeyManager.test.ts +2 -3
- package/src/__tests__/encrypt-decrypt.test.ts +2 -3
- package/src/agent/SphereonKeyManager.ts +11 -12
- package/src/types/ISphereonKeyManager.ts +1 -1
- package/dist/index.cjs +0 -615
- package/dist/index.cjs.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IKey, ManagedKeyInfo } from '@veramo/core';
|
|
2
|
+
import { AbstractKeyManagementSystem, AbstractKeyStore, KeyManager as VeramoKeyManager } from '@veramo/key-manager';
|
|
3
|
+
import { IKeyManagerGetArgs, ISphereonKeyManager, ISphereonKeyManagerCreateArgs, ISphereonKeyManagerHandleExpirationsArgs, ISphereonKeyManagerSignArgs, ISphereonKeyManagerVerifyArgs } from '../types/ISphereonKeyManager';
|
|
4
|
+
export declare const sphereonKeyManagerMethods: Array<string>;
|
|
5
|
+
export declare class SphereonKeyManager extends VeramoKeyManager {
|
|
6
|
+
private kmsStore;
|
|
7
|
+
private readonly availableKmses;
|
|
8
|
+
_defaultKms: string;
|
|
9
|
+
readonly kmsMethods: ISphereonKeyManager;
|
|
10
|
+
constructor(options: {
|
|
11
|
+
store: AbstractKeyStore;
|
|
12
|
+
kms: Record<string, AbstractKeyManagementSystem>;
|
|
13
|
+
defaultKms?: string;
|
|
14
|
+
});
|
|
15
|
+
keyManagerGetDefaultKeyManagementSystem(): Promise<string>;
|
|
16
|
+
keyManagerCreate(args: ISphereonKeyManagerCreateArgs): Promise<ManagedKeyInfo>;
|
|
17
|
+
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>;
|
|
18
|
+
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>;
|
|
19
|
+
keyManagerListKeys(): Promise<ManagedKeyInfo[]>;
|
|
20
|
+
keyManagerHandleExpirations(args: ISphereonKeyManagerHandleExpirationsArgs): Promise<Array<ManagedKeyInfo>>;
|
|
21
|
+
private getKmsByName;
|
|
22
|
+
keyManagerGet({ kid }: IKeyManagerGetArgs): Promise<IKey>;
|
|
23
|
+
get defaultKms(): string;
|
|
24
|
+
set defaultKms(kms: string);
|
|
25
|
+
setKms(name: string, kms: AbstractKeyManagementSystem): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=SphereonKeyManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SphereonKeyManager.d.ts","sourceRoot":"","sources":["../../src/agent/SphereonKeyManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAe,cAAc,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAGnH,OAAO,EAEL,kBAAkB,EAClB,mBAAmB,EACnB,6BAA6B,EAC7B,wCAAwC,EACxC,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,8BAA8B,CAAA;AAErC,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,CASnD,CAAA;AAED,qBAAa,kBAAmB,SAAQ,gBAAgB;IAEtD,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IACrE,WAAW,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAA;gBAE5B,OAAO,EAAE;QAAE,KAAK,EAAE,gBAAgB,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAevH,uCAAuC,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C,gBAAgB,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,cAAc,CAAC;IAyBvF,cAAc,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAUlE,gBAAgB,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,OAAO,CAAC;IAevE,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAI/C,2BAA2B,CAAC,IAAI,EAAE,wCAAwC,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAiBjH,OAAO,CAAC,YAAY;IASd,aAAa,CAAC,EAAE,GAAG,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB/D,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,UAAU,CAAC,GAAG,EAAE,MAAM,EAKzB;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,2BAA2B,GAAG,IAAI;CAG7D"}
|
|
@@ -0,0 +1,190 @@
|
|
|
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
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.SphereonKeyManager = exports.sphereonKeyManagerMethods = void 0;
|
|
36
|
+
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
37
|
+
const key_manager_1 = require("@veramo/key-manager");
|
|
38
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
39
|
+
const ISphereonKeyManager_1 = require("../types/ISphereonKeyManager");
|
|
40
|
+
exports.sphereonKeyManagerMethods = [
|
|
41
|
+
'keyManagerCreate',
|
|
42
|
+
'keyManagerGet',
|
|
43
|
+
'keyManagerImport',
|
|
44
|
+
'keyManagerSign',
|
|
45
|
+
'keyManagerVerify',
|
|
46
|
+
'keyManagerListKeys',
|
|
47
|
+
'keyManagerGetDefaultKeyManagementSystem',
|
|
48
|
+
'keyManagerHandleExpirations',
|
|
49
|
+
];
|
|
50
|
+
class SphereonKeyManager extends key_manager_1.KeyManager {
|
|
51
|
+
constructor(options) {
|
|
52
|
+
var _a;
|
|
53
|
+
super({ store: options.store, kms: options.kms });
|
|
54
|
+
this.kmsStore = options.store;
|
|
55
|
+
this.availableKmses = options.kms;
|
|
56
|
+
this._defaultKms = (_a = options.defaultKms) !== null && _a !== void 0 ? _a : Object.keys(this.availableKmses)[0];
|
|
57
|
+
if (!Object.keys(this.availableKmses).includes(this._defaultKms)) {
|
|
58
|
+
throw Error(`Default KMS needs to be listed in the kms object as well. Found kms-es: ${Object.keys(this.availableKmses).join(',')}`);
|
|
59
|
+
}
|
|
60
|
+
const methods = this.methods;
|
|
61
|
+
methods.keyManagerVerify = this.keyManagerVerify.bind(this);
|
|
62
|
+
methods.keyManagerListKeys = this.keyManagerListKeys.bind(this);
|
|
63
|
+
methods.keyManagerGetDefaultKeyManagementSystem = this.keyManagerGetDefaultKeyManagementSystem.bind(this);
|
|
64
|
+
this.kmsMethods = methods;
|
|
65
|
+
}
|
|
66
|
+
keyManagerGetDefaultKeyManagementSystem() {
|
|
67
|
+
return Promise.resolve(this._defaultKms);
|
|
68
|
+
}
|
|
69
|
+
keyManagerCreate(args) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
var _a, _b, _c, _d, _e, _f;
|
|
72
|
+
const kms = this.getKmsByName((_a = args.kms) !== null && _a !== void 0 ? _a : this._defaultKms);
|
|
73
|
+
const meta = Object.assign(Object.assign({}, args.meta), (args.opts && { opts: args.opts }));
|
|
74
|
+
if ((0, ISphereonKeyManager_1.hasKeyOptions)(meta) && ((_b = meta.opts) === null || _b === void 0 ? void 0 : _b.ephemeral) && !((_c = meta.opts.expiration) === null || _c === void 0 ? void 0 : _c.removalDate)) {
|
|
75
|
+
// Make sure we set a delete date on an ephemeral key
|
|
76
|
+
meta.opts = Object.assign(Object.assign({}, meta.opts), { expiration: Object.assign(Object.assign({}, (_d = meta.opts) === null || _d === void 0 ? void 0 : _d.expiration), { removalDate: new Date(Date.now() + 5 * 60 * 1000) }) });
|
|
77
|
+
}
|
|
78
|
+
const partialKey = yield kms.createKey({ type: args.type, meta });
|
|
79
|
+
const key = Object.assign(Object.assign({}, partialKey), { kms: (_e = args.kms) !== null && _e !== void 0 ? _e : this._defaultKms });
|
|
80
|
+
key.meta = Object.assign(Object.assign({}, meta), key.meta);
|
|
81
|
+
key.meta.jwkThumbprint = (_f = key.meta.jwkThumbprint) !== null && _f !== void 0 ? _f : (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprintForKey)({ key });
|
|
82
|
+
yield this.kmsStore.import(key);
|
|
83
|
+
if (key.privateKeyHex) {
|
|
84
|
+
// Make sure to not export the private key
|
|
85
|
+
delete key.privateKeyHex;
|
|
86
|
+
}
|
|
87
|
+
return key;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//FIXME extend the IKeyManagerSignArgs.data to be a string or array of strings
|
|
91
|
+
keyManagerSign(args) {
|
|
92
|
+
const _super = Object.create(null, {
|
|
93
|
+
keyManagerSign: { get: () => super.keyManagerSign }
|
|
94
|
+
});
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const keyInfo = yield this.keyManagerGet({ kid: args.keyRef });
|
|
97
|
+
const kms = this.getKmsByName(keyInfo.kms);
|
|
98
|
+
if (keyInfo.type === 'Bls12381G2') {
|
|
99
|
+
return yield kms.sign({ keyRef: keyInfo, data: typeof args.data === 'string' ? u8a.fromString(args.data) : args.data });
|
|
100
|
+
}
|
|
101
|
+
// @ts-ignore // we can pass in uint8arrays as well, which the super also can handle but does not expose in its types
|
|
102
|
+
return yield _super.keyManagerSign.call(this, Object.assign(Object.assign({}, args), { keyRef: keyInfo.kid }));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
keyManagerVerify(args) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
if (args.kms) {
|
|
108
|
+
const kms = this.getKmsByName(args.kms);
|
|
109
|
+
if (kms && 'verify' in kms && typeof kms.verify === 'function') {
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
return yield kms.verify(args);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return yield (0, ssi_sdk_ext_key_utils_1.verifyRawSignature)({
|
|
115
|
+
key: (0, ssi_sdk_ext_key_utils_1.toJwk)(args.publicKeyHex, args.type),
|
|
116
|
+
data: args.data,
|
|
117
|
+
signature: u8a.fromString(args.signature, 'utf-8'),
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
keyManagerListKeys() {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
return this.kmsStore.list({});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
keyManagerHandleExpirations(args) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const keys = yield this.keyManagerListKeys();
|
|
129
|
+
const expiredKeys = keys
|
|
130
|
+
.filter((key) => (0, ISphereonKeyManager_1.hasKeyOptions)(key.meta))
|
|
131
|
+
.filter((key) => {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
if ((0, ISphereonKeyManager_1.hasKeyOptions)(key.meta) && ((_b = (_a = key.meta) === null || _a === void 0 ? void 0 : _a.opts) === null || _b === void 0 ? void 0 : _b.expiration)) {
|
|
134
|
+
const expiration = key.meta.opts.expiration;
|
|
135
|
+
return !(expiration.expiryDate && expiration.expiryDate.getMilliseconds() > Date.now());
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
});
|
|
139
|
+
if (args.skipRemovals !== true) {
|
|
140
|
+
yield Promise.all(expiredKeys.map((key) => this.keyManagerDelete({ kid: key.kid })));
|
|
141
|
+
}
|
|
142
|
+
return keys;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
getKmsByName(name) {
|
|
146
|
+
const kms = this.availableKmses[name];
|
|
147
|
+
if (!kms) {
|
|
148
|
+
throw Error(`invalid_argument: This agent has no registered KeyManagementSystem with name='${name}'`);
|
|
149
|
+
}
|
|
150
|
+
return kms;
|
|
151
|
+
}
|
|
152
|
+
//todo https://sphereon.atlassian.net/browse/SDK-28 improve the logic for keyManagerGet in sphereon-key-manager
|
|
153
|
+
keyManagerGet(_a) {
|
|
154
|
+
return __awaiter(this, arguments, void 0, function* ({ kid }) {
|
|
155
|
+
try {
|
|
156
|
+
const key = yield this.kmsStore.get({ kid });
|
|
157
|
+
return key;
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
const keys = yield this.keyManagerListKeys();
|
|
161
|
+
const foundKey = keys.find((key) => {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
return key.publicKeyHex === kid ||
|
|
164
|
+
((_a = key.meta) === null || _a === void 0 ? void 0 : _a.jwkThumbprint) === kid ||
|
|
165
|
+
(((_b = key.meta) === null || _b === void 0 ? void 0 : _b.jwkThumbprint) == null && (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprintForKey)({ key }) === kid);
|
|
166
|
+
});
|
|
167
|
+
if (foundKey) {
|
|
168
|
+
return foundKey;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
throw new Error(`Key with kid ${kid} not found`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
get defaultKms() {
|
|
177
|
+
return this._defaultKms;
|
|
178
|
+
}
|
|
179
|
+
set defaultKms(kms) {
|
|
180
|
+
if (!Object.keys(this.availableKmses).includes(kms)) {
|
|
181
|
+
throw Error(`Default KMS needs to be listed in the kms object as well. Found kms-es: ${Object.keys(this.availableKmses).join(',')}`);
|
|
182
|
+
}
|
|
183
|
+
this._defaultKms = kms;
|
|
184
|
+
}
|
|
185
|
+
setKms(name, kms) {
|
|
186
|
+
this.availableKmses[name] = kms;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.SphereonKeyManager = SphereonKeyManager;
|
|
190
|
+
//# sourceMappingURL=SphereonKeyManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SphereonKeyManager.js","sourceRoot":"","sources":["../../src/agent/SphereonKeyManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAAyG;AAEzG,qDAAmH;AAEnH,iDAAkC;AAClC,sEAQqC;AAExB,QAAA,yBAAyB,GAAkB;IACtD,kBAAkB;IAClB,eAAe;IACf,kBAAkB;IAClB,gBAAgB;IAChB,kBAAkB;IAClB,oBAAoB;IACpB,yCAAyC;IACzC,6BAA6B;CAC9B,CAAA;AAED,MAAa,kBAAmB,SAAQ,wBAAgB;IAOtD,YAAY,OAA2G;;QACrH,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QACjD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAA;QAC7B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,CAAA;QACjC,IAAI,CAAC,WAAW,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;QAC5E,IAAI,CAAC,MAAM,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from '@veramo/core';
|
|
2
|
-
import { KeyManager, AbstractKeyStore, AbstractKeyManagementSystem } from '@veramo/key-manager';
|
|
3
|
-
export * from '@veramo/key-manager';
|
|
4
|
-
|
|
5
|
-
type PartialKey = ManagedKeyInfo & {
|
|
6
|
-
privateKeyHex: string;
|
|
7
|
-
};
|
|
8
|
-
interface ISphereonKeyManager extends IKeyManager, IPluginMethodMap {
|
|
9
|
-
keyManagerCreate(args: ISphereonKeyManagerCreateArgs): Promise<PartialKey>;
|
|
10
|
-
keyManagerImport(key: MinimalImportableKey): Promise<PartialKey>;
|
|
11
|
-
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>;
|
|
12
|
-
/**
|
|
13
|
-
* Verifies a signature using the key
|
|
14
|
-
*
|
|
15
|
-
* Does not exist in IKeyManager
|
|
16
|
-
* @param args
|
|
17
|
-
*/
|
|
18
|
-
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>;
|
|
19
|
-
keyManagerListKeys(): Promise<Array<ManagedKeyInfo>>;
|
|
20
|
-
/**
|
|
21
|
-
* Get the KMS registered as default. Handy when no explicit KMS is provided for a function
|
|
22
|
-
*/
|
|
23
|
-
keyManagerGetDefaultKeyManagementSystem(): Promise<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Set keys to expired and remove keys eligible for deletion.
|
|
26
|
-
* @param args
|
|
27
|
-
*/
|
|
28
|
-
keyManagerHandleExpirations(args: ISphereonKeyManagerHandleExpirationsArgs): Promise<Array<ManagedKeyInfo>>;
|
|
29
|
-
}
|
|
30
|
-
interface IkeyOptions {
|
|
31
|
-
/**
|
|
32
|
-
* Is this a temporary key?
|
|
33
|
-
*/
|
|
34
|
-
ephemeral?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Expiration and remove the key
|
|
37
|
-
*/
|
|
38
|
-
expiration?: {
|
|
39
|
-
expiryDate?: Date;
|
|
40
|
-
removalDate?: Date;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Input arguments for {@link ISphereonKeyManager.keyManagerCreate | keyManagerCreate}
|
|
45
|
-
* @public
|
|
46
|
-
*/
|
|
47
|
-
interface ISphereonKeyManagerCreateArgs {
|
|
48
|
-
/**
|
|
49
|
-
* Key type
|
|
50
|
-
*/
|
|
51
|
-
type: TKeyType;
|
|
52
|
-
/**
|
|
53
|
-
* Key Management System
|
|
54
|
-
*/
|
|
55
|
-
kms?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Key options
|
|
58
|
-
*/
|
|
59
|
-
opts?: IkeyOptions;
|
|
60
|
-
/**
|
|
61
|
-
* Optional. Key meta data
|
|
62
|
-
*/
|
|
63
|
-
meta?: KeyMetadata;
|
|
64
|
-
}
|
|
65
|
-
declare function hasKeyOptions(object: any): object is {
|
|
66
|
-
opts?: IkeyOptions;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Input arguments for {@link ISphereonKeyManager.keyManagerGet | keyManagerGet}
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
72
|
-
interface IKeyManagerGetArgs {
|
|
73
|
-
/**
|
|
74
|
-
* Key ID
|
|
75
|
-
*/
|
|
76
|
-
kid: string;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Input arguments for {@link ISphereonKeyManager.keyManagerDelete | keyManagerDelete}
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
interface IKeyManagerDeleteArgs {
|
|
83
|
-
/**
|
|
84
|
-
* Key ID
|
|
85
|
-
*/
|
|
86
|
-
kid: string;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Input arguments for {@link ISphereonKeyManagerSignArgs.keyManagerSign | keyManagerSign}
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
92
|
-
interface ISphereonKeyManagerSignArgs extends IKeyManagerSignArgs {
|
|
93
|
-
/**
|
|
94
|
-
* Data to sign
|
|
95
|
-
*/
|
|
96
|
-
data: string | Uint8Array;
|
|
97
|
-
}
|
|
98
|
-
interface ISphereonKeyManagerHandleExpirationsArgs {
|
|
99
|
-
skipRemovals?: boolean;
|
|
100
|
-
}
|
|
101
|
-
interface ISphereonKeyManagerVerifyArgs {
|
|
102
|
-
kms?: string;
|
|
103
|
-
publicKeyHex: string;
|
|
104
|
-
type: TKeyType;
|
|
105
|
-
algorithm?: string;
|
|
106
|
-
data: Uint8Array;
|
|
107
|
-
signature: string;
|
|
108
|
-
}
|
|
109
|
-
declare const isDefined: <T extends unknown>(object: T | undefined) => object is T;
|
|
110
|
-
|
|
111
|
-
declare const sphereonKeyManagerMethods: Array<string>;
|
|
112
|
-
declare class SphereonKeyManager extends KeyManager {
|
|
113
|
-
private kmsStore;
|
|
114
|
-
private readonly availableKmses;
|
|
115
|
-
_defaultKms: string;
|
|
116
|
-
readonly kmsMethods: ISphereonKeyManager;
|
|
117
|
-
constructor(options: {
|
|
118
|
-
store: AbstractKeyStore;
|
|
119
|
-
kms: Record<string, AbstractKeyManagementSystem>;
|
|
120
|
-
defaultKms?: string;
|
|
121
|
-
});
|
|
122
|
-
keyManagerGetDefaultKeyManagementSystem(): Promise<string>;
|
|
123
|
-
keyManagerCreate(args: ISphereonKeyManagerCreateArgs): Promise<ManagedKeyInfo>;
|
|
124
|
-
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>;
|
|
125
|
-
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>;
|
|
126
|
-
keyManagerListKeys(): Promise<ManagedKeyInfo[]>;
|
|
127
|
-
keyManagerHandleExpirations(args: ISphereonKeyManagerHandleExpirationsArgs): Promise<Array<ManagedKeyInfo>>;
|
|
128
|
-
private getKmsByName;
|
|
129
|
-
keyManagerGet({ kid }: IKeyManagerGetArgs): Promise<IKey>;
|
|
130
|
-
get defaultKms(): string;
|
|
131
|
-
set defaultKms(kms: string);
|
|
132
|
-
setKms(name: string, kms: AbstractKeyManagementSystem): void;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
1
|
declare const schema: any;
|
|
136
|
-
|
|
137
|
-
export {
|
|
2
|
+
export { schema };
|
|
3
|
+
export { SphereonKeyManager, sphereonKeyManagerMethods } from './agent/SphereonKeyManager';
|
|
4
|
+
export * from './types/ISphereonKeyManager';
|
|
5
|
+
export * from '@veramo/key-manager';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAC1F,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA"}
|