Methods
Last updated
Was this helpful?
Was this helpful?
const pinBlock = await wepinPin.generateRegistrationPINBlock()
fetch({
url: 'https://sdk.wepin.io/v1/app/register',
method: 'POST',
// Omit authentication headers
body: {
// Omit other bodies
UVD: pinBlock.UVD,
hint: pinBlock.hint,
}
})await wepinPin.generateAuthPINBlock(count?)const pinBlock = await wepinPin.generateAuthPINBlock(count)
// Sort seqNum of uvd in ascending order from 1 because I need to write it in order starting from 1
pinBlock.UVDs.sort((a, b) => (a.seqNum ?? 0) - (b.seqNum ?? 0))
const resArray: any[] = []
for (const encUVD of pinBlock.UVDs) {
await fetch({
url: 'https://sdk.wepin.io/v1/tx/sign',
method: 'POST',
body: {
userId: await getUserId(),
walletId: await getWalletId(),
accountId: (await getEthereumAccount()).accountId,
type: 'msg_sign',
txData: {
data: '0x0',
},
pin: encUVD,
otpCode: {
code: pinBlock.otp,
},
}
})
}await wepinPin.generateChangePINBlock()const pinBlock = await wepinPin.generateChangePINBlock()
const res = await fetch({
url: 'https://sdk.wepin.io/v1/wallet/pin/change'
body: {
userId: await getUserId(),
walletId: await getWalletId(),
UVD: pinBlock.UVD,
newUVD: pinBlock.newUVD,
hint: pinBlock.hint,
otpCode: {
code: pinBlock.otp
}
}
})await wepinPin.generateAuthOTP()let res = await getWepinSignMessage(pinBlocks.UVDs, pinBlock.otp)
if (res.body[0].message === 'OTP_MISMATCH_WRONG_CODE') {
const otp = await wepinPin.generateAuthOTP()
res = await getWepinSignMessage(pinBlocks.UVDs, otp.code)
}wepinPin.finalize()wepinPin.finalize()