@nexus-cross/crossx-sdk-core 2.6.0 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/adapters/confirmation/HeadlessConfirmationAdapter.d.ts +25 -0
  2. package/dist/adapters/onewallet/AuthzKeyManager.d.ts +27 -0
  3. package/dist/adapters/onewallet/OneWalletApiAdapter.d.ts +61 -0
  4. package/dist/adapters/onewallet/OneWalletApiClient.d.ts +37 -0
  5. package/dist/adapters/onewallet/crypto/bytes.d.ts +16 -0
  6. package/dist/adapters/onewallet/crypto/envelope.d.ts +103 -0
  7. package/dist/adapters/onewallet/crypto/hpke.d.ts +17 -0
  8. package/dist/core/config/environments.d.ts +5 -0
  9. package/dist/core/constants.d.ts +1 -1
  10. package/dist/core/ports/ConfirmationPort.d.ts +28 -1
  11. package/dist/core/services/PinMemoryStore.d.ts +4 -0
  12. package/dist/core/services/PinReusePolicy.d.ts +30 -0
  13. package/dist/core/types/errors.d.ts +2 -0
  14. package/dist/core/types/index.d.ts +10 -0
  15. package/dist/core/types/internal.d.ts +6 -0
  16. package/dist/core/usecases/SignOutUseCase.d.ts +2 -0
  17. package/dist/crossx.global +5 -3263
  18. package/dist/factory--q6B2KiB.js +7803 -0
  19. package/dist/factory-DKz-M7y8.cjs +9 -0
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.d.ts +4 -2
  22. package/dist/index.js +19 -16
  23. package/dist/internal.cjs +1 -1
  24. package/dist/internal.d.ts +2 -0
  25. package/dist/internal.js +4 -3
  26. package/dist/sdk/CROSSxSDK.d.ts +13 -0
  27. package/dist/sdk/factory.d.ts +18 -3
  28. package/dist/sdk/services/AddressResolverService.d.ts +2 -0
  29. package/dist/sdk/services/OneIdSessionManager.d.ts +2 -0
  30. package/dist/sdk/services/PinOrchestrator.d.ts +12 -0
  31. package/dist/sdk/services/SigningOrchestrator.d.ts +3 -0
  32. package/package.json +1 -1
  33. package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts +0 -140
  34. package/dist/adapters/confirmation/walletCreatedIllustration.d.ts +0 -11
  35. package/dist/factory-CFIZEUse.cjs +0 -3267
  36. package/dist/factory-CJQfgIu8.js +0 -11704
