Skip to content

Commit

Permalink
Merge branch 'plugin-initial' of github.com:XPRNetwork/wallet-plugin-…
Browse files Browse the repository at this point in the history
…webauth into plugin-initial
  • Loading branch information
andreyjamer committed Nov 24, 2023
2 parents 4f29f33 + eeda168 commit febbdb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import {
PromptResponse,
PublicKey,
ResolvedSigningRequest,
Serializer, TransactContext, WalletPluginConfig,
Serializer,
TransactContext,
WalletPluginConfig,
WalletPluginLoginResponse,
WalletPluginMetadata,
WalletPluginSignResponse
WalletPluginSignResponse,
} from '@wharfkit/session'
import {
extractSignaturesFromCallback,
Expand All @@ -34,7 +36,7 @@ import { inBrowserPayload, isInBrowserPayload } from './types'

import defaultTranslations from './translations'

type ProtonScheme = 'esr' | 'proton' | 'proton-dev';
type ProtonScheme = 'esr' | 'proton' | 'proton-dev'

interface WalletPluginOptions {
buoyUrl?: string
Expand Down Expand Up @@ -70,8 +72,8 @@ export class WalletPluginWebAuth extends AbstractWalletPlugin {

this.buoyUrl = options?.buoyUrl || 'https://cb.anchor.link'
this.buoyWs = options?.buoyWs
if(options?.scheme) {
this.scheme = options.scheme;
if (options?.scheme) {
this.scheme = options.scheme
}

this.browserTransport = new BrowserTransport({ scheme: this.scheme });
Expand Down Expand Up @@ -127,11 +129,11 @@ export class WalletPluginWebAuth extends AbstractWalletPlugin {
const browserLogin = new Deferred<inBrowserPayload>();

// Create the identity request to be presented to the user
const { callback, request, requestKey, privateKey } = await createIdentityRequest(
const {callback, request, requestKey, privateKey} = await createIdentityRequest(
context,
this.buoyUrl
)

// Tell Wharf we need to prompt the user with a QR code and a button
const promptResponse = context.ui?.prompt({
title: t('login.title', {default: 'Connect with WebAuth'}),
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export async function createIdentityRequest(
identity: {
permission: undefined,
},
broadcast: false
broadcast: false,
},
context.esrOptions
)

request.setInfoKey('req_account', String(context.appName));
request.setInfoKey('req_account', String(context.appName))

// Return the request and the callback data
return {
Expand Down Expand Up @@ -89,4 +89,4 @@ function prepareCallbackChannel(buoyUrl): ReceiveOptions {
service: buoyUrl,
channel: uuid(),
}
}
}

0 comments on commit febbdb9

Please sign in to comment.