wallaby-cash 3.2.1 → 3.3.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/dist/generated/api.d.ts +689 -143
- package/dist/index.cjs.js +122 -21
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +122 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +122 -21
- package/dist/index.js.map +1 -1
- package/dist/lib/transactions/index.d.ts +19 -13
- package/dist/package.json +7 -5
- package/dist/routes/transactions.d.ts +15 -0
- package/package.json +7 -5
package/dist/index.esm.js
CHANGED
|
@@ -589,7 +589,7 @@ const MASTER_ENCRYPTION_KEY = '9fa9d3f3c77c20d3a50a08e5299644be29f6e6206ef3479fe
|
|
|
589
589
|
{ type: 'public-key', alg: PublicKeyCredentialAlgorithm.ES256 },
|
|
590
590
|
];
|
|
591
591
|
const isWeb = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
592
|
-
const currentPackageVersion = "3.
|
|
592
|
+
const currentPackageVersion = "3.3.0" ;
|
|
593
593
|
|
|
594
594
|
/**
|
|
595
595
|
* Storage keys adapter for Storage interface across different platforms.
|
|
@@ -4427,14 +4427,19 @@ class Cipher {
|
|
|
4427
4427
|
return AES.encrypt(typeof data === 'string' ? data : JSON.stringify(data), this.getMasterKey().key).toString();
|
|
4428
4428
|
}
|
|
4429
4429
|
decryptWithMasterKey({ cipherText }) {
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4430
|
+
try {
|
|
4431
|
+
const decrypted = AES.decrypt(cipherText, this.getMasterKey().key).toString(enc.Utf8);
|
|
4432
|
+
if (decrypted) {
|
|
4433
|
+
return isJsonString(decrypted) ? safeJsonParse(decrypted) : decrypted;
|
|
4434
|
+
}
|
|
4433
4435
|
}
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
+
catch (error) {
|
|
4437
|
+
// crypto-js throws "Malformed UTF-8 data" when the ciphertext can't be decrypted
|
|
4438
|
+
logger.error('Decryption failed with master key', error);
|
|
4436
4439
|
return undefined;
|
|
4437
4440
|
}
|
|
4441
|
+
logger.error('Decryption failed with master key');
|
|
4442
|
+
return undefined;
|
|
4438
4443
|
}
|
|
4439
4444
|
/**
|
|
4440
4445
|
* Validate that a public key is the correct length and format.
|
|
@@ -5653,6 +5658,16 @@ class Api {
|
|
|
5653
5658
|
* @secure
|
|
5654
5659
|
*/
|
|
5655
5660
|
signIn: (data, params = {}) => this.http.request(Object.assign({ path: `/api/v1/auth/sign-in`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params)),
|
|
5661
|
+
/**
|
|
5662
|
+
* No description
|
|
5663
|
+
*
|
|
5664
|
+
* @tags Auth
|
|
5665
|
+
* @name IssueJwtToken
|
|
5666
|
+
* @summary Issue a Wallaby JWT token for a user using only x-api-key and x-client-jwt headers. Requires mfaVerified and that the user belongs to the API key merchant.
|
|
5667
|
+
* @request POST:/api/v1/auth/issue-jwt-token
|
|
5668
|
+
* @secure
|
|
5669
|
+
*/
|
|
5670
|
+
issueJwtToken: (params = {}) => this.http.request(Object.assign({ path: `/api/v1/auth/issue-jwt-token`, method: "POST", secure: true, format: "json" }, params)),
|
|
5656
5671
|
/**
|
|
5657
5672
|
* No description
|
|
5658
5673
|
*
|
|
@@ -6151,6 +6166,20 @@ class Api {
|
|
|
6151
6166
|
if (params === void 0) { params = {}; }
|
|
6152
6167
|
return this.http.request(Object.assign({ path: `/api/v1/wallets/${walletId}/assets`, method: "GET", query: query, secure: true, format: "json" }, params));
|
|
6153
6168
|
},
|
|
6169
|
+
/**
|
|
6170
|
+
* No description
|
|
6171
|
+
*
|
|
6172
|
+
* @tags Wallets
|
|
6173
|
+
* @name GetWalletAddresses
|
|
6174
|
+
* @summary Get all assets that exist in a certain wallet, by specifying a wallet ID
|
|
6175
|
+
* @request GET:/api/v1/wallets/{walletId}/addresses
|
|
6176
|
+
* @secure
|
|
6177
|
+
*/
|
|
6178
|
+
getWalletAddresses: (_a, params) => {
|
|
6179
|
+
var { walletId } = _a, query = __rest(_a, ["walletId"]);
|
|
6180
|
+
if (params === void 0) { params = {}; }
|
|
6181
|
+
return this.http.request(Object.assign({ path: `/api/v1/wallets/${walletId}/addresses`, method: "GET", query: query, secure: true, format: "json" }, params));
|
|
6182
|
+
},
|
|
6154
6183
|
/**
|
|
6155
6184
|
* No description
|
|
6156
6185
|
*
|
|
@@ -6350,23 +6379,35 @@ class Api {
|
|
|
6350
6379
|
/**
|
|
6351
6380
|
* No description
|
|
6352
6381
|
*
|
|
6353
|
-
* @tags Transactions, Transactions
|
|
6382
|
+
* @tags Transactions, Transactions
|
|
6354
6383
|
* @name DetectTransferRestriction
|
|
6355
6384
|
* @summary Request to detect whether there is a transfer restriction on a particular transaction
|
|
6356
6385
|
* @request GET:/api/v1/transactions/detect-transfers-restrictions
|
|
6386
|
+
* @deprecated
|
|
6357
6387
|
* @secure
|
|
6358
6388
|
*/
|
|
6359
6389
|
detectTransferRestriction: (query, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/detect-transfers-restrictions`, method: "GET", query: query, secure: true, format: "json" }, params)),
|
|
6360
6390
|
/**
|
|
6361
6391
|
* No description
|
|
6362
6392
|
*
|
|
6363
|
-
* @tags Transactions, Transactions
|
|
6393
|
+
* @tags Transactions, Transactions
|
|
6364
6394
|
* @name FetchMessageForTransferRestriction
|
|
6365
6395
|
* @summary Request restriction message by providing a restriction code
|
|
6366
6396
|
* @request GET:/api/v1/transactions/transfer-restriction-message
|
|
6397
|
+
* @deprecated
|
|
6367
6398
|
* @secure
|
|
6368
6399
|
*/
|
|
6369
6400
|
fetchMessageForTransferRestriction: (query, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/transfer-restriction-message`, method: "GET", query: query, secure: true, format: "json" }, params)),
|
|
6401
|
+
/**
|
|
6402
|
+
* No description
|
|
6403
|
+
*
|
|
6404
|
+
* @tags Transactions, Transactions
|
|
6405
|
+
* @name GetRestriction
|
|
6406
|
+
* @summary Request to detect whether there is a transfer restriction on a particular transaction
|
|
6407
|
+
* @request GET:/api/v1/transactions/restriction
|
|
6408
|
+
* @secure
|
|
6409
|
+
*/
|
|
6410
|
+
getRestriction: (query, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/restriction`, method: "GET", query: query, secure: true, format: "json" }, params)),
|
|
6370
6411
|
/**
|
|
6371
6412
|
* No description
|
|
6372
6413
|
*
|
|
@@ -7340,7 +7381,22 @@ const TransactionsRoutes = {
|
|
|
7340
7381
|
requiresAccessToken: true,
|
|
7341
7382
|
},
|
|
7342
7383
|
getTransactions: {
|
|
7343
|
-
fullPath: '/
|
|
7384
|
+
fullPath: '/transactions',
|
|
7385
|
+
method: RequestMethod.Get,
|
|
7386
|
+
requiresAccessToken: true,
|
|
7387
|
+
},
|
|
7388
|
+
detectTransferRestrictions: {
|
|
7389
|
+
fullPath: '/transactions/detect-transfers-restrictions',
|
|
7390
|
+
method: RequestMethod.Get,
|
|
7391
|
+
requiresAccessToken: true,
|
|
7392
|
+
},
|
|
7393
|
+
transferRestrictionMessage: {
|
|
7394
|
+
fullPath: '/transactions/transfer-restriction-message',
|
|
7395
|
+
method: RequestMethod.Get,
|
|
7396
|
+
requiresAccessToken: true,
|
|
7397
|
+
},
|
|
7398
|
+
restriction: {
|
|
7399
|
+
fullPath: '/transactions/restriction',
|
|
7344
7400
|
method: RequestMethod.Get,
|
|
7345
7401
|
requiresAccessToken: true,
|
|
7346
7402
|
},
|
|
@@ -9366,6 +9422,17 @@ class WalletService extends Base {
|
|
|
9366
9422
|
decryptionKey: oldCredentialsKeyPair.privateKey,
|
|
9367
9423
|
encryptionKey: newCredentialsKeyPair.publicKey,
|
|
9368
9424
|
});
|
|
9425
|
+
// Guard against persisting an empty/invalid re-wrap, which would lock the user out of
|
|
9426
|
+
// their device private key (the one mandatory item) under the new password. The type says
|
|
9427
|
+
// this is always defined, but we defend against a runtime contract violation regardless.
|
|
9428
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
9429
|
+
if (!reWrappedDevicePrivateKey) {
|
|
9430
|
+
throw new WallabyError({
|
|
9431
|
+
message: 'Failed to re-wrap device private key during password change.',
|
|
9432
|
+
statusCode: 500,
|
|
9433
|
+
errorCode: ErrorResponseCodes.sdk_unknown_error,
|
|
9434
|
+
});
|
|
9435
|
+
}
|
|
9369
9436
|
await this.localStorageService.save(LocalStorageItems.EncryptedDevicePrivateKey, reWrappedDevicePrivateKey);
|
|
9370
9437
|
if (encryptedSeedPhraseString) {
|
|
9371
9438
|
const parsedSeed = safeJsonParse(encryptedSeedPhraseString);
|
|
@@ -11013,6 +11080,7 @@ class Swap extends Base {
|
|
|
11013
11080
|
});
|
|
11014
11081
|
}
|
|
11015
11082
|
else {
|
|
11083
|
+
// Unreachable in practice: prepareSwapAuth throws sdk_seed_phrase_not_found before we get here; kept as a defensive guard.
|
|
11016
11084
|
throw new WallabyError({
|
|
11017
11085
|
message: 'No valid seed option found on this device.',
|
|
11018
11086
|
statusCode: 400,
|
|
@@ -11434,27 +11502,54 @@ class Transactions extends Base {
|
|
|
11434
11502
|
/**
|
|
11435
11503
|
*
|
|
11436
11504
|
* @public
|
|
11437
|
-
* @param {
|
|
11438
|
-
* @
|
|
11439
|
-
* @param {TokenStandard} tokenStandard an optional param used when dealing with non native assets
|
|
11440
|
-
* @returns {Promise<{ address: string; transactions: Transaction[] }>}
|
|
11505
|
+
* @param {GetTransactionsParams} params - Query parameters for filtering and paginating transactions
|
|
11506
|
+
* @returns {GetTransactionsResponseDto} Paginated list of transactions matching the given criteria
|
|
11441
11507
|
*/
|
|
11442
|
-
async getTransactions(
|
|
11508
|
+
async getTransactions(params) {
|
|
11443
11509
|
try {
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
address,
|
|
11447
|
-
tokenSymbol: symbol,
|
|
11448
|
-
tokenType: tokenStandard,
|
|
11449
|
-
},
|
|
11510
|
+
return await this.request(TransactionsRoutes.getTransactions, {
|
|
11511
|
+
queryParams: params,
|
|
11450
11512
|
});
|
|
11451
|
-
return response;
|
|
11452
11513
|
}
|
|
11453
11514
|
catch (error) {
|
|
11454
11515
|
logger.error('SDK::Transactions::getTransactions::error', error);
|
|
11455
11516
|
throw error;
|
|
11456
11517
|
}
|
|
11457
11518
|
}
|
|
11519
|
+
/**
|
|
11520
|
+
*
|
|
11521
|
+
* @public
|
|
11522
|
+
* @param {GetRestrictionParams} params - Parameters to detect transfer restrictions (addresses, asset, value)
|
|
11523
|
+
* - {string} fromAddress
|
|
11524
|
+
* - {string} toAddress
|
|
11525
|
+
* - {string} amount
|
|
11526
|
+
* - [string] assetId
|
|
11527
|
+
* - [string] contractAddress
|
|
11528
|
+
* - [BlockchainName] blockchainName
|
|
11529
|
+
* @returns {Promise<DetectRestrictionResponseDto>}
|
|
11530
|
+
* Detection result; when transfer is blocked, also includes the human-readable restriction message and a boolean canTransfer
|
|
11531
|
+
*/
|
|
11532
|
+
async getRestriction(params) {
|
|
11533
|
+
try {
|
|
11534
|
+
const hasAssetId = Boolean(params.assetId);
|
|
11535
|
+
const hasContractAndChain = Boolean(params.contractAddress && params.blockchainName);
|
|
11536
|
+
if (!hasAssetId && !hasContractAndChain) {
|
|
11537
|
+
throw new WallabyError({
|
|
11538
|
+
message: 'Either assetId or both contractAddress and blockchainName must be provided.',
|
|
11539
|
+
statusCode: 400,
|
|
11540
|
+
errorCode: ErrorResponseCodes.sdk_missing_parameter,
|
|
11541
|
+
});
|
|
11542
|
+
}
|
|
11543
|
+
const restrictionData = await this.request(TransactionsRoutes.restriction, {
|
|
11544
|
+
queryParams: Object.assign(Object.assign(Object.assign({ fromAddress: params.fromAddress, toAddress: params.toAddress, amount: params.amount }, (params.assetId && { assetId: params.assetId })), (params.contractAddress && { contractAddress: params.contractAddress })), (params.blockchainName && { blockchainName: params.blockchainName })),
|
|
11545
|
+
});
|
|
11546
|
+
return restrictionData;
|
|
11547
|
+
}
|
|
11548
|
+
catch (error) {
|
|
11549
|
+
logger.error('SDK::Transactions::getRestriction::error', error);
|
|
11550
|
+
throw error;
|
|
11551
|
+
}
|
|
11552
|
+
}
|
|
11458
11553
|
/**
|
|
11459
11554
|
*
|
|
11460
11555
|
* @public
|
|
@@ -11789,6 +11884,12 @@ class Transactions extends Base {
|
|
|
11789
11884
|
});
|
|
11790
11885
|
}
|
|
11791
11886
|
}
|
|
11887
|
+
__decorate([
|
|
11888
|
+
WithLock('transaction-restriction-message'),
|
|
11889
|
+
__metadata("design:type", Function),
|
|
11890
|
+
__metadata("design:paramtypes", [Object]),
|
|
11891
|
+
__metadata("design:returntype", Promise)
|
|
11892
|
+
], Transactions.prototype, "getRestriction", null);
|
|
11792
11893
|
__decorate([
|
|
11793
11894
|
WithLock('transfer'),
|
|
11794
11895
|
__metadata("design:type", Function),
|