@ikas/app-helpers
Advanced tools
Comparing version 1.0.1-alpha.10 to 1.0.1-alpha.11
@@ -67,14 +67,22 @@ "use strict"; | ||
static getNewToken() { | ||
return new Promise((resolve) => { | ||
const callback = (msg) => { | ||
var _a, _b, _c; | ||
if (((_a = msg.data) === null || _a === void 0 ? void 0 : _a.type) === AppBridgeCallbackMessageType.REQUEST_TOKEN) { | ||
const token = (_c = (_b = msg.data) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.token; | ||
resolve(token); | ||
} | ||
resolve(undefined); | ||
AppBridgeHelper.stopListener(callback); | ||
}; | ||
AppBridgeHelper.startListener(callback); | ||
AppBridgeHelper.requestToken(); | ||
return new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => reject('Timed out'), 30000); | ||
try { | ||
const callback = (msg) => { | ||
var _a, _b, _c; | ||
if (((_a = msg.data) === null || _a === void 0 ? void 0 : _a.type) === AppBridgeCallbackMessageType.REQUEST_TOKEN) { | ||
const token = (_c = (_b = msg.data) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.token; | ||
resolve(token); | ||
} | ||
resolve(undefined); | ||
AppBridgeHelper.stopListener(callback); | ||
clearTimeout(timer); | ||
}; | ||
AppBridgeHelper.startListener(callback); | ||
AppBridgeHelper.requestToken(); | ||
} | ||
catch (e) { | ||
clearTimeout(timer); | ||
reject(e); | ||
} | ||
}); | ||
@@ -81,0 +89,0 @@ } |
{ | ||
"name": "@ikas/app-helpers", | ||
"version": "1.0.1-alpha.10", | ||
"version": "1.0.1-alpha.11", | ||
"description": "ikas store app helpers", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -80,16 +80,23 @@ export class AppBridgeHelper { | ||
static getNewToken(): Promise<string | undefined> { | ||
return new Promise((resolve) => { | ||
const callback = (msg: MessageEvent) => { | ||
if (msg.data?.type === AppBridgeCallbackMessageType.REQUEST_TOKEN) { | ||
const token = msg.data?.data?.token; | ||
resolve(token); | ||
} | ||
resolve(undefined); | ||
return new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => reject('Timed out'), 30000); | ||
try { | ||
const callback = (msg: MessageEvent) => { | ||
if (msg.data?.type === AppBridgeCallbackMessageType.REQUEST_TOKEN) { | ||
const token = msg.data?.data?.token; | ||
resolve(token); | ||
} | ||
resolve(undefined); | ||
AppBridgeHelper.stopListener(callback); | ||
}; | ||
AppBridgeHelper.stopListener(callback); | ||
clearTimeout(timer); | ||
}; | ||
AppBridgeHelper.startListener(callback); | ||
AppBridgeHelper.startListener(callback); | ||
AppBridgeHelper.requestToken(); | ||
AppBridgeHelper.requestToken(); | ||
} catch (e) { | ||
clearTimeout(timer); | ||
reject(e); | ||
} | ||
}); | ||
@@ -96,0 +103,0 @@ } |
Sorry, the diff of this file is not supported yet
18314
307