Skip to content

Commit

Permalink
fix prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
metallicusdev committed Oct 31, 2023
1 parent 1355be2 commit eeda168
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
26 changes: 15 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { send } from '@greymass/buoy'
import {send} from '@greymass/buoy'
import {
AbstractWalletPlugin,
CallbackPayload,
Expand All @@ -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 @@ -28,11 +30,11 @@ import {
} from '@wharfkit/protocol-esr'

import WebSocket from 'isomorphic-ws'
import { createIdentityRequest } from './utils'
import {createIdentityRequest} from './utils'

// import defaultTranslations from './translations'

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

interface WalletPluginOptions {
buoyUrl?: string
Expand Down Expand Up @@ -67,8 +69,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
}
}

Expand Down Expand Up @@ -119,13 +121,13 @@ export class WalletPluginWebAuth extends AbstractWalletPlugin {
}

const t = context.ui.getTranslate(this.id)

// 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 Expand Up @@ -251,7 +253,9 @@ export class WalletPluginWebAuth extends AbstractWalletPlugin {
label: t('transact.sign_manually.link.title', {default: 'Open WebAuth'}),
data: {
href: String(request),
label: t('transact.sign_manually.link.title', {default: 'Open WebAuth'}),
label: t('transact.sign_manually.link.title', {
default: 'Open WebAuth',
}),
},
},
],
Expand Down
19 changes: 12 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ReceiveOptions } from '@greymass/buoy'
import { BuoySession, IdentityRequestResponse, getUserAgent, prepareCallback, uuid } from '@wharfkit/protocol-esr'
import { LoginContext, PrivateKey, SigningRequest } from '@wharfkit/session'
import {ReceiveOptions} from '@greymass/buoy'
import {
BuoySession,
getUserAgent,
IdentityRequestResponse,
prepareCallback,
uuid,
} from '@wharfkit/protocol-esr'
import {LoginContext, PrivateKey, SigningRequest} from '@wharfkit/session'

/**
* createIdentityRequest
Expand Down Expand Up @@ -42,12 +48,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 All @@ -58,10 +64,9 @@ export async function createIdentityRequest(
}
}


function prepareCallbackChannel(buoyUrl): ReceiveOptions {
return {
service: buoyUrl,
channel: uuid(),
}
}
}

0 comments on commit eeda168

Please sign in to comment.