@dfns/sdk-keyexport-utils-nodejs 0.5.9-rc.0
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/index.d.ts +6 -0
- package/index.js +41 -0
- package/package.json +15 -0
- package/types.d.ts +21 -0
- package/types.js +2 -0
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.newWalletExportContext = void 0;
|
|
18
|
+
const dfns_key_export_nodejs_1 = require("@dfns/dfns-key-export-nodejs");
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
const newWalletExportContext = () => {
|
|
21
|
+
const ctx = dfns_key_export_nodejs_1.KeyExportContext.new();
|
|
22
|
+
const getConf = () => {
|
|
23
|
+
const req = ctx.buildKeyExportRequest();
|
|
24
|
+
return {
|
|
25
|
+
encryptionKey: req.encryptionKey,
|
|
26
|
+
supportedSchemes: req.supportedSchemes,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const recoverSecretKey = (params) => {
|
|
30
|
+
const secretKey = ctx.recoverSecretKey({
|
|
31
|
+
...params,
|
|
32
|
+
encryptedShares: params.encryptedKeyShares, // re-mapping field name, since wasm module has wrong name
|
|
33
|
+
});
|
|
34
|
+
return secretKey.toBytesBE();
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
getConf,
|
|
38
|
+
recoverSecretKey,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.newWalletExportContext = newWalletExportContext;
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dfns/sdk-keyexport-utils-nodejs",
|
|
3
|
+
"version": "0.5.9-rc.0",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@dfns/dfns-key-export-nodejs": "0.2.1",
|
|
6
|
+
"buffer": "6.0.3",
|
|
7
|
+
"cross-fetch": "3.1.6",
|
|
8
|
+
"uuid": "9.0.0"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"@dfns/sdk": "0.5.9-rc.0"
|
|
12
|
+
},
|
|
13
|
+
"main": "./index.js",
|
|
14
|
+
"type": "commonjs"
|
|
15
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ExportWalletRequest } from '@dfns/sdk/types/wallets';
|
|
2
|
+
type KeyProtocol = ExportWalletRequest['body']['supportedSchemes'][number]['protocol'];
|
|
3
|
+
type KeyCurve = ExportWalletRequest['body']['supportedSchemes'][number]['curve'];
|
|
4
|
+
export type WalletExportConfig = {
|
|
5
|
+
encryptionKey: string;
|
|
6
|
+
supportedSchemes: {
|
|
7
|
+
protocol: KeyProtocol;
|
|
8
|
+
curve: KeyCurve;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
export type RecoverSecretKeyParams = {
|
|
12
|
+
minSigners: number;
|
|
13
|
+
publicKey: string;
|
|
14
|
+
protocol: KeyProtocol;
|
|
15
|
+
curve: KeyCurve;
|
|
16
|
+
encryptedKeyShares: {
|
|
17
|
+
signerId: string;
|
|
18
|
+
encryptedKeyShare: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
export {};
|
package/types.js
ADDED