# 메서드

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

## &#x20;generateRegistrationPINBlock

```kotlin
wepinPin.generateRegistrationPINBlock()
```

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

### **Parameters**

* `<void>`

### **Return value**

* `CompletableFuture` \<RegistrationPinBlock>
  * `uvd` \<EncUVD>

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

  * `hint` \<EncPinHint>

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

    &#x20;      PIN 힌트의 버전

### **Example**

{% tabs %}
{% tab title="Java" %}

```java
wepinPin.generateRegistrationPINBlock().whenComplete((res, err) -> {
    if (err == null) {
        RegistrationPinBlock registerPin = new RegistrationPinBlock(res.getUvd(), res.getHint());
        // You need to make a Wepin RESTful API request using the received data.
    } else {
        System.out.println(err);
    }
});

```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
wepinPin.generateRegistrationPINBlock().whenComplete { res, err ->
    if (err == null) {
        registerPin = RegistrationPinBlock(uvd = res!!.uvd, hint = res!!.hint)
        // You need to make a Wepin RESTful API request using the received data.
    } else {
      println(err)
    }
}
```

{% endtab %}
{% endtabs %}

## generateAuthPINBlock

```kotlin
wepinPin.generateAuthPINBlock(3)
```

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

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

### **Parameters**

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

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

### **Return value**

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

### **Example**

{% tabs %}
{% tab title="Java" %}

```java
wepinPin.generateAuthPINBlock(3).whenComplete((res, err) -> {
    if (err == null) {
        AuthPinBlock authPin = new AuthPinBlock(res.getUvdList(), res.getOtp());
        // You need to make a Wepin RESTful API request using the received data.
    } else {
        System.out.println(err);
    }
});

```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
wepinPin.generateAuthPINBlock(3).whenComplete { res, err ->
    if (err == null) {
        authPin = AuthPinBlock(uvdList = res!!.uvdList, otp = res!!.otp)
        // You need to make a Wepin RESTful API request using the received data.
    } else {
      println(err)
    }
}
```

{% endtab %}
{% endtabs %}

## generateChangePINBlock

```kotlin
wepinPin.generateChangePINBlock()
```

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

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

### **Parameters**

* `<void>`

### **Return Value**

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

### **Example**

{% tabs %}
{% tab title="Java" %}

```java
wepinPin.generateChangePINBlock().whenComplete((res, err) -> {
    if (err == null) {
        ChangePinBlock changePin = new ChangePinBlock(res.getUvd(), res.getNewUVD(), res.getHint(), res.getOtp());
        // You need to make a Wepin RESTful API request using the received data.
    } else {
        System.out.println(err);
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
wepinPin.generateChangePINBlock().whenComplete { res, err ->
    if (err == null) {
        changePin = ChangePinBlock(uvd = res!!.uvd, newUVD = res.newUVD, hint = res.hint, otp = res.otp)
        // You need to make a Wepin RESTful API request using the received data.
    } else {
      println(err)
    }
}
```

{% endtab %}
{% endtabs %}

## generateAuthOTP

```kotlin
wepinPin.generateAuthOTPCode()
```

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

### **Parameters**

* `<void>`

### **Return Value**

* `CompletableFuture` \<AuthOTP>
  * `code` \<String>\
    입력받은 OTP 코드

### **Example**

{% tabs %}
{% tab title="Java" %}

```java
wepinPin.generateAuthOTPCode().whenComplete((res, err) -> {
    if (err == null) {
        AuthOTP authOTPCode = new AuthOTP(res.getCode());
        // You need to make a Wepin RESTful API request using the received data.
    } else {
        System.out.println(err);
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
wepinPin.generateAuthOTPCode().whenComplete { res, err ->
    if (err == null) {
        authOTPCode = AuthOTP(res!!.code)
        // You need to make a Wepin RESTful API request using the received data.
    } else {
      println(err)
    }
}
```

{% endtab %}
{% endtabs %}

## finalize

```kotlin
wepinPin.finalize()
```

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

### **Parameters**

