@tonconnect/sdk 0.0.43 → 0.0.45

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 (209) hide show
  1. package/README.md +7 -6
  2. package/dist/tonconnect-sdk.min.js +1 -1
  3. package/dist/tonconnect-sdk.min.js.map +1 -1
  4. package/lib/cjs/errors/address/index.js +5 -0
  5. package/lib/cjs/errors/address/wrong-address.error.js +11 -0
  6. package/lib/cjs/errors/binary/base64-encode.error.js +11 -0
  7. package/lib/cjs/errors/binary/index.js +7 -0
  8. package/lib/cjs/errors/binary/parse-hex.error.js +11 -0
  9. package/lib/{errors → cjs/errors}/dapp/dapp-metadata.error.js +0 -0
  10. package/lib/{errors → cjs/errors}/index.js +2 -0
  11. package/lib/{errors → cjs/errors}/protocol/events/connect/index.js +0 -0
  12. package/lib/{errors → cjs/errors}/protocol/events/connect/manifest-content-error.error.js +0 -0
  13. package/lib/{errors → cjs/errors}/protocol/events/connect/manifest-not-found.error.js +0 -0
  14. package/lib/{errors → cjs/errors}/protocol/events/connect/user-rejects.error.js +0 -0
  15. package/lib/{errors → cjs/errors}/protocol/events/index.js +0 -0
  16. package/lib/{errors → cjs/errors}/protocol/index.js +0 -0
  17. package/lib/{errors → cjs/errors}/protocol/responses/bad-request.error.js +0 -0
  18. package/lib/{errors → cjs/errors}/protocol/responses/index.js +0 -0
  19. package/lib/{errors → cjs/errors}/protocol/responses/unknown-app.error.js +0 -0
  20. package/lib/{errors → cjs/errors}/storage/index.js +0 -0
  21. package/lib/{errors → cjs/errors}/storage/localstorage-not-found.error.js +0 -0
  22. package/lib/{errors → cjs/errors}/ton-connect.error.js +0 -0
  23. package/lib/{errors → cjs/errors}/unknown.error.js +0 -0
  24. package/lib/{errors → cjs/errors}/wallet/index.js +0 -0
  25. package/lib/{errors → cjs/errors}/wallet/wallet-already-connected.error.js +0 -0
  26. package/lib/{errors → cjs/errors}/wallet/wallet-not-connected.error.js +0 -0
  27. package/lib/{errors → cjs/errors}/wallet/wallet-not-injected.error.js +0 -0
  28. package/lib/{errors → cjs/errors}/wallet/wallet-not-support-feature.error.js +0 -0
  29. package/lib/{errors → cjs/errors}/wallets-manager/fetch-wallets.error.js +0 -0
  30. package/lib/{errors → cjs/errors}/wallets-manager/index.js +0 -0
  31. package/lib/{index.js → cjs/index.js} +3 -1
  32. package/lib/{models → cjs/models}/dapp/dapp-metadata.js +0 -0
  33. package/lib/{models → cjs/models}/index.js +0 -0
  34. package/lib/{models → cjs/models}/methods/connect/connect-additional-request.js +0 -0
  35. package/lib/{models → cjs/models}/methods/connect/index.js +0 -0
  36. package/lib/{models → cjs/models}/methods/index.js +0 -0
  37. package/lib/{models → cjs/models}/methods/send-transaction/index.js +0 -0
  38. package/lib/{models → cjs/models}/methods/send-transaction/send-transaction-request.js +0 -0
  39. package/lib/{models → cjs/models}/methods/send-transaction/send-transaction-response.js +0 -0
  40. package/lib/{models → cjs/models}/ton-connect-options.js +0 -0
  41. package/lib/{models → cjs/models}/wallet/account.js +0 -0
  42. package/lib/{models → cjs/models}/wallet/index.js +0 -0
  43. package/lib/{models → cjs/models}/wallet/wallet-connection-source.js +0 -0
  44. package/lib/{models → cjs/models}/wallet/wallet-info.js +0 -0
  45. package/lib/{models → cjs/models}/wallet/wallet.js +0 -0
  46. package/lib/{parsers → cjs/parsers}/connect-errors-parser.js +0 -0
  47. package/lib/{parsers → cjs/parsers}/rpc-parser.js +0 -0
  48. package/lib/{parsers → cjs/parsers}/send-transaction-parser.js +2 -3
  49. package/lib/{provider → cjs/provider}/bridge/bridge-gateway.js +14 -0
  50. package/lib/{provider → cjs/provider}/bridge/bridge-provider.js +2 -25
  51. package/lib/{provider → cjs/provider}/bridge/models/bridge-connection.js +0 -0
  52. package/lib/{provider → cjs/provider}/bridge/models/bridge-incomming-message.js +0 -0
  53. package/lib/{provider → cjs/provider}/bridge/models/bridge-session-raw.js +0 -0
  54. package/lib/{provider → cjs/provider}/bridge/models/bridge-session.js +0 -0
  55. package/lib/{provider → cjs/provider}/injected/injected-provider.js +2 -25
  56. package/lib/{provider → cjs/provider}/injected/models/injected-wallet-api.js +0 -0
  57. package/lib/{provider → cjs/provider}/provider.js +0 -0
  58. package/lib/cjs/resources/protocol.js +4 -0
  59. package/lib/{storage → cjs/storage}/bridge-connection-storage.js +0 -0
  60. package/lib/{storage → cjs/storage}/default-storage.js +0 -0
  61. package/lib/{storage → cjs/storage}/http-bridge-gateway-storage.js +0 -0
  62. package/lib/{storage → cjs/storage}/models/storage.interface.js +0 -0
  63. package/lib/{ton-connect.interface.js → cjs/ton-connect.interface.js} +0 -0
  64. package/lib/{ton-connect.js → cjs/ton-connect.js} +3 -5
  65. package/lib/cjs/utils/address.js +87 -0
  66. package/lib/{utils → cjs/utils}/options.js +0 -0
  67. package/lib/{utils → cjs/utils}/types.js +0 -0
  68. package/lib/{utils → cjs/utils}/url.js +0 -0
  69. package/lib/{utils → cjs/utils}/web-api.js +0 -0
  70. package/lib/{wallets-list-manager.js → cjs/wallets-list-manager.js} +40 -16
  71. package/lib/esm/errors/address/index.js +1 -0
  72. package/lib/esm/errors/address/wrong-address.error.js +7 -0
  73. package/lib/esm/errors/binary/base64-encode.error.js +7 -0
  74. package/lib/esm/errors/binary/index.js +2 -0
  75. package/lib/esm/errors/binary/parse-hex.error.js +7 -0
  76. package/lib/esm/errors/dapp/dapp-metadata.error.js +10 -0
  77. package/lib/esm/errors/index.js +8 -0
  78. package/lib/{errors/protocol/events/connect/index.d.ts → esm/errors/protocol/events/connect/index.js} +0 -0
  79. package/lib/esm/errors/protocol/events/connect/manifest-content-error.error.js +11 -0
  80. package/lib/esm/errors/protocol/events/connect/manifest-not-found.error.js +11 -0
  81. package/lib/esm/errors/protocol/events/connect/user-rejects.error.js +10 -0
  82. package/lib/{errors/protocol/events/index.d.ts → esm/errors/protocol/events/index.js} +0 -0
  83. package/lib/{errors/protocol/index.d.ts → esm/errors/protocol/index.js} +0 -0
  84. package/lib/esm/errors/protocol/responses/bad-request.error.js +10 -0
  85. package/lib/{errors/protocol/responses/index.d.ts → esm/errors/protocol/responses/index.js} +0 -0
  86. package/lib/esm/errors/protocol/responses/unknown-app.error.js +10 -0
  87. package/lib/{errors/storage/index.d.ts → esm/errors/storage/index.js} +0 -0
  88. package/lib/esm/errors/storage/localstorage-not-found.error.js +10 -0
  89. package/lib/esm/errors/ton-connect.error.js +13 -0
  90. package/lib/esm/errors/unknown.error.js +10 -0
  91. package/lib/{errors/wallet/index.d.ts → esm/errors/wallet/index.js} +0 -0
  92. package/lib/esm/errors/wallet/wallet-already-connected.error.js +10 -0
  93. package/lib/esm/errors/wallet/wallet-not-connected.error.js +10 -0
  94. package/lib/esm/errors/wallet/wallet-not-injected.error.js +10 -0
  95. package/lib/esm/errors/wallet/wallet-not-support-feature.error.js +10 -0
  96. package/lib/esm/errors/wallets-manager/fetch-wallets.error.js +10 -0
  97. package/lib/{errors/wallets-manager/index.d.ts → esm/errors/wallets-manager/index.js} +0 -0
  98. package/lib/esm/index.js +6 -0
  99. package/lib/esm/models/dapp/dapp-metadata.js +1 -0
  100. package/lib/esm/models/index.js +2 -0
  101. package/lib/esm/models/methods/connect/connect-additional-request.js +1 -0
  102. package/lib/esm/models/methods/connect/index.js +1 -0
  103. package/lib/{models/methods/index.d.ts → esm/models/methods/index.js} +0 -0
  104. package/lib/esm/models/methods/send-transaction/index.js +1 -0
  105. package/lib/esm/models/methods/send-transaction/send-transaction-request.js +1 -0
  106. package/lib/esm/models/methods/send-transaction/send-transaction-response.js +1 -0
  107. package/lib/esm/models/ton-connect-options.js +1 -0
  108. package/lib/esm/models/wallet/account.js +1 -0
  109. package/lib/esm/models/wallet/index.js +1 -0
  110. package/lib/esm/models/wallet/wallet-connection-source.js +3 -0
  111. package/lib/esm/models/wallet/wallet-info.js +3 -0
  112. package/lib/esm/models/wallet/wallet.js +1 -0
  113. package/lib/esm/parsers/connect-errors-parser.js +23 -0
  114. package/lib/esm/parsers/rpc-parser.js +5 -0
  115. package/lib/esm/parsers/send-transaction-parser.js +31 -0
  116. package/lib/esm/provider/bridge/bridge-gateway.js +105 -0
  117. package/lib/esm/provider/bridge/bridge-provider.js +140 -0
  118. package/lib/esm/provider/bridge/models/bridge-connection.js +1 -0
  119. package/lib/esm/provider/bridge/models/bridge-incomming-message.js +1 -0
  120. package/lib/esm/provider/bridge/models/bridge-session-raw.js +1 -0
  121. package/lib/esm/provider/bridge/models/bridge-session.js +1 -0
  122. package/lib/esm/provider/injected/injected-provider.js +121 -0
  123. package/lib/esm/provider/injected/models/injected-wallet-api.js +1 -0
  124. package/lib/esm/provider/provider.js +1 -0
  125. package/lib/esm/resources/protocol.js +1 -0
  126. package/lib/esm/storage/bridge-connection-storage.js +96 -0
  127. package/lib/esm/storage/default-storage.js +35 -0
  128. package/lib/esm/storage/http-bridge-gateway-storage.js +34 -0
  129. package/lib/esm/storage/models/storage.interface.js +1 -0
  130. package/lib/esm/ton-connect.interface.js +1 -0
  131. package/lib/esm/ton-connect.js +252 -0
  132. package/lib/esm/utils/address.js +83 -0
  133. package/lib/esm/utils/options.js +8 -0
  134. package/lib/esm/utils/types.js +1 -0
  135. package/lib/esm/utils/url.js +9 -0
  136. package/lib/esm/utils/web-api.js +20 -0
  137. package/lib/esm/wallets-list-manager.js +115 -0
  138. package/lib/types/errors/address/index.d.ts +1 -0
  139. package/lib/types/errors/address/wrong-address.error.d.ts +4 -0
  140. package/lib/types/errors/binary/base64-encode.error.d.ts +4 -0
  141. package/lib/types/errors/binary/index.d.ts +2 -0
  142. package/lib/types/errors/binary/parse-hex.error.d.ts +4 -0
  143. package/lib/{errors → types/errors}/dapp/dapp-metadata.error.d.ts +0 -0
  144. package/lib/{errors → types/errors}/index.d.ts +2 -0
  145. package/lib/types/errors/protocol/events/connect/index.d.ts +1 -0
  146. package/lib/{errors → types/errors}/protocol/events/connect/manifest-content-error.error.d.ts +0 -0
  147. package/lib/{errors → types/errors}/protocol/events/connect/manifest-not-found.error.d.ts +0 -0
  148. package/lib/{errors → types/errors}/protocol/events/connect/user-rejects.error.d.ts +0 -0
  149. package/lib/types/errors/protocol/events/index.d.ts +1 -0
  150. package/lib/types/errors/protocol/index.d.ts +2 -0
  151. package/lib/{errors → types/errors}/protocol/responses/bad-request.error.d.ts +0 -0
  152. package/lib/types/errors/protocol/responses/index.d.ts +2 -0
  153. package/lib/{errors → types/errors}/protocol/responses/unknown-app.error.d.ts +0 -0
  154. package/lib/types/errors/storage/index.d.ts +1 -0
  155. package/lib/{errors → types/errors}/storage/localstorage-not-found.error.d.ts +0 -0
  156. package/lib/{errors → types/errors}/ton-connect.error.d.ts +0 -0
  157. package/lib/{errors → types/errors}/unknown.error.d.ts +0 -0
  158. package/lib/types/errors/wallet/index.d.ts +3 -0
  159. package/lib/{errors → types/errors}/wallet/wallet-already-connected.error.d.ts +0 -0
  160. package/lib/{errors → types/errors}/wallet/wallet-not-connected.error.d.ts +0 -0
  161. package/lib/{errors → types/errors}/wallet/wallet-not-injected.error.d.ts +0 -0
  162. package/lib/{errors → types/errors}/wallet/wallet-not-support-feature.error.d.ts +0 -0
  163. package/lib/{errors → types/errors}/wallets-manager/fetch-wallets.error.d.ts +0 -0
  164. package/lib/types/errors/wallets-manager/index.d.ts +1 -0
  165. package/lib/{index.d.ts → types/index.d.ts} +1 -0
  166. package/lib/{models → types/models}/dapp/dapp-metadata.d.ts +0 -0
  167. package/lib/{models → types/models}/index.d.ts +0 -0
  168. package/lib/types/models/methods/connect/connect-additional-request.d.ts +6 -0
  169. package/lib/{models → types/models}/methods/connect/index.d.ts +0 -0
  170. package/lib/types/models/methods/index.d.ts +2 -0
  171. package/lib/{models → types/models}/methods/send-transaction/index.d.ts +0 -1
  172. package/lib/{models → types/models}/methods/send-transaction/send-transaction-request.d.ts +0 -0
  173. package/lib/{models → types/models}/methods/send-transaction/send-transaction-response.d.ts +0 -0
  174. package/lib/{models → types/models}/ton-connect-options.d.ts +0 -0
  175. package/lib/{models → types/models}/wallet/account.d.ts +0 -0
  176. package/lib/{models → types/models}/wallet/index.d.ts +0 -0
  177. package/lib/{models → types/models}/wallet/wallet-connection-source.d.ts +0 -0
  178. package/lib/{models → types/models}/wallet/wallet-info.d.ts +14 -7
  179. package/lib/{models → types/models}/wallet/wallet.d.ts +0 -0
  180. package/lib/{parsers → types/parsers}/connect-errors-parser.d.ts +0 -0
  181. package/lib/{parsers → types/parsers}/rpc-parser.d.ts +0 -0
  182. package/lib/{parsers → types/parsers}/send-transaction-parser.d.ts +2 -2
  183. package/lib/{provider → types/provider}/bridge/bridge-gateway.d.ts +1 -0
  184. package/lib/{provider → types/provider}/bridge/bridge-provider.d.ts +0 -0
  185. package/lib/{provider → types/provider}/bridge/models/bridge-connection.d.ts +0 -0
  186. package/lib/{provider → types/provider}/bridge/models/bridge-incomming-message.d.ts +0 -0
  187. package/lib/{provider → types/provider}/bridge/models/bridge-session-raw.d.ts +0 -0
  188. package/lib/{provider → types/provider}/bridge/models/bridge-session.d.ts +0 -0
  189. package/lib/{provider → types/provider}/injected/injected-provider.d.ts +0 -0
  190. package/lib/{provider → types/provider}/injected/models/injected-wallet-api.d.ts +0 -0
  191. package/lib/{provider → types/provider}/provider.d.ts +0 -0
  192. package/lib/types/resources/protocol.d.ts +1 -0
  193. package/lib/{storage → types/storage}/bridge-connection-storage.d.ts +0 -0
  194. package/lib/{storage → types/storage}/default-storage.d.ts +0 -0
  195. package/lib/{storage → types/storage}/http-bridge-gateway-storage.d.ts +0 -0
  196. package/lib/{storage → types/storage}/models/storage.interface.d.ts +0 -0
  197. package/lib/{ton-connect.d.ts → types/ton-connect.d.ts} +1 -3
  198. package/lib/{ton-connect.interface.d.ts → types/ton-connect.interface.d.ts} +1 -3
  199. package/lib/types/utils/address.d.ts +1 -0
  200. package/lib/{utils → types/utils}/options.d.ts +0 -0
  201. package/lib/{utils → types/utils}/types.d.ts +0 -0
  202. package/lib/{utils → types/utils}/url.d.ts +0 -0
  203. package/lib/{utils → types/utils}/web-api.d.ts +0 -0
  204. package/lib/{wallets-list-manager.d.ts → types/wallets-list-manager.d.ts} +0 -0
  205. package/package.json +15 -6
  206. package/lib/models/methods/connect/connect-additional-request.d.ts +0 -15
  207. package/lib/models/methods/send-transaction/send-transaction-options.d.ts +0 -11
  208. package/lib/models/methods/send-transaction/send-transaction-options.js +0 -2
  209. package/lib/resources/protocol.json +0 -3
