@dfns/sdk 0.1.0-beta.7 → 0.1.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/baseAuthApi.d.ts CHANGED
@@ -94,6 +94,10 @@ export declare class BaseAuthApi {
94
94
  * Completes user login by sending the signed login challenge.
95
95
  */
96
96
  static createUserLogin(request: CreateUserLoginRequest, options: DfnsBaseApiOptions): Promise<UserLoginResponse>;
97
+ /**
98
+ * Completes user logout by sending the user auth token.
99
+ */
100
+ static userLogout(options: DfnsBaseApiOptions): Promise<void>;
97
101
  /**
98
102
  * Initiates Registration by creating a challenge that will need to be signed by a new set of Credentials.
99
103
  */
package/baseAuthApi.js CHANGED
@@ -47,6 +47,19 @@ class BaseAuthApi {
47
47
  });
48
48
  return response.json();
49
49
  }
50
+ /**
51
+ * Completes user logout by sending the user auth token.
52
+ */
53
+ static async userLogout(options) {
54
+ if (!options.authToken) {
55
+ throw new Error('authToken is required');
56
+ }
57
+ const response = await (0, fetch_1.simpleFetch)('/auth/logout', {
58
+ method: 'PUT',
59
+ apiOptions: options,
60
+ });
61
+ return response.json();
62
+ }
50
63
  /**
51
64
  * Initiates Registration by creating a challenge that will need to be signed by a new set of Credentials.
52
65
  */
@@ -25,4 +25,6 @@ export declare class DelegatedWalletsClient {
25
25
  listSignatures(request: T.ListSignaturesRequest): Promise<T.ListSignaturesResponse>;
26
26
  importWalletInit(request: T.ImportWalletRequest): Promise<UserActionChallengeResponse>;
27
27
  importWalletComplete(request: T.ImportWalletRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.ImportWalletResponse>;
28
+ exportWalletInit(request: T.ExportWalletRequest): Promise<UserActionChallengeResponse>;
29
+ exportWalletComplete(request: T.ExportWalletRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.ExportWalletResponse>;
28
30
  }
@@ -272,5 +272,32 @@ class DelegatedWalletsClient {
272
272
  });
273
273
  return response.json();
274
274
  }
275
+ async exportWalletInit(request) {
276
+ const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/export', {
277
+ path: { walletId: request.walletId },
278
+ query: {},
279
+ });
280
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
281
+ userActionHttpMethod: 'POST',
282
+ userActionHttpPath: path,
283
+ userActionPayload: JSON.stringify(request.body),
284
+ userActionServerKind: 'Api',
285
+ }, this.apiOptions);
286
+ return challenge;
287
+ }
288
+ async exportWalletComplete(request, signedChallenge) {
289
+ const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/export', {
290
+ path: { walletId: request.walletId },
291
+ query: {},
292
+ });
293
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
294
+ const response = await (0, fetch_1.simpleFetch)(path, {
295
+ method: 'POST',
296
+ body: request.body,
297
+ headers: { 'x-dfns-useraction': userAction },
298
+ apiOptions: this.apiOptions,
299
+ });
300
+ return response.json();
301
+ }
275
302
  }
276
303
  exports.DelegatedWalletsClient = DelegatedWalletsClient;
@@ -19,4 +19,5 @@ export declare class WalletsClient {
19
19
  getSignature(request: T.GetSignatureRequest): Promise<T.GetSignatureResponse>;
20
20
  listSignatures(request: T.ListSignaturesRequest): Promise<T.ListSignaturesResponse>;
21
21
  importWallet(request: T.ImportWalletRequest): Promise<T.ImportWalletResponse>;
22
+ exportWallet(request: T.ExportWalletRequest): Promise<T.ExportWalletResponse>;
22
23
  }
@@ -196,5 +196,17 @@ class WalletsClient {
196
196
  });
197
197
  return response.json();
198
198
  }
