@stellar/typescript-wallet-sdk 1.9.0 → 1.10.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.
@@ -16,7 +16,8 @@ describe("Customer", () => {
16
16
  );
17
17
  }, 10000);
18
18
 
19
- test("Sep-12 methods work", async () => {
19
+ // skipped: the testanchor changed its SEP-12 API behavior
20
+ test.skip("Sep-12 methods work", async () => {
20
21
  const anchor = wallet.anchor({ homeDomain: "testanchor.stellar.org" });
21
22
 
22
23
  const auth = await anchor.sep10();
@@ -53,7 +53,7 @@ services:
53
53
  environment:
54
54
  SIGNING_KEY: SDYHSG4V2JP5H66N2CXBFCOBTAUFWXGJVPKWY6OXSIPMYW743N62QX6U
55
55
  JWK: '{"kty":"EC","crv":"P-256","alg":"ES256","x":"dzqvhrMYwbmv7kcZK6L1oOATMFXG9wLFlnKfHf3E7FM","y":"Vb_wmcX-Zq2Hg2LFoXCEVWMwdJ01q41pSnxC3psunUY","d":"ivOMB4Wscz8ShvhwWDRyd-JJVfSMsjsz1oU3sNc-XJo"}'
56
- DOMAIN: test-domain
56
+ DOMAIN: localhost
57
57
  AUTH_HOME_DOMAIN: test-domain
58
58
  JWT_ISSUER: test
59
59
  PORT: 8001
@@ -65,7 +65,7 @@ services:
65
65
  environment:
66
66
  SIGNING_KEY: SCAS7BUKVDL44A2BAP23RVAM6XXHB24YRCANQGDTP24HP7T6LPUFIGGU # Use a different key for the second web auth server
67
67
  JWK: '{"kty":"EC","crv":"P-256","alg":"ES256","x":"dzqvhrMYwbmv7kcZK6L1oOATMFXG9wLFlnKfHf3E7FM","y":"Vb_wmcX-Zq2Hg2LFoXCEVWMwdJ01q41pSnxC3psunUY","d":"ivOMB4Wscz8ShvhwWDRyd-JJVfSMsjsz1oU3sNc-XJo"}'
68
- DOMAIN: test-domain
68
+ DOMAIN: localhost
69
69
  AUTH_HOME_DOMAIN: test-domain
70
70
  JWT_ISSUER: test
71
71
  PORT: 8003
@@ -14,8 +14,6 @@ describe("Test browser build", () => {
14
14
  const browser = await b.instance.launch();
15
15
  const page = await browser.newPage();
16
16
 
17
- await page.goto("https://stellar.org");
18
-
19
17
  await page.addScriptTag({
20
18
  path: "./lib/bundle_browser.js",
21
19
  });
@@ -28,11 +28,6 @@ against.
28
28
 
29
29
  ## To run tests locally:
30
30
 
31
- - follow the steps defined in the
32
- (.github/workflows/integration.anchorPlatformTest.yml)[https://github.com/stellar/typescript-wallet-sdk/blob/main/.github/workflows/integration.anchorPlatformTest.yml]
33
- file locally
34
-
35
- 1. Clone the java-stellar-anchor-sdk repo locally
36
- 2. Run the docker build command
37
- 3. Run the docker command
38
- 4. Run the anchorPlatform tests from this repo
31
+ ```
32
+ yarn test:anchorplatform:ci
33
+ ```
@@ -6,7 +6,7 @@ let wallet;
6
6
  let stellar;
7
7
  let anchor;
8
8
  let accountKp;
9
- const anchorUrl = "http://localhost:8080";
9
+ const anchorUrl = "https://anchor-sep-server-dev.stellar.org/";
10
10
 
11
11
  describe("Anchor Platform Integration Tests", () => {
12
12
  beforeAll(async () => {
@@ -69,6 +69,7 @@ describe("Anchor Platform Integration Tests", () => {
69
69
  params: {
70
70
  asset_code: "USDC",
71
71
  account: accountKp.publicKey,
72
+ type: "SEPA",
72
73
  },
73
74
  });
74
75
  expect(dResp.id).toBeTruthy();
@@ -29,7 +29,6 @@ describe("SEP-38", () => {
29
29
  const resp = await sep38.prices({
30
30
  sellAsset: "iso4217:USD",
31
31
  sellAmount: "5",
32
- sellDeliveryMethod: "ach_debit",
33
32
  });
34
33
  expect(resp.buy_assets[0].asset).toBeTruthy();
35
34
  });
@@ -59,7 +58,6 @@ describe("SEP-38", () => {
59
58
  "stellar:SRT:GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B",
60
59
  sell_amount: "5",
61
60
  context: "sep6",
62
- sell_delivery_method: "ach_debit",
63
61
  });
64
62
  expect(postResp.id).toBeTruthy();
65
63
 
package/test/sep6.test.ts CHANGED
@@ -17,6 +17,7 @@ describe("SEP-6", () => {
17
17
  "https://friendbot.stellar.org/?addr=" + accountKp.publicKey,
18
18
  );
19
19
  }, 10000);
20
+
20
21
  it("should get anchor info", async () => {
21
22
  const resp = await sep6.info();
22
23
  expect(resp.deposit).toBeTruthy();
@@ -26,7 +27,9 @@ describe("SEP-6", () => {
26
27
  expect(refreshed.deposit).toBeTruthy();
27
28
  expect(refreshed.withdraw).toBeTruthy();
28
29
  });
29
- it("should deposit", async () => {
30
+
31
+ // skipped: the testanchor changed its SEP-6 API behavior
32
+ it.skip("should deposit", async () => {
30
33
  const auth = await anchor.sep10();
31
34
  const authToken = await auth.authenticate({ accountKp });
32
35
 
@@ -65,6 +68,7 @@ describe("SEP-6", () => {
65
68
  });
66
69
  expect(resp.id).toBeTruthy();
67
70
  });
71
+
68
72
  it("should withdraw", async () => {
69
73
  const auth = await anchor.sep10();
70
74
  const authToken = await auth.authenticate({ accountKp });
@@ -94,7 +98,8 @@ describe("SEP-6", () => {
94
98
  expect(resp.id).toBeTruthy();
95
99
  });
96
100
 
97
- it("deposit-exchange should work", async () => {
101
+ // skipped: the testanchor changed its SEP-6 API behavior
102
+ it.skip("deposit-exchange should work", async () => {
98
103
  const auth = await anchor.sep10();
99
104
  const authToken = await auth.authenticate({ accountKp });
100
105
 
@@ -122,7 +127,8 @@ describe("SEP-6", () => {
122
127
  expect(resp.id).toBeTruthy();
123
128
  });
124
129
 
125
- it("withdraw-exchange should work", async () => {
130
+ // skipped: the testanchor changed its SEP-6 API behavior
131
+ it.skip("withdraw-exchange should work", async () => {
126
132
  const auth = await anchor.sep10();
127
133
  const authToken = await auth.authenticate({ accountKp });
128
134
 
package/test/sep7.test.ts CHANGED
@@ -11,7 +11,10 @@ import {
11
11
  sep7ReplacementsFromString,
12
12
  sep7ReplacementsToString,
13
13
  } from "../src";
14
- import { Sep7OperationType } from "../src/walletSdk/Types";
14
+ import {
15
+ Sep7OperationType,
16
+ URI_REPLACE_MAX_LENGTH,
17
+ } from "../src/walletSdk/Types";
15
18
  import {
16
19
  Sep7InvalidUriError,
17
20
  Sep7LongMsgError,
@@ -798,6 +801,45 @@ describe("sep7Parser", () => {
798
801
  );
799
802
  });
800
803
 
804
+ it("sep7ReplacementsFromString() throws on replace string without hints (no ';' delimiter)", () => {
805
+ const str = "sourceAccount:X,operations[0].sourceAccount:Y";
806
+ expect(() => sep7ReplacementsFromString(str)).toThrow(Sep7InvalidUriError);
807
+ });
808
+
809
+ it("sep7ReplacementsFromString() throws on single replacement without hints", () => {
810
+ const str = "sourceAccount:X";
811
+ expect(() => sep7ReplacementsFromString(str)).toThrow(Sep7InvalidUriError);
812
+ });
813
+
814
+ it("sep7ReplacementsFromString() throws on unbalanced identifiers", () => {
815
+ // Spec example: {X} on left but {Y} on right should be rejected
816
+ const str = "sourceAccount:X;Y:The account";
817
+ expect(() => sep7ReplacementsFromString(str)).toThrow(Sep7InvalidUriError);
818
+ });
819
+
820
+ it("sep7ReplacementsFromString() throws when replace string exceeds URI_REPLACE_MAX_LENGTH", () => {
821
+ const longPath = "a".repeat(URI_REPLACE_MAX_LENGTH);
822
+ const str = `${longPath}:X;X:hint`;
823
+ expect(str.length).toBeGreaterThan(URI_REPLACE_MAX_LENGTH);
824
+ expect(() => sep7ReplacementsFromString(str)).toThrow(Sep7InvalidUriError);
825
+ expect(() => sep7ReplacementsFromString(str)).toThrow(
826
+ "the 'replace' parameter exceeds the maximum allowed length",
827
+ );
828
+ });
829
+
830
+ it("sep7ReplacementsFromString() returns empty array for undefined/empty input", () => {
831
+ expect(sep7ReplacementsFromString(undefined)).toEqual([]);
832
+ expect(sep7ReplacementsFromString("")).toEqual([]);
833
+ });
834
+
835
+ it("Sep7Tx.getReplacements() throws on replace param missing hints", () => {
836
+ const uri = new Sep7Tx(
837
+ `web+stellar:tx?xdr=test&replace=${encodeURIComponent("sourceAccount:X")}`,
838
+ );
839
+
840
+ expect(() => uri.getReplacements()).toThrow(Sep7InvalidUriError);
841
+ });
842
+
801
843
  it("sep7ReplacementsToString outputs the right string", () => {
802
844
  const expected =
803
845
  "sourceAccount:X,operations[0].sourceAccount:Y,operations[1].destination:Y;X:account from where you want to pay fees,Y:account that needs the trustline and which will receive the new tokens";
@@ -1,3 +1,4 @@
1
+ import axios from "axios";
1
2
  import { TransactionBuilder } from "@stellar/stellar-sdk";
2
3
  import { Wallet, Server } from "../src";
3
4
 
@@ -5,6 +6,7 @@ let wallet;
5
6
  let account;
6
7
  let accountKp;
7
8
  const networkPassphrase = "Test SDF Network ; September 2015";
9
+ const anchorDomain = "testanchor.stellar.org";
8
10
  describe("SEP-10 helpers", () => {
9
11
  beforeEach(() => {
10
12
  wallet = Wallet.TestNet();
@@ -13,29 +15,23 @@ describe("SEP-10 helpers", () => {
13
15
  });
14
16
 
15
17
  it("should validate and sign challenge txn", async () => {
16
- const validChallengeTx =
17
- "AAAAAgAAAACpn2Fr7GAZ4XOcFvEz+xduBFDK1NDLQP875GtWWlJ0XQAAAMgAAAAAAAAAAAAAAAEAAAAAZa76AgAAAABlrv2GAAAAAAAAAAIAAAABAAAAALO9GbK9e+E+ul46lJyGjkzjlQnwqNryiqBsIR1vgMlAAAAACgAAABt0ZXN0YW5jaG9yLnN0ZWxsYXIub3JnIGF1dGgAAAAAAQAAAEBRT0ZDTE02OFQ0cVF4Um55TCtRdlBlVTdPeDJYNnhLdzdyenZTbzBBYUdqdUtIdGxQRkpHNTFKMndJazBwMXl2AAAAAQAAAACpn2Fr7GAZ4XOcFvEz+xduBFDK1NDLQP875GtWWlJ0XQAAAAoAAAAPd2ViX2F1dGhfZG9tYWluAAAAAAEAAAAWdGVzdGFuY2hvci5zdGVsbGFyLm9yZwAAAAAAAAAAAAFaUnRdAAAAQG6cMkt4YhwOzgizIimXRX8zTfFjAOItG7kSX14A454KlhGj9ocFhaRpj3tCc4fK45toFCBKRAdyFM7aQq331QI=";
18
+ const resp = await axios.get(
19
+ `https://${anchorDomain}/auth?account=${accountKp.publicKey}&home_domain=${anchorDomain}`,
20
+ );
21
+ const validChallengeTx = resp.data.transaction;
18
22
 
19
- let isValid;
20
- try {
21
- const signedResp = await Server.signChallengeTransaction({
22
- accountKp,
23
- challengeTx: validChallengeTx,
24
- networkPassphrase,
25
- anchorDomain: "testanchor.stellar.org",
26
- });
27
- const signedTxn = TransactionBuilder.fromXDR(
28
- signedResp.transaction,
29
- networkPassphrase,
30
- );
31
- expect(signedTxn.signatures.length).toBe(2);
32
- expect(signedResp.networkPassphrase).toBe(networkPassphrase);
33
- isValid = true;
34
- } catch (e) {
35
- isValid = false;
36
- }
37
-
38
- expect(isValid).toBeTruthy();
23
+ const signedResp = await Server.signChallengeTransaction({
24
+ accountKp,
25
+ challengeTx: validChallengeTx,
26
+ networkPassphrase,
27
+ anchorDomain,
28
+ });
29
+ const signedTxn = TransactionBuilder.fromXDR(
30
+ signedResp.transaction,
31
+ networkPassphrase,
32
+ );
33
+ expect(signedTxn.signatures.length).toBe(2);
34
+ expect(signedResp.networkPassphrase).toBe(networkPassphrase);
39
35
  });
40
36
 
41
37
  it("should invalidate bad challenge txn", async () => {
@@ -48,7 +44,7 @@ describe("SEP-10 helpers", () => {
48
44
  accountKp,
49
45
  challengeTx: invalidChallengeTx,
50
46
  networkPassphrase,
51
- anchorDomain: "testanchor.stellar.org",
47
+ anchorDomain,
52
48
  });
53
49
  isValid = true;
54
50
  } catch (e) {
@@ -91,12 +91,12 @@ describe("Anchor", () => {
91
91
  it("should give TOML info", async () => {
92
92
  let resp = await anchor.sep1();
93
93
  expect(resp.webAuthEndpoint).toBe("https://testanchor.stellar.org/auth");
94
- expect(resp.currencies.length).toBe(2);
94
+ expect(resp.currencies.length).toBe(3);
95
95
 
96
96
  // alias
97
97
  resp = await anchor.getInfo();
98
98
  expect(resp.webAuthEndpoint).toBe("https://testanchor.stellar.org/auth");
99
- expect(resp.currencies.length).toBe(2);
99
+ expect(resp.currencies.length).toBe(3);
100
100
  });
101
101
  it("should be able to authenticate", async () => {
102
102
  let auth = await anchor.sep10();
@@ -339,15 +339,14 @@ describe("Anchor", () => {
339
339
  expect(transactions.length === 2).toBeTruthy();
340
340
  });
341
341
 
342
- it("should error fetching transactions with invalid pading id", async () => {
343
- await expect(async () => {
344
- await anchor.sep24().getTransactionsForAsset({
345
- authToken,
346
- assetCode: "SRT",
347
- lang: "en-US",
348
- pagingId: "randomPagingId",
349
- });
350
- }).rejects.toThrowError(ServerRequestFailedError);
342
+ it("should accept any paging id when fetching transactions", async () => {
343
+ const transactions = await anchor.sep24().getTransactionsForAsset({
344
+ authToken,
345
+ assetCode: "SRT",
346
+ lang: "en-US",
347
+ pagingId: "randomPagingId",
348
+ });
349
+ expect(transactions).toBeDefined();
351
350
  });
352
351
 
353
352
  describe("watchAllTransactions", () => {
package/tsconfig.json CHANGED
@@ -4,7 +4,8 @@
4
4
  "baseUrl": "src/",
5
5
  "outDir": "lib",
6
6
  "declaration": true,
7
- "declarationDir": "lib"
7
+ "declarationDir": "lib",
8
+ "stripInternal": true
8
9
  },
9
10
  "include": ["src"]
10
11
  }