@@ -0,0 +1,25 @@
1
+ import { ConfirmationDetails, ConfirmationPort, TransactionCompleteDetails, TransactionPendingDetails } from '../../core/ports/ConfirmationPort';
2
+ import { LoginSelectorResult } from '../../core/types';
3
+
4
+ export declare class HeadlessConfirmationAdapter implements ConfirmationPort {
5
+ requestConfirmation(_details: ConfirmationDetails): Promise<boolean>;
6
+ showLoginSelector(): Promise<LoginSelectorResult | null>;
7
+ showMigrationFoundPrompt(): Promise<'recover' | 'skip'>;
8
+ showRecoveryPinInputPrompt(): Promise<string | null>;
9
+ showWalletSelector(): Promise<{
10
+ address: string;
11
+ index: number;
12
+ name?: string;
13
+ } | null>;
14
+ showPinSetupPrompt(): Promise<string | null>;
15
+ showPinInputPrompt(): Promise<string | null>;
16
+ showSessionAlert(): Promise<'signout' | 'signin-again'>;
17
+ showTransactionComplete(_details: TransactionCompleteDetails): Promise<void>;
18
+ /** 화면은 없지만 영수증은 기다린다 — 결과 처리는 호출자 몫이라 에러는 삼킨다 (BridgeConfirmationAdapter 와 같음). */
19
+ showTransactionProgress(_pending: TransactionPendingDetails, receiptPromise: Promise<TransactionCompleteDetails>): Promise<void>;
20
+ showRecoveryPinLockedPrompt(_lockExpiresInSeconds: number, _message: string): Promise<void>;
21
+ showUpdateRequired(): Promise<void>;
22
+ setTheme(): void;
23
+ setMessages(): void;
24
+ setPinKeyboard(): void;
25
+ }
@@ -0,0 +1,27 @@
1
+ import { AuthzSigner } from './crypto/envelope';
2
+ import { OneWalletApiClient } from './OneWalletApiClient';
3
+
4
+ /** 만료가 이만큼 남으면 새로 발급한다. 봉투 TTL(60s)보다 짧으면 안 된다 */
5
+ export declare const AUTHZ_KEY_RENEW_BEFORE_MS: number;
6
+ export interface AuthzKeyManagerOptions {
7
+ client: OneWalletApiClient;
8
+ /** 발급 요청 본문의 jwt — 지금은 Bearer 와 같은 one-oauth access token */
9
+ getIssuanceJwt: () => Promise<string>;
10
+ now?: () => number;
11
+ }
12
+ export declare class AuthzKeyManager {
13
+ private readonly opts;
14
+ private current;
15
+ private pending;
16
+ /** 폐기 · 로그아웃 뒤 늦게 끝난 발급이 키를 되살리지 않게 세대를 센다 */
17
+ private generation;
18
+ private readonly now;
19
+ constructor(opts: AuthzKeyManagerOptions);
20
+ /** 쓸 수 있는 B 키. 없거나 만료가 가까우면 발급한다 */
21
+ get(): Promise<AuthzSigner>;
22
+ /** 서버가 키를 거부했을 때 — 다음 {@link get} 에서 새로 발급한다 */
23
+ invalidate(): void;
24
+ /** 로그아웃 · 세션 종료 — 서버에서 폐기하고 잊는다. 폐기 실패는 무시한다(cert 는 곧 만료된다) */
25
+ revoke(): Promise<void>;
26
+ private issue;
27
+ }
@@ -0,0 +1,61 @@
1
+ import { WalletCheckResult, WalletData, WalletProviderPort, SignResponse } from '../../core/ports/WalletProviderPort';
2
+ import { PinMemoryStore } from '../../core/services/PinMemoryStore';
3
+ import { AddressInfo, EvmTransactionRequest } from '../../core/types/chain';
4
+ import { AuthzKeyManager } from './AuthzKeyManager';
5
+ import { OneWalletApiClient } from './OneWalletApiClient';
6
+ import { TransportPort } from '../../core/ports/TransportPort';
7
+
8
+ export interface OneWalletApiAdapterOptions {
9
+ /** 예: `https://dev-one-pocket-api.onechain.nexus/embed/v1`. 함수면 요청마다 읽는다 */
10
+ baseUrl: string | (() => string);
11
+ transport: TransportPort;
12
+ pinStore: PinMemoryStore;
13
+ /** 유효한 one-oauth access token(`aud=one-wallet`) */
14
+ getAccessToken: () => Promise<string>;
15
+ /**
16
+ * 지갑 생성 응답의 share C(백업 조각)를 받는다. 보관 방식은 후속 작업(DEV2TF-2755 R-4)에서 정한다.
17
+ * 넘기지 않으면 버린다 — 그 지갑은 share C 복구를 쓸 수 없다.
18
+ */
19
+ onShareC?: (shareC: Uint8Array, walletAddress: string) => Promise<void> | void;
20
+ now?: () => number;
21
+ }
22
+ /** access token(JWT)의 sub. 서명 검증은 서버 몫이고 여기서는 바인딩 값으로만 쓴다 */
23
+ export declare function subjectOf(accessToken: string): string;
24
+ /** 2.x 포트의 메시지(문자열) → 서명할 바이트. `0x` hex 는 바이트로, 그 밖은 UTF-8 (personal_sign 관례) */
25
+ export declare function messageBytes(message: string): Uint8Array;
26
+ /** EvmTransactionRequest → intent unsigned_tx (snake_case hex). enclave 가 모르는 필드를 넣으면 거부하므로 빈 값은 뺀다 */
27
+ export declare function toUnsignedTx(tx: EvmTransactionRequest, chainId: string): Record<string, string>;
28
+ export declare class OneWalletApiAdapter implements WalletProviderPort {
29
+ private readonly opts;
30
+ readonly client: OneWalletApiClient;
31
+ readonly authzKeys: AuthzKeyManager;
32
+ private walletAddress;
33
+ constructor(opts: OneWalletApiAdapterOptions);
34
+ checkWallet(): Promise<WalletCheckResult>;
35
+ getOrCreateWallet(_userId: string): Promise<WalletData>;
36
+ getAddresses(_userId: string): Promise<Array<{
37
+ address: string;
38
+ index: number;
39
+ name?: string;
40
+ }>>;
41
+ getAddress(userId: string, index: number): Promise<AddressInfo>;
42
+ signMessage(_userId: string, chainId: string, message: string, index?: number, _uuid?: string, from?: string): Promise<SignResponse>;
43
+ signTypedData(_userId: string, chainId: string, typedData: unknown, index?: number, _uuid?: string, from?: string): Promise<SignResponse>;
44
+ signTransaction(_userId: string, chainId: string, tx: EvmTransactionRequest, index?: number): Promise<SignResponse>;
45
+ sendTransaction(_userId: string, chainId: string, tx: EvmTransactionRequest): Promise<{
46
+ txHash: string;
47
+ }>;
48
+ /** 로그아웃 · 세션 종료 — B 키를 폐기하고 캐시를 지운다 */
49
+ signOut(): Promise<void>;
50
+ private walletData;
51
+ private findWallet;
52
+ private requireWalletAddress;
53
+ /**
54
+ * 서명할 계정(주소 · index). 주소 경로 작업은 서버가 intent index 를 경로 주소의 index 와 대조하므로
55
+ * 경로 · 바인딩 · intent 를 모두 같은 계정으로 맞춘다. `from` 이 있으면 그것이 우선이다.
56
+ */
57
+ private resolveTarget;
58
+ private requirePin;
59
+ /** 봉투를 만들어 보낸다. 키 · 수신키 문제로 거부되면 새로 받아 한 번 더 보낸다 */
60
+ private withEnvelope;
61
+ }
@@ -0,0 +1,37 @@
1
+ import { TransportPort, TransportRequest } from '../../core/ports/TransportPort';
2
+ import { CROSSxError } from '../../core/types/errors';
3
+ import { Bytes } from './crypto/bytes';
4
+
5
+ export interface OneWalletApiClientOptions {
6
+ /** 예: `https://dev-one-pocket-api.onechain.nexus/embed/v1`. 함수면 요청마다 읽는다(환경 설정이 초기화 때 정해진다) */
7
+ baseUrl: string | (() => string);
8
+ transport: TransportPort;
9
+ /** 유효한 one-oauth access token 을 돌려준다(필요하면 갱신). 없으면 AUTH_NOT_AUTHENTICATED 를 던진다 */
10
+ getAccessToken: () => Promise<string>;
11
+ now?: () => number;
12
+ }
13
+ export interface OneWalletErrorBody {
14
+ code?: string;
15
+ message?: string;
16
+ remaining_attempts?: number;
17
+ lock_expires_at?: number;
18
+ permanent?: boolean;
19
+ tx_hash?: string;
20
+ }
21
+ /** 서버 오류 → CROSSxError. 모르는 코드는 상태로 고른다 */
22
+ export declare function toOneWalletError(status: number, body: OneWalletErrorBody | null | undefined): CROSSxError;
23
+ export declare class OneWalletApiClient {
24
+ private readonly opts;
25
+ private recipient;
26
+ private readonly now;
27
+ constructor(opts: OneWalletApiClientOptions);
28
+ /** 인증이 필요한 요청. 2xx 가 아니면 CROSSxError 를 던진다 */
29
+ call<T>(method: TransportRequest['method'], path: string, body?: unknown): Promise<T>;
30
+ /** 인증 없는 요청(`/attestation`, `/chains`) */
31
+ callPublic<T>(method: TransportRequest['method'], path: string): Promise<T>;
32
+ /** enclave 수신 공개키(SEC1 65B) */
33
+ getRecipientKey(): Promise<Bytes>;
34
+ /** 수신키 회전 등으로 봉투가 거부되면 다음 요청에서 다시 받는다 */
35
+ forgetRecipientKey(): void;
36
+ private send;
37
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 인증 봉투용 바이트 도우미 (DEV2TF-2755).
3
+ * one-wallet-api `testbed/web/js/crypto/bytes.js` 와 같은 규칙 — 브라우저 · Node 공통.
4
+ */
5
+ export type Bytes = Uint8Array<ArrayBuffer>;
6
+ export declare function utf8(s: string): Bytes;
7
+ export declare function concat(...parts: Uint8Array[]): Bytes;
8
+ export declare function u32be(n: number): Bytes;
9
+ /** 표준 base64 — 서버 wire(Go []byte JSON) 규칙 */
10
+ export declare function b64encode(bytes: Uint8Array): string;
11
+ export declare function b64decode(str: string): Bytes;
12
+ /** base64url(패딩 없음) — JWK 필드 */
13
+ export declare function b64uEncode(bytes: Uint8Array): string;
14
+ export declare function b64uDecode(str: string): Bytes;
15
+ export declare function randomBytes(n: number): Bytes;
16
+ export declare function sha256(data: Uint8Array): Promise<Bytes>;
@@ -0,0 +1,103 @@
1
+ import { Bytes } from './bytes';
2
+ import { HpkeRecipientKeyPair } from './hpke';
3
+
4
+ /** 봉투 기본 수명(초). enclave 상한은 60s + 시계 오차 */
5
+ export declare const ENVELOPE_TTL_SEC = 60;
6
+ /** 지갑 API 표면 → enclave command 바이트 (signer protocol.Command) */
7
+ export declare const ONE_WALLET_COMMAND: {
8
+ readonly generate: 1;
9
+ readonly recover: 3;
10
+ readonly verify_pin: 4;
11
+ readonly change_pin: 5;
12
+ readonly get_address: 10;
13
+ readonly get_mnemonic: 11;
14
+ readonly get_private_key: 12;
15
+ readonly get_share_c: 13;
16
+ readonly activate: 14;
17
+ readonly sign: 20;
18
+ readonly sign_typed_data: 21;
19
+ readonly sign_message: 22;
20
+ };
21
+ export type OneWalletCommand = keyof typeof ONE_WALLET_COMMAND;
22
+ /** 서버가 준 B 키 인증서(key_cert)에 cert_sig 를 sig 필드로 붙인 것 — 봉투에 그대로 싣는다 */
23
+ export interface AuthzKeyCert {
24
+ key_id: string;
25
+ pubkey: string;
26
+ user_id: string;
27
+ session_id: string;
28
+ issued_at: string;
29
+ expires_at: string;
30
+ sig: string;
31
+ }
32
+ export interface AuthzSigner {
33
+ /** B 키 개인키. 꺼낼 수 없는 ECDSA P-256 키 */
34
+ signingKey: CryptoKey;
35
+ keyId: string;
36
+ cert: AuthzKeyCert;
37
+ }
38
+ export interface EnvelopePlaintext {
39
+ pin: string;
40
+ new_pin?: string;
41
+ share_c?: Uint8Array;
42
+ response_key?: Uint8Array;
43
+ }
44
+ export interface AuthEnvelope {
45
+ enc: string;
46
+ ciphertext: string;
47
+ nonce: string;
48
+ expires_at: string;
49
+ intent_hash: string;
50
+ authz_key_id: string;
51
+ authz_sig: string;
52
+ authz_key_cert: AuthzKeyCert;
53
+ }
54
+ export interface SealedValue {
55
+ enc: string;
56
+ ciphertext: string;
57
+ }
58
+ interface TranscriptCore {
59
+ nonce: Uint8Array;
60
+ expiresAt: string;
61
+ intentHash: Uint8Array;
62
+ authzKeyId: string;
63
+ }
64
+ /** HPKE AAD = SHA-256(seal-aad 트랜스크립트). 봉인 응답을 열 때도 같은 값을 쓴다 */
65
+ export declare function sealAadDigest(core: TranscriptCore, bindingId: string, command: number): Promise<Bytes>;
66
+ /** authz_sig 대상 다이제스트 (테스트 · 대조용) */
67
+ export declare function signingDigest(core: TranscriptCore & {
68
+ enc: Uint8Array;
69
+ ciphertext: Uint8Array;
70
+ }, bindingId: string, command: number): Promise<Bytes>;
71
+ /** RFC 3339 UTC, 초 단위('Z', 소수초 없음) */
72
+ export declare function rfc3339Seconds(date: Date): string;
73
+ /** B 키 발급 응답의 32B scalar 와 cert 공개키로 서명 키를 만든다. 꺼낼 수 없다 */
74
+ export declare function importAuthzSigningKey(scalar: Uint8Array, pubSec1: Uint8Array): Promise<CryptoKey>;
75
+ export interface BuildEnvelopeOptions {
76
+ /** enclave 수신 공개키 (attestation `recipient_public_key`, SEC1 65B) */
77
+ recipientPub: Uint8Array;
78
+ /**
79
+ * 지갑 슬롯 바인딩 값. `/wallets/{address}/...` 는 그 주소 문자열 그대로,
80
+ * 주소가 없는 generate(`POST /wallets`)만 토큰 sub.
81
+ */
82
+ bindingId: string;
83
+ command: OneWalletCommand;
84
+ /** 커맨드별 공개 파라미터. `command` 필드를 포함한다 */
85
+ intent: {
86
+ command: OneWalletCommand;
87
+ } & Record<string, unknown>;
88
+ plaintext: EnvelopePlaintext;
89
+ authz: AuthzSigner;
90
+ ttlSec?: number;
91
+ now?: Date;
92
+ }
93
+ export interface BuiltEnvelope {
94
+ envelope: AuthEnvelope;
95
+ /** intent JSON 바이트의 base64 — 서버가 그대로 enclave 로 넘긴다 */
96
+ intent: string;
97
+ /** 봉인 응답(sealed_share_c 등)을 열 때 쓰는 AAD */
98
+ aad: Bytes;
99
+ }
100
+ export declare function buildAuthEnvelope(opts: BuildEnvelopeOptions): Promise<BuiltEnvelope>;
101
+ /** 서버가 우리 응답 키로 봉인한 값({enc, ciphertext}, 표준 base64)을 연다 */
102
+ export declare function openSealed(recipient: HpkeRecipientKeyPair, sealed: SealedValue, aad: Uint8Array): Promise<Bytes>;
103
+ export {};
@@ -0,0 +1,17 @@
1
+ import { Bytes } from './bytes';
2
+
3
+ /** 봉인 응답을 받을 임시 수신 키. publicKey 는 SEC1 uncompressed 65B */
4
+ export interface HpkeRecipientKeyPair {
5
+ privateKey: CryptoKey;
6
+ publicKey: Bytes;
7
+ }
8
+ export declare function assertSec1P256(pub: Uint8Array, what: string): void;
9
+ /** 응답 봉인용 임시 키를 만든다. 개인키는 꺼낼 수 없다 */
10
+ export declare function generateRecipientKeyPair(): Promise<HpkeRecipientKeyPair>;
11
+ /** recipientPub(SEC1 65B)에게 plaintext 를 봉인한다 */
12
+ export declare function seal(recipientPub: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): Promise<{
13
+ enc: Bytes;
14
+ ciphertext: Bytes;
15
+ }>;
16
+ /** 우리 수신 키로 봉인된 값을 연다. AAD 가 다르면 실패한다 */
17
+ export declare function open(recipient: HpkeRecipientKeyPair, enc: Uint8Array, ciphertext: Uint8Array, aad: Uint8Array): Promise<Bytes>;
@@ -53,6 +53,11 @@ export interface EnvironmentUrls {
53
53
  * `SDKConfig.oneId.issuer`로 덮어쓸 수 있다. 상용 issuer는 아직 확인되지 않아 비어 있다.
54
54
  */
55
55
  oneIdIssuer: string;
56
+ /**
57
+ * 새 지갑 서버 one-wallet-api (`SDKConfig.walletServer: 'one-wallet'`, DEV2TF-2755).
58
+ * stage · 상용 주소는 아직 확인되지 않아 비어 있다.
59
+ */
60
+ oneWalletApiUrl: string;
56
61
  }
57
62
  export declare const ENVIRONMENTS: Record<SDKEnvironment, EnvironmentUrls>;
58
63
  /**
@@ -46,7 +46,7 @@ export declare const PIN_KEY_CACHE_TTL_MS: number;
46
46
  */
47
47
  export declare const PIN_KEY_PROBE_RETRY_MS: number;
48
48
  /** Token History API clientVersion (registerTokenHistory 호출 시 전송) */
49
- export declare const SDK_CLIENT_VERSION = "crossx-sdk-js/2.6.0";
49
+ export declare const SDK_CLIENT_VERSION = "crossx-sdk-js/3.0.0-beta.1";
50
50
  /**
51
51
  * 게이트웨이 요청마다 SDK 버전을 실어 보내는 헤더. 값은 {@link SDK_CLIENT_VERSION}.
52
52
  * 게이트웨이(walletGatewayUrl)로 가는 요청에만 붙는다 — 체인 RPC·인증 서버·CDN 은
@@ -1,4 +1,4 @@
1
- import { ConnectOtherWalletItem, LoginSelectorResult, SDKThemeTokens, SelectWalletOptions } from '../types';
1
+ import { ConnectOtherWalletItem, LoginSelectorResult, PinKeyboardOption, SDKThemeTokens, SelectWalletOptions } from '../types';
2
2
  import { SDKMessages } from '../i18n';
3
3
 
4
4
  /** 모든 컨펌 상세에 공통으로 포함되는 UI 메타 필드 */
@@ -225,5 +225,32 @@ export interface ConfirmationPort {
225
225
  * 다음 모달이 열릴 때부터 적용됩니다.
226
226
  */
227
227
  setMessages(messages: SDKMessages): void;
228
+ /**
229
+ * 런타임에 PIN 키보드 방식을 변경합니다. 다음 PIN 모달부터 적용됩니다.
230
+ * 화면이 없는 구현은 생략할 수 있습니다.
231
+ */
232
+ setPinKeyboard?(option: PinKeyboardOption | undefined): void;
233
+ }
234
+ /**
235
+ * 화면(UI) 어댑터를 만들 때 core 가 넘기는 값 (DEV2TF-2321).
236
+ * UI 는 환경 · 테마를 스스로 정하지 않고 이 값만 쓴다.
237
+ */
238
+ export interface ConfirmationUIOptions {
239
+ theme: 'light' | 'dark';
240
+ themeTokens?: SDKThemeTokens;
241
+ displayDecimals?: number;
242
+ pinKeyboard?: PinKeyboardOption;
243
+ /** core 빌드 환경에서 정한 CDN 주소 */
244
+ endpoints: {
245
+ /** chains.json 등 정적 콘텐츠 (빈 문자열이면 사용 안 함) */
246
+ contentsBaseUrl: string;
247
+ /** 지갑 portrait 이미지 */
248
+ portraitBaseUrl: string;
249
+ };
228
250
  }
251
+ /**
252
+ * 화면(UI) 어댑터 생성 함수. `@nexus-cross/crossx-sdk-core/internal` 의 `createCROSSxSDKWithOverrides(config, { ui })` 로 넘긴다.
253
+ * 브라우저 기본 화면은 `@nexus-cross/crossx-sdk-ui` 의 `createBrowserUI` 다.
254
+ */
255
+ export type ConfirmationUIFactory = (options: ConfirmationUIOptions) => ConfirmationPort;
229
256
  export {};
@@ -23,6 +23,8 @@ export declare class PinMemoryStore {
23
23
  private encryptedBytes;
24
24
  /** PIN과 같은 길이의 랜덤 XOR 키 */
25
25
  private xorKey;
26
+ /** PIN 을 넣은 시각 (ms). 재사용 시간 판단용 (PinReusePolicy, DEV2TF-2370) */
27
+ private setAt;
26
28
  /**
27
29
  * PIN을 메모리에 암호화하여 저장합니다.
28
30
  * 이전 값이 있으면 먼저 안전하게 소거합니다.
@@ -37,6 +39,8 @@ export declare class PinMemoryStore {
37
39
  * 저장된 PIN과 키를 안전하게 소거합니다.
38
40
  */
39
41
  clear(): void;
42
+ /** PIN 을 넣은 시각 (ms). 없으면 null. */
43
+ getSetAt(): number | null;
40
44
  /** PIN이 저장되어 있는지 여부를 반환합니다. */
41
45
  has(): boolean;
42
46
  }
@@ -0,0 +1,30 @@
1
+ import { PrepareAction, PrepareContext } from '../types/prepare';
2
+
3
+ export type PinReusePolicy =
4
+ /** 서명마다 PIN 을 받는다. */
5
+ {
6
+ mode: 'off';
7
+ }
8
+ /** PIN 을 넣은 지 `ttlMs` 안이고 위험 요청이 아니면 메모리의 PIN 을 다시 쓴다. */
9
+ | {
10
+ mode: 'memory';
11
+ ttlMs: number;
12
+ };
13
+ /** 기본 재사용 시간 — authz key B 수명 상한(15분)과 맞춘다. */
14
+ export declare const DEFAULT_PIN_REUSE_TTL_MS: number;
15
+ export type PinSigningRequest = {
16
+ action: PrepareAction;
17
+ context: PrepareContext;
18
+ };
19
+ /**
20
+ * 사용 권한을 넘기는 요청이면 true. 이런 요청은 시간 안이어도 PIN 을 다시 받는다.
21
+ * 다른 호출 안에 감싼 approve(multicall · router 등)는 풀어 보지 않는다 (범위 밖, DEV2TF-2370).
22
+ */
23
+ export declare function isHighRiskSigning(request: PinSigningRequest): boolean;
24
+ /**
25
+ * 메모리의 PIN 을 이번 서명에 다시 써도 되는지.
26
+ * 정책이 없으면(공개 SDK) 지금 동작대로 true.
27
+ */
28
+ export declare function canReusePin(policy: PinReusePolicy | undefined, pinSetAt: number | null, now: number, request: PinSigningRequest): boolean;
29
+ /** 서명이 끝난 뒤 PIN 을 지워야 하면 true (서명마다 PIN). */
30
+ export declare function shouldClearAfterSigning(policy: PinReusePolicy | undefined): boolean;
@@ -76,6 +76,8 @@ export declare enum ErrorCode {
76
76
  PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED",// -10022: 미등록 프로젝트 또는 origin
77
77
  /** 게이트웨이가 이 SDK 버전을 더 이상 지원하지 않음 (SDK_VERSION_UNSUPPORTED_SERVER_CODE). SDK 업데이트 필요 */
78
78
  SDK_VERSION_UNSUPPORTED = "SDK_VERSION_UNSUPPORTED",
79
+ /** 화면(UI) 어댑터 없이 PIN · 확인 화면이 필요한 기능을 호출함. core/internal 의 createCROSSxSDKWithOverrides(config, { ui }) 로 주입 필요 (DEV2TF-2321) */
80
+ UI_NOT_PROVIDED = "UI_NOT_PROVIDED",
79
81
  /** Gateway 서명 ecrecover 불일치 — 서명자 주소가 기대 주소와 다름 */
80
82
  SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH",
81
83
  /** Gas 자동 조회 실패 (eth_gasPrice / eth_estimateGas) */
@@ -390,6 +390,16 @@ export interface SDKConfig {
390
390
  * ONE ID 로그인(one-oauth 경유) 설정. 없으면 `signInWithOneId()`가 `NOT_IMPLEMENTED`.
391
391
  */
392
392
  oneId?: OneIdConfig;
393
+ /**
394
+ * 지갑 서버 (DEV2TF-2755). 기본값 `'cross-gateway'`(2.x 게이트웨이).
395
+ *
396
+ * `'one-wallet'` 이면 새 지갑 서버(one-wallet-api, B 모델)를 쓰고 로그인은 ONE ID 세션만 인정한다.
397
+ * - `oneId` 설정이 필요하다.
398
+ * - 초기화 때 저장된 2.x 로그인 토큰은 무시하고 지운다(로그아웃 상태로 시작).
399
+ * - 지갑은 로그인 때 만들지 않고 처음 쓸 때(서명 · 전송 · `createWallet()`) PIN 설정과 함께 만든다.
400
+ * - 보안 화면 앱(iframe) 안의 core 에서만 쓴다 (onepocket-web decisions/0018).
401
+ */
402
+ walletServer?: 'cross-gateway' | 'one-wallet';
393
403
  /**
394
404
  * SDK 모달 UI 언어 설정
395
405
  *
@@ -6,6 +6,7 @@ import { ConfirmationPort } from '../ports/ConfirmationPort';
6
6
  import { TokenMemoryStore } from '../services/TokenMemoryStore';
7
7
  import { PinMemoryStore } from '../services/PinMemoryStore';
8
8
  import { PinEncryptorPort } from '../ports/PinEncryptorPort';
9
+ import { PinReusePolicy } from '../services/PinReusePolicy';
9
10
 
10
11
  /**
11
12
  * @internal internal 패키지 전용 — 공개 API에 노출하지 않음
@@ -47,6 +48,11 @@ export interface InternalSDKConfig extends SDKConfig {
47
48
  * false인 경우 refresh_token을 localStorage에 저장하지 않음 (JS-003).
48
49
  */
49
50
  secureStorageAvailable?: boolean;
51
+ /**
52
+ * PIN 재사용 정책 (DEV2TF-2370). `/internal` 의 `FactoryOverrides.pinReuse` 로만 채운다 —
53
+ * 공개 config 에 같은 이름을 넣어도 factory 가 덮어쓴다.
54
+ */
55
+ pinReuse?: PinReusePolicy;
50
56
  }
51
57
  /**
52
58
  * Firebase JWT 페이로드 (sign_in_provider, identities 포함)
@@ -15,5 +15,7 @@ export declare class SignOutUseCase {
15
15
  * 쓴다 — 다시 로그인할 때 같은 지갑을 모달 없이 고르기 위해서다 (DEV2TF-2368).
16
16
  */
17
17
  constructor(config: InternalSDKConfig, storage: StoragePort, tokenStore: TokenMemoryStore, preservedKeys?: readonly string[]);
18
+ /** 저장된 2.x 로그인 흔적(토큰 · 사용자 정보)이 있는지 — one-wallet 초기화에서 지울지 판단한다 (DEV2TF-2755) */
19
+ hasStoredSession(): Promise<boolean>;
18
20
  execute(): Promise<void>;
19
21
  }