199
+ async exportWallet(request) {
200
+ const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/export', {
201
+ path: { walletId: request.walletId },
202
+ query: {},
203
+ });
204
+ const response = await (0, fetch_1.userActionFetch)(path, {
205
+ method: 'POST',
206
+ body: request.body,
207
+ apiOptions: this.apiOptions,
208
+ });
209
+ return response.json();
210
+ }
199
211
  }
200
212
  exports.WalletsClient = WalletsClient;
@@ -89,3 +89,8 @@ export type ImportWalletRequest = {
89
89
  body: Wallets.ImportWalletBody;
90
90
  };
91
91
  export type ImportWalletResponse = Wallets.Wallet;
92
+ export type ExportWalletRequest = {
93
+ walletId: Foundations.EntityId;
94
+ body: Wallets.ExportWalletBody;
95
+ };
96
+ export type ExportWalletResponse = Wallets.ExportedSigningKey;
@@ -5,3 +5,23 @@ export type ListSignersError = {
5
5
  error: ForbiddenError | UnauthorizedError | BadRequestError;
6
6
  };
7
7
  export type ListSignersResponse = ListSignersSuccess | ListSignersError;
8
+ export type GetLatestClusterHealthSuccess = String;
9
+ export type GetLatestClusterHealthError = {
10
+ error: ForbiddenError;
11
+ };
12
+ export type GetLatestClusterHealthResponse = GetLatestClusterHealthSuccess | GetLatestClusterHealthError;
13
+ export type ListClustersHealthSuccess = String;
14
+ export type ListClustersHealthError = {
15
+ error: ForbiddenError;
16
+ };
17
+ export type ListClustersHealthResponse = ListClustersHealthSuccess | ListClustersHealthError;
18
+ export type SetKeyMaxPresigsSuccess = String;
19
+ export type SetKeyMaxPresigsError = {
20
+ error: ForbiddenError;
21
+ };
22
+ export type SetKeyMaxPresigsResponse = SetKeyMaxPresigsSuccess | SetKeyMaxPresigsError;
23
+ export type TriggerClusterProvisioningSuccess = String;
24
+ export type TriggerClusterProvisioningError = {
25
+ error: ForbiddenError;
26
+ };
27
+ export type TriggerClusterProvisioningResponse = TriggerClusterProvisioningSuccess | TriggerClusterProvisioningError;
@@ -1,5 +1,5 @@
1
1
  import { BadRequestError, EntityNotFoundError, ForbiddenError, UnauthorizedError } from '../Foundations';
2
- import { PaginatedEventHistory, PaginatedSignatureList, PaginatedTransactionList, PaginatedTransferList, PaginatedWalletList, SignatureRequest, TransactionRequest, TransferRequest, Wallet, WalletAssets, WalletNfts } from './types';
2
+ import { ExportedSigningKey, PaginatedEventHistory, PaginatedSignatureList, PaginatedTransactionList, PaginatedTransferList, PaginatedWalletList, SignatureRequest, TransactionRequest, TransferRequest, Wallet, WalletAssets, WalletNfts } from './types';
3
3
  export type CreateWalletSuccess = Wallet;
