Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} = opts
const { onError = onErrorNop } = callbacks
let state: ClientState
const message: ConnectionMessage = {
apiKey,
appId,
hideKeys,
vendorName,
vendorImageUrl,
clientDispatch: message => clientDispatch(state, message)
}
// Set up the frame:
const frame = makeFrame(assetsPath)
return postRobot
.send(frame, 'connect', message, { timeout: frameTimeout })
.then((reply: PostRobotEvent) => {
const frameDispatch: any = reply.data.frameDispatch
state = {
accounts: {},
appId,
createCurrencyWallet: reply.data.createCurrencyWallet,
createWallet: reply.data.createWallet,
signEthereumTransaction: reply.data.signEthereumTransaction,
frame,
frameDispatch,
localUsers: reply.data.localUsers,
onClose: void 0,
onError,
onLogin: void 0
}
export function openURL(url) {
return postRobot.send(window.top, "bcup-open-url", { url });
}
new Promise((resolve, reject) => {
postRobot
.send(this.iframe, Events.HAS_AUTHORIZED, {
integrationId,
clientId: Bearer.config.clientId
})
.then(({ data, data: { authorized } }: { data: { authorized: boolean } }) => {
logger('HAS_AUTHORIZED response %j', data)
authorized ? resolve(true) : reject(false)
})
.catch(iframeError)
})
export function getTopURL() {
return postRobot.send(window.top, "bcup-get-url").then(response => {
return response.data;
});
}
export function closeDialog() {
return postRobot.send(window.top, "bcup-close-dialog");
}
revokeAuthorization = (integrationId: string, authId: string): void => {
postRobot
.send(this.iframe, Events.REVOKE, {
authId,
integrationId,
clientId: Bearer.config.clientId
})
.then(() => {
logger('Signing out')
})
.catch(iframeError)
}