---
title: "@xid-kit/tauri"
description: "PKCE S256 흐름, 딥링크 콜백 핸들러, OS keychain 어댑터, Rust 플러그인 템플릿이 있는 Tauri v2 데스크톱 SDK."
locale: "ko"
---

> Documentation Index
> Fetch the locale documentation index at: https://xid.dev/ko/llms.txt
> Use this file to discover all available pages before exploring further.

# @xid-kit/tauri

## 상태

패키지 상태: **현재 패키지**. JS 브리지, PKCE S256 흐름, 딥링크 콜백 핸들러, OS keychain 어댑터, Rust 플러그인 템플릿이 구현되었습니다. 프로덕션 인프라에서의 실제 IdP 왕복 테스트는 아직 수동 검증 대기 중입니다.

## Tauri 설정

```json
// tauri.conf.json
{
  "bundle": { "identifier": "com.example.myapp" },
  "plugins": {
"deep-link": { "desktop": { "schemes": ["myapp"] } }
  }
}
```

## Rust 플러그인

`templates/xid-keychain-plugin.rs`를 `src-tauri/src/xid_keychain.rs`에 복사하고 `templates/tauri-app-setup.rs`를 참고하여 등록하세요. `src-tauri/Cargo.toml`에 `keyring = \"2\"`, `tauri-plugin-deep-link = \"2\"`, `tauri-plugin-shell = \"2\"`를 추가하세요.

## JS 통합

```ts
import { createXidTauriClient, createTauriKeychainAdapter } from '@xid-kit/tauri'
import { invoke } from '@tauri-apps/api/core'
import { open } from '@tauri-apps/plugin-shell'
import { onOpenUrl } from '@tauri-apps/plugin-deep-link'

const client = createXidTauriClient({
  issuer: 'https://xid.dev',
  clientId: 'YOUR_CLIENT_ID',
  redirectUri: 'myapp://auth/callback',
  keychain: createTauriKeychainAdapter({ invoke }),
})

// Register deeplink handler (e.g. on App component mount)
await onOpenUrl(async (urls) => {
  for (const url of urls) await client.handleRedirect(url)
})

// Trigger sign-in: opens system browser
await client.signIn({ openUrl: open })
```

## 토큰 검색 및 로그아웃

```ts
// Get current access token (refreshes transparently if near expiry)
const token = await client.getAccessToken()

// Get full session (userId, organizationId, expiresAt)
const session = await client.getSession()

// Revoke server session and clear all keychain entries
await client.signOut()

// OIDC RP-initiated logout URL for full IdP sign-out
const logoutUrl = client.buildSignOutUrl({ postLogoutRedirectUri: 'myapp://logout' })
await open(logoutUrl.toString())
```

## Tauri 런타임 없이 개발/테스트

```ts
import { createXidTauriClient, createMemoryKeychainAdapter } from '@xid-kit/tauri'

const client = createXidTauriClient({
  issuer: 'http://localhost:8788',
  clientId: 'test-client',
  redirectUri: 'http://localhost:1420/callback',
  keychain: createMemoryKeychainAdapter(),
})
```

## createXidTauriClient 옵션

| 옵션 | 유형 | 설명 |
| --- | --- | --- |
| `issuer` | string | XID 발급자 URL |
| `clientId` | string | OAuth 2.0 client\_id |
| `redirectUri` | string | 사용자 정의 URI 스킴 콜백 |
| `scopes` | readonly string\[\] | 기본값: openid, profile, email |
| `keychain` | XidKeychainAdapter | 토큰 저장소 어댑터; 기본값은 MemoryKeychainAdapter입니다(프로덕션에서는 Tauri 어댑터 사용) |

## XidTauriClient 메서드

| 방법 | 설명 |
| --- | --- |
| `signIn(options?)` | PKCE 인증 URL 생성; openUrl 콜백을 통해 엽니다 |
| `handleRedirect(url)` | 딥링크를 파싱하고 state를 검증하며 코드를 토큰으로 교환합니다 |
| `getSession()` | TauriSession 또는 null; 만료가 임박하면 토큰을 갱신합니다 |
| `getAccessToken(options?)` | 액세스 토큰 문자열 또는 null; 만료가 임박하면 갱신합니다 |
| `signOut()` | 서버 세션을 폐기하고 keychain을 지웁니다 |
| `buildSignOutUrl(options?)` | RP 주도 로그아웃을 위한 OIDC end\_session URL 생성 |
| `setTokenStorage(adapter)` | 런타임에 keychain 어댑터 교체 |

## PKCE 및 토큰 저장소

- PKCE S256이 항상 사용됩니다. Plain challenge는 절대 생성되지 않습니다.
- 검증자 엔트로피는 64바이트입니다. challenge는 Web Crypto `crypto.subtle.digest('SHA-256', ...)`를 통해 파생됩니다.
- 모든 키는 `xid.*` 네임스페이스 하에 있습니다: `xid.access_token`, `xid.refresh_token`, `xid.session`, `xid.pkce_verifier`, `xid.oauth_state`.

Source: https://xid.dev/ko/sdks/tauri/index.mdx