* `<void>`

### **Return Value**

* `<void>`

### **Example**

{% tabs %}
{% tab title="Java" %}

```java
wepinPin.finalize();
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
wepinPin.finalize()
```

{% endtab %}
{% endtabs %}

## login

<mark style="color:red;">`v1.1.0`</mark> 부터 `WepinPin` SDK에 `WepinLogin`이 통합되었습니다.`WepinPin` 에 통합된 `WepinLogin` 을 사용하지 않고 별도의 `WepinLogin` 을 사용할 때, 두 SDK 의 버전이 동일하지 않은 경우 에러가 발생할 수 있습니다.

`login` 변수는 다양한 인증 방법을 포함한 위핀 로그인 라이브러리로, 사용자가 여러 방식으로 로그인할 수 있도록 합니다. 이메일 및 비밀번호 로그인, OAuth 프로바이더 로그인, ID Token 또는 Access Token을 사용한 로그인 등을 지원합니다. 각 메서드에 대한 자세한 정보는 공식 라이브러리 문서 [Login Library 가이드](/widget-integration/android-java-and-kotlin-sdk/login-library.md)에서 확인할 수 있습니다.

### **Available Methods**

* [`loginWithOauthProvider`](https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/methods#loginwithoauthprovider)
* [`signUpWithEmailAndPassword`](https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/methods#signupwithemailandpassword)
* [`loginWithEmailAndPassword`](https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/methods#loginwithemailandpassword)
* [`loginWithIdToken`](https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/methods#loginwithidtoken)
* [`loginWithAccessToken`](https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/methods#loginwithaccesstoken)
* [`getRefreshFirebaseToken`](https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/methods#getrefreshfirebasetoken)
* [`loginWepin`](https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/methods#loginwepin)
* [`getCurrentWepinUser`](https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/methods#getcurrentwepinuser)
* [`logout`](https://docs.wepin.io/widget-integration/ios-swift-sdk/login-library/methods#logoutwepin)

이 메서드들은 다양한 로그인 시나리오를 지원하며, 필요에 맞는 적절한 방법을 선택할 수 있습니다.

**Exception**

* [WepinError](https://docs.wepin.io/widget-integration/flutter-sdk/widget/methods#wepinerror)

**Example**

<pre class="language-kotlin"><code class="lang-kotlin"><strong>// OAuth Provider를 사용한 로그인
</strong>wepinSDK.login.loginWithOauthProvider("google", "your-client-id")
    .thenCompose { authResult ->
        // ID Token을 사용한 로그인
        wepinSDK.login.loginWithIdToken(authResult.idToken)
    }.thenCompose { idTokenResult ->
        // 위핀에 로그인
        wepinSDK.login.loginWepin(idTokenResult)
    }.thenAccept { user ->
        Log.d("WepinSDK", "로그인 성공! 사용자 정보: $user")
    }.exceptionally { e ->
        Log.e("WepinSDK", "로그인 실패: ${e.message}", e)
        null
    }

// 이메일 및 비밀번호로 회원가입 및 로그인
wepinSDK.login.signUpWithEmailAndPassword(
    email = 'example@example.com', 
    password = 'password123'
).thenAccept { signUpResult ->
    Log.d("WepinSDK", "로그인 성공! 사용자 정보: $user")
}.exceptionally { error ->
    if (error is WepinError) {
    }
}

// 현재 로그인된 사용자 가져오기
var currentUser = wepinSDK.login.getCurrentWepinUser()
    .thenAccept { user ->
        Log.d("WepinSDK", "현재 사용자: $user")
    }.exceptionally { e ->
        Log.e("WepinSDK", "사용자 가져오기 실패", e)
        null
    }

// 로그아웃
wepinSDK.login.logout()
    .thenAccept { result ->
        Log.d("WepinSDK", "로그아웃 결과: $result")
    }.exceptionally { e ->
        Log.e("WepinSDK", "로그아웃 실패", e)
        null
    }    
</code></pre>


---

# 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/android-java-and-kotlin-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.
