@dynamic-labs-wallet/core 0.0.3 → 0.0.4
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.esm.js +52 -20
- package/package.json +1 -1
- package/src/api/api.d.ts +13 -8
- package/src/api/api.d.ts.map +1 -1
- package/src/api/client.d.ts +1 -1
- package/src/api/client.d.ts.map +1 -1
- package/src/mpc/constants.d.ts +12 -0
- package/src/mpc/constants.d.ts.map +1 -1
package/index.esm.js
CHANGED
|
@@ -3,12 +3,12 @@ import axios from 'axios';
|
|
|
3
3
|
const RELAY_API_URL = 'relay.dynamic-preprod.xyz';
|
|
4
4
|
const DYNAMIC_AUTH_BASE_API_URL = 'https://app.dynamicauth.com';
|
|
5
5
|
|
|
6
|
-
var SigningAlgorithm
|
|
7
|
-
(function(SigningAlgorithm) {
|
|
6
|
+
var SigningAlgorithm = /*#__PURE__*/ function(SigningAlgorithm) {
|
|
8
7
|
SigningAlgorithm["ECDSA"] = "ECDSA";
|
|
9
8
|
SigningAlgorithm["ED25519"] = "ED25519";
|
|
10
9
|
SigningAlgorithm["BIP340"] = "BIP340";
|
|
11
|
-
|
|
10
|
+
return SigningAlgorithm;
|
|
11
|
+
}({});
|
|
12
12
|
const BITCOIN_DERIVATION_PATHS = {
|
|
13
13
|
LEGACY: [
|
|
14
14
|
44,
|
|
@@ -92,26 +92,45 @@ const getMPCChainConfig = (chainName)=>{
|
|
|
92
92
|
}
|
|
93
93
|
return chainConfig;
|
|
94
94
|
};
|
|
95
|
-
var ThresholdSignatureScheme
|
|
96
|
-
(function(ThresholdSignatureScheme) {
|
|
95
|
+
var ThresholdSignatureScheme = /*#__PURE__*/ function(ThresholdSignatureScheme) {
|
|
97
96
|
ThresholdSignatureScheme["TWO_OF_TWO"] = "TWO_OF_TWO";
|
|
98
97
|
ThresholdSignatureScheme["TWO_OF_THREE"] = "TWO_OF_THREE";
|
|
99
98
|
ThresholdSignatureScheme["THREE_OF_FIVE"] = "THREE_OF_FIVE";
|
|
100
|
-
|
|
99
|
+
return ThresholdSignatureScheme;
|
|
100
|
+
}({});
|
|
101
101
|
const MPC_CONFIG = {
|
|
102
102
|
["TWO_OF_TWO"]: {
|
|
103
103
|
numberOfParties: 2,
|
|
104
|
-
threshold: 2
|
|
104
|
+
threshold: 2,
|
|
105
|
+
clientThreshold: 1,
|
|
106
|
+
dynamicServerThreshold: 1
|
|
105
107
|
},
|
|
106
108
|
["TWO_OF_THREE"]: {
|
|
107
109
|
numberOfParties: 3,
|
|
108
|
-
threshold: 2
|
|
110
|
+
threshold: 2,
|
|
111
|
+
clientThreshold: 2,
|
|
112
|
+
dynamicServerThreshold: 1
|
|
109
113
|
},
|
|
110
114
|
["THREE_OF_FIVE"]: {
|
|
111
115
|
numberOfParties: 5,
|
|
112
|
-
threshold: 3
|
|
116
|
+
threshold: 3,
|
|
117
|
+
clientThreshold: 3,
|
|
118
|
+
dynamicServerThreshold: 2
|
|
113
119
|
}
|
|
114
120
|
};
|
|
121
|
+
const getTSSConfig = (thresholdSignatureScheme)=>{
|
|
122
|
+
const { threshold, numberOfParties } = MPC_CONFIG[thresholdSignatureScheme];
|
|
123
|
+
return {
|
|
124
|
+
threshold,
|
|
125
|
+
numberOfParties
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
const getClientThreshold = (thresholdSignatureScheme)=>{
|
|
129
|
+
return MPC_CONFIG[thresholdSignatureScheme].clientThreshold;
|
|
130
|
+
};
|
|
131
|
+
const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
|
|
132
|
+
return MPC_CONFIG[thresholdSignatureScheme].dynamicServerThreshold;
|
|
133
|
+
};
|
|
115
134
|
|
|
116
135
|
class BaseClient {
|
|
117
136
|
constructor({ environmentId, baseApiUrl, authToken }){
|
|
@@ -127,12 +146,12 @@ class BaseClient {
|
|
|
127
146
|
}
|
|
128
147
|
|
|
129
148
|
class DynamicApiClient extends BaseClient {
|
|
130
|
-
async createWalletAccount({ chainName, clientKeygenIds }) {
|
|
149
|
+
async createWalletAccount({ chainName, clientKeygenIds, thresholdSignatureScheme }) {
|
|
131
150
|
// Initilize keygen, create room, and create the wallet account on the server
|
|
132
151
|
const { data } = await this.apiClient.post(`/api/v0/sdk/${this.environmentId}/waas/create`, {
|
|
133
152
|
chain: chainName,
|
|
134
153
|
clientKeygenIds,
|
|
135
|
-
thresholdSignatureScheme
|
|
154
|
+
thresholdSignatureScheme
|
|
136
155
|
});
|
|
137
156
|
return data;
|
|
138
157
|
}
|
|
@@ -158,14 +177,18 @@ class DynamicApiClient extends BaseClient {
|
|
|
158
177
|
});
|
|
159
178
|
return data;
|
|
160
179
|
}
|
|
161
|
-
async
|
|
162
|
-
const { data } = await this.apiClient.post(`/api/v0/sdk/${this.environmentId}/waas/${walletId}/
|
|
163
|
-
|
|
180
|
+
async storeEncryptedBackupByWallet({ walletId, encryptedKeyShares, passwordEncrypted }) {
|
|
181
|
+
const { data } = await this.apiClient.post(`/api/v0/sdk/${this.environmentId}/waas/${walletId}/keyShares/backup`, {
|
|
182
|
+
// TODO: decide on whether to store encryptedAccountCredentials or encryptedKeyShares as backup
|
|
183
|
+
encryptedAccountCredentials: encryptedKeyShares,
|
|
184
|
+
passwordEncrypted
|
|
164
185
|
});
|
|
165
186
|
return data;
|
|
166
187
|
}
|
|
167
|
-
async
|
|
168
|
-
const { data } = await this.apiClient.
|
|
188
|
+
async recoverEncryptedBackupByWallet({ walletId, keyShareIds }) {
|
|
189
|
+
const { data } = await this.apiClient.post(`/api/v0/sdk/${this.environmentId}/waas/${walletId}/keyShares/recover`, keyShareIds ? {
|
|
190
|
+
keyShareIds
|
|
191
|
+
} : undefined);
|
|
169
192
|
return data;
|
|
170
193
|
}
|
|
171
194
|
async getAccessToken({ oauthAccountId }) {
|
|
@@ -174,13 +197,22 @@ class DynamicApiClient extends BaseClient {
|
|
|
174
197
|
return data.accessToken;
|
|
175
198
|
}
|
|
176
199
|
// TODO: return array instead considering cases where server has multiple parties
|
|
177
|
-
async importPrivateKey({ chainName,
|
|
178
|
-
const { data } = await this.apiClient.post(`/api/v0/sdk/${this.environmentId}/waas
|
|
200
|
+
async importPrivateKey({ chainName, clientKeygenIds, thresholdSignatureScheme }) {
|
|
201
|
+
const { data } = await this.apiClient.post(`/api/v0/sdk/${this.environmentId}/waas/privateKey/import`, {
|
|
179
202
|
chain: chainName,
|
|
180
|
-
clientKeygenIds
|
|
203
|
+
clientKeygenIds,
|
|
204
|
+
thresholdSignatureScheme
|
|
181
205
|
});
|
|
182
206
|
return data;
|
|
183
207
|
}
|
|
208
|
+
async getUser() {
|
|
209
|
+
const { data } = await this.apiClient.get(`/api/v0/sdk/${this.environmentId}/users`);
|
|
210
|
+
return data;
|
|
211
|
+
}
|
|
212
|
+
async refreshUser() {
|
|
213
|
+
const { data } = await this.apiClient.post(`/api/v0/sdk/${this.environmentId}/refresh`, undefined);
|
|
214
|
+
return data;
|
|
215
|
+
}
|
|
184
216
|
constructor({ environmentId, authToken, baseApiUrl }){
|
|
185
217
|
super({
|
|
186
218
|
environmentId,
|
|
@@ -190,4 +222,4 @@ class DynamicApiClient extends BaseClient {
|
|
|
190
222
|
}
|
|
191
223
|
}
|
|
192
224
|
|
|
193
|
-
export { BITCOIN_DERIVATION_PATHS, DYNAMIC_AUTH_BASE_API_URL, DynamicApiClient, MPC_CHAIN_CONFIG, MPC_CONFIG, RELAY_API_URL, SigningAlgorithm, ThresholdSignatureScheme, getMPCChainConfig };
|
|
225
|
+
export { BITCOIN_DERIVATION_PATHS, DYNAMIC_AUTH_BASE_API_URL, DynamicApiClient, MPC_CHAIN_CONFIG, MPC_CONFIG, RELAY_API_URL, SigningAlgorithm, ThresholdSignatureScheme, getClientThreshold, getDynamicServerThreshold, getMPCChainConfig, getTSSConfig };
|
package/package.json
CHANGED
package/src/api/api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ThresholdSignatureScheme } from '../mpc/constants';
|
|
1
2
|
import { BaseClient } from './client';
|
|
2
3
|
export declare class DynamicApiClient extends BaseClient {
|
|
3
4
|
constructor({ environmentId, authToken, baseApiUrl, }: {
|
|
@@ -5,9 +6,10 @@ export declare class DynamicApiClient extends BaseClient {
|
|
|
5
6
|
authToken: string;
|
|
6
7
|
baseApiUrl?: string;
|
|
7
8
|
});
|
|
8
|
-
createWalletAccount({ chainName, clientKeygenIds, }: {
|
|
9
|
+
createWalletAccount({ chainName, clientKeygenIds, thresholdSignatureScheme, }: {
|
|
9
10
|
chainName: string;
|
|
10
11
|
clientKeygenIds: string[];
|
|
12
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
11
13
|
}): Promise<any>;
|
|
12
14
|
signMessage({ walletId, message, }: {
|
|
13
15
|
walletId: string;
|
|
@@ -24,24 +26,27 @@ export declare class DynamicApiClient extends BaseClient {
|
|
|
24
26
|
walletId: string;
|
|
25
27
|
exportId: string;
|
|
26
28
|
}): Promise<any>;
|
|
27
|
-
|
|
29
|
+
storeEncryptedBackupByWallet({ walletId, encryptedKeyShares, passwordEncrypted, }: {
|
|
28
30
|
walletId: string;
|
|
29
|
-
|
|
31
|
+
encryptedKeyShares: string[];
|
|
32
|
+
passwordEncrypted: boolean;
|
|
30
33
|
}): Promise<any>;
|
|
31
|
-
|
|
34
|
+
recoverEncryptedBackupByWallet({ walletId, keyShareIds, }: {
|
|
32
35
|
walletId: string;
|
|
33
|
-
|
|
36
|
+
keyShareIds?: string[];
|
|
34
37
|
}): Promise<any>;
|
|
35
38
|
getAccessToken({ oauthAccountId }: {
|
|
36
39
|
oauthAccountId: string;
|
|
37
40
|
}): Promise<any>;
|
|
38
|
-
importPrivateKey({ chainName,
|
|
41
|
+
importPrivateKey({ chainName, clientKeygenIds, thresholdSignatureScheme, }: {
|
|
39
42
|
chainName: string;
|
|
40
|
-
walletId: string;
|
|
41
43
|
clientKeygenIds: string[];
|
|
44
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
42
45
|
}): Promise<{
|
|
43
46
|
roomId: string;
|
|
44
|
-
|
|
47
|
+
serverKeygenIds: string[];
|
|
45
48
|
}>;
|
|
49
|
+
getUser(): Promise<any>;
|
|
50
|
+
refreshUser(): Promise<any>;
|
|
46
51
|
}
|
|
47
52
|
//# sourceMappingURL=api.d.ts.map
|
package/src/api/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,qBAAa,gBAAiB,SAAQ,UAAU;gBAClC,EACV,aAAa,EACb,SAAS,EACT,UAAU,GACX,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;IAIK,mBAAmB,CAAC,EACxB,SAAS,EACT,eAAe,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,qBAAa,gBAAiB,SAAQ,UAAU;gBAClC,EACV,aAAa,EACb,SAAS,EACT,UAAU,GACX,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;IAIK,mBAAmB,CAAC,EACxB,SAAS,EACT,eAAe,EACf,wBAAwB,GACzB,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,wBAAwB,EAAE,wBAAwB,CAAC;KACpD;IAaK,WAAW,CAAC,EAChB,QAAQ,EACR,OAAO,GACR,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB;I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"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAGlD,qBAAa,UAAU;IACd,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;gBAEjB,EACV,aAAa,EACb,UAAU,EACV,SAAS,GACV,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;CAWF"}
|
package/src/mpc/constants.d.ts
CHANGED
|
@@ -25,14 +25,26 @@ export declare const MPC_CONFIG: {
|
|
|
25
25
|
TWO_OF_TWO: {
|
|
26
26
|
numberOfParties: number;
|
|
27
27
|
threshold: number;
|
|
28
|
+
clientThreshold: number;
|
|
29
|
+
dynamicServerThreshold: number;
|
|
28
30
|
};
|
|
29
31
|
TWO_OF_THREE: {
|
|
30
32
|
numberOfParties: number;
|
|
31
33
|
threshold: number;
|
|
34
|
+
clientThreshold: number;
|
|
35
|
+
dynamicServerThreshold: number;
|
|
32
36
|
};
|
|
33
37
|
THREE_OF_FIVE: {
|
|
34
38
|
numberOfParties: number;
|
|
35
39
|
threshold: number;
|
|
40
|
+
clientThreshold: number;
|
|
41
|
+
dynamicServerThreshold: number;
|
|
36
42
|
};
|
|
37
43
|
};
|
|
44
|
+
export declare const getTSSConfig: (thresholdSignatureScheme: ThresholdSignatureScheme) => {
|
|
45
|
+
threshold: number;
|
|
46
|
+
numberOfParties: number;
|
|
47
|
+
};
|
|
48
|
+
export declare const getClientThreshold: (thresholdSignatureScheme: ThresholdSignatureScheme) => number;
|
|
49
|
+
export declare const getDynamicServerThreshold: (thresholdSignatureScheme: ThresholdSignatureScheme) => number;
|
|
38
50
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/mpc/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IAC1B,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,wBAAwB;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,MAAM,EACN;IAAE,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,gBAAgB,EAAE,gBAAgB,CAAA;CAAE,CA2BjE,CAAC;AAEF,eAAO,MAAM,iBAAiB,cAAe,MAAM;oBA7B/B,MAAM,EAAE;sBAAoB,gBAAgB;CAmC/D,CAAC;AAEF,oBAAY,wBAAwB;IAClC,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;CAChC;AAED,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/mpc/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IAC1B,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,wBAAwB;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,MAAM,EACN;IAAE,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,gBAAgB,EAAE,gBAAgB,CAAA;CAAE,CA2BjE,CAAC;AAEF,eAAO,MAAM,iBAAiB,cAAe,MAAM;oBA7B/B,MAAM,EAAE;sBAAoB,gBAAgB;CAmC/D,CAAC;AAEF,oBAAY,wBAAwB;IAClC,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;CAChC;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;CAmBtB,CAAC;AAEF,eAAO,MAAM,YAAY,6BACG,wBAAw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