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.cjs.js
CHANGED
|
@@ -618,7 +618,7 @@ const MASTER_ENCRYPTION_KEY = '9fa9d3f3c77c20d3a50a08e5299644be29f6e6206ef3479fe
|
|
|
618
618
|
{ type: 'public-key', alg: exports.PublicKeyCredentialAlgorithm.ES256 },
|
|
619
619
|
];
|
|
620
620
|
const isWeb = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
621
|
-
const currentPackageVersion = "3.
|
|
621
|
+
const currentPackageVersion = "3.3.0" ;
|
|
622
622
|
|
|
623
623
|
/**
|
|
624
624
|
* Storage keys adapter for Storage interface across different platforms.
|
|
@@ -4456,14 +4456,19 @@ class Cipher {
|
|
|
4456
4456
|
return cryptoJs.AES.encrypt(typeof data === 'string' ? data : JSON.stringify(data), this.getMasterKey().key).toString();
|
|
4457
4457
|
}
|
|
4458
4458
|
decryptWithMasterKey({ cipherText }) {
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4459
|
+
try {
|
|
4460
|
+
const decrypted = cryptoJs.AES.decrypt(cipherText, this.getMasterKey().key).toString(cryptoJs.enc.Utf8);
|
|
4461
|
+
if (decrypted) {
|
|
4462
|
+
return isJsonString(decrypted) ? safeJsonParse(decrypted) : decrypted;
|
|
4463
|
+
}
|
|
4462
4464
|
}
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
+
catch (error) {
|
|
4466
|
+
// crypto-js throws "Malformed UTF-8 data" when the ciphertext can't be decrypted
|
|
4467
|
+
logger.error('Decryption failed with master key', error);
|
|
4465
4468
|
return undefined;
|
|
4466
4469
|
}
|
|
4470
|
+
logger.error('Decryption failed with master key');
|
|
4471
|
+
return undefined;
|
|
4467
4472
|
}
|
|
4468
4473
|
/**
|
|
4469
4474
|
* Validate that a public key is the correct length and format.
|
|
@@ -5682,6 +5687,16 @@ class Api {
|
|
|
5682
5687
|
* @secure
|
|
5683
5688
|
*/
|
|
5684
5689
|
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)),
|
|
5690
|
+
/**
|
|
5691
|
+
* No description
|
|
5692
|
+
*
|
|
5693
|
+
* @tags Auth
|
|
5694
|
+
* @name IssueJwtToken
|
|
5695
|
+
* @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.
|
|
5696
|
+
* @request POST:/api/v1/auth/issue-jwt-token
|
|
5697
|
+
* @secure
|
|
5698
|
+
*/
|
|
5699
|
+
issueJwtToken: (params = {}) => this.http.request(Object.assign({ path: `/api/v1/auth/issue-jwt-token`, method: "POST", secure: true, format: "json" }, params)),
|
|
5685
5700
|
/**
|
|
5686
5701
|
* No description
|
|
5687
5702
|
*
|
|
@@ -6180,6 +6195,20 @@ class Api {
|
|
|
6180
6195
|
if (params === void 0) { params = {}; }
|
|
6181
6196
|
return this.http.request(Object.assign({ path: `/api/v1/wallets/${walletId}/assets`, method: "GET", query: query, secure: true, format: "json" }, params));
|
|
6182
6197
|
},
|
|
6198
|
+
/**
|
|
6199
|
+
* No description
|
|
6200
|
+
*
|
|
6201
|
+
* @tags Wallets
|
|
6202
|
+
* @name GetWalletAddresses
|
|
6203
|
+
* @summary Get all assets that exist in a certain wallet, by specifying a wallet ID
|
|
6204
|
+
* @request GET:/api/v1/wallets/{walletId}/addresses
|
|
6205
|
+
* @secure
|
|
6206
|
+
*/
|
|
6207
|
+
getWalletAddresses: (_a, params) => {
|
|
6208
|
+
var { walletId } = _a, query = __rest(_a, ["walletId"]);
|
|
6209
|
+
if (params === void 0) { params = {}; }
|
|
6210
|
+
return this.http.request(Object.assign({ path: `/api/v1/wallets/${walletId}/addresses`, method: "GET", query: query, secure: true, format: "json" }, params));
|
|
6211
|
+
},
|
|
6183
6212
|
/**
|
|
6184
6213
|
* No description
|
|
6185
6214
|
*
|
|
@@ -6379,23 +6408,35 @@ class Api {
|
|
|
6379
6408
|
/**
|
|
6380
6409
|
* No description
|
|
6381
6410
|
*
|
|
6382
|
-
* @tags Transactions, Transactions
|
|
6411
|
+
* @tags Transactions, Transactions
|
|
6383
6412
|
* @name DetectTransferRestriction
|
|
6384
6413
|
* @summary Request to detect whether there is a transfer restriction on a particular transaction
|
|
6385
6414
|
* @request GET:/api/v1/transactions/detect-transfers-restrictions
|
|
6415
|
+
* @deprecated
|
|
6386
6416
|
* @secure
|
|
6387
6417
|
*/
|
|
6388
6418
|
detectTransferRestriction: (query, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/detect-transfers-restrictions`, method: "GET", query: query, secure: true, format: "json" }, params)),
|
|
6389
6419
|
/**
|
|
6390
6420
|
* No description
|
|
6391
6421
|
*
|
|
6392
|
-
* @tags Transactions, Transactions
|
|
6422
|
+
* @tags Transactions, Transactions
|
|
6393
6423
|
* @name FetchMessageForTransferRestriction
|
|
6394
6424
|
* @summary Request restriction message by providing a restriction code
|
|
6395
6425
|
* @request GET:/api/v1/transactions/transfer-restriction-message
|
|
6426
|
+
* @deprecated
|
|
6396
6427
|
* @secure
|
|
6397
6428
|
*/
|
|
6398
6429
|
fetchMessageForTransferRestriction: (query, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/transfer-restriction-message`, method: "GET", query: query, secure: true, format: "json" }, params)),
|
|
6430
|
+
/**
|
|
6431
|
+
* No description
|
|
6432
|
+
*
|
|
6433
|
+
* @tags Transactions, Transactions
|
|
6434
|
+
* @name GetRestriction
|
|
6435
|
+
* @summary Request to detect whether there is a transfer restriction on a particular transaction
|
|
6436
|
+
* @request GET:/api/v1/transactions/restriction
|
|
6437
|
+
* @secure
|
|
6438
|
+
*/
|
|
6439
|
+
getRestriction: (query, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/restriction`, method: "GET", query: query, secure: true, format: "json" }, params)),
|
|
6399
6440
|
/**
|
|
6400
6441
|
* No description
|
|
6401
6442
|
*
|
|
@@ -7369,7 +7410,22 @@ const TransactionsRoutes = {
|
|
|
7369
7410
|
requiresAccessToken: true,
|
|
7370
7411
|
},
|
|
7371
7412
|
getTransactions: {
|
|
7372
|
-
fullPath: '/
|
|
7413
|
+
fullPath: '/transactions',
|
|
7414
|
+
method: exports.RequestMethod.Get,
|
|
7415
|
+
requiresAccessToken: true,
|
|
7416
|
+
},
|
|
7417
|
+
detectTransferRestrictions: {
|
|
7418
|
+
fullPath: '/transactions/detect-transfers-restrictions',
|
|
7419
|
+
method: exports.RequestMethod.Get,
|
|
7420
|
+
requiresAccessToken: true,
|
|
7421
|
+
},
|
|
7422
|
+
transferRestrictionMessage: {
|
|
7423
|
+
fullPath: '/transactions/transfer-restriction-message',
|
|
7424
|
+
method: exports.RequestMethod.Get,
|
|
7425
|
+
requiresAccessToken: true,
|
|
7426
|
+
},
|
|
7427
|
+
restriction: {
|
|
7428
|
+
fullPath: '/transactions/restriction',
|
|
7373
7429
|
method: exports.RequestMethod.Get,
|
|
7374
7430
|
requiresAccessToken: true,
|
|
7375
7431
|
},
|
|
@@ -9395,6 +9451,17 @@ class WalletService extends Base {
|
|
|
9395
9451
|
decryptionKey: oldCredentialsKeyPair.privateKey,
|
|
9396
9452
|
encryptionKey: newCredentialsKeyPair.publicKey,
|
|
9397
9453
|
});
|
|
9454
|
+
// Guard against persisting an empty/invalid re-wrap, which would lock the user out of
|
|
9455
|
+
// their device private key (the one mandatory item) under the new password. The type says
|
|
9456
|
+
// this is always defined, but we defend against a runtime contract violation regardless.
|
|
9457
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
9458
|
+
if (!reWrappedDevicePrivateKey) {
|
|
9459
|
+
throw new WallabyError({
|
|
9460
|
+
message: 'Failed to re-wrap device private key during password change.',
|
|
9461
|
+
statusCode: 500,
|
|
9462
|
+
errorCode: exports.ErrorResponseCodes.sdk_unknown_error,
|
|
9463
|
+
});
|
|
9464
|
+
}
|
|
9398
9465
|
await this.localStorageService.save(exports.LocalStorageItems.EncryptedDevicePrivateKey, reWrappedDevicePrivateKey);
|
|
9399
9466
|
if (encryptedSeedPhraseString) {
|
|
9400
9467
|
const parsedSeed = safeJsonParse(encryptedSeedPhraseString);
|
|
@@ -11042,6 +11109,7 @@ class Swap extends Base {
|
|
|
11042
11109
|
});
|
|
11043
11110
|
}
|
|
11044
11111
|
else {
|
|
11112
|
+
// Unreachable in practice: prepareSwapAuth throws sdk_seed_phrase_not_found before we get here; kept as a defensive guard.
|
|
11045
11113
|
throw new WallabyError({
|
|
11046
11114
|
message: 'No valid seed option found on this device.',
|
|
11047
11115
|
statusCode: 400,
|
|
@@ -11463,27 +11531,54 @@ class Transactions extends Base {
|
|
|
11463
11531
|
/**
|
|
11464
11532
|
*
|
|
11465
11533
|
* @public
|
|
11466
|
-
* @param {
|
|
11467
|
-
* @
|
|
11468
|
-
* @param {TokenStandard} tokenStandard an optional param used when dealing with non native assets
|
|
11469
|
-
* @returns {Promise<{ address: string; transactions: Transaction[] }>}
|
|
11534
|
+
* @param {GetTransactionsParams} params - Query parameters for filtering and paginating transactions
|
|
11535
|
+
* @returns {GetTransactionsResponseDto} Paginated list of transactions matching the given criteria
|
|
11470
11536
|
*/
|
|
11471
|
-
async getTransactions(
|
|
11537
|
+
async getTransactions(params) {
|
|
11472
11538
|
try {
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
address,
|
|
11476
|
-
tokenSymbol: symbol,
|
|
11477
|
-
tokenType: tokenStandard,
|
|
11478
|
-
},
|
|
11539
|
+
return await this.request(TransactionsRoutes.getTransactions, {
|
|
11540
|
+
queryParams: params,
|
|
11479
11541
|
});
|
|
11480
|
-
return response;
|
|
11481
11542
|
}
|
|
11482
11543
|
catch (error) {
|
|
11483
11544
|
logger.error('SDK::Transactions::getTransactions::error', error);
|
|
11484
11545
|
throw error;
|
|
11485
11546
|
}
|
|
11486
11547
|
}
|
|
11548
|
+
/**
|
|
11549
|
+
*
|
|
11550
|
+
* @public
|
|
11551
|
+
* @param {GetRestrictionParams} params - Parameters to detect transfer restrictions (addresses, asset, value)
|
|
11552
|
+
* - {string} fromAddress
|
|
11553
|
+
* - {string} toAddress
|
|
11554
|
+
* - {string} amount
|
|
11555
|
+
* - [string] assetId
|
|
11556
|
+
* - [string] contractAddress
|
|
11557
|
+
* - [BlockchainName] blockchainName
|
|
11558
|
+
* @returns {Promise<DetectRestrictionResponseDto>}
|
|
11559
|
+
* Detection result; when transfer is blocked, also includes the human-readable restriction message and a boolean canTransfer
|
|
11560
|
+
*/
|
|
11561
|
+
async getRestriction(params) {
|
|
11562
|
+
try {
|
|
11563
|
+
const hasAssetId = Boolean(params.assetId);
|
|
11564
|
+
const hasContractAndChain = Boolean(params.contractAddress && params.blockchainName);
|
|
11565
|
+
if (!hasAssetId && !hasContractAndChain) {
|
|
11566
|
+
throw new WallabyError({
|
|
11567
|
+
message: 'Either assetId or both contractAddress and blockchainName must be provided.',
|
|
11568
|
+
statusCode: 400,
|
|
11569
|
+
errorCode: exports.ErrorResponseCodes.sdk_missing_parameter,
|
|
11570
|
+
});
|
|
11571
|
+
}
|
|
11572
|
+
const restrictionData = await this.request(TransactionsRoutes.restriction, {
|
|
11573
|
+
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 })),
|
|
11574
|
+
});
|
|
11575
|
+
return restrictionData;
|
|
11576
|
+
}
|
|
11577
|
+
catch (error) {
|
|
11578
|
+
logger.error('SDK::Transactions::getRestriction::error', error);
|
|
11579
|
+
throw error;
|
|
11580
|
+
}
|
|
11581
|
+
}
|
|
11487
11582
|
/**
|
|
11488
11583
|
*
|
|
11489
11584
|
* @public
|
|
@@ -11818,6 +11913,12 @@ class Transactions extends Base {
|
|
|
11818
11913
|
});
|
|
11819
11914
|
}
|
|
11820
11915
|
}
|
|
11916
|
+
__decorate([
|
|
11917
|
+
WithLock('transaction-restriction-message'),
|
|
11918
|
+
__metadata("design:type", Function),
|
|
11919
|
+
__metadata("design:paramtypes", [Object]),
|
|
11920
|
+
__metadata("design:returntype", Promise)
|
|
11921
|
+
], Transactions.prototype, "getRestriction", null);
|
|
11821
11922
|
__decorate([
|
|
11822
11923
|
WithLock('transfer'),
|
|
11823
11924
|
__metadata("design:type", Function),
|