WEPIN Developer Documentation
WepinBlogContact
English
English
  • Get Started
    • Introduction
  • Wepin
    • Features
    • Architecture
      • Key Generation
      • Signing
      • Key Backup
    • Workspace
      • App Registration and Key Issuance
      • Networks and Assets Addition
      • Widget Design
    • Supported blockchains
    • Account Abstraction
  • login
    • Overview
    • Social Login Auth Providers
      • Email/Password
      • Google
      • Apple
      • Discord
      • Naver
      • Facebook
      • Line
      • Kakao
    • User Interface
    • Simplified Login
    • Resource
  • Widget Integration
    • Prerequisites
    • Web: JavaScript SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • PIN Pad Library
        • Installation
        • Initialization
        • Methods
      • Widget
        • Installation
        • Initialization
        • Methods
        • Final Review
      • Provider
        • Ethereum Provider
        • Kaia Provider
        • Solana Provider
        • Wagmi Connector
      • Wallet Adapter
        • Solana Wallet Adapter
    • Android: Java & Kotlin SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • PIN Pad Library
        • Installation
        • Initialization
        • Methods
      • Widget Library
        • Installation
        • Initialization
        • Methods
    • iOS: Swift SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • PIN Pad Library
        • Installation
        • Initialization
        • Methods
      • Widget Library
        • installation
        • initialization
        • Methods
    • Flutter SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • Widget
        • Installation
        • Initialization
        • Methods
        • Final Review
      • PIN Pad Library
        • Installation
        • Initialization
        • Methods
    • React Native SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
    • Unity SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
    • Compose Multiplatform SDK
      • Login Library
        • Installation
        • Initialization
        • Methods
      • Widget
        • Installation
        • Initialization
        • Methods
        • Final Review
  • API
    • Overview
    • Registration
    • Login
    • Wallet
    • Token and NFT
    • Transaction
  • Deprecated
    • Web: JavaScript SDK
      • SDK
        • Installation
        • Initialization
        • Methods
        • Final Review
      • Provider
        • EVM-Compatible Networks
      • Wagmi Connector
    • Android: Java & Kotlin SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
    • iOS: Swift SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
    • Flutter SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
    • React Native SDK
      • Installation
      • Initialization
      • Methods
      • Final Review
      • Providers
        • Ethereum Providers
  • MISC
    • Logo & Brand
Powered by GitBook
On this page
  • generateRegistrationPINBlock
  • Parameters
  • Return value
  • Example
  • generateAuthPINBlock
  • Parameters
  • Return value
  • Example
  • generateChangePINBlock
  • Parameters
  • Return Value
  • Example
  • generateAuthOTP
  • Parameters
  • Return Value
  • Example
  • finalize
  • Parameters
  • Return Value
  • Example

Was this helpful?

  1. Widget Integration
  2. Web: JavaScript SDK
  3. PIN Pad Library

Methods

Methods can be used after initializing the Wepin PIN Pad Library.

generateRegistrationPINBlock

await wepinPin.generateRegistrationPINBlock()

To display the PIN pad screen to receive the PIN required for wallet creation and user registration, process the entered PIN to create a PIN Block.

Parameters

  • <void>

Return value

  • Promise <RegistrationPinBlock>

    • UVD <EncUVD>

      • b64Data <string> Data encrypted with the original key of b64SKey.

      • b64SKey <string> The key used to generate b64Data.

      • seqNum <number> optional A value used to verify that PIN Blocks are used in sequential order.

    • hint <EncPinHint>

      • data <string> The encrypted value of the PIN hint.

      • length <string> The length of the PIN hint.

      • version <number> The version of the PIN hint.

Example

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,
  }
})

generateAuthPINBlock

await wepinPin.generateAuthPINBlock(count?)

To display the PIN pad screen to receive the PIN required for user authentication and process the entered PIN to create a PIN Block. If the user has enabled 2FA (OTP), display a screen to receive the OTP code and process it as well.

Parameters

  • count <number> optional

    The number of PIN Blocks to be generated. The default value is 1.

Return value

  • Promise <AuthPinBlock>

    • UVDs <EncUVD[]> A list of encrypted PIN Blocks.

      • UVD <EncUVD>

        • b64Data <string> Data encrypted with the original key of b64SKey.

        • b64SKey <string> The key used to generate b64Data.

        • seqNum <number> optional A value used to verify that PIN Blocks are used in sequential order. In a Multi Tx request, PIN Blocks must be used strictly in the received order (1, 2, 3...).

    • otp <string> optional The OTP code entered by the user if they have enabled 2FA (OTP).

Example

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,
      },
    }
  })
}

generateChangePINBlock

await wepinPin.generateChangePINBlock()

To display the PIN pad screen to receive the PIN required for the user to change their PIN and process the entered PIN to create a PIN Block. If the user has enabled 2FA (OTP), display a screen to receive the OTP code and process it as well.

Parameters

  • <void>

Return Value

  • Promise <ChangePinBlock>

    • UVD <EncUVD>

      • b64Data <string> Data encrypted with the original key of b64SKey.

      • b64SKey <string> The key used to generate b64Data.

      • seqNum <number> optional A value used to verify that PIN Blocks are used in sequential order.

    • newUVD <EncUVD>

      • b64Data <string> Data encrypted with the original key of b64SKey.

      • b64SKey <string> The key used to generate b64Data.

      • seqNum <number> optional A value used to verify that PIN Blocks are used in sequential order.

    • hint <EncPinHint>

      • data <string> The encrypted value of the PIN hint.

      • length <string> The length of the PIN hint.

      • version <number> The version of the PIN hint.

    • otp <string> optional The OTP code entered by the user if they have enabled 2FA (OTP).

Example

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
    }
  }
})

generateAuthOTP

await wepinPin.generateAuthOTP()

Display a screen to receive the OTP code from the user and process it.

Parameters

  • <void>

Return Value

  • Promise<AuthOTP>

    • code <string> The entered OTP code.

Example

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)
}

finalize

wepinPin.finalize()

It terminates the use of the Wepin PIN Pad Library.

Parameters

  • <void>

Return Value

  • <void>

Example

wepinPin.finalize()

PreviousInitializationNextWidget

Last updated 6 months ago

Was this helpful?