4
4
  export type CreateWalletError = {
5
5
  error: BadRequestError | ForbiddenError | UnauthorizedError | ForbiddenError | BadRequestError | EntityNotFoundError;
@@ -80,3 +80,8 @@ export type ImportWalletError = {
80
80
  error: BadRequestError | ForbiddenError | UnauthorizedError | ForbiddenError | BadRequestError | EntityNotFoundError;
81
81
  };
82
82
  export type ImportWalletResponse = ImportWalletSuccess | ImportWalletError;
83
+ export type ExportWalletSuccess = ExportedSigningKey;
84
+ export type ExportWalletError = {
85
+ error: BadRequestError | ForbiddenError | UnauthorizedError | ForbiddenError | BadRequestError | EntityNotFoundError;
86
+ };
87
+ export type ExportWalletResponse = ExportWalletSuccess | ExportWalletError;
@@ -16,6 +16,10 @@ export type TransferErc721Asset = {
16
16
  to: BlockchainAddress;
17
17
  tokenId: string;
18
18
  };
19
+ export type BroadcastTransaction = {
20
+ kind: TransactionKind.Transaction;
21
+ transaction: string;
22
+ };
19
23
  export type BroadcastEvmTransaction = {
20
24
  kind: TransactionKind.Evm;
21
25
  to?: BlockchainAddress;
@@ -42,6 +46,10 @@ export type BroadcastEvmLegacyTransaction = {
42
46
  gasLimit?: Amount;
43
47
  gasPrice?: Amount;
44
48
  };
49
+ export type BroadcastPsbt = {
50
+ kind: TransactionKind.Psbt;
51
+ psbt: string;
52
+ };
45
53
  export type SignHash = {
46
54
  kind: SignatureKind.Hash;
47
55
  hash: string;
@@ -50,6 +58,10 @@ export type SignMessage = {
50
58
  kind: SignatureKind.Message;
51
59
  message: string;
52
60
  };
61
+ export type SignTransaction = {
62
+ kind: SignatureKind.Transaction;
63
+ transaction: string;
64
+ };
53
65
  export type Eip712Domain = {
54
66
  name?: string;
55
67
  version?: string;
@@ -63,10 +75,30 @@ export type SignEip712TypedData = {
63
75
  domain: Eip712Domain;
64
76
  message: Record<string, unknown>;
65
77
  };
78
+ export type SignPsbt = {
79
+ kind: SignatureKind.Psbt;
80
+ psbt: string;
81
+ };
66
82
  export type EncryptedKeyShare = {
83
+ /**
84
+ * Base64-encoded ID of the signer where the encrypted key share comes from.
85
+ */
67
86
  signerId: string;
87
+ /**
88
+ * Base64-encoded key share.
89
+ */
68
90
  encryptedKeyShare: string;
69
91
  };
92
+ export type SupportedExportScheme = {
93
+ /**
94
+ * Base64-encoded ID of the signer where the encrypted key share comes from.
95
+ */
96
+ curve: KeyCurve;
97
+ /**
98
+ * Base64-encoded key share.
99
+ */
100
+ protocol: KeyProtocol;
101
+ };
70
102
  export type Wallet = {
71
103
  id: EntityId;
72
104
  network: BlockchainNetwork;
@@ -77,10 +109,18 @@ export type Wallet = {
77
109
  externalId?: string;
78
110
  tags: Tag[];
79
111
  dateCreated: IsoDatetime;
112
+ /**
113
+ * If present, represents the moment when the wallet was exported for the first time.
114
+ */
115
+ dateExported?: IsoDatetime;
80
116
  /**
81
117
  * Whether the wallet was imported, or if it was generated on Dfns side.
82
118
  */
83
119
  imported?: boolean;
120
+ /**
121
+ * Whether the wallet was ever exported.
122
+ */
123
+ exported?: boolean;
84
124
  };
85
125
  export type SigningKey = {
86
126
  scheme: KeyScheme;
@@ -187,6 +227,7 @@ export type TransferRequest = {
187
227
  dateBroadcasted?: IsoDatetime;
188
228
  dateConfirmed?: IsoDatetime;
189
229
  reason?: string;
230
+ metadata: TransferRequestMetadata;
190
231
  };
191
232
  export type PaginatedTransferList = {
192
233
  walletId: EntityId;
@@ -226,6 +267,8 @@ export type SignatureRequest = {
226
267
  requester: RequesterIdentity;
227
268
  requestBody: GenerateSignatureBody;
228
269
  signature?: Signature;
270
+ signatures?: Signature[];
271
+ signedData?: string;
229
272
  status: SignatureStatus;
230
273
  txHash?: string;
231
274
  fee?: Amount;
@@ -245,6 +288,27 @@ export type RequesterIdentity = {
245
288
  tokenId?: EntityId;
246
289
  appId?: EntityId;
247
290
  };
291
+ export type TransferRequestMetadata = {
292
+ asset: AssetMetadata;
293
+ };
294
+ export type AssetMetadata = {
295
+ symbol?: string;
296
+ decimals?: number;
297
+ verified?: boolean;
298
+ };
299
+ export type ExportedSigningKey = {
300
+ publicKey: string;
301
+ /**
302
+ * The TSS threshold parameter of this wallet private signing key shares.
303
+ */
304
+ minSigners: IntegerPositiveStrict;
305
+ curve: KeyCurve;
306
+ protocol: KeyProtocol;
307
+ /**
308
+ * Key shares of the exported wallet. These key shares are encrypted with the provided encryption key. The wallet private key must then be re-constructed from them.
309
+ */
310
+ encryptedKeyShares: EncryptedKeyShare[];
311
+ };
248
312
  export type CreateWalletBody = {
249
313
  network: BlockchainNetwork;
250
314
  externalId?: string;
@@ -261,9 +325,19 @@ export type ImportWalletBody = {
261
325
  curve: KeyCurve;
262
326
  encryptedKeyShares: EncryptedKeyShare[];
263
327
  };
328
+ export type ExportWalletBody = {
329
+ /**
330
+ * Encryption public key that will be used by signers to encrypt the exported wallet key shares. The purpose of encrypting key shares is to have them extra-safe and not usable in any place in the system until they are safely returned back to the client issuing the export command.
331
+ */
332
+ encryptionKey: string;
333
+ /**
334
+ * The schemes supported by the client issuing the export request, for private key reconstruction.
335
+ */
336
+ supportedSchemes: SupportedExportScheme[];
337
+ };
264
338
  export type TransferAssetBody = TransferNativeAsset | TransferErc20Asset | TransferErc721Asset;
265
- export type BroadcastTransactionBody = BroadcastEvmTransaction | BroadcastEip1559Transaction | BroadcastEvmLegacyTransaction;
266
- export type GenerateSignatureBody = SignHash | SignMessage | SignEip712TypedData;
339
+ export type BroadcastTransactionBody = BroadcastTransaction | BroadcastEvmTransaction | BroadcastEip1559Transaction | BroadcastEvmLegacyTransaction | BroadcastPsbt;
340
+ export type GenerateSignatureBody = SignHash | SignMessage | SignTransaction | SignEip712TypedData | SignPsbt;
267
341
  export type BlockchainEvent = NativeTransferEvent | Erc20TransferEvent | Erc721TransferEvent;
268
342
  export declare enum TransferKind {
269
343
  Native = "Native",
@@ -271,19 +345,24 @@ export declare enum TransferKind {
271
345
  Erc721 = "Erc721"
272
346
  }
273
347
  export declare enum TransactionKind {
348
+ Transaction = "Transaction",
274
349
  Evm = "Evm",
275
350
  Eip1559 = "Eip1559",
276
- EvmLegacy = "EvmLegacy"
351
+ EvmLegacy = "EvmLegacy",
352
+ Psbt = "Psbt"
277
353
  }
278
354
  export declare enum SignatureKind {
279
355
  Hash = "Hash",
280
356
  Message = "Message",
281
- Eip712 = "Eip712"
357
+ Transaction = "Transaction",
358
+ Eip712 = "Eip712",
359
+ Psbt = "Psbt"
282
360
  }
283
361
  export declare enum WalletStatus {
284
362
  Active = "Active",
285
363
  Creating = "Creating",
286
- Failed = "Failed"
364
+ Failed = "Failed",
365
+ Archived = "Archived"
287
366
  }
288
367
  export declare enum KeyScheme {
289
368
  ECDSA = "ECDSA",
@@ -336,7 +415,7 @@ export declare enum BlockchainNetwork {
336
415
  AvalancheC = "AvalancheC",
337
416
  AvalancheCFuji = "AvalancheCFuji",
338
417
  Bitcoin = "Bitcoin",
339
- BitcoinTestnet = "BitcoinTestnet",
418
+ BitcoinTestnet3 = "BitcoinTestnet3",
340
419
  Bsc = "Bsc",
341
420
  BscTestnet = "BscTestnet",
342
421
  Ethereum = "Ethereum",
@@ -14,12 +14,16 @@ var TransferKind;
14
14
  // FIXME: Missing documentation for TransactionKind
15
15
  var TransactionKind;
16
16
  (function (TransactionKind) {
17
+ // FIXME: Missing documentation for Transaction
18
+ TransactionKind["Transaction"] = "Transaction";
17
19
  // FIXME: Missing documentation for Evm
18
20
  TransactionKind["Evm"] = "Evm";
19
21
  // FIXME: Missing documentation for Eip1559
20
22
  TransactionKind["Eip1559"] = "Eip1559";
21
23
  // FIXME: Missing documentation for EvmLegacy
22
24
  TransactionKind["EvmLegacy"] = "EvmLegacy";
25
+ // FIXME: Missing documentation for Psbt
26
+ TransactionKind["Psbt"] = "Psbt";
23
27
  })(TransactionKind = exports.TransactionKind || (exports.TransactionKind = {}));
24
28
  // FIXME: Missing documentation for SignatureKind
25
29
  var SignatureKind;
@@ -28,8 +32,12 @@ var SignatureKind;
28
32
  SignatureKind["Hash"] = "Hash";
29
33
  // FIXME: Missing documentation for Message
30
34
  SignatureKind["Message"] = "Message";
35
+ // FIXME: Missing documentation for Transaction
36
+ SignatureKind["Transaction"] = "Transaction";
31
37
  // FIXME: Missing documentation for Eip712
32
38
  SignatureKind["Eip712"] = "Eip712";
39
+ // FIXME: Missing documentation for Psbt
40
+ SignatureKind["Psbt"] = "Psbt";
33
41
  })(SignatureKind = exports.SignatureKind || (exports.SignatureKind = {}));
34
42
  // FIXME: Missing documentation for WalletStatus
35
43
  var WalletStatus;
@@ -40,6 +48,8 @@ var WalletStatus;
40
48
  WalletStatus["Creating"] = "Creating";
41
49
  // FIXME: Missing documentation for Failed
42
50
  WalletStatus["Failed"] = "Failed";
51
+ // FIXME: Missing documentation for Archived
52
+ WalletStatus["Archived"] = "Archived";
43
53
  })(WalletStatus = exports.WalletStatus || (exports.WalletStatus = {}));
44
54
  // FIXME: Missing documentation for KeyScheme
45
55
  var KeyScheme;
@@ -144,8 +154,8 @@ var BlockchainNetwork;
144
154
  BlockchainNetwork["AvalancheCFuji"] = "AvalancheCFuji";
145
155
  // FIXME: Missing documentation for Bitcoin
146
156
  BlockchainNetwork["Bitcoin"] = "Bitcoin";
147
- // FIXME: Missing documentation for BitcoinTestnet
148
- BlockchainNetwork["BitcoinTestnet"] = "BitcoinTestnet";
157
+ // FIXME: Missing documentation for BitcoinTestnet3
158
+ BlockchainNetwork["BitcoinTestnet3"] = "BitcoinTestnet3";
149
159
  // FIXME: Missing documentation for Bsc
150
160
  BlockchainNetwork["Bsc"] = "Bsc";
151
161
  // FIXME: Missing documentation for BscTestnet
package/package.json CHANGED
@@ -1,11 +1,6 @@
1
1
  {
2
2
  "name": "@dfns/sdk",
3
- "version": "0.1.0-beta.7",
4
- "dependencies": {
5
- "buffer": "6.0.3",
6
- "cross-fetch": "3.1.6",
7
- "uuid": "9.0.0"
8
- },
3
+ "version": "0.1.0",
9
4
  "main": "./index.js",
10
- "types": "./index.d.ts"
5
+ "type": "commonjs"
11
6
  }