跳到主要内容

smartAccountAuth

功能

智能账户,应用方 EverID 登录方法,传递应用方 logo 跳转 https://beta.everpay.io/auth 页面,当用户 注册/登录 everPay 后,返回用户信息。

危险

此方法仅适用于浏览器环境

参数

everpay.smartAccountAuth(logo: string, email?: string, emailEditable?: boolean): Promise<SmartAccountAuthResult>
参数是否必需描述
logoYES应用方 logo
emailNO应用方可选择传递用户邮箱,默认为空字符串
emailEditableNO应用方可选择传递的用户邮箱是否可编辑,默认为可编辑,当且仅当此参数传递 false 时,邮箱不可编辑

返回

export interface SmartAccountAuthResult {
account: string
publicId: string
public: string
type: 'sign' | 'register'
message: string
sig: string
}

示例

const authResult = await new Everpay().smartAccountAuth('https://app-dev.permaswap.network/permalogo.svg')
console.log('authResult', authResult)

/* 示例返回
{
// 账户邮箱
account: "[email protected]",
// 签名信息
message: "0x69c96d89610d732a126a5652118e49d853705d2fc17642cdcea705e2a44e2f4b",
// 该邮箱登录 everPay 时使用的 webauthn ID 对应的公钥
public: "eyJpZCI6IjMxMXFZREhCZTE4U0hLVStIUjFYUHJoUGZ2bjE5Q3I1RVYwU1FZbi9scVk9IiwicHVibGljS2V5IjoicFFFQ0F5WWdBU0ZZSUZldWlsY0ZVdGowZGl5SUFRcnZGdFJRVjRRbndSem1SUldmRGNtY1ZYd0JJbGdnOW5hdjVUeVdiL2Y1RWgxWkQ4c2k3aFRROXlVY2wybVRuQi9iOUF3Z1I4MD0iLCJhdHRlc3RhdGlvblR5cGUiOiJwYWNrZWQiLCJ0cmFuc3BvcnQiOlsiaW50ZXJuYWwiXSwiZmxhZ3MiOnsidXNlclByZXNlbnQiOnRydWUsInVzZXJWZXJpZmllZCI6dHJ1ZSwiYmFja3VwRWxpZ2libGUiOmZhbHNlLCJiYWNrdXBTdGF0ZSI6ZmFsc2V9LCJhdXRoZW50aWNhdG9yIjp7IkFBR1VJRCI6InJjNEFBalc4eGdwa2l3c2w4ZkJWQXc9PSIsInNpZ25Db3VudCI6MCwiY2xvbmVXYXJuaW5n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