@stellar/typescript-wallet-sdk 4.0.0 → 4.0.1
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/CHANGELOG.MD +13 -0
- package/lib/bundle.js +59 -15
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +59 -15
- package/lib/bundle_browser.js.map +1 -1
- package/lib/walletSdk/Exceptions/index.d.ts +9 -0
- package/lib/walletSdk/Server/index.d.ts +17 -1
- package/lib/walletSdk/Types/auth.d.ts +5 -0
- package/package.json +1 -1
- package/src/walletSdk/Exceptions/index.ts +19 -0
- package/src/walletSdk/Server/index.ts +54 -11
- package/src/walletSdk/Types/auth.ts +5 -0
- package/test/server.test.ts +219 -1
package/lib/bundle_browser.js
CHANGED
|
@@ -2235,7 +2235,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
2235
2235
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2236
2236
|
};
|
|
2237
2237
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2238
|
-
exports.
|
|
2238
|
+
exports.Sep7LongMsgError = exports.Sep7InvalidUriError = exports.AuthHeaderClientDomainRequiredError = exports.AuthHeaderSigningKeypairRequiredError = exports.DomainSigningModifiedError = exports.DefaultSignerDomainAccountError = exports.SigningKeypairMissingSecretError = exports.InvalidJsonError = exports.UnknownAnchorTransactionError = exports.AllowHttpOnNonTestnetError = exports.ChallengeTxnClientAccountMismatchError = exports.ChallengeTxnInvalidSignatureError = exports.ChallengeTxnIncorrectSequenceError = exports.NetworkPassphraseMismatchError = exports.ChallengeValidationFailedError = exports.MissingSigningKeyError = exports.Sep38PriceOnlyOneAmountError = exports.NoAccountAndNoSponsorError = exports.DeviceKeyEqualsMasterKeyError = exports.NoAccountSignersError = exports.UnableToDeduceKeyError = exports.NoDeviceKeyForAccountError = exports.LostSignerKeyNotFound = exports.NotAllSignaturesFetchedError = exports.RecoveryIdentityNotFoundError = exports.RecoveryServerNotFoundError = exports.KYCServerNotFoundError = exports.CustomerNotFoundError = exports.Sep9InfoRequiredError = exports.WithdrawalTxMemoError = exports.PathPayOnlyOneAmountError = exports.WithdrawalTxMissingMemoError = exports.WithdrawalTxMissingDestinationError = exports.WithdrawalTxNotPendingUserTransferStartError = exports.OperationsLimitExceededError = exports.SignerRequiredError = exports.TransactionSubmitWithFeeIncreaseFailedError = exports.ExpiredTokenError = exports.InvalidTokenError = exports.MissingTokenError = exports.InsufficientStartingBalanceError = exports.TransactionSubmitFailedError = exports.AccountDoesNotExistError = exports.InvalidTransactionsResponseError = exports.InvalidTransactionResponseError = exports.MissingTransactionIdError = exports.ClientDomainWithMemoError = exports.InvalidMemoError = exports.AssetNotSupportedError = exports.ServerRequestFailedError = void 0;
|
|
2239
|
+
exports.Sep7UriTypeNotSupportedError = void 0;
|
|
2239
2240
|
var axios_1 = __importDefault(__webpack_require__(/*! axios */ "../../node_modules/axios/dist/browser/axios.cjs"));
|
|
2240
2241
|
var Utils_1 = __webpack_require__(/*! ../Utils */ "./src/walletSdk/Utils/index.ts");
|
|
2241
2242
|
var ServerRequestFailedError = /** @class */ (function (_super) {
|
|
@@ -2629,6 +2630,12 @@ var ChallengeTxnIncorrectSequenceError = /** @class */ (function (_super) {
|
|
|
2629
2630
|
return ChallengeTxnIncorrectSequenceError;
|
|
2630
2631
|
}(Error));
|
|
2631
2632
|
exports.ChallengeTxnIncorrectSequenceError = ChallengeTxnIncorrectSequenceError;
|
|
2633
|
+
/**
|
|
2634
|
+
* @deprecated No longer thrown. `Server.signChallengeTransaction` now validates
|
|
2635
|
+
* challenges with `WebAuth.readChallengeTx` and reports every failure, including
|
|
2636
|
+
* an invalid server signature, as `ChallengeValidationFailedError`. This class
|
|
2637
|
+
* will be removed in the next major release.
|
|
2638
|
+
*/
|
|
2632
2639
|
var ChallengeTxnInvalidSignatureError = /** @class */ (function (_super) {
|
|
2633
2640
|
__extends(ChallengeTxnInvalidSignatureError, _super);
|
|
2634
2641
|
function ChallengeTxnInvalidSignatureError() {
|
|
@@ -2639,6 +2646,17 @@ var ChallengeTxnInvalidSignatureError = /** @class */ (function (_super) {
|
|
|
2639
2646
|
return ChallengeTxnInvalidSignatureError;
|
|
2640
2647
|
}(Error));
|
|
2641
2648
|
exports.ChallengeTxnInvalidSignatureError = ChallengeTxnInvalidSignatureError;
|
|
2649
|
+
var ChallengeTxnClientAccountMismatchError = /** @class */ (function (_super) {
|
|
2650
|
+
__extends(ChallengeTxnClientAccountMismatchError, _super);
|
|
2651
|
+
function ChallengeTxnClientAccountMismatchError(expected, received) {
|
|
2652
|
+
var _this = _super.call(this, "Challenge transaction client account mismatch: expected \"".concat(expected, "\" ") +
|
|
2653
|
+
"but challenge was issued for \"".concat(received, "\"")) || this;
|
|
2654
|
+
Object.setPrototypeOf(_this, ChallengeTxnClientAccountMismatchError.prototype);
|
|
2655
|
+
return _this;
|
|
2656
|
+
}
|
|
2657
|
+
return ChallengeTxnClientAccountMismatchError;
|
|
2658
|
+
}(Error));
|
|
2659
|
+
exports.ChallengeTxnClientAccountMismatchError = ChallengeTxnClientAccountMismatchError;
|
|
2642
2660
|
var AllowHttpOnNonTestnetError = /** @class */ (function (_super) {
|
|
2643
2661
|
__extends(AllowHttpOnNonTestnetError, _super);
|
|
2644
2662
|
function AllowHttpOnNonTestnetError() {
|
|
@@ -4456,33 +4474,59 @@ var Utils_1 = __webpack_require__(/*! ../Utils */ "./src/walletSdk/Utils/index.t
|
|
|
4456
4474
|
var Exceptions_1 = __webpack_require__(/*! ../Exceptions */ "./src/walletSdk/Exceptions/index.ts");
|
|
4457
4475
|
/**
|
|
4458
4476
|
* Helper method for signing a SEP-10 challenge transaction if valid.
|
|
4477
|
+
*
|
|
4478
|
+
* The challenge is validated with `WebAuth.readChallengeTx` from
|
|
4479
|
+
* `@stellar/stellar-sdk` — the same validator used by `Sep10.sign()` — which
|
|
4480
|
+
* checks the full SEP-10 structure and binds the challenge to the expected
|
|
4481
|
+
* anchor: the transaction source must be the anchor's `SIGNING_KEY`, the
|
|
4482
|
+
* `<home domain> auth` operation must match the expected home domain, and any
|
|
4483
|
+
* `web_auth_domain` operation must match the host of the anchor's
|
|
4484
|
+
* `WEB_AUTH_ENDPOINT` (falling back to `anchorDomain` when the TOML omits it).
|
|
4485
|
+
* The client account the challenge was issued for is then checked against
|
|
4486
|
+
* `accountKp`, so this helper only signs challenges meant for it. Muxed client
|
|
4487
|
+
* accounts are supported: the comparison is made on the underlying `G...`
|
|
4488
|
+
* address, since that is the key that signs. The muxed id itself is not pinned
|
|
4489
|
+
* — a caller that needs to bind a specific subaccount should check the
|
|
4490
|
+
* challenge's client account itself.
|
|
4491
|
+
*
|
|
4459
4492
|
* @param {SignChallengeTxnParams} params - The Authentication params.
|
|
4460
4493
|
* @param {AccountKeypair} params.accountKp - Keypair for the Stellar account signing the transaction.
|
|
4461
4494
|
* @param {string} [params.challengeTx] - The challenge transaction given by an anchor for authentication.
|
|
4462
4495
|
* @param {string} [params.networkPassphrase] - The network passphrase for the network authenticating on.
|
|
4463
4496
|
* @param {string} [params.anchorDomain] - Domain hosting stellar.toml file containing `SIGNING_KEY`.
|
|
4497
|
+
* @param {string|string[]} [params.homeDomain] - Expected home domain(s) of the challenge. Defaults to `anchorDomain`.
|
|
4464
4498
|
* @returns {Promise<SignChallengeTxnResponse>} The signed transaction.
|
|
4465
4499
|
*/
|
|
4466
4500
|
var signChallengeTransaction = function (_a) {
|
|
4467
|
-
var accountKp = _a.accountKp, challengeTx = _a.challengeTx, networkPassphrase = _a.networkPassphrase, anchorDomain = _a.anchorDomain;
|
|
4501
|
+
var accountKp = _a.accountKp, challengeTx = _a.challengeTx, networkPassphrase = _a.networkPassphrase, anchorDomain = _a.anchorDomain, homeDomain = _a.homeDomain;
|
|
4468
4502
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
4469
|
-
var
|
|
4470
|
-
|
|
4471
|
-
|
|
4503
|
+
var parsedTx, tomlResp, _b, signingKey, webAuthEndpoint, tx, clientAccountID, webAuthDomain;
|
|
4504
|
+
var _c;
|
|
4505
|
+
return __generator(this, function (_d) {
|
|
4506
|
+
switch (_d.label) {
|
|
4472
4507
|
case 0:
|
|
4473
|
-
|
|
4474
|
-
if (parseInt(
|
|
4508
|
+
parsedTx = stellar_sdk_1.TransactionBuilder.fromXDR(challengeTx, networkPassphrase);
|
|
4509
|
+
if (parseInt(parsedTx.sequence) !== 0) {
|
|
4475
4510
|
throw new Exceptions_1.ChallengeTxnIncorrectSequenceError();
|
|
4476
4511
|
}
|
|
4477
4512
|
return [4 /*yield*/, stellar_sdk_1.StellarToml.Resolver.resolve(anchorDomain)];
|
|
4478
4513
|
case 1:
|
|
4479
|
-
tomlResp =
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4514
|
+
tomlResp = _d.sent();
|
|
4515
|
+
_b = (0, Utils_1.parseToml)(tomlResp), signingKey = _b.signingKey, webAuthEndpoint = _b.webAuthEndpoint;
|
|
4516
|
+
try {
|
|
4517
|
+
webAuthDomain = webAuthEndpoint
|
|
4518
|
+
? new URL(webAuthEndpoint).hostname
|
|
4519
|
+
: anchorDomain;
|
|
4520
|
+
(_c = stellar_sdk_1.WebAuth.readChallengeTx(challengeTx, signingKey, networkPassphrase, homeDomain !== null && homeDomain !== void 0 ? homeDomain : anchorDomain, webAuthDomain), tx = _c.tx, clientAccountID = _c.clientAccountID);
|
|
4521
|
+
}
|
|
4522
|
+
catch (e) {
|
|
4523
|
+
throw new Exceptions_1.ChallengeValidationFailedError(e instanceof Error ? e : new Error(String(e)));
|
|
4524
|
+
}
|
|
4525
|
+
// readChallengeTx returns the operation source verbatim, which is an `M...`
|
|
4526
|
+
// address for a muxed client account. accountKp.publicKey is always the
|
|
4527
|
+
// underlying `G...` key, so compare base addresses.
|
|
4528
|
+
if ((0, stellar_sdk_1.extractBaseAddress)(clientAccountID) !== accountKp.publicKey) {
|
|
4529
|
+
throw new Exceptions_1.ChallengeTxnClientAccountMismatchError(accountKp.publicKey, clientAccountID);
|
|
4486
4530
|
}
|
|
4487
4531
|
accountKp.sign(tx);
|
|
4488
4532
|
return [2 /*return*/, {
|
|
@@ -89758,7 +89802,7 @@ function includes(array, value) {
|
|
|
89758
89802
|
/***/ ((module) => {
|
|
89759
89803
|
|
|
89760
89804
|
"use strict";
|
|
89761
|
-
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"4.0.
|
|
89805
|
+
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"4.0.1","engines":{"node":">=22"},"browser":"./lib/bundle_browser.js","main":"./lib/bundle.js","types":"./lib/index.d.ts","license":"Apache-2.0","private":false,"devDependencies":{"@babel/preset-env":"^7.20.2","@babel/preset-typescript":"^7.23.3","@stellar/prettier-config":"^1.0.1","@stellar/tsconfig":"^1.0.2","@types/jest":"^29.4.0","@types/lodash":"^4.14.194","@types/sinon":"^10.0.15","@typescript-eslint/eslint-plugin":"^6.7.5","@typescript-eslint/parser":"^6.7.5","babel-jest":"^29.4.1","crypto-browserify":"^3.12.0","dotenv":"^16.3.1","eslint":"^8.51.0","eslint-config-prettier":"^9.0.0","eslint-plugin-jsdoc":"^46.8.2","express":"^4.19.2","husky":"^8.0.0","jest":"^29.4.1","lint-staged":"^14.0.1","npm-run-all":"^4.1.5","playwright":"^1.43.1","prettier":"^2.0.5","pretty-quick":"^2.0.1","process":"^0.11.10","sinon":"^15.1.0","smol-toml":"^1.7.1","stream-browserify":"^3.0.0","ts-jest":"^29.0.5","ts-loader":"^9.4.2","ts-node":"^10.9.1","tslib":"^2.5.0","typescript":"^5.0.4","webpack":"^5.83.1","webpack-cli":"^5.1.1"},"dependencies":{"@stablelib/base64":"^2.0.0","@stablelib/utf8":"^2.0.0","@stellar/stellar-sdk":"16.2.0","axios":"^1.4.0","base64url":"^3.0.1","https-browserify":"^1.0.0","jws":"^4.0.0","lodash":"^4.17.21","query-string":"^7.1.3","stream-http":"^3.2.0","tweetnacl":"^1.0.3","url":"^0.11.0","util":"^0.12.5","utility-types":"^3.10.0","vm-browserify":"^1.1.2"},"scripts":{"test":"jest --watchAll","test:ci":"jest --ci","test:e2e:ci":"jest --config jest.e2e.config.js --ci","test:recovery:ci":"jest --config jest.integration.config.js recovery.test.ts --ci","test:anchorplatform:ci":"yarn jest --config jest.integration.config.js anchorplatform.test.ts --ci","build:web":"webpack --config webpack.config.js","build:node":"webpack --env NODE=true --config webpack.config.js","build":"run-p build:web build:node","example:sep10Server":"ts-node examples/sep10/sep10Server.ts","example:sep10Wallet":"ts-node examples/sep10/sep10Wallet.ts","example:sep24":"ts-node examples/sep24/sep24.ts","example:sep12":"ts-node examples/sep12/sep12.ts"}}');
|
|
89762
89806
|
|
|
89763
89807
|
/***/ }),
|
|
89764
89808
|
|