From c44be2b89921e3f961f417b828a5615b8099ef9c Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Tue, 28 Jul 2020 11:27:17 -0400 Subject: [PATCH 1/3] Upon initial login, expose the identity proof values. --- src/Anchor.ts | 4 ++-- src/AnchorUser.ts | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Anchor.ts b/src/Anchor.ts index a4a3e49..0bacda6 100644 --- a/src/Anchor.ts +++ b/src/Anchor.ts @@ -104,7 +104,7 @@ export class Anchor extends Authenticator { // attempt to restore any existing session for this app const session = await this.link.restoreSession(this.appName); if (session) { - this.users = [new AnchorUser(this.rpc, session)] + this.users = [new AnchorUser(this.rpc, { session })] } } @@ -206,7 +206,7 @@ export class Anchor extends Authenticator { // some changes to UAL are going to be required to support multiple users if (this.users.length === 0) { const identity = await this.link.login(this.appName) - this.users = [new AnchorUser(this.rpc, identity.session)] + this.users = [new AnchorUser(this.rpc, identity)] } } catch (e) { throw new UALAnchorError( diff --git a/src/AnchorUser.ts b/src/AnchorUser.ts index 2e1daa7..90ea993 100644 --- a/src/AnchorUser.ts +++ b/src/AnchorUser.ts @@ -6,16 +6,30 @@ import { UALAnchorError } from './UALAnchorError' export class AnchorUser extends User { public rpc: JsonRpc public session: any - private signatureProvider: any + public signerKey?: string + public signerProof?: string + public signerRequest?: any + + private signatureProvider: any private chainId: string private accountName: string = '' private requestPermission: string = '' - constructor(rpc, session) { + constructor(rpc, identity) { super() - this.chainId = session.link.chainId + const { session } = identity this.accountName = session.auth.actor + this.chainId = session.link.chainId + if (identity.signatures) { + [this.signerProof] = identity.signatures + } + if (identity.signerKey) { + this.signerKey = identity.signerKey + } + if (identity.serializedTransaction) { + this.signerRequest = identity.serializedTransaction + } this.requestPermission = session.auth.permission this.session = session this.rpc = rpc From f9484b327a2756e14dbcd5eab0976f1207355357 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Mon, 10 Aug 2020 12:10:48 -0400 Subject: [PATCH 2/3] Removed debug strings --- src/AnchorUser.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/AnchorUser.ts b/src/AnchorUser.ts index 90ea993..d162afc 100644 --- a/src/AnchorUser.ts +++ b/src/AnchorUser.ts @@ -52,7 +52,6 @@ export class AnchorUser extends User { } async signArbitrary(publicKey: string, data: string, _: string): Promise { - console.log("signArbitrary", publicKey, data) throw new UALAnchorError( `Anchor does not currently support signArbitrary`, UALErrorType.Unsupported, @@ -60,7 +59,6 @@ export class AnchorUser extends User { } async verifyKeyOwnership(challenge: string): Promise { - console.log("verifyKeyOwnership", challenge) throw new UALAnchorError( `Anchor does not currently support verifyKeyOwnership`, UALErrorType.Unsupported, @@ -76,7 +74,6 @@ export class AnchorUser extends User { } async getKeys() { - console.log("getKeys") try { const keys = await this.signatureProvider.getAvailableKeys(this.requestPermission) return keys @@ -90,7 +87,6 @@ export class AnchorUser extends User { } async isAccountValid() { - console.log("isAccountValid") try { const account = this.rpc && await this.rpc.get_account(this.accountName) const actualKeys = this.extractAccountKeys(account) @@ -112,7 +108,6 @@ export class AnchorUser extends User { } extractAccountKeys(account) { - console.log("extractAccountKeys", account) const keySubsets = account.permissions.map((permission) => permission.required_auth.keys.map((key) => key.key)) let keys = [] for (const keySubset of keySubsets) { From d53d5121ee6f9be26644c7d954488d22326e0e22 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Mon, 10 Aug 2020 12:48:19 -0400 Subject: [PATCH 3/3] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 555f709..7eff6d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ual-anchor", - "version": "0.5.0", + "version": "0.5.1", "main": "dist/index.js", "license": "MIT", "author": {