@@ -0,0 +1,20 @@
1
+ export function getWindow() {
2
+ if (typeof window === 'undefined') {
3
+ return undefined;
4
+ }
5
+ return window;
6
+ }
7
+ export function getDocument() {
8
+ if (typeof document === 'undefined') {
9
+ return undefined;
10
+ }
11
+ return document;
12
+ }
13
+ export function getWebPageManifest() {
14
+ var _a;
15
+ const origin = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.location.origin;
16
+ if (origin) {
17
+ return origin + '/tonconnect-manifest.json';
18
+ }
19
+ return '';
20
+ }
@@ -0,0 +1,115 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { FetchWalletsError } from "./errors/wallets-manager/fetch-wallets.error";
11
+ import { isWalletInfoInjected } from "./models/wallet/wallet-info";
12
+ import { InjectedProvider } from "./provider/injected/injected-provider";
13
+ export class WalletsListManager {
14
+ constructor() {
15
+ this.walletsListCache = null;
16
+ this.walletsListSource = 'https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json';
17
+ }
18
+ getWallets() {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ if (!this.walletsListCache) {
21
+ this.walletsListCache = this.fetchWalletsList();
22
+ this.walletsListCache.catch(() => (this.walletsListCache = null));
23
+ }
24
+ return this.walletsListCache;
25
+ });
26
+ }
27
+ getEmbeddedWallet() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const walletsList = yield this.getWallets();
30
+ const injectedWallets = walletsList.filter(isWalletInfoInjected);
31
+ if (injectedWallets.length !== 1) {
32
+ return null;
33
+ }
34
+ return injectedWallets[0].embedded ? injectedWallets[0] : null;
35
+ });
36
+ }
37
+ fetchWalletsList() {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ try {
40
+ const walletsResponse = yield fetch(this.walletsListSource);
41
+ const walletsList = yield walletsResponse.json();
42
+ if (!Array.isArray(walletsList) ||
43
+ !walletsList.every(wallet => this.isCorrectWalletConfigDTO(wallet))) {
44
+ throw new FetchWalletsError('Wrong wallets list format');
45
+ }
46
+ return this.walletConfigDTOListToWalletConfigList(walletsList);
47
+ }
48
+ catch (e) {
49
+ throw new FetchWalletsError(e);
50
+ }
51
+ });
52
+ }
53
+ walletConfigDTOListToWalletConfigList(walletConfigDTO) {
54
+ return walletConfigDTO.map(walletConfigDTO => {
55
+ const walletConfig = {
56
+ name: walletConfigDTO.name,
57
+ imageUrl: walletConfigDTO.image,
58
+ aboutUrl: walletConfigDTO.about_url,
59
+ tondns: walletConfigDTO.tondns
60
+ };
61
+ walletConfigDTO.bridge.forEach(bridge => {
62
+ if (bridge.type === 'sse') {
63
+ walletConfig.bridgeUrl = bridge.url;
64
+ walletConfig.universalLink =
65
+ walletConfigDTO.universal_url;
66
+ walletConfig.deepLink = walletConfigDTO.deepLink;
67
+ }
68
+ if (bridge.type === 'js') {
69
+ const jsBridgeKey = bridge.key;
70
+ walletConfig.jsBridgeKey = jsBridgeKey;
71
+ walletConfig.injected =
72
+ InjectedProvider.isWalletInjected(jsBridgeKey);
73
+ walletConfig.embedded =
74
+ InjectedProvider.isInsideWalletBrowser(jsBridgeKey);
75
+ }
76
+ });
77
+ return walletConfig;
78
+ });
79
+ }
80
+ isCorrectWalletConfigDTO(value) {
81
+ if (!value || !(typeof value === 'object')) {
82
+ return false;
83
+ }
84
+ const containsName = 'name' in value;
85
+ const containsImage = 'image' in value;
86
+ const containsAbout = 'about_url' in value;
87
+ if (!containsName || !containsImage || !containsAbout) {
88
+ return false;
89
+ }
90
+ if (!('bridge' in value) ||
91
+ !Array.isArray(value.bridge) ||
92
+ !value.bridge.length) {
93
+ return false;
94
+ }
95
+ const bridge = value.bridge;
96
+ if (bridge.some(item => !item || typeof item !== 'object' || !('type' in item))) {
97
+ return false;
98
+ }
99
+ const sseBridge = bridge.find(item => item.type === 'sse');
100
+ if (sseBridge) {
101
+ if (!('url' in sseBridge) ||
102
+ !sseBridge.url ||
103
+ !value.universal_url) {
104
+ return false;
105
+ }
106
+ }
107
+ const jsBridge = bridge.find(item => item.type === 'js');
108
+ if (jsBridge) {
109
+ if (!('key' in jsBridge) || !jsBridge.key) {
110
+ return false;
111
+ }
112
+ }
113
+ return true;
114
+ }
115
+ }
@@ -0,0 +1 @@
1
+ export { WrongAddressError } from './wrong-address.error';
@@ -0,0 +1,4 @@
1
+ import { TonConnectError } from "..";
2
+ export declare class WrongAddressError extends TonConnectError {
3
+ constructor(...args: ConstructorParameters<typeof Error>);
4
+ }
@@ -0,0 +1,4 @@
1
+ import { TonConnectError } from "..";
2
+ export declare class Base64EncodeError extends TonConnectError {
3
+ constructor(...args: ConstructorParameters<typeof Error>);
4
+ }
@@ -0,0 +1,2 @@
1
+ export { Base64EncodeError } from './base64-encode.error';
2
+ export { ParseHexError } from './parse-hex.error';
@@ -0,0 +1,4 @@
1
+ import { TonConnectError } from "..";
2
+ export declare class ParseHexError extends TonConnectError {
3
+ constructor(...args: ConstructorParameters<typeof Error>);
4
+ }
@@ -2,5 +2,7 @@ export * from './protocol';
2
2
  export * from './wallet';
