@stellar/typescript-wallet-sdk 4.0.1 → 5.0.0-beta.1788982897683

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.
Files changed (41) hide show
  1. package/CHANGELOG.MD +27 -0
  2. package/examples/sep10/sep10Server.ts +1 -1
  3. package/examples/sep24/sep24.ts +1 -1
  4. package/examples/tsconfig.json +1 -0
  5. package/jest.e2e.config.js +2 -1
  6. package/jest.integration.config.js +2 -1
  7. package/lib/bundle.js +58580 -22168
  8. package/lib/bundle.js.map +1 -1
  9. package/lib/bundle_browser.js +49268 -12817
  10. package/lib/bundle_browser.js.map +1 -1
  11. package/lib/walletSdk/Customer/index.d.ts +4 -4
  12. package/lib/walletSdk/Exceptions/index.d.ts +3 -0
  13. package/lib/walletSdk/Horizon/AccountService.d.ts +2 -3
  14. package/lib/walletSdk/Horizon/Transaction/TransactionBuilder.d.ts +17 -14
  15. package/lib/walletSdk/Types/horizon.d.ts +11 -5
  16. package/lib/walletSdk/Types/sep12.d.ts +1 -2
  17. package/lib/walletSdk/Uri/Sep7Base.d.ts +1 -1
  18. package/lib/walletSdk/Watcher/index.d.ts +1 -1
  19. package/package.json +7 -6
  20. package/src/walletSdk/Auth/AuthHeaderSigner.ts +11 -5
  21. package/src/walletSdk/Auth/WalletSigner.ts +1 -1
  22. package/src/walletSdk/Auth/index.ts +4 -3
  23. package/src/walletSdk/Customer/index.ts +6 -6
  24. package/src/walletSdk/Exceptions/index.ts +8 -0
  25. package/src/walletSdk/Horizon/AccountService.ts +2 -2
  26. package/src/walletSdk/Horizon/Stellar.ts +1 -1
  27. package/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts +31 -19
  28. package/src/walletSdk/Recovery/AccountRecover.ts +1 -1
  29. package/src/walletSdk/Server/index.ts +2 -2
  30. package/src/walletSdk/Types/horizon.ts +16 -5
  31. package/src/walletSdk/Types/sep12.ts +1 -1
  32. package/src/walletSdk/Uri/Sep7Base.ts +10 -9
  33. package/src/walletSdk/Uri/Sep7Tx.ts +1 -1
  34. package/src/walletSdk/Watcher/index.ts +5 -3
  35. package/test/auth.test.ts +42 -0
  36. package/test/e2e/reactNative.test.ts +190 -0
  37. package/test/sep7.test.ts +72 -7
  38. package/test/transaction.test.ts +107 -4
  39. package/test/tsconfig.json +1 -0
  40. package/test/wallet.test.ts +122 -0
  41. package/webpack.config.js +0 -4
