Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release] 1.0.10 #219

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arcana/auth",
"version": "1.0.9",
"version": "1.0.10",
"description": "Arcana Auth",
"main": "dist/index.js",
"type": "module",
Expand Down
16 changes: 11 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
private connectCtrl: ModalController
private _standaloneMode: {
mode: 1 | 2
handler: (...args: any) => void | undefined

Check warning on line 56 in src/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/index.ts#L56

Unexpected any. Specify a different type (@typescript-eslint/no-explicit-any)
}
constructor(clientId: string, p?: Partial<ConstructorParams>) {
let network = p?.network
Expand Down Expand Up @@ -129,6 +129,10 @@
return this
}

/**
* A function to start otp login
*/

public loginWithOTPStart = async (email: string) => {
await this.init()
return {
Expand All @@ -139,14 +143,15 @@
}
}

public loginWithOTPComplete = async (
email: string,
onMFAFlow?: () => void
) => {
/**
* A function to finish otp login
*/

public loginWithOTPComplete = async (otp: string, onMFAFlow?: () => void) => {
if ((await this._provider.getKeySpaceConfigType()) === 'global') {
throw new Error('complete is not required for global login')
}
await this._loginWithOTPComplete(email, onMFAFlow)
await this._loginWithOTPComplete(otp, onMFAFlow)
}

/**
Expand Down Expand Up @@ -216,6 +221,7 @@

/**
* A function to trigger passwordless login in the wallet
* @deprecated use loginWithOTPStart and loginWithOTPComplete instead
*/
loginWithLink = async (
email: string,
Expand Down Expand Up @@ -562,7 +568,7 @@

private standaloneMode(
mode: 1 | 2,
handler: (eventName: string, data: any) => void

Check warning on line 571 in src/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/index.ts#L571

Unexpected any. Specify a different type (@typescript-eslint/no-explicit-any)
) {
this._standaloneMode = {
mode,
Expand Down
48 changes: 4 additions & 44 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
JsonRpcId,
JsonRpcRequest,
JsonRpcResponse,
JsonRpcSuccess,

Check warning on line 8 in src/provider.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/provider.ts#L8

'JsonRpcSuccess' is defined but never used (@typescript-eslint/no-unused-vars)
} from './typings'
import { Connection } from 'penpal'
import { ethErrors } from 'eth-rpc-errors'
Expand Down Expand Up @@ -33,7 +33,7 @@
}
}

const permissionedMethod = [

Check warning on line 36 in src/provider.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/provider.ts#L36

'permissionedMethod' is assigned a value but never used (@typescript-eslint/no-unused-vars)
'eth_sendTransaction',
'eth_signTransaction',
'eth_sign',
Expand Down Expand Up @@ -226,51 +226,11 @@
id: getUniqueId(),
}

const keySpaceType = await this.getKeySpaceConfigType()
const c = await this.getCommunication('addToActivity')

return new Promise((resolve, reject) => {
if (permissionedMethod.includes(method) && keySpaceType === 'global') {
this.popup
.sendRequest({
chainId: this.chainId,
request: req,
})
.then((value: JsonRpcResponse<unknown>) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore-next-line
const error = value.error
if (error) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore-next-line
c.addToActivity({
req,
error,
chainId: this.chainId,
})
if (error !== 'user_closed_popup') {
return reject(getError(error))
}
} else {
const result = (<JsonRpcSuccess<unknown>>value).result
c.addToActivity({
req,
result,
chainId: this.chainId,
})
return resolve(result)
}
})
this.getCommunication().then(async (c) => {
this.getResponse<string>(method, req.id).then(resolve, reject)
await c.sendRequest(req, 'auth-verify')
}, reject)
} else {
this.getCommunication().then(async (c) => {
this.getResponse<string>(method, req.id).then(resolve, reject)
await c.sendRequest(req)
}, reject)
}
this.getCommunication().then(async (c) => {
this.getResponse<string>(method, req.id).then(resolve, reject)
await c.sendRequest(req)
}, reject)
})
}

Expand Down
Loading