3
3
  export * from './storage';
4
4
  export * from './wallets-manager';
5
+ export * from './address';
6
+ export * from './binary';
5
7
  export { TonConnectError } from './ton-connect.error';
6
8
  export { UnknownError } from './unknown.error';
@@ -0,0 +1 @@
1
+ export { UserRejectsError } from "./user-rejects.error";
@@ -0,0 +1 @@
1
+ export * from './connect';
@@ -0,0 +1,2 @@
1
+ export * from './events';
2
+ export * from './responses';
@@ -0,0 +1,2 @@
1
+ export { BadRequestError } from './bad-request.error';
2
+ export { UnknownAppError } from './unknown-app.error';
@@ -0,0 +1 @@
1
+ export { LocalstorageNotFoundError } from './localstorage-not-found.error';
File without changes
@@ -0,0 +1,3 @@
1
+ export { WalletAlreadyConnectedError } from './wallet-already-connected.error';
2
+ export { WalletNotConnectedError } from './wallet-not-connected.error';
3
+ export { WalletNotInjectedError } from './wallet-not-injected.error';
@@ -0,0 +1 @@
1
+ export { FetchWalletsError } from './fetch-wallets.error';
@@ -5,3 +5,4 @@ export { IStorage } from './storage/models/storage.interface';
5
5
  export { TonConnect as default } from './ton-connect';
