From 05c79d040b519f0ad7004812758e4ba7d4ac95eb Mon Sep 17 00:00:00 2001 From: aaroncox Date: Sat, 27 Sep 2025 14:23:44 -0700 Subject: [PATCH 1/9] Renamed keys --- src/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 61d0998..f942505 100644 --- a/src/index.ts +++ b/src/index.ts @@ -228,8 +228,8 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement context.ui ) - this.data.privateKey = String(privateKey) - this.data.publicKey = payload.link_key + this.data.encryptionKey = String(privateKey) + this.data.messageKey = payload.link_key if (!payload.cid) { throw new Error('Login failed: No chain ID returned') @@ -274,7 +274,7 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement ): Promise { try { // Ensure we have a request key from login - if (!this.data.privateKey || !this.data.publicKey) { + if (!this.data.encryptionKey || !this.data.messageKey) { throw new Error('No request keys available - please login first') } @@ -299,8 +299,8 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement const sealedRequest = await sealMessage( modifiedRequest.encode(), - PrivateKey.from(this.data.privateKey), - PublicKey.from(this.data.publicKey), + PrivateKey.from(this.data.encryptionKey), + PublicKey.from(this.data.messageKey), nonce ) @@ -310,7 +310,7 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement context.accountName }&permissionName=${context.permissionName}&appName=${ context.appName - }&requestKey=${String(PrivateKey.from(this.data.privateKey).toPublic())}` + }&requestKey=${String(PrivateKey.from(this.data.encryptionKey).toPublic())}` const response = await this.openPopup(signUrl, callback, context.ui) From cc177d42c40847b6f6368bf65f3cc869478c3e6b Mon Sep 17 00:00:00 2001 From: aaroncox Date: Sat, 27 Sep 2025 14:23:57 -0700 Subject: [PATCH 2/9] v0.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e0f48b7..38a0fc7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-web-authenticator", "description": "A Web Authenticator wallet plugin for use with @wharfkit/session.", - "version": "0.3.1", + "version": "0.4.0", "homepage": "https://github.com/wharfkit/wallet-plugin-web-authenticator", "license": "BSD-3-Clause", "main": "lib/wallet-plugin-web-authenticator.js", From 28f36b316d5ce8aefc46486857029ea386d1f1d9 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Sat, 27 Sep 2025 18:29:21 -0700 Subject: [PATCH 3/9] Fixed tests --- test/tests/common.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/tests/common.ts b/test/tests/common.ts index ee896ee..80ffa1a 100644 --- a/test/tests/common.ts +++ b/test/tests/common.ts @@ -1,5 +1,5 @@ import {Chains, SessionKit} from '@wharfkit/session' -import {PermissionLevel, Signature, APIClient, PrivateKey} from '@wharfkit/antelope' +import {APIClient, PermissionLevel, PrivateKey, Signature} from '@wharfkit/antelope' import { mockChainDefinition, mockPermissionLevel, @@ -9,21 +9,21 @@ import { } from '@wharfkit/mock-data' import {assert} from 'chai' import { - LoginContext, - ResolvedSigningRequest, - TransactContext, - ChainDefinition, ABICacheInterface, - WalletPluginSignResponse, - UserInterface, Cancelable, + ChainDefinition, + CreateAccountContext, + LoginContext, + LoginHooks, PromptArgs, PromptResponse, + ResolvedSigningRequest, + TransactContext, TransactHooks, - LoginHooks, - UserInterfaceLoginResponse, + UserInterface, UserInterfaceAccountCreationResponse, - CreateAccountContext, + UserInterfaceLoginResponse, + WalletPluginSignResponse, } from '@wharfkit/session' import {WalletPluginWebAuthenticator} from '$lib' @@ -235,8 +235,8 @@ suite('wallet plugin', function () { // Use different keys for the sign test to avoid channel ID conflicts const signPrivateKey = PrivateKey.generate('K1') const signPublicKey = signPrivateKey.toPublic() - plugin.data.privateKey = signPrivateKey - plugin.data.publicKey = signPublicKey + plugin.data.encryptionKey = signPrivateKey + plugin.data.messageKey = signPublicKey const mockResolvedSigningRequest = await makeMockResolvedSigningRequest() From b2dea4e352361d2657571a60baa7fce38b067ef9 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Fri, 24 Oct 2025 14:00:28 -0700 Subject: [PATCH 4/9] Allow multiple chains and URLs --- src/index.ts | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index f942505..e911878 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,8 +29,8 @@ import WebSocket from 'isomorphic-ws' import defaultTranslations from './translations' interface WebAuthenticatorOptions { - /** The URL of the web authenticator service */ - webAuthenticatorUrl?: string + /** The URLs for the web authenticator service, keyed by chain ID */ + urls: Record /** The buoy service URL for messaging */ buoyServiceUrl?: string /** The buoy WebSocket for messaging */ @@ -38,13 +38,13 @@ interface WebAuthenticatorOptions { } export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implements WalletPlugin { - private webAuthenticatorUrl: string + private urls: Record private buoyServiceUrl: string private buoyWs?: WebSocket - constructor(options: WebAuthenticatorOptions = {}) { + constructor(options: WebAuthenticatorOptions) { super() - this.webAuthenticatorUrl = options.webAuthenticatorUrl || 'http://localhost:5174' + this.urls = options.urls this.buoyServiceUrl = options.buoyServiceUrl || 'https://cb.anchor.link' this.buoyWs = options?.buoyWs } @@ -85,6 +85,24 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement */ translations = defaultTranslations + getChainUrl(context: LoginContext | TransactContext): string { + // default to first + let url = this.urls[0] + + // override if chain specified + if (context.chain) { + url = this.urls[String(context.chain.id)] + } + + if (!url) { + throw new Error( + `No web authenticator URL configured for chain ID: ${context.chain?.id}` + ) + } + + return url + } + /** * Opens a popup window with the given URL and waits for it to complete */ @@ -218,7 +236,8 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement privateKey, } = await createIdentityRequest(context, this.buoyServiceUrl) - const loginUrl = `${this.webAuthenticatorUrl}/sign?esr=${request.encode()}&chain=${ + const url = this.getChainUrl(context) + const loginUrl = `${url}/sign?esr=${request.encode()}&chain=${ context.chain?.id }&requestKey=${requestKey}` @@ -304,7 +323,8 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement nonce ) - const signUrl = `${this.webAuthenticatorUrl}/sign?sealed=${sealedRequest.toString( + const url = this.getChainUrl(context) + const signUrl = `${url}/sign?sealed=${sealedRequest.toString( 'hex' )}&nonce=${nonce.toString()}&chain=${context.chain?.id}&accountName=${ context.accountName From b7bd9555759663a553c1813ebba3ec6225b79f65 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Fri, 24 Oct 2025 14:00:43 -0700 Subject: [PATCH 5/9] v0.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 38a0fc7..90a6a86 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-web-authenticator", "description": "A Web Authenticator wallet plugin for use with @wharfkit/session.", - "version": "0.4.0", + "version": "0.5.0", "homepage": "https://github.com/wharfkit/wallet-plugin-web-authenticator", "license": "BSD-3-Clause", "main": "lib/wallet-plugin-web-authenticator.js", From 6149fffd1ef26f41c737a9c353ca958b7d931e4b Mon Sep 17 00:00:00 2001 From: aaroncox Date: Tue, 4 Nov 2025 22:35:40 -0800 Subject: [PATCH 6/9] Fixed tests --- test/tests/common.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/tests/common.ts b/test/tests/common.ts index 80ffa1a..23a30ca 100644 --- a/test/tests/common.ts +++ b/test/tests/common.ts @@ -184,7 +184,10 @@ suite('wallet plugin', function () { test('login functionality', async function () { const plugin = new WalletPluginWebAuthenticator({ - webAuthenticatorUrl: 'https://web-authenticator.greymass.com', + urls: { + '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d': + 'https://web-authenticator.greymass.com', + }, }) // Mock login context @@ -229,7 +232,10 @@ suite('wallet plugin', function () { test('sign functionality', async function () { const plugin = new WalletPluginWebAuthenticator({ - webAuthenticatorUrl: 'https://web-authenticator.greymass.com', + urls: { + '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d': + 'https://web-authenticator.greymass.com', + }, }) // Use different keys for the sign test to avoid channel ID conflicts @@ -275,7 +281,10 @@ suite('wallet plugin', function () { test('popup success with UI feedback', async function () { const plugin = new WalletPluginWebAuthenticator({ - webAuthenticatorUrl: 'https://web-authenticator.greymass.com', + urls: { + '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d': + 'https://web-authenticator.greymass.com', + }, }) // Mock login context with UI From 4bace84176fe8510f5962931e9091638668f9296 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Tue, 10 Feb 2026 18:22:23 -0800 Subject: [PATCH 7/9] Moved popup to center of current display --- src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index e911878..e68b683 100644 --- a/src/index.ts +++ b/src/index.ts @@ -117,10 +117,15 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement // Show status message using WharfKit UI ui?.status('Opening wallet window...') + const popupWidth = 450 + const popupHeight = 750 + const left = Math.round(window.screenX + (window.outerWidth - popupWidth) / 2) + const top = Math.round(window.screenY + (window.outerHeight - popupHeight) / 2) + const popup: Window | null = window.open( url, 'Web Authenticator', - 'width=450,height=750' + `width=${popupWidth},height=${popupHeight},left=${left},top=${top}` ) if (!popup) { From 8e0c9bc40f94398f4ee917dd95d081cf86b1fed2 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Tue, 10 Feb 2026 18:25:43 -0800 Subject: [PATCH 8/9] Reapplied changes from #14 --- src/index.ts | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/index.ts b/src/index.ts index e68b683..a7341fb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -145,29 +145,6 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement elements: [], }) - const checkClosed = setInterval(() => { - if (popup?.closed) { - clearInterval(checkClosed) - ui?.status('Transaction cancelled') - reject(new Error('Transaction cancelled by user')) - } - }, 1000) - - waitForCallback(receiveOptions, this.buoyWs, t) - .then((response) => { - resolve({payload: response}) - }) - .catch((error) => { - reject(error) - }) - - // Update status - ui?.prompt({ - title: 'Approve', - body: 'Please approve the transaction in the wallet window.', - elements: [], - }) - const checkClosedInterval = setInterval(() => { if (popup?.closed) { clearInterval(checkClosedInterval) From 94eb18f5d4583230cf581b8cf321b7fbd63a2bd2 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Tue, 10 Feb 2026 18:26:25 -0800 Subject: [PATCH 9/9] v0.5.1 --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 90a6a86..ac76dcf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/wallet-plugin-web-authenticator", "description": "A Web Authenticator wallet plugin for use with @wharfkit/session.", - "version": "0.5.0", + "version": "0.5.1", "homepage": "https://github.com/wharfkit/wallet-plugin-web-authenticator", "license": "BSD-3-Clause", "main": "lib/wallet-plugin-web-authenticator.js", @@ -63,5 +63,6 @@ "typedoc": "^0.23.14", "typescript": "^4.1.2", "yarn-deduplicate": "^6.0.1" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" }