@stellar/typescript-wallet-sdk 1.4.1 → 1.6.0-beta.1719865729038
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 +98 -0
- package/examples/sep24/sep24.ts +4 -9
- package/jest.e2e.config.js +9 -0
- package/lib/bundle.js +47445 -43024
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +45409 -41445
- package/lib/bundle_browser.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/walletSdk/Anchor/index.d.ts +1 -1
- package/lib/walletSdk/Auth/AuthHeaderSigner.d.ts +61 -0
- package/lib/walletSdk/Auth/index.d.ts +2 -2
- package/lib/walletSdk/Exceptions/index.d.ts +21 -0
- package/lib/walletSdk/Horizon/AccountService.d.ts +1 -1
- package/lib/walletSdk/Horizon/Stellar.d.ts +1 -1
- package/lib/walletSdk/Horizon/Transaction/TransactionBuilder.d.ts +1 -1
- package/lib/walletSdk/Recovery/AccountRecover.d.ts +1 -1
- package/lib/walletSdk/Recovery/index.d.ts +2 -2
- package/lib/walletSdk/Types/anchor.d.ts +5 -1
- package/lib/walletSdk/Types/auth.d.ts +17 -0
- package/lib/walletSdk/Types/horizon.d.ts +1 -1
- package/lib/walletSdk/Types/index.d.ts +2 -1
- package/lib/walletSdk/Types/recovery.d.ts +2 -2
- package/lib/walletSdk/Types/sep7.d.ts +15 -0
- package/lib/walletSdk/Uri/Sep7Base.d.ts +187 -0
- package/lib/walletSdk/Uri/Sep7Pay.d.ts +121 -0
- package/lib/walletSdk/Uri/Sep7Tx.d.ts +133 -0
- package/lib/walletSdk/Uri/index.d.ts +4 -0
- package/lib/walletSdk/Uri/sep7Parser.d.ts +60 -0
- package/lib/walletSdk/Utils/index.d.ts +2 -1
- package/package.json +8 -3
- package/src/index.ts +14 -0
- package/src/walletSdk/Anchor/index.ts +1 -1
- package/src/walletSdk/Auth/AuthHeaderSigner.ts +162 -0
- package/src/walletSdk/Auth/WalletSigner.ts +3 -3
- package/src/walletSdk/Auth/index.ts +48 -2
- package/src/walletSdk/Customer/index.ts +7 -7
- package/src/walletSdk/Exceptions/index.ts +56 -0
- package/src/walletSdk/Horizon/Account.ts +2 -1
- package/src/walletSdk/Horizon/AccountService.ts +1 -1
- package/src/walletSdk/Horizon/Stellar.ts +1 -1
- package/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts +1 -1
- package/src/walletSdk/Recovery/AccountRecover.ts +1 -1
- package/src/walletSdk/Recovery/index.ts +2 -2
- package/src/walletSdk/Types/anchor.ts +4 -0
- package/src/walletSdk/Types/auth.ts +19 -0
- package/src/walletSdk/Types/horizon.ts +1 -1
- package/src/walletSdk/Types/index.ts +2 -1
- package/src/walletSdk/Types/recovery.ts +2 -2
- package/src/walletSdk/Types/sep7.ts +19 -0
- package/src/walletSdk/Uri/Sep7Base.ts +311 -0
- package/src/walletSdk/Uri/Sep7Pay.ts +169 -0
- package/src/walletSdk/Uri/Sep7Tx.ts +193 -0
- package/src/walletSdk/Uri/index.ts +9 -0
- package/src/walletSdk/Uri/sep7Parser.ts +220 -0
- package/src/walletSdk/Utils/index.ts +2 -1
- package/src/walletSdk/Watcher/index.ts +3 -1
- package/test/customer.test.ts +7 -7
- package/test/e2e/README.md +11 -0
- package/test/e2e/browser.test.ts +52 -0
- package/test/integration/README.md +38 -0
- package/test/integration/anchorplatform.test.ts +11 -2
- package/test/sep7.test.ts +825 -0
- package/test/server.test.ts +13 -0
- package/test/wallet.test.ts +85 -0
- package/webpack.config.js +4 -0
- package/test/README.md +0 -18
package/test/server.test.ts
CHANGED
|
@@ -68,4 +68,17 @@ describe("Server helpers", () => {
|
|
|
68
68
|
parsed = Server.parseAnchorTransaction(withdrawJson);
|
|
69
69
|
expect(parsed.kind).toBe("withdrawal");
|
|
70
70
|
});
|
|
71
|
+
it("should parse moneygram JSON transactions", () => {
|
|
72
|
+
const d1 = `{"id":"19489958-c0c4-4090-a272-a51fc851f524","kind":"deposit","status":"incomplete","amount_in":"3.00","amount_in_asset":"USD","amount_out":"3.00","amount_out_asset":"USD","amount_fee":"0.00","amount_fee_asset":"USD","started_at":"2024-03-28T16:20:09Z","stellar_transaction_id":"","refunded":false,"from":"","to":""}`;
|
|
73
|
+
let parsed = Server.parseAnchorTransaction(d1);
|
|
74
|
+
expect(parsed.kind).toBe("deposit");
|
|
75
|
+
|
|
76
|
+
const w1 = `{"withdraw_anchor_account":"GAYF33NNNMI2Z6VNRFXQ64D4E4SF77PM46NW3ZUZEEU5X7FCHAZCMHKU","withdraw_memo":"639496083328800102","withdraw_memo_type":"id","id":"d64c5d56-de6d-492e-95dd-412fb86c1c14","kind":"withdrawal","status":"pending_user_transfer_start","more_info_url":"https://extstellar.moneygram.com/transaction-status?transaction_id\u003dd64c5d56-de6d-492e-95dd-412fb86c1c14\u0026token\u003deyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkNjRjNWQ1Ni1kZTZkLTQ5MmUtOTVkZC00MTJmYjg2YzFjMTQiLCJpc3MiOiJtb3JlSW5mb1VybCIsInN1YiI6IkdBWkRVRlIyTDQ3S0hBS1g0V1NVWDNJUFo3NDYyVDVFNzNNQVpIWE9XT0NFQlBBUVlIVDdFNjJGIiwiaWF0IjoxNzExNjQyNzU0LCJleHAiOjE3MTE3MjkxNTQsImNsaWVudF9kb21haW4iOiJhcGktZGV2LnZpYnJhbnRhcHAuY29tIn0.CNjnMzXYA9aSU0ZA9Gd-P5bDWmpnaoAen8SnGz6PlHQ\u0026lang\u003den-US\u0026refNumber\u003d89445520","amount_in":"3.0","amount_in_asset":"USDC","amount_out":"4.02","amount_out_asset":"CAD","amount_fee":"0.0","amount_fee_asset":"USDC","started_at":"2024-03-28T16:18:02Z","stellar_transaction_id":"","external_transaction_id":"89445520","refunded":false,"from":"GAZDUFR2L47KHAKX4WSUX3IPZ7462T5E73MAZHXOWOCEBPAQYHT7E62F","to":"GAYF33NNNMI2Z6VNRFXQ64D4E4SF77PM46NW3ZUZEEU5X7FCHAZCMHKU"}`;
|
|
77
|
+
parsed = Server.parseAnchorTransaction(w1);
|
|
78
|
+
expect(parsed.kind).toBe("withdrawal");
|
|
79
|
+
|
|
80
|
+
const w2 = `{"id":"d64c5d56-de6d-492e-95dd-412fb86c1c14","kind":"withdrawal","status":"incomplete","amount_in":"0","amount_out":"0","amount_fee":"0","started_at":"2024-03-28T16:18:02Z","stellar_transaction_id":"","refunded":false,"from":"GAZDUFR2L47KHAKX4WSUX3IPZ7462T5E73MAZHXOWOCEBPAQYHT7E62F"}`;
|
|
81
|
+
parsed = Server.parseAnchorTransaction(w2);
|
|
82
|
+
expect(parsed.kind).toBe("withdrawal");
|
|
83
|
+
});
|
|
71
84
|
});
|
package/test/wallet.test.ts
CHANGED
|
@@ -20,6 +20,10 @@ import {
|
|
|
20
20
|
WalletSigner,
|
|
21
21
|
DefaultSigner,
|
|
22
22
|
} from "../src/walletSdk/Auth/WalletSigner";
|
|
23
|
+
import {
|
|
24
|
+
DefaultAuthHeaderSigner,
|
|
25
|
+
DomainAuthHeaderSigner,
|
|
26
|
+
} from "../src/walletSdk/Auth/AuthHeaderSigner";
|
|
23
27
|
import { SigningKeypair } from "../src/walletSdk/Horizon/Account";
|
|
24
28
|
import { Sep24 } from "../src/walletSdk/Anchor/Sep24";
|
|
25
29
|
import { DomainSigner } from "../src/walletSdk/Auth/WalletSigner";
|
|
@@ -1880,3 +1884,84 @@ describe("Http client", () => {
|
|
|
1880
1884
|
expect(resp.data.transaction).toBeTruthy();
|
|
1881
1885
|
});
|
|
1882
1886
|
});
|
|
1887
|
+
|
|
1888
|
+
describe("AuthHeaderSigner", () => {
|
|
1889
|
+
beforeAll(() => {
|
|
1890
|
+
jest.resetAllMocks();
|
|
1891
|
+
});
|
|
1892
|
+
it("full sep-10 auth using header token should work", async () => {
|
|
1893
|
+
const wallet = Wallet.TestNet();
|
|
1894
|
+
const accountKp = wallet.stellar().account().createKeypair();
|
|
1895
|
+
wallet.stellar().fundTestnetAccount(accountKp.publicKey);
|
|
1896
|
+
|
|
1897
|
+
const anchor = wallet.anchor({ homeDomain: "testanchor.stellar.org" });
|
|
1898
|
+
const auth = await anchor.sep10();
|
|
1899
|
+
|
|
1900
|
+
const authHeaderSigner = new DefaultAuthHeaderSigner();
|
|
1901
|
+
const authToken = await auth.authenticate({
|
|
1902
|
+
accountKp,
|
|
1903
|
+
authHeaderSigner,
|
|
1904
|
+
});
|
|
1905
|
+
|
|
1906
|
+
expect(authToken).toBeTruthy();
|
|
1907
|
+
}, 15000);
|
|
1908
|
+
|
|
1909
|
+
it("should match example implementation generated JWT", async () => {
|
|
1910
|
+
const generatedAuthToken =
|
|
1911
|
+
"eyJhbGciOiJFZERTQSJ9.eyJpYXQiOjE3MTE2NDg0ODYsImV4cCI6MTcxMTY0OTM4NiwiYWNjb3VudCI6IkdDNlVDWFZUQU1ORzVKTE9NWkJTQ05ZWFZTTk5GSEwyM1NKUFlPT0ZKRTJBVllERFMyRkZUNDVDIiwiY2xpZW50X2RvbWFpbiI6ImV4YW1wbGUtd2FsbGV0LnN0ZWxsYXIub3JnIiwid2ViX2F1dGhfZW5kcG9pbnQiOiJodHRwczovL2V4YW1wbGUuY29tL3NlcDEwL2F1dGgifQ.UQt8FpUK-BlnFw35o8Ke4GDOoCrMe9ztEx4_TGQ06XhMgUbn_b7EMPMVLWJ8RRNgSk2dNhyGUgIbhKzKtWtBBw";
|
|
1912
|
+
const issuer = SigningKeypair.fromSecret(
|
|
1913
|
+
"SCYVDFYEHNDNTB2UER2FCYSZAYQFAAZ6BDYXL3BWRQWNL327GZUXY7D7",
|
|
1914
|
+
);
|
|
1915
|
+
|
|
1916
|
+
const claims = {
|
|
1917
|
+
iat: 1711648486,
|
|
1918
|
+
exp: 1711649386,
|
|
1919
|
+
account: "GC6UCXVTAMNG5JLOMZBSCNYXVSNNFHL23SJPYOOFJE2AVYDDS2FFT45C",
|
|
1920
|
+
client_domain: "example-wallet.stellar.org",
|
|
1921
|
+
web_auth_endpoint: "https://example.com/sep10/auth",
|
|
1922
|
+
};
|
|
1923
|
+
|
|
1924
|
+
const signer = new DefaultAuthHeaderSigner();
|
|
1925
|
+
const token = await signer.createToken({
|
|
1926
|
+
claims,
|
|
1927
|
+
clientDomain: "",
|
|
1928
|
+
issuer,
|
|
1929
|
+
});
|
|
1930
|
+
|
|
1931
|
+
expect(token).toBe(generatedAuthToken);
|
|
1932
|
+
});
|
|
1933
|
+
|
|
1934
|
+
it("DefaultAuthHeaderSigner should work", async () => {
|
|
1935
|
+
const accountKp = SigningKeypair.fromSecret(
|
|
1936
|
+
"SAFXVNFRZQAC66RUZ2IJKMSNQCPXTKXVRX356COUKJJKJXBSLRX43DEZ",
|
|
1937
|
+
);
|
|
1938
|
+
|
|
1939
|
+
const signer = new DefaultAuthHeaderSigner();
|
|
1940
|
+
const token = await signer.createToken({
|
|
1941
|
+
claims: {},
|
|
1942
|
+
clientDomain: "test-domain",
|
|
1943
|
+
issuer: accountKp,
|
|
1944
|
+
});
|
|
1945
|
+
expect(token).toBeTruthy();
|
|
1946
|
+
});
|
|
1947
|
+
|
|
1948
|
+
it("DomainAuthHeaderSigner should work", async () => {
|
|
1949
|
+
const accountKp = SigningKeypair.fromSecret(
|
|
1950
|
+
"SAFXVNFRZQAC66RUZ2IJKMSNQCPXTKXVRX356COUKJJKJXBSLRX43DEZ",
|
|
1951
|
+
);
|
|
1952
|
+
|
|
1953
|
+
const signer = new DomainAuthHeaderSigner("some-url.com");
|
|
1954
|
+
|
|
1955
|
+
const data = { account: "dummy-account" };
|
|
1956
|
+
|
|
1957
|
+
jest.spyOn(signer, "signTokenRemote").mockResolvedValue("success-token");
|
|
1958
|
+
|
|
1959
|
+
const token = await signer.createToken({
|
|
1960
|
+
authTokenData: data,
|
|
1961
|
+
clientDomain: "test-domain",
|
|
1962
|
+
issuer: accountKp,
|
|
1963
|
+
});
|
|
1964
|
+
|
|
1965
|
+
expect(token).toBe("success-token");
|
|
1966
|
+
});
|
|
1967
|
+
});
|
package/webpack.config.js
CHANGED
|
@@ -29,6 +29,7 @@ module.exports = (env = { NODE: false }) => {
|
|
|
29
29
|
util: require.resolve("util"),
|
|
30
30
|
vm: require.resolve("vm-browserify"),
|
|
31
31
|
"process/browser": require.resolve("process/browser"),
|
|
32
|
+
buffer: require.resolve("buffer"),
|
|
32
33
|
}
|
|
33
34
|
: {},
|
|
34
35
|
},
|
|
@@ -45,6 +46,9 @@ module.exports = (env = { NODE: false }) => {
|
|
|
45
46
|
new webpack.ProvidePlugin({
|
|
46
47
|
process: "process/browser",
|
|
47
48
|
}),
|
|
49
|
+
new webpack.ProvidePlugin({
|
|
50
|
+
Buffer: ["buffer", "Buffer"],
|
|
51
|
+
}),
|
|
48
52
|
]
|
|
49
53
|
: [],
|
|
50
54
|
};
|
package/test/README.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# Recovery Integration Tests
|
|
2
|
-
|
|
3
|
-
## How it works
|
|
4
|
-
|
|
5
|
-
The recovery integration tests run different recovery scenarios against recovery
|
|
6
|
-
signer and webauth servers. 2 recovery signer and 2 webauth servers are started
|
|
7
|
-
in a docker-compose file (see test/docker/docker-compose.yml), to simulate a
|
|
8
|
-
wallet interacting with 2 separate recovery servers.
|
|
9
|
-
|
|
10
|
-
## To run tests locally:
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
// start servers using docker
|
|
14
|
-
$ docker-compose -f test/docker/docker-compose.yml up
|
|
15
|
-
|
|
16
|
-
// run tests
|
|
17
|
-
$ yarn test:integration:ci
|
|
18
|
-
```
|