6
6
  export { ITonConnect } from './ton-connect.interface';
7
7
  export { CHAIN, DeviceInfo } from '@tonconnect/protocol';
8
+ export { toUserFriendlyAddress } from './utils/address';
File without changes
@@ -0,0 +1,6 @@
1
+ export interface ConnectAdditionalRequest {
2
+ /**
3
+ * Payload for ton_proof
4
+ */
5
+ tonProof?: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from './connect';
2
+ export * from './send-transaction';
@@ -1,3 +1,2 @@
1
1
  export { SendTransactionRequest } from './send-transaction-request';
2
2
  export { SendTransactionResponse } from './send-transaction-response';
3
- export { SendTransactionOptions } from './send-transaction-options';
File without changes
File without changes
@@ -21,6 +21,10 @@ export interface WalletInfoRemote extends WalletInfoBase {
21
21
  * Base part of the wallet universal url. The link should support [Ton Connect parameters]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#universal-link}.
22
22
  */
23
23
  universalLink: string;
24
+ /**
25
+ * Native wallet app deepLink. The link should support [Ton Connect parameters]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#universal-link}.
26
+ */
27
+ deepLink: string;
24
28
  /**
25
29
  * Url of the wallet's implementation of the [HTTP bridge]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#http-bridge}.
26
30
  */
@@ -41,18 +45,21 @@ export interface WalletInfoInjected extends WalletInfoBase {
41
45
  embedded: boolean;
42
46
  }
43
47
  export declare type WalletInfo = WalletInfoRemote | WalletInfoInjected | (WalletInfoRemote & WalletInfoInjected);
44
- export interface WalletInfoDTOBase {
48
+ export interface WalletInfoDTO {
45
49
  name: string;
46
50
  image: string;
47
51
  tondns?: string;
48
52
  about_url: string;
49
- }
50
- export interface WalletInfoRemoteDTO extends WalletInfoDTOBase {
51
53
  universal_url: string;
52
- bridge_url: string;
54
+ deepLink: string;
55
+ bridge: (WalletInfoBridgeRemoteDTO | WalletInfoBridgeInjectedDTO)[];
56
+ }
57
+ export interface WalletInfoBridgeRemoteDTO {
58
+ type: 'sse';
59
+ url: string;
53
60
  }
54
- export interface WalletInfoInjectedDTO extends WalletInfoDTOBase {
55
- js_bridge_key: string;
61
+ export interface WalletInfoBridgeInjectedDTO {
62
+ type: 'js';
63
+ key: string;
56
64
  }
57
- export declare type WalletInfoDTO = WalletInfoRemoteDTO | WalletInfoInjectedDTO | (WalletInfoRemoteDTO & WalletInfoInjectedDTO);
58
65
  export declare function isWalletInfoInjected(value: WalletInfo): value is WalletInfoInjected;
File without changes
File without changes
@@ -1,11 +1,11 @@
1
- import { ReturnStrategy, SendTransactionRpcRequest, SendTransactionRpcResponseError, SendTransactionRpcResponseSuccess } from '@tonconnect/protocol';
1
+ import { SendTransactionRpcRequest, SendTransactionRpcResponseError, SendTransactionRpcResponseSuccess } from '@tonconnect/protocol';
2
2
  import { SendTransactionRequest, SendTransactionResponse } from "../models/methods";
3
3
  import { RpcParser } from "./rpc-parser";
4
4
  import { WithoutId } from "../utils/types";
5
5
  declare class SendTransactionParser extends RpcParser<'sendTransaction'> {
6
6
  convertToRpcRequest(request: Omit<SendTransactionRequest, 'validUntil'> & {
7
7
  valid_until: number;
8
- }, returnStrategy: ReturnStrategy): WithoutId<SendTransactionRpcRequest>;
8
+ }): WithoutId<SendTransactionRpcRequest>;
9
9
  parseAndThrowError(response: WithoutId<SendTransactionRpcResponseError>): never;
10
10
  convertFromRpcResponse(rpcResponse: WithoutId<SendTransactionRpcResponseSuccess>): SendTransactionResponse;
11
11
  }
@@ -7,6 +7,7 @@ export declare class BridgeGateway {
7
7
  private readonly errorsListener;
8
8
  private readonly ssePath;
9
9
  private readonly postPath;
10
+ private readonly heartbeatMessage;
10
11
  private readonly defaultTtl;
11
12
  private eventSource;
12
13
  private isClosed;
File without changes
@@ -0,0 +1 @@
1
+ export declare const PROTOCOL_VERSION = 2;
@@ -5,7 +5,6 @@ import { ConnectAdditionalRequest } from "./models/methods/connect/connect-addit
5
5
  import { TonConnectOptions } from "./models/ton-connect-options";
6
6
  import { WalletConnectionSourceJS } from "./models/wallet/wallet-connection-source";
7
7
  import { ITonConnect } from "./ton-connect.interface";
8
- import { SendTransactionOptions } from "./models/methods/send-transaction/send-transaction-options";
9
8
  export declare class TonConnect implements ITonConnect {
10
9
  private readonly walletsList;
11
10
  private readonly dappSettings;
@@ -53,11 +52,10 @@ export declare class TonConnect implements ITonConnect {
53
52
  /**
54
53
  * Asks connected wallet to sign and send the transaction.
55
54
  * @param transaction transaction to send.
56
- * @param options request options
57
55
  * @returns signed transaction boc that allows you to find the transaction in the blockchain.
58
56
  * If user rejects transaction, method will throw the corresponding error.
59
57
  */
60
- sendTransaction(transaction: SendTransactionRequest, options: SendTransactionOptions): Promise<SendTransactionResponse>;
58
+ sendTransaction(transaction: SendTransactionRequest): Promise<SendTransactionResponse>;
61
59
  /**
62
60
  * Disconnect form thw connected wallet and drop current session.
63
61
  */
@@ -4,7 +4,6 @@ import { SendTransactionRequest, SendTransactionResponse } from "./models/method
4
4
  import { ConnectAdditionalRequest } from "./models/methods/connect/connect-additional-request";
5
5
  import { WalletInfo } from "./models/wallet/wallet-info";
6
6
  import { WalletConnectionSourceJS } from "./models/wallet/wallet-connection-source";
7
- import { SendTransactionOptions } from "./models/methods/send-transaction/send-transaction-options";
8
7
  export interface ITonConnect {
9
8
  /**
10
9
  * Shows if the wallet is connected right now.
@@ -47,9 +46,8 @@ export interface ITonConnect {
47
46
  /**
48
47
  * Asks connected wallet to sign and send the transaction.
49
48
  * @param transaction transaction to send.
50
- * @param options request options
51
49
  * @returns signed transaction boc that allows you to find the transaction in the blockchain.
52
50
  * If user rejects transaction, method will throw the corresponding error.
53
51
  */
54
- sendTransaction(transaction: SendTransactionRequest, options: SendTransactionOptions): Promise<SendTransactionResponse>;
52
+ sendTransaction(transaction: SendTransactionRequest): Promise<SendTransactionResponse>;
55
53
  }
@@ -0,0 +1 @@
1
+ export declare function toUserFriendlyAddress(hexAddress: string): string;
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tonconnect/sdk",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "scripts": {
5
- "build": "npx rimraf lib && ttsc && npx rimraf dist && webpack --mode development",
6
- "build:production": "npx rimraf lib && ttsc --sourceMap false && npx rimraf dist && webpack --mode production"
5
+ "build": "npx rimraf lib && ttsc --outDir ./lib/cjs && ttsc --module esnext --outDir ./lib/esm && npx rimraf dist && webpack --mode development",
6
+ "build:production": "npx rimraf lib && ttsc --project tsconfig.cjs.json --sourceMap false && ttsc --project tsconfig.esm.json --sourceMap false && npx rimraf dist && webpack --mode production"
7
7
  },
8
8
  "repository": {
9
9
  "type": "git",
@@ -28,14 +28,23 @@
28
28
  "tweetnacl": "^1.0.3",
29
29
  "eventsource": "^2.0.2",
30
30
  "node-fetch": "^2.6.7",
31
- "@tonconnect/protocol": "^0.0.24"
31
+ "@tonconnect/protocol": "^0.0.25"
32
32
  },
33
33
  "files": [
34
34
  "lib",
35
35
  "dist"
36
36
  ],
37
- "main": "./lib/index.js",
38
- "types": "./lib/index.d.ts",
37
+ "main": "./lib/cjs/index.js",
38
+ "module": "./lib/esm/index.js",
39
+ "types": "./lib/types/index.d.ts",
40
+ "exports": {
41
+ ".": {
42
+ "types": "./lib/types/index.d.ts",
43
+ "require": "./lib/cjs/index.js",
44
+ "import": "./lib/esm/index.js",
45
+ "default": "./lib/cjs/index.js"
46
+ }
47
+ },
39
48
  "nx": {
40
49
  "tags": ["scope:sdk"]
41
50
  },
@@ -1,15 +0,0 @@
1
- import { ReturnStrategy } from '@tonconnect/protocol';
2
- export interface ConnectAdditionalRequest {
3
- /**
4
- * Payload for ton_proof
5
- */
6
- tonProof?: string;
7
- /**
8
- * @default 'back'
9
- * Return strategy for deeplinks when the user accepts or declines the request.
10
- * - `'back'` means return to the app which initialized deeplink jump (e.g. browser, native app, ...),
11
- * - `'none'` means no jumps after user action;
12
- * - a URL: wallet will open this URL after completing the user's action. Note, that you shouldn't pass your app's URL if it is a webpage. This option should be used for native apps to work around possible OS-specific issues with `'back'` option.
13
- */
14
- return?: ReturnStrategy;
15
- }
@@ -1,11 +0,0 @@
1
- import { ReturnStrategy } from '@tonconnect/protocol';
2
- export interface SendTransactionOptions {
3
- /**
4
- * @default 'back'
5
- * Return strategy for deeplinks when the user accepts or declines the request.
6
- * - `'back'` means return to the app which initialized deeplink jump (e.g. browser, native app, ...),
7
- * - `'none'` means no jumps after user action;
8
- * - a URL: wallet will open this URL after completing the user's action. Note, that you shouldn't pass your app's URL if it is a webpage. This option should be used for native apps to work around possible OS-specific issues with `'back'` option.
9
- */
10
- return: ReturnStrategy;
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- {
2
- "version": 2
3
- }