@tonconnect/sdk
Advanced tools
Comparing version 0.0.22 to 0.0.23
@@ -17,2 +17,13 @@ "use strict"; | ||
const url_1 = require("../../utils/url"); | ||
const web_api_1 = require("../../utils/web-api"); | ||
if ((0, web_api_1.isNode)()) { | ||
try { | ||
// noinspection JSConstantReassignment | ||
global.EventSource = require('eventsource'); | ||
global.fetch = require('node-fetch'); | ||
} | ||
catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
class BridgeGateway { | ||
@@ -38,3 +49,3 @@ constructor(storage, bridgeUrl, sessionId, listener, errorsListener) { | ||
} | ||
this.eventSource = new EventSource(url); | ||
this.eventSource = new EventSource(url.toString()); | ||
return new Promise((resolve, reject) => { | ||
@@ -41,0 +52,0 @@ this.eventSource.onerror = reject; |
@@ -134,3 +134,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
throw new ton_connect_error_1.TonConnectError(`Bridge error ${e}`); | ||
throw new ton_connect_error_1.TonConnectError(`Bridge error ${JSON.stringify(e)}`); | ||
}); | ||
@@ -137,0 +137,0 @@ } |
@@ -39,2 +39,3 @@ "use strict"; | ||
const bridge_connection_storage_1 = require("../../storage/bridge-connection-storage"); | ||
const web_api_1 = require("../../utils/web-api"); | ||
class InjectedProvider { | ||
@@ -69,3 +70,3 @@ constructor(injectedWalletKey) { | ||
static isWindowContainsWallet(window, injectedWalletKey) { | ||
return (window && | ||
return (!!window && | ||
injectedWalletKey in window && | ||
@@ -149,2 +150,2 @@ typeof window[injectedWalletKey] === 'object' && | ||
exports.InjectedProvider = InjectedProvider; | ||
InjectedProvider.window = window; | ||
InjectedProvider.window = (0, web_api_1.getWindow)(); |
import { IStorage } from "./models/storage.interface"; | ||
export declare class DefaultStorage implements IStorage { | ||
private readonly window; | ||
constructor(); | ||
@@ -4,0 +5,0 @@ getItem(key: string): Promise<string | null>; |
@@ -14,11 +14,14 @@ "use strict"; | ||
const localstorage_not_found_error_1 = require("../errors/storage/localstorage-not-found.error"); | ||
const web_api_1 = require("../utils/web-api"); | ||
class DefaultStorage { | ||
constructor() { | ||
const window = (0, web_api_1.getWindow)(); | ||
if (!(window === null || window === void 0 ? void 0 : window.localStorage)) { | ||
throw new localstorage_not_found_error_1.LocalstorageNotFoundError(); | ||
} | ||
this.window = window; | ||
} | ||
getItem(key) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return Promise.resolve(window.localStorage.getItem(key)); | ||
return Promise.resolve(this.window.localStorage.getItem(key)); | ||
}); | ||
@@ -28,3 +31,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
window.localStorage.removeItem(key); | ||
this.window.localStorage.removeItem(key); | ||
return Promise.resolve(); | ||
@@ -34,3 +37,3 @@ }); | ||
setItem(key, value) { | ||
window.localStorage.setItem(key, value); | ||
this.window.localStorage.setItem(key, value); | ||
return Promise.resolve(); | ||
@@ -37,0 +40,0 @@ } |
import { DappMetadata } from "../models"; | ||
export declare function getWindow(): Window | undefined; | ||
export declare function getDocument(): Document | undefined; | ||
export declare function isNode(): boolean; | ||
export declare function getWebPageMetadata(): DappMetadata; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getWebPageMetadata = void 0; | ||
exports.getWebPageMetadata = exports.isNode = exports.getDocument = exports.getWindow = void 0; | ||
function getWindow() { | ||
if (typeof window === 'undefined') { | ||
return undefined; | ||
} | ||
return window; | ||
} | ||
exports.getWindow = getWindow; | ||
function getDocument() { | ||
if (typeof document === 'undefined') { | ||
return undefined; | ||
} | ||
return document; | ||
} | ||
exports.getDocument = getDocument; | ||
function isNode() { | ||
return typeof require === 'function' && typeof global === 'object'; | ||
} | ||
exports.isNode = isNode; | ||
function getWebPageMetadata() { | ||
var _a, _b; | ||
return { | ||
url: (window === null || window === void 0 ? void 0 : window.location.origin) || '', | ||
url: ((_a = getWindow()) === null || _a === void 0 ? void 0 : _a.location.origin) || '', | ||
icon: getIconUrl(), | ||
name: (document === null || document === void 0 ? void 0 : document.title) || 'Unknown dapp' | ||
name: ((_b = getDocument()) === null || _b === void 0 ? void 0 : _b.title) || 'Unknown dapp' | ||
}; | ||
@@ -13,2 +32,6 @@ } | ||
function getIconUrl() { | ||
const document = getDocument(); | ||
if (!document) { | ||
return ''; | ||
} | ||
const appleTouchIcons = document.querySelectorAll("link[rel='apple-touch-icon']"); | ||
@@ -15,0 +38,0 @@ if (appleTouchIcons === null || appleTouchIcons === void 0 ? void 0 : appleTouchIcons.length) { |
{ | ||
"name": "@tonconnect/sdk", | ||
"version": "0.0.22", | ||
"version": "0.0.23", | ||
"scripts": { | ||
@@ -29,2 +29,4 @@ "build": "npx rimraf lib && ttsc", | ||
"tweetnacl": "^1.0.3", | ||
"eventsource": "^2.0.2", | ||
"node-fetch": "^2.6.7", | ||
"@tonconnect/protocol": "^0.0.11" | ||
@@ -31,0 +33,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101526
1928
5
+ Addedeventsource@^2.0.2
+ Addednode-fetch@^2.6.7
+ Addedeventsource@2.0.2(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)