@tonconnect/sdk 0.0.11 → 0.0.13
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/lib/errors/protocol/events/connect/user-rejects.error.d.ts +4 -1
- package/lib/errors/protocol/events/connect/user-rejects.error.js +16 -2
- package/lib/errors/protocol/responses/bad-request.error.d.ts +4 -1
- package/lib/errors/protocol/responses/bad-request.error.js +16 -2
- package/lib/errors/protocol/responses/unknown-app.error.d.ts +4 -1
- package/lib/errors/protocol/responses/unknown-app.error.js +16 -2
- package/lib/errors/storage/localstorage-not-found.error.d.ts +4 -1
- package/lib/errors/storage/localstorage-not-found.error.js +16 -2
- package/lib/errors/ton-connect.error.d.ts +1 -1
- package/lib/errors/ton-connect.error.js +7 -3
- package/lib/errors/unknown.error.d.ts +4 -1
- package/lib/errors/unknown.error.js +16 -2
- package/lib/errors/wallet/wallet-already-connected.error.d.ts +4 -1
- package/lib/errors/wallet/wallet-already-connected.error.js +16 -2
- package/lib/errors/wallet/wallet-not-connected.error.d.ts +4 -1
- package/lib/errors/wallet/wallet-not-connected.error.js +16 -2
- package/lib/errors/wallet/wallet-not-injected.error.d.ts +4 -1
- package/lib/errors/wallet/wallet-not-injected.error.js +16 -2
- package/lib/provider/bridge/bridge-gateway.d.ts +3 -1
- package/lib/provider/bridge/bridge-gateway.js +45 -23
- package/lib/provider/bridge/bridge-provider.d.ts +1 -0
- package/lib/provider/bridge/bridge-provider.js +3 -2
- package/lib/storage/bridge-gateway-storage.d.ts +9 -0
- package/lib/storage/bridge-gateway-storage.js +42 -0
- package/package.json +1 -1
- package/lib/errors/generate-error.d.ts +0 -2
- package/lib/errors/generate-error.js +0 -18
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { TonConnectError } from "../../../ton-connect.error";
|
|
2
|
+
export declare class UserRejectsError extends TonConnectError {
|
|
3
|
+
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
4
|
+
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserRejectsError = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ton_connect_error_1 = require("../../../ton-connect.error");
|
|
6
|
+
var UserRejectsError = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(UserRejectsError, _super);
|
|
8
|
+
function UserRejectsError() {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
var _this = _super.apply(this, args) || this;
|
|
14
|
+
Object.setPrototypeOf(_this, UserRejectsError.prototype);
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
return UserRejectsError;
|
|
18
|
+
}(ton_connect_error_1.TonConnectError));
|
|
19
|
+
exports.UserRejectsError = UserRejectsError;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { TonConnectError } from "../../ton-connect.error";
|
|
2
|
+
export declare class BadRequestError extends TonConnectError {
|
|
3
|
+
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
4
|
+
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BadRequestError = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ton_connect_error_1 = require("../../ton-connect.error");
|
|
6
|
+
var BadRequestError = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(BadRequestError, _super);
|
|
8
|
+
function BadRequestError() {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
var _this = _super.apply(this, args) || this;
|
|
14
|
+
Object.setPrototypeOf(_this, BadRequestError.prototype);
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
return BadRequestError;
|
|
18
|
+
}(ton_connect_error_1.TonConnectError));
|
|
19
|
+
exports.BadRequestError = BadRequestError;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { TonConnectError } from "../../ton-connect.error";
|
|
2
|
+
export declare class UnknownAppError extends TonConnectError {
|
|
3
|
+
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
4
|
+
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UnknownAppError = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ton_connect_error_1 = require("../../ton-connect.error");
|
|
6
|
+
var UnknownAppError = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(UnknownAppError, _super);
|
|
8
|
+
function UnknownAppError() {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
var _this = _super.apply(this, args) || this;
|
|
14
|
+
Object.setPrototypeOf(_this, UnknownAppError.prototype);
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
return UnknownAppError;
|
|
18
|
+
}(ton_connect_error_1.TonConnectError));
|
|
19
|
+
exports.UnknownAppError = UnknownAppError;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
export declare class LocalstorageNotFoundError extends TonConnectError {
|
|
3
|
+
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
4
|
+
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LocalstorageNotFoundError = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ton_connect_error_1 = require("../ton-connect.error");
|
|
6
|
+
var LocalstorageNotFoundError = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(LocalstorageNotFoundError, _super);
|
|
8
|
+
function LocalstorageNotFoundError() {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
var _this = _super.apply(this, args) || this;
|
|
14
|
+
Object.setPrototypeOf(_this, LocalstorageNotFoundError.prototype);
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
return LocalstorageNotFoundError;
|
|
18
|
+
}(ton_connect_error_1.TonConnectError));
|
|
19
|
+
exports.LocalstorageNotFoundError = LocalstorageNotFoundError;
|
|
@@ -4,9 +4,13 @@ exports.TonConnectError = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var TonConnectError = /** @class */ (function (_super) {
|
|
6
6
|
tslib_1.__extends(TonConnectError, _super);
|
|
7
|
-
function TonConnectError(
|
|
8
|
-
var
|
|
9
|
-
|
|
7
|
+
function TonConnectError() {
|
|
8
|
+
var args = [];
|
|
9
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10
|
+
args[_i] = arguments[_i];
|
|
11
|
+
}
|
|
12
|
+
var _this = _super.apply(this, args) || this;
|
|
13
|
+
Object.setPrototypeOf(_this, TonConnectError.prototype);
|
|
10
14
|
return _this;
|
|
11
15
|
}
|
|
12
16
|
return TonConnectError;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { TonConnectError } from "./ton-connect.error";
|
|
2
|
+
export declare class UnknownError extends TonConnectError {
|
|
3
|
+
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
4
|
+
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UnknownError = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ton_connect_error_1 = require("./ton-connect.error");
|
|
6
|
+
var UnknownError = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(UnknownError, _super);
|
|
8
|
+
function UnknownError() {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
var _this = _super.apply(this, args) || this;
|
|
14
|
+
Object.setPrototypeOf(_this, UnknownError.prototype);
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
return UnknownError;
|
|
18
|
+
}(ton_connect_error_1.TonConnectError));
|
|
19
|
+
exports.UnknownError = UnknownError;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
export declare class WalletAlreadyConnectedError extends TonConnectError {
|
|
3
|
+
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
4
|
+
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WalletAlreadyConnectedError = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ton_connect_error_1 = require("../ton-connect.error");
|
|
6
|
+
var WalletAlreadyConnectedError = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(WalletAlreadyConnectedError, _super);
|
|
8
|
+
function WalletAlreadyConnectedError() {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
var _this = _super.apply(this, args) || this;
|
|
14
|
+
Object.setPrototypeOf(_this, WalletAlreadyConnectedError.prototype);
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
return WalletAlreadyConnectedError;
|
|
18
|
+
}(ton_connect_error_1.TonConnectError));
|
|
19
|
+
exports.WalletAlreadyConnectedError = WalletAlreadyConnectedError;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
export declare class WalletNotConnectedError extends TonConnectError {
|
|
3
|
+
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
4
|
+
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WalletNotConnectedError = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ton_connect_error_1 = require("../ton-connect.error");
|
|
6
|
+
var WalletNotConnectedError = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(WalletNotConnectedError, _super);
|
|
8
|
+
function WalletNotConnectedError() {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
var _this = _super.apply(this, args) || this;
|
|
14
|
+
Object.setPrototypeOf(_this, WalletNotConnectedError.prototype);
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
return WalletNotConnectedError;
|
|
18
|
+
}(ton_connect_error_1.TonConnectError));
|
|
19
|
+
exports.WalletNotConnectedError = WalletNotConnectedError;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
export declare class WalletNotInjectedError extends TonConnectError {
|
|
3
|
+
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
4
|
+
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WalletNotInjectedError = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var ton_connect_error_1 = require("../ton-connect.error");
|
|
6
|
+
var WalletNotInjectedError = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(WalletNotInjectedError, _super);
|
|
8
|
+
function WalletNotInjectedError() {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
var _this = _super.apply(this, args) || this;
|
|
14
|
+
Object.setPrototypeOf(_this, WalletNotInjectedError.prototype);
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
return WalletNotInjectedError;
|
|
18
|
+
}(ton_connect_error_1.TonConnectError));
|
|
19
|
+
exports.WalletNotInjectedError = WalletNotInjectedError;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BridgeIncomingMessage } from "./models/bridge-incomming-message";
|
|
2
|
+
import { IStorage } from "../../storage/models/storage.interface";
|
|
2
3
|
export declare class BridgeGateway {
|
|
3
4
|
private readonly bridgeUrl;
|
|
4
5
|
readonly sessionId: string;
|
|
@@ -9,7 +10,8 @@ export declare class BridgeGateway {
|
|
|
9
10
|
private readonly defaultTtl;
|
|
10
11
|
private eventSource;
|
|
11
12
|
private isClosed;
|
|
12
|
-
|
|
13
|
+
private readonly bridgeGatewayStorage;
|
|
14
|
+
constructor(storage: IStorage, bridgeUrl: string, sessionId: string, listener: (msg: BridgeIncomingMessage) => void, errorsListener: (err: Event) => void);
|
|
13
15
|
registerSession(): Promise<void>;
|
|
14
16
|
send(message: Uint8Array, receiver: string, ttl?: number): Promise<void>;
|
|
15
17
|
close(): void;
|
|
@@ -4,9 +4,10 @@ exports.BridgeGateway = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var protocol_1 = require("@tonconnect/protocol");
|
|
6
6
|
var errors_1 = require("../../errors");
|
|
7
|
+
var bridge_gateway_storage_1 = require("../../storage/bridge-gateway-storage");
|
|
7
8
|
var url_1 = require("../../utils/url");
|
|
8
9
|
var BridgeGateway = /** @class */ (function () {
|
|
9
|
-
function BridgeGateway(bridgeUrl, sessionId, listener, errorsListener) {
|
|
10
|
+
function BridgeGateway(storage, bridgeUrl, sessionId, listener, errorsListener) {
|
|
10
11
|
this.bridgeUrl = bridgeUrl;
|
|
11
12
|
this.sessionId = sessionId;
|
|
12
13
|
this.listener = listener;
|
|
@@ -15,23 +16,33 @@ var BridgeGateway = /** @class */ (function () {
|
|
|
15
16
|
this.postPath = 'message';
|
|
16
17
|
this.defaultTtl = 300;
|
|
17
18
|
this.isClosed = false;
|
|
19
|
+
this.bridgeGatewayStorage = new bridge_gateway_storage_1.BridgeGatewayStorage(storage);
|
|
18
20
|
}
|
|
19
21
|
BridgeGateway.prototype.registerSession = function () {
|
|
20
22
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
21
|
-
var url;
|
|
23
|
+
var url, lastEventId;
|
|
22
24
|
var _this = this;
|
|
23
25
|
return tslib_1.__generator(this, function (_a) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
26
|
+
switch (_a.label) {
|
|
27
|
+
case 0:
|
|
28
|
+
url = new URL((0, url_1.addPathToUrl)(this.bridgeUrl, this.ssePath));
|
|
29
|
+
url.searchParams.append('client_id', this.sessionId);
|
|
30
|
+
return [4 /*yield*/, this.bridgeGatewayStorage.getLastEventId()];
|
|
31
|
+
case 1:
|
|
32
|
+
lastEventId = _a.sent();
|
|
33
|
+
if (lastEventId) {
|
|
34
|
+
url.searchParams.append('last_event_id', lastEventId);
|
|
35
|
+
}
|
|
36
|
+
this.eventSource = new EventSource(url);
|
|
37
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
38
|
+
_this.eventSource.onerror = reject;
|
|
39
|
+
_this.eventSource.onopen = function () {
|
|
40
|
+
_this.eventSource.onerror = _this.errorsHandler.bind(_this);
|
|
41
|
+
_this.eventSource.onmessage = _this.messagesHandler.bind(_this);
|
|
42
|
+
resolve();
|
|
43
|
+
};
|
|
44
|
+
})];
|
|
45
|
+
}
|
|
35
46
|
});
|
|
36
47
|
});
|
|
37
48
|
};
|
|
@@ -67,16 +78,27 @@ var BridgeGateway = /** @class */ (function () {
|
|
|
67
78
|
}
|
|
68
79
|
};
|
|
69
80
|
BridgeGateway.prototype.messagesHandler = function (e) {
|
|
70
|
-
|
|
71
|
-
var bridgeIncomingMessage
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
82
|
+
var bridgeIncomingMessage;
|
|
83
|
+
return tslib_1.__generator(this, function (_a) {
|
|
84
|
+
switch (_a.label) {
|
|
85
|
+
case 0: return [4 /*yield*/, this.bridgeGatewayStorage.storeLastEventId(e.lastEventId)];
|
|
86
|
+
case 1:
|
|
87
|
+
_a.sent();
|
|
88
|
+
if (!this.isClosed) {
|
|
89
|
+
bridgeIncomingMessage = void 0;
|
|
90
|
+
try {
|
|
91
|
+
bridgeIncomingMessage = JSON.parse(e.data);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
throw new errors_1.TonConnectError("Bridge message parse failed, message ".concat(e.data));
|
|
95
|
+
}
|
|
96
|
+
this.listener(bridgeIncomingMessage);
|
|
97
|
+
}
|
|
98
|
+
return [2 /*return*/];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
80
102
|
};
|
|
81
103
|
return BridgeGateway;
|
|
82
104
|
}());
|
|
@@ -4,6 +4,7 @@ import { HTTPProvider } from "../provider";
|
|
|
4
4
|
import { IStorage } from "../../storage/models/storage.interface";
|
|
5
5
|
import { WithoutId } from "../../utils/types";
|
|
6
6
|
export declare class BridgeProvider implements HTTPProvider {
|
|
7
|
+
private readonly storage;
|
|
7
8
|
private readonly walletConnectionSource;
|
|
8
9
|
readonly type = "http";
|
|
9
10
|
private readonly universalLinkPath;
|
|
@@ -10,6 +10,7 @@ var protocol = tslib_1.__importStar(require("../../resources/protocol.json"));
|
|
|
10
10
|
var url_1 = require("../../utils/url");
|
|
11
11
|
var BridgeProvider = /** @class */ (function () {
|
|
12
12
|
function BridgeProvider(storage, walletConnectionSource) {
|
|
13
|
+
this.storage = storage;
|
|
13
14
|
this.walletConnectionSource = walletConnectionSource;
|
|
14
15
|
this.type = 'http';
|
|
15
16
|
this.universalLinkPath = 'ton-connect';
|
|
@@ -28,7 +29,7 @@ var BridgeProvider = /** @class */ (function () {
|
|
|
28
29
|
sessionCrypto: sessionCrypto,
|
|
29
30
|
walletConnectionSource: this.walletConnectionSource
|
|
30
31
|
};
|
|
31
|
-
this.bridge = new bridge_gateway_1.BridgeGateway(this.walletConnectionSource.bridgeUrl, sessionCrypto.sessionId, this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this));
|
|
32
|
+
this.bridge = new bridge_gateway_1.BridgeGateway(this.storage, this.walletConnectionSource.bridgeUrl, sessionCrypto.sessionId, this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this));
|
|
32
33
|
this.bridge.registerSession();
|
|
33
34
|
return this.generateUniversalLink(message);
|
|
34
35
|
};
|
|
@@ -47,7 +48,7 @@ var BridgeProvider = /** @class */ (function () {
|
|
|
47
48
|
return [2 /*return*/];
|
|
48
49
|
}
|
|
49
50
|
this.session = storedConnection.session;
|
|
50
|
-
this.bridge = new bridge_gateway_1.BridgeGateway(this.walletConnectionSource.bridgeUrl, storedConnection.session.sessionCrypto.sessionId, this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this));
|
|
51
|
+
this.bridge = new bridge_gateway_1.BridgeGateway(this.storage, this.walletConnectionSource.bridgeUrl, storedConnection.session.sessionCrypto.sessionId, this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this));
|
|
51
52
|
return [4 /*yield*/, this.bridge.registerSession()];
|
|
52
53
|
case 2:
|
|
53
54
|
_b.sent();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IStorage } from "./models/storage.interface";
|
|
2
|
+
export declare class BridgeGatewayStorage {
|
|
3
|
+
private readonly storage;
|
|
4
|
+
private readonly storeKey;
|
|
5
|
+
constructor(storage: IStorage);
|
|
6
|
+
storeLastEventId(lastEventId: string): Promise<void>;
|
|
7
|
+
removeLastEventId(): Promise<void>;
|
|
8
|
+
getLastEventId(): Promise<string | null>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BridgeGatewayStorage = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var BridgeGatewayStorage = /** @class */ (function () {
|
|
6
|
+
function BridgeGatewayStorage(storage) {
|
|
7
|
+
this.storage = storage;
|
|
8
|
+
this.storeKey = 'ton-connect-storage_http-bridge-gateway';
|
|
9
|
+
}
|
|
10
|
+
BridgeGatewayStorage.prototype.storeLastEventId = function (lastEventId) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
12
|
+
return tslib_1.__generator(this, function (_a) {
|
|
13
|
+
return [2 /*return*/, this.storage.setItem(this.storeKey, lastEventId)];
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
BridgeGatewayStorage.prototype.removeLastEventId = function () {
|
|
18
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
19
|
+
return tslib_1.__generator(this, function (_a) {
|
|
20
|
+
return [2 /*return*/, this.storage.removeItem(this.storeKey)];
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
BridgeGatewayStorage.prototype.getLastEventId = function () {
|
|
25
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
26
|
+
var stored;
|
|
27
|
+
return tslib_1.__generator(this, function (_a) {
|
|
28
|
+
switch (_a.label) {
|
|
29
|
+
case 0: return [4 /*yield*/, this.storage.getItem(this.storeKey)];
|
|
30
|
+
case 1:
|
|
31
|
+
stored = _a.sent();
|
|
32
|
+
if (!stored) {
|
|
33
|
+
return [2 /*return*/, null];
|
|
34
|
+
}
|
|
35
|
+
return [2 /*return*/, stored];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return BridgeGatewayStorage;
|
|
41
|
+
}());
|
|
42
|
+
exports.BridgeGatewayStorage = BridgeGatewayStorage;
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateError = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var ton_connect_error_1 = require("./ton-connect.error");
|
|
6
|
-
function generateError(ExtendsFrom) {
|
|
7
|
-
if (ExtendsFrom === void 0) { ExtendsFrom = ton_connect_error_1.TonConnectError; }
|
|
8
|
-
return /** @class */ (function (_super) {
|
|
9
|
-
tslib_1.__extends(class_1, _super);
|
|
10
|
-
function class_1(message) {
|
|
11
|
-
var _this = _super.call(this, message) || this;
|
|
12
|
-
Object.setPrototypeOf(_this, ExtendsFrom.prototype);
|
|
13
|
-
return _this;
|
|
14
|
-
}
|
|
15
|
-
return class_1;
|
|
16
|
-
}(ExtendsFrom));
|
|
17
|
-
}
|
|
18
|
-
exports.generateError = generateError;
|