# 메서드

Wepin PIN Pad Library  초기화 이후 사용할 수 있습니다.

## generateRegistrationPINBlock

```javascript
await wepinPin.generateRegistrationPINBlock()
```

사용자의  지갑생성 및 회원가입을 위해 필요한 PIN을 입력 받을 수 있는 핀 패드 화면을 띄우고 입력받은 PIN을 처리하여 PIN Block을 생성합니다.

### **Parameters**

* `<void>`

### **Return value**

* `Promise` \<RegistrationPinBlock>
  * `UVD` \<EncUVD>

    * `b64Data` \<string> \
      b64SKey의  원본키로 암호화된 데이터
    * `b64SKey` \<string> \
      b64Data 를 생성할때  사용하는 키
    * `seqNum` \<number> **optional** \
      **P**IN Block 사용시 순서대로 사용되었는지 확인하기 위한 값

  * `hint` \<EncPinHint>

    * `data` \<string> \
      &#x20;PIN 힌트를 암호화한 값
    * `length` \<string>\
      PIN 힌트의 길이
    * `version` \<number>&#x20;

    &#x20;      PIN 힌트의 버전

### **Example**

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

## &#x20;generateAuthPINBlock

```javascript
await wepinPin.generateAuthPINBlock(count?)
```

사용자 인증에 필요한 PIN을 입력 받을 수 있는 핀 패드 화면을 띄우고 입력받은 PIN을 처리하여 PIN Block을 생성합니다.&#x20;

사용자가 2FA(OTP)를 활성화한 경우에는, OTP 코드를 입력받을 수 있는 화면도 띄우고 처리합니다.

### **Parameters**

* `count` \<number> **optional**&#x20;

  생성하려는 PIN Block의 갯수. 기본값은 `1` 입니다.

### **Return value**

* `Promise` \<AuthPinBlock>
  * `UVDs` \<EncUVD\[]> \
    암호화된 PIN Block의 리스트
    * `UVD` \<EncUVD>
      * `b64Data` \<string> \
        b64SKey의  원본키로 암호화된 데이터
      * `b64SKey` \<string> \
        b64Data 를 생성할때  사용하는 키
      * `seqNum` \<number> **optional** \
        **P**IN Block 사용시 순서대로 사용되었는지 확인하기 위한 값.\
        Multi Tx 요청시, 반드시 받은 PIN Block의 순서대로 사용해야 합니다.(1,2,3...)
  * `otp` \<string> **optional** \
    사용자가 2FA(OTP) 를 활성화한 경우, 입력받은 OTP 코드

### **Example**

```javascript
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

```javascript
await wepinPin.generateChangePINBlock()
```

사용자 PIN 변경을 위해 PIN을 입력 받을 수 있는 핀 패드 화면을 띄우고 입력받은 PIN을 처리하여 PIN Block을 생성합니다.&#x20;

사용자가 2FA(OTP)를 활성화한 경우에는, OTP 코드를 입력받을 수 있는 화면도 띄우고 처리합니다.

### **Parameters**

* `<void>`

### **Return Value**

* `Promise` \<ChangePinBlock>
  * `UVD` \<EncUVD>
    * `b64Data` \<string> \
      b64SKey의  원본키로 암호화된 데이터
    * `b64SKey` \<string> \
      b64Data 를 생성할때  사용하는 키
    * `seqNum` \<number> **optional** \
      **P**IN Block 사용시 순서대로 사용되었는지 확인하기 위한 값
  * `newUVD` \<EncUVD>
    * `b64Data` \<string> \
      b64SKey의  원본키로 암호화된 데이터
    * `b64SKey` \<string> \
      b64Data 를 생성할때  사용하는 키
    * `seqNum` \<number> **optional** \
      **P**IN Block 사용시 순서대로 사용되었는지 확인하기 위한 값.
  * `hint` \<EncPinHint>
    * `data` \<string> \
      &#x20;PIN 힌트를 암호화한 값
    * `length` \<string>\
      PIN 힌트의 길이
    * `version` \<number> \
      PIN 힌트의 버전
  * `otp` \<string> **optional** \
    사용자가 2FA(OTP) 를 활성화한 경우, 입력받은 OTP 코드

### **Example**

```javascript
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

```javascript
await wepinPin.generateAuthOTP()
```

사용자로부터 OTP 코드를  입력받을 수 있는 화면을 띄우고 처리합니다.

### **Parameters**

* `<void>`

### **Return Value**

* `Promise`\<AuthOTP>
  * `code` \<string>\
    입력받은 OTP 코드

### **Example**

```javascript
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

```javascript
wepinPin.finalize()
```

Wepin PIN Pad Library 사용을 종료합니다.

### **Parameters**

* \<void>

### **Return Value**

* \<void>

### **Example**

```javascript
wepinPin.finalize()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wepin.io/widget-integration/web-javascript-sdk/pin-pad-library/methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
