@stellar/typescript-wallet-sdk 3.0.2 → 3.0.3-beta.1786146826692
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 +8 -0
- package/lib/bundle.js +42 -2
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +42 -2
- package/lib/bundle_browser.js.map +1 -1
- package/lib/walletSdk/Types/sep7.d.ts +18 -0
- package/package.json +2 -2
- package/src/walletSdk/Types/sep7.ts +22 -0
- package/src/walletSdk/Uri/Sep7Base.ts +14 -1
- package/src/walletSdk/Uri/sep7Parser.ts +14 -0
- package/test/sep7.test.ts +138 -1
package/CHANGELOG.MD
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# Release notes - Typescript Wallet SDK - 3.0.3
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
* Validate SEP-7 origin_domain as a fully qualified domain name (#244)
|
|
5
|
+
|
|
6
|
+
### Added
|
|
7
|
+
* `Types.isValidFullyQualifiedDomainName` and `Types.FULLY_QUALIFIED_DOMAIN_NAME_REGEX` (#244)
|
|
8
|
+
|
|
1
9
|
# Release notes - Typescript Wallet SDK - 3.0.2
|
|
2
10
|
* Version bump
|
|
3
11
|
|
package/lib/bundle.js
CHANGED
|
@@ -4851,7 +4851,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
4851
4851
|
"use strict";
|
|
4852
4852
|
|
|
4853
4853
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4854
|
-
exports.URI_REPLACE_MAX_LENGTH = exports.URI_MSG_MAX_LENGTH = exports.Sep7OperationType = exports.WEB_STELLAR_SCHEME = void 0;
|
|
4854
|
+
exports.isValidFullyQualifiedDomainName = exports.FULLY_QUALIFIED_DOMAIN_NAME_REGEX = exports.URI_REPLACE_MAX_LENGTH = exports.URI_MSG_MAX_LENGTH = exports.Sep7OperationType = exports.WEB_STELLAR_SCHEME = void 0;
|
|
4855
4855
|
exports.WEB_STELLAR_SCHEME = "web+stellar:";
|
|
4856
4856
|
var Sep7OperationType;
|
|
4857
4857
|
(function (Sep7OperationType) {
|
|
@@ -4860,6 +4860,27 @@ var Sep7OperationType;
|
|
|
4860
4860
|
})(Sep7OperationType = exports.Sep7OperationType || (exports.Sep7OperationType = {}));
|
|
4861
4861
|
exports.URI_MSG_MAX_LENGTH = 300;
|
|
4862
4862
|
exports.URI_REPLACE_MAX_LENGTH = 4096;
|
|
4863
|
+
/**
|
|
4864
|
+
* Matches a fully qualified domain name (e.g. "example.com", "sub.example.co.uk").
|
|
4865
|
+
*
|
|
4866
|
+
* Rejects userinfo ('@'), ports (':'), paths/queries ('/', '?'), scheme
|
|
4867
|
+
* prefixes ('//'), bare hostnames like 'localhost', and raw IPv4/IPv6
|
|
4868
|
+
* addresses (the all-numeric final label fails the alphabetic TLD rule).
|
|
4869
|
+
*
|
|
4870
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0007.md#verifying-the-signature step 3.
|
|
4871
|
+
*/
|
|
4872
|
+
exports.FULLY_QUALIFIED_DOMAIN_NAME_REGEX = /^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/;
|
|
4873
|
+
/**
|
|
4874
|
+
* Returns true if the given string is a valid fully qualified domain name.
|
|
4875
|
+
*
|
|
4876
|
+
* @param {string} domain the domain string to validate.
|
|
4877
|
+
*
|
|
4878
|
+
* @returns {boolean} true if 'domain' is a valid fully qualified domain name.
|
|
4879
|
+
*/
|
|
4880
|
+
var isValidFullyQualifiedDomainName = function (domain) {
|
|
4881
|
+
return exports.FULLY_QUALIFIED_DOMAIN_NAME_REGEX.test(domain);
|
|
4882
|
+
};
|
|
4883
|
+
exports.isValidFullyQualifiedDomainName = isValidFullyQualifiedDomainName;
|
|
4863
4884
|
|
|
4864
4885
|
|
|
4865
4886
|
/***/ }),
|
|
@@ -5178,6 +5199,14 @@ var Sep7Base = /** @class */ (function () {
|
|
|
5178
5199
|
if (!originDomain || !signature) {
|
|
5179
5200
|
return [2 /*return*/, false];
|
|
5180
5201
|
}
|
|
5202
|
+
// SEP-7 step 3: "If the origin_domain is not a valid fully qualified
|
|
5203
|
+
// domain name, do not allow the user to sign the transaction." This must
|
|
5204
|
+
// be enforced before resolving the stellar.toml, otherwise a malformed
|
|
5205
|
+
// origin_domain (e.g. containing userinfo, a port, or a path) could
|
|
5206
|
+
// redirect the trust-anchoring TOML fetch to an attacker-controlled host.
|
|
5207
|
+
if (!(0, Types_1.isValidFullyQualifiedDomainName)(originDomain)) {
|
|
5208
|
+
return [2 /*return*/, false];
|
|
5209
|
+
}
|
|
5181
5210
|
_a.label = 1;
|
|
5182
5211
|
case 1:
|
|
5183
5212
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -5748,6 +5777,7 @@ var isValidSep7Uri = function (uri) {
|
|
|
5748
5777
|
var networkPassphrase = url.searchParams.get("network_passphrase") || stellar_sdk_1.Networks.PUBLIC;
|
|
5749
5778
|
var destination = url.searchParams.get("destination");
|
|
5750
5779
|
var msg = url.searchParams.get("msg");
|
|
5780
|
+
var originDomain = url.searchParams.get("origin_domain");
|
|
5751
5781
|
if (![Types_1.Sep7OperationType.tx, Types_1.Sep7OperationType.pay].includes(type)) {
|
|
5752
5782
|
return {
|
|
5753
5783
|
result: false,
|
|
@@ -5795,6 +5825,16 @@ var isValidSep7Uri = function (uri) {
|
|
|
5795
5825
|
reason: "the 'msg' parameter should be no longer than ".concat(Types_1.URI_MSG_MAX_LENGTH, " characters"),
|
|
5796
5826
|
};
|
|
5797
5827
|
}
|
|
5828
|
+
// 'origin_domain' is optional (SEP-7), but when present it must be a valid
|
|
5829
|
+
// fully qualified domain name (SEP-7 step 3), otherwise a malformed value
|
|
5830
|
+
// could later redirect the trust-anchoring stellar.toml fetch in
|
|
5831
|
+
// Sep7Base.verifySignature() to an attacker-controlled host.
|
|
5832
|
+
if (originDomain && !(0, Types_1.isValidFullyQualifiedDomainName)(originDomain)) {
|
|
5833
|
+
return {
|
|
5834
|
+
result: false,
|
|
5835
|
+
reason: "the provided 'origin_domain' parameter is not a valid fully qualified domain name",
|
|
5836
|
+
};
|
|
5837
|
+
}
|
|
5798
5838
|
return {
|
|
5799
5839
|
result: true,
|
|
5800
5840
|
};
|
|
@@ -82472,7 +82512,7 @@ function decode(arr) {
|
|
|
82472
82512
|
/***/ ((module) => {
|
|
82473
82513
|
|
|
82474
82514
|
"use strict";
|
|
82475
|
-
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"3.0.
|
|
82515
|
+
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"3.0.3","engines":{"node":">=20"},"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","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":"15.0.1","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"}}');
|
|
82476
82516
|
|
|
82477
82517
|
/***/ }),
|
|
82478
82518
|
|