package/CHANGELOG.MD CHANGED
@@ -1,3 +1,30 @@
1
+ # Release notes - Typescript Wallet SDK - 5.0.0
2
+
3
+ ### BREAKING CHANGES
4
+ * Upgraded `@stellar/stellar-sdk` from `16.2.0` to `17.0.1` — Protocol 28 support
5
+ * Minimum Node.js version raised from 22 to 22.12.0, as required by stellar-sdk v17
6
+ * **Minimum TypeScript 5.7** for consumers compiling against our type declarations — v17's typings use the generic `Uint8Array<ArrayBufferLike>` form, and `Uint8Array` only became generic in the TypeScript 5.7 lib
7
+ * Byte-valued public inputs widen from `Buffer` to `Uint8Array` (`AccountService.createKeypairFromRandom`, `CustomerBinaryInfoMap`, the `Customer.add`/`update` SEP-9 binary maps). Source-compatible for existing callers, because `Buffer` is a `Uint8Array` — **but only on `@types/node` >= 20**. Against an older `@types/node`, `Buffer` is not assignable to `Uint8Array<ArrayBufferLike>` and unchanged call sites will fail to compile, so `@types/node` >= 20 is a precondition for that compatibility promise
8
+ * **`btoa`/`atob` are now a runtime requirement for base64.** stellar-sdk v17 performs base64 through the bare `btoa` identifier (`lib/cjs/base/util/base64.js`, with no fallback), and this release removes the browser bundle's `Buffer` `ProvidePlugin` that previously serviced it — a posture change from v16, where the bundle self-served base64 from that polyfill. Hermes provides `btoa`/`atob` natively from React Native 0.74 onward (facebook/hermes#1255); React Native's own JS layer never has, so **React Native < 0.74 or a non-Hermes engine (JSC, V8) needs a polyfill** such as `base-64`. Verified: a built bundle in a Hermes-like context without `btoa` throws `ReferenceError: btoa is not defined` on any base64 operation, while hex and base32/StrKey keep working (they are pure JS)
9
+ * **`TextEncoder`/`TextDecoder` are a runtime prerequisite for loading this bundle.** `uint8array-extras` — a direct dependency of ours and a transitive dependency of stellar-sdk — constructs both at module initialization with no fallback (unlike `@exodus/bytes`, which only uses them when natively available and otherwise decodes in pure JS), so an environment missing either one fails at load, before any of our code runs. This is a prerequisite the consumer's environment must satisfy; React Native applications commonly polyfill `TextEncoder`/`TextDecoder` already. Verified: a built bundle in a context without them throws `TypeError: globalThis.TextDecoder is not a constructor` at load
10
+ * Removed the `base64url` dependency, replaced by `uint8array-extras`' `uint8ArrayToBase64(bytes, { urlSafe: true })`
11
+ * `pathPay()` now requires an explicit conversion bound and throws `PathPayBoundRequiredError` when it is missing — `destMin` for a strict-send payment, `sendMax` for a strict-receive one. It previously substituted defaults (one stroop for `destMin`, the int64 maximum for `sendMax`) which left the bound inert, so the conversion was effectively unbounded. Bounds supplied by the caller are now passed through verbatim. `PathPayParams` became a discriminated union, so omitting the bound — or passing both `sendAmount` and `destAmount` — is a compile-time error, and `swap()` takes `destMin` as a required fourth argument. This brings the Wallet SDK in line with `@stellar/stellar-sdk`, which already treats both fields as required (#252)
12
+
13
+ ### Added
14
+ * `PathPayBoundRequiredError`, exported via `Exceptions` (#252)
15
+
16
+ ### Changed
17
+ * Byte-derived values that used to be produced with `Buffer#toString(encoding)` are now produced with `xdr.encodeBytes(bytes, "hex" | "base64")`. `Uint8Array#toString()` ignores its encoding argument, so the old idiom silently returned comma-joined decimals under v17
18
+ * The core SDK and soroban `src` trees no longer reference the `Buffer` global at all, and the core SDK's browser bundle ships without a `buffer` polyfill. The key manager retains one sanctioned exception (`Handlers/ledger.ts`, where `@ledgerhq/hw-app-str` requires a real `Buffer`), so its browser bundle still inlines the polyfill for that one path. This boundary is enforced by ESLint (`no-restricted-globals` / `no-restricted-syntax` / `no-restricted-imports`) and by a React Native sandbox test that loads each package's built bundle with `Buffer`, `Event`, `EventTarget` and `process` absent
19
+
20
+ ### Fixed
21
+ * SEP-7 signatures and transaction URIs are correctly base64-encoded. Under stellar-sdk v17 the previous `Buffer`-era code produced comma-joined decimals, which made a signed `Sep7Tx` URI unparseable
22
+ * The SEP-10 `client_domain` integrity check compares transaction hashes correctly again — it used `Buffer#equals`, which does not exist on `Uint8Array`
23
+ * `Watcher` treats `on_hold` as a transient status. `TransactionStatus.on_hold` documents itself as a temporary state — an anchor holding a transfer for review, after which "transaction should follow the regular flow" — but neither watcher recognised it as in progress. `watchOneTransaction` fell through to its terminal branch and invoked `onError` before stopping its poll, so a transfer merely awaiting a compliance check was reported to the caller as a failure and then abandoned; `watchAllTransactions` filed it in the ignored registry and omitted it from the first poll entirely. Both now treat it like `incomplete` and the `pending_*` statuses, so the transaction keeps being watched and surfaces through `onMessage` until it reaches a genuinely final status (#251)
24
+
25
+ ### Known limitations
26
+ * SEP-12 binary upload (`Customer.add`/`update` with `sep9BinaryInfo`) is not usable on React Native. axios's `toFormData` takes a `Buffer.from(value)` path for typed-array values whenever `FormData` is not spec-compliant, which is the case on React Native. That path was already non-functional there — React Native's `FormData.append` cannot consume a `Buffer` part — so this is a change of failure mode, not of capability: with the polyfill removed it now raises `ReferenceError` instead of producing silent garbage. Browsers and Node.js are unaffected
27
+
1
28
  # Release notes - Typescript Wallet SDK - 4.0.1
2
29
 
3
30
  ### Changed
@@ -43,7 +43,7 @@ app.post("/sign", (req, res) => {
43
43
  res.set("Access-Control-Allow-Origin", "*");
44
44
  res.status(200);
45
45
  res.send({
46
- transaction: transaction.toEnvelope().toXDR("base64"),
46
+ transaction: transaction.toEnvelope().toXdr("base64"),
47
47
  network_passphrase: network_passphrase,
48
48
  });
49
49
  });
@@ -228,7 +228,7 @@ walletSigner.signWithDomainAccount = async ({
228
228
 
229
229
  const signer = SigningKeypair.fromSecret(clientSecret);
230
230
 
231
- const transaction = TransactionBuilder.fromXDR(
231
+ const transaction = TransactionBuilder.fromXdr(
232
232
  transactionXDR,
233
233
  networkPassphrase,
234
234
  ) as Transaction;
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "esModuleInterop": true,
4
+ "skipLibCheck": true,
4
5
  "baseUrl": "./",
5
6
  "outDir": "lib",
6
7
  "declaration": true,
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  rootDir: "./",
3
3
  preset: "ts-jest",
4
- // @stellar/stellar-sdk v16 pulls in several ESM-only packages (directly or
4
+ // @stellar/stellar-sdk v17 pulls in several ESM-only packages (directly or
5
5
  // transitively) that must be transformed to run under Jest's CommonJS runtime.
6
6
  transformIgnorePatterns: [
7
7
  `/node_modules/(?!${[
8
8
  "@stablelib",
9
+ "@exodus/bytes",
9
10
  "@noble",
10
11
  "uint8array-extras",
11
12
  "smol-toml",
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  rootDir: "./",
3
3
  preset: "ts-jest",
4
- // @stellar/stellar-sdk v16 pulls in several ESM-only packages (directly or
4
+ // @stellar/stellar-sdk v17 pulls in several ESM-only packages (directly or
5
5
  // transitively) that must be transformed to run under Jest's CommonJS runtime.
6
6
  transformIgnorePatterns: [
7
7
  `/node_modules/(?!${[
8
8
  "@stablelib",
9
+ "@exodus/bytes",
9
10
  "@noble",
10
11
  "uint8array-extras",
11
12
  "smol-toml",