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

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 (45) hide show
  1. package/README.md +4 -1
  2. package/dist/adapters/confirmation/BridgeConfirmationAdapter.d.ts +2 -0
  3. package/dist/adapters/confirmation/HeadlessConfirmationAdapter.d.ts +25 -0
  4. package/dist/adapters/oneid/BrowserOneIdAuthAdapter.d.ts +27 -2
  5. package/dist/adapters/oneid/appSecureFrameChannel.d.ts +22 -0
  6. package/dist/adapters/onewallet/AuthzKeyManager.d.ts +32 -0
  7. package/dist/adapters/onewallet/OneWalletApiAdapter.d.ts +80 -0
  8. package/dist/adapters/onewallet/OneWalletApiClient.d.ts +48 -0
  9. package/dist/adapters/onewallet/crypto/bytes.d.ts +16 -0
  10. package/dist/adapters/onewallet/crypto/envelope.d.ts +103 -0
  11. package/dist/adapters/onewallet/crypto/hpke.d.ts +17 -0
  12. package/dist/core/config/environments.d.ts +5 -0
  13. package/dist/core/constants.d.ts +1 -1
  14. package/dist/core/i18n/types.d.ts +11 -0
  15. package/dist/core/ports/ConfirmationPort.d.ts +33 -2
  16. package/dist/core/ports/TransportPort.d.ts +1 -1
  17. package/dist/core/ports/WalletProviderPort.d.ts +19 -0
  18. package/dist/core/services/PinMemoryStore.d.ts +26 -0
  19. package/dist/core/services/PinReusePolicy.d.ts +30 -0
  20. package/dist/core/types/errors.d.ts +13 -0
  21. package/dist/core/types/index.d.ts +38 -1
  22. package/dist/core/types/internal.d.ts +6 -0
  23. package/dist/core/usecases/SignOutUseCase.d.ts +2 -0
  24. package/dist/core/utils/walletName.d.ts +11 -0
  25. package/dist/crossx.global +6 -3264
  26. package/dist/factory-C1Sze9RB.js +8366 -0
  27. package/dist/factory-gz0FAIjv.cjs +9 -0
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.ts +6 -4
  30. package/dist/index.js +22 -18
  31. package/dist/internal.cjs +1 -1
  32. package/dist/internal.d.ts +8 -1
  33. package/dist/internal.js +11 -3
  34. package/dist/sdk/CROSSxSDK.d.ts +85 -1
  35. package/dist/sdk/factory.d.ts +25 -3
  36. package/dist/sdk/internalContext.d.ts +15 -0
  37. package/dist/sdk/services/AddressResolverService.d.ts +2 -0
  38. package/dist/sdk/services/OneIdSessionManager.d.ts +48 -1
  39. package/dist/sdk/services/PinOrchestrator.d.ts +37 -1
  40. package/dist/sdk/services/SigningOrchestrator.d.ts +3 -0
  41. package/package.json +1 -1
  42. package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts +0 -140
  43. package/dist/adapters/confirmation/walletCreatedIllustration.d.ts +0 -11
  44. package/dist/factory-CFIZEUse.cjs +0 -3267
  45. package/dist/factory-CJQfgIu8.js +0 -11704
package/README.md CHANGED
@@ -101,9 +101,12 @@ const addr = await sdk.getAddress(1); // specific index
101
101
  // List all wallet addresses
102
102
  const addrs = await sdk.getAddresses(); // [{ address, index, name? }]
103
103
 
104
- // Open wallet selector modal (multi-wallet)
104
+ // Open wallet selector modal (multi-wallet) — select or add; emits addressChanged
105
105
  const selected = await sdk.selectWallet();
106
106
 
107
+ // Switch to a listed wallet without the modal (WALLET_NOT_FOUND if not in getAddresses())
108
+ const switched = await sdk.switchWallet(addrs[1].address);
109
+
107
110
  // Native balance
108
111
  const { wei, formatted } = await sdk.getBalance(ChainId.ONE_MAINNET);
109
112
  console.log(formatted); // "1.234567 CROSS"
@@ -54,6 +54,8 @@ export declare class BridgeConfirmationAdapter implements ConfirmationPort {
54
54
  showWalletCreatedPrompt(): Promise<void>;
55
55
  showPinSetupPrompt(options?: {
56
56
  errorMessage?: string;
57
+ /** 'change' 면 안내(동의) 단계 없이 새 PIN 입력 · 확인만 — PIN 변경용 (GASPQA-6804) */
58
+ mode?: 'create' | 'change';
57
59
  }): Promise<string | null>;
58
60
  showPinInputPrompt(options?: {
59
61
  errorMessage?: string;
@@ -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
+ }
@@ -1,5 +1,6 @@
1
1
  import { OneIdAuthPort, OneIdAuthorizeRequest, OneIdAuthorizeResult, OneIdClientConfig, OneIdTokens } from '../../core/ports/OneIdAuthPort';
2
2
  import { ErrorCode } from '../../core/types/errors';
3
+ import { AppChannel } from './appSecureFrameChannel';
3
4
 
4
5
  /** 팝업 결과 대기 제한 시간 — 2.x OAuth와 같은 5분 */
5
6
  export declare const ONEID_AUTH_TIMEOUT_MS: number;
@@ -7,6 +8,8 @@ export declare const ONEID_AUTH_TIMEOUT_MS: number;
7
8
  export declare const ONEID_PENDING_TTL_MS: number;
8
9
  /** 같은 창 이동 진행 정보 저장 키 (sessionStorage) */
9
10
  export declare const ONEID_PENDING_STORAGE_KEY = "crossx.oneid.pending";
11
+ /** 원포켓 앱 안 로그인의 redirect_uri 경로 — 보안 화면 서버가 받은 값을 앱으로 넘긴다 (docs/30 §5.2) */
12
+ export declare const ONEID_APP_CALLBACK_PATH = "/auth/app-callback";
10
13
  /**
11
14
  * ONE ID · one-oauth 인가 오류 코드 → SDK ErrorCode
12
15
  *
@@ -17,15 +20,28 @@ export declare const ONEID_PENDING_STORAGE_KEY = "crossx.oneid.pending";
17
20
  export declare function mapOneIdError(error: string): ErrorCode;
18
21
  /** refresh 실패 사유(`error_reason`, SPEC-0009 Rule 7) → SDK ErrorCode */
19
22
  export declare function mapSessionEndReason(reason: string | undefined): ErrorCode;
23
+ /** refresh 응답을 기다리는 최대 시간 */
24
+ export declare const REFRESH_TIMEOUT_MS: number;
20
25
  /**
21
- * 같은 창 이동 뒤 돌아갈 앱 경로. 같은 origin 상대 경로(`/`로 시작, `//` · `/\\` 아님)만 받는다 —
22
- * 그 밖의 값은 버린다(열린 리다이렉트 방지).
26
+ * 같은 창 이동 뒤 돌아갈 앱 경로. 같은 origin 상대 경로(`/`로 시작)만 받는다 — 그 밖의 값은 버린다(열린 리다이렉트 방지).
27
+ * 브라우저는 경로의 탭 · 줄바꿈을 지우고 `\\` 를 `/` 로 읽어 `/\t/evil.com` 도 `//evil.com` 이 되므로,
28
+ * 제어 문자 · `\\` 가 있으면 버리고 URL 로 해석한 결과의 origin 을 다시 확인한다 (DEV2TF-2912 AC-4).
29
+ * 돌려주는 값은 해석된 경로 · query · hash 다.
23
30
  */
24
31
  export declare function toSafeReturnTo(value: string | undefined): string | undefined;
25
32
  /** issuer를 끝 `/` 없는 절대 URL로 고친다 */
26
33
  export declare function normalizeIssuer(issuer: string): string;
27
34
  /** JWT payload를 읽는다 (서명 검증 없음 — `/token` 응답을 TLS로 직접 받은 값에만 쓴다) */
28
35
  export declare function decodeJwtPayload(token: string): Record<string, unknown> | null;
36
+ /** 인가 결과에서 값을 읽는 형태 — URLSearchParams 와 앱 응답을 같은 검사로 본다 */
37
+ interface ResultParams {
38
+ get(name: string): string | null;
39
+ }
40
+ /**
41
+ * 인가 결과 검사 — state → iss → error → code 순서 (같은 창 이동 콜백 · 앱 결과 공통).
42
+ * 성공이면 code 를 돌려준다.
43
+ */
44
+ export declare function checkAuthorizationResult(params: ResultParams, expectedState: string, issuer: string): string;
29
45
  export interface BrowserOneIdAuthAdapterOptions {
30
46
  /** 테스트용 fetch */
31
47
  fetch?: typeof fetch;
@@ -35,6 +51,8 @@ export interface BrowserOneIdAuthAdapterOptions {
35
51
  pendingStorage?: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
36
52
  /** 같은 창 이동. 기본 `window.location.assign` */
37
53
  navigate?: (url: string) => void;
54
+ /** 원포켓 앱 채널. 기본은 호출마다 `window` 에서 찾는다 (테스트 · 끄기용 null) */
55
+ appChannel?: AppChannel | null;
38
56
  }
39
57
  export declare class BrowserOneIdAuthAdapter implements OneIdAuthPort {
40
58
  private abortPending;
@@ -53,6 +71,12 @@ export declare class BrowserOneIdAuthAdapter implements OneIdAuthPort {
53
71
  }>;
54
72
  refresh(config: OneIdClientConfig, refreshToken: string): Promise<OneIdTokens>;
55
73
  logout(config: OneIdClientConfig, accessToken: string): Promise<void>;
74
+ private findAppChannel;
75
+ /**
76
+ * 원포켓 앱에 인증을 맡긴다 (docs/30 §5). PAR · 토큰 교환은 이 페이지(보안 화면 origin)에서 하고,
77
+ * 앱은 인증 화면을 열어 결과만 돌려준다. PKCE verifier 는 이 함수 밖으로 나가지 않는다.
78
+ */
79
+ private authorizeWithApp;
56
80
  private openBlankPopup;
57
81
  /** PAR — request_uri를 받는다 */
58
82
  private pushAuthorizationRequest;
@@ -63,3 +87,4 @@ export declare class BrowserOneIdAuthAdapter implements OneIdAuthPort {
63
87
  /** 진행 정보를 꺼내고 지운다 (한 번만 쓴다) */
64
88
  private takePending;
65
89
  }
90
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ErrorCode } from '../../core/types/errors';
2
+
3
+ export declare const APP_CHANNEL_NAME = "onepocketSecureFrame";
4
+ export declare const APP_CHANNEL_VERSION = 1;
5
+ /** 앱이 돌려주는 채널 오류 코드 */
6
+ export type AppChannelErrorCode = 'cancelled' | 'busy' | 'invalid_request' | 'unsupported' | 'internal';
7
+ export interface AppChannel {
8
+ /**
9
+ * 요청을 보내고 응답 payload 를 받는다. 앱 오류는 CROSSxError 로 던진다.
10
+ * `signal` 이 끊기면 응답을 더 기다리지 않는다(늦은 응답은 버린다).
11
+ */
12
+ request(type: string, payload: Record<string, unknown>, signal?: AbortSignal): Promise<Record<string, unknown>>;
13
+ /** 응답을 기다리지 않는 알림 (예: `oneid.cancel`) */
14
+ notify(type: string, payload: Record<string, unknown>): void;
15
+ }
16
+ /** 앱 채널 오류 → SDK ErrorCode. 취소만 USER_REJECTED, 나머지는 로그인 실패 */
17
+ export declare function mapAppChannelError(code: unknown): ErrorCode;
18
+ /**
19
+ * 원포켓 앱 채널을 찾는다. 동기 — 팝업을 열기 전(사용자 활성화 안)에 판별해야 한다.
20
+ * iframe 안이 아니거나 채널이 없으면(브라우저, 구버전 앱, dApp 메인 프레임) null.
21
+ */
22
+ export declare function detectAppChannel(win?: unknown): AppChannel | null;
@@ -0,0 +1,32 @@
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
+ /**
25
+ * 서버 호출 없이 잊는다 — 토큰이 이미 끝나 폐기를 부를 수 없을 때(세션 만료 · 폐기).
26
+ * 진행 중인 발급 결과도 버린다. 서버의 키는 cert 수명이 지나면 끝난다 (DEV2TF-2912 AC-6).
27
+ */
28
+ forget(): void;
29
+ /** 로그아웃 — 서버에서 폐기하고 잊는다. 폐기 실패는 무시한다(cert 는 곧 만료된다) */
30
+ revoke(): Promise<void>;
31
+ private issue;
32
+ }
@@ -0,0 +1,80 @@
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, OneWalletApiClientOptions } 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
+ /** 요청 인증 헤더. 없으면 Bearer (DEV2TF-2950, {@link OneWalletApiClientOptions.getAuthorizationHeaders}) */
16
+ getAuthorizationHeaders?: OneWalletApiClientOptions['getAuthorizationHeaders'];
17
+ /**
18
+ * 지갑 생성 응답의 share C(백업 조각)를 받는다. 보관 방식은 후속 작업(DEV2TF-2755 R-4)에서 정한다.
19
+ * 넘기지 않으면 버린다 — 그 지갑은 share C 복구를 쓸 수 없다.
20
+ */
21
+ onShareC?: (shareC: Uint8Array, walletAddress: string) => Promise<void> | void;
22
+ now?: () => number;
23
+ }
24
+ /** access token(JWT)의 sub. 서명 검증은 서버 몫이고 여기서는 바인딩 값으로만 쓴다 */
25
+ export declare function subjectOf(accessToken: string): string;
26
+ /** 2.x 포트의 메시지(문자열) → 서명할 바이트. `0x` hex 는 바이트로, 그 밖은 UTF-8 (personal_sign 관례) */
27
+ export declare function messageBytes(message: string): Uint8Array;
28
+ /** EvmTransactionRequest → intent unsigned_tx (snake_case hex). enclave 가 모르는 필드를 넣으면 거부하므로 빈 값은 뺀다 */
29
+ export declare function toUnsignedTx(tx: EvmTransactionRequest, chainId: string): Record<string, string>;
30
+ export declare class OneWalletApiAdapter implements WalletProviderPort {
31
+ private readonly opts;
32
+ readonly client: OneWalletApiClient;
33
+ readonly authzKeys: AuthzKeyManager;
34
+ private walletAddress;
35
+ constructor(opts: OneWalletApiAdapterOptions);
36
+ checkWallet(): Promise<WalletCheckResult>;
37
+ getOrCreateWallet(_userId: string): Promise<WalletData>;
38
+ getAddresses(_userId: string): Promise<Array<{
39
+ address: string;
40
+ index: number;
41
+ name?: string;
42
+ }>>;
43
+ /**
44
+ * `POST /wallets/{지갑}/pin/verify` — verify_pin 봉투 (docs/26 §5.1, GASPQA-6804).
45
+ * 틀리면 서버가 200 `{valid:false, remaining_attempts}` 를 주므로 `PIN_WRONG` 으로 바꿔 던진다. 잠금은 423 `PIN_LOCKED`.
46
+ */
47
+ checkPinForChange(pin: string): Promise<void>;
48
+ /** `PUT /wallets/{지갑}/pin` — change_pin 봉투, 평문 `{pin, new_pin}` → 204 (docs/26 §5.1, GASPQA-6804) */
49
+ changePin(oldPin: string, newPin: string): Promise<void>;
50
+ /** `PATCH /wallets/{addr}/addresses` — 봉투 없음, 한 번에 1~10개 (docs/26 §5.1, GASPQA-6803) */
51
+ setAddressNames(_userId: string, names: Array<{
52
+ address: string;
53
+ name: string;
54
+ }>): Promise<void>;
55
+ getAddress(userId: string, index: number): Promise<AddressInfo>;
56
+ signMessage(_userId: string, chainId: string, message: string, index?: number, _uuid?: string, from?: string): Promise<SignResponse>;
57
+ signTypedData(_userId: string, chainId: string, typedData: unknown, index?: number, _uuid?: string, from?: string): Promise<SignResponse>;
58
+ signTransaction(_userId: string, chainId: string, tx: EvmTransactionRequest, index?: number): Promise<SignResponse>;
59
+ sendTransaction(_userId: string, chainId: string, tx: EvmTransactionRequest): Promise<{
60
+ txHash: string;
61
+ }>;
62
+ /** 로그아웃 — B 키를 폐기하고 캐시를 지운다 */
63
+ signOut(): Promise<void>;
64
+ /**
65
+ * 세션이 끝났을 때(만료 · 폐기 · 강제 로그아웃) — 서버를 부르지 않고 B 키 · 지갑 주소 캐시를 잊는다.
66
+ * 남겨 두면 다음 로그인(다른 계정일 수 있다)이 이전 세션의 키 · 주소를 쓴다 (DEV2TF-2912 AC-6).
67
+ */
68
+ forgetSession(): void;
69
+ private walletData;
70
+ private findWallet;
71
+ private requireWalletAddress;
72
+ /**
73
+ * 서명할 계정(주소 · index). 주소 경로 작업은 서버가 intent index 를 경로 주소의 index 와 대조하므로
74
+ * 경로 · 바인딩 · intent 를 모두 같은 계정으로 맞춘다. `from` 이 있으면 그것이 우선이다.
75
+ */
76
+ private resolveTarget;
77
+ private requirePin;
78
+ /** 봉투를 만들어 보낸다. 키 · 수신키 문제로 거부되면 새로 받아 한 번 더 보낸다 */
79
+ private withEnvelope;
80
+ }
@@ -0,0 +1,48 @@
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
+ /**
12
+ * 이 요청에 붙일 인증 헤더(`Authorization` · `DPoP`). 없으면 `Authorization: Bearer <getAccessToken()>`.
13
+ * `url` 은 쿼리까지 포함한 요청 주소 — DPoP `htu` 는 받는 쪽에서 쿼리를 뺀다 (DEV2TF-2950)
14
+ */
15
+ getAuthorizationHeaders?: (request: {
16
+ method: string;
17
+ url: string;
18
+ retry?: boolean;
19
+ }) => Promise<Record<string, string>>;
20
+ now?: () => number;
21
+ }
22
+ export interface OneWalletErrorBody {
23
+ code?: string;
24
+ message?: string;
25
+ remaining_attempts?: number;
26
+ lock_expires_at?: number;
27
+ permanent?: boolean;
28
+ tx_hash?: string;
29
+ }
30
+ /** 서버 오류 → CROSSxError. 모르는 코드는 상태로 고른다 */
31
+ export declare function toOneWalletError(status: number, body: OneWalletErrorBody | null | undefined): CROSSxError;
32
+ export declare class OneWalletApiClient {
33
+ private readonly opts;
34
+ private recipient;
35
+ private readonly now;
36
+ constructor(opts: OneWalletApiClientOptions);
37
+ /** 인증이 필요한 요청. 2xx 가 아니면 CROSSxError 를 던진다 */
38
+ call<T>(method: TransportRequest['method'], path: string, body?: unknown): Promise<T>;
39
+ /** 인증 없는 요청(`/attestation`, `/chains`) */
40
+ callPublic<T>(method: TransportRequest['method'], path: string): Promise<T>;
41
+ /** enclave 수신 공개키(SEC1 65B) */
42
+ getRecipientKey(): Promise<Bytes>;
43
+ /** 수신키 회전 등으로 봉투가 거부되면 다음 요청에서 다시 받는다 */
44
+ forgetRecipientKey(): void;
45
+ /** 요청 주소. 환경 설정이 비어 있으면 INVALID_CONFIG */
46
+ private url;
47
+ private send;
48
+ }
@@ -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 는 2026-11-25 one-oauth 담당이 올린 주소(DEV2TF-2785). 상용 주소는 아직 확인되지 않아 비어 있다.
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.10";
50
50
  /**
51
51
  * 게이트웨이 요청마다 SDK 버전을 실어 보내는 헤더. 값은 {@link SDK_CLIENT_VERSION}.
52
52
  * 게이트웨이(walletGatewayUrl)로 가는 요청에만 붙는다 — 체인 RPC·인증 서버·CDN 은
@@ -46,6 +46,10 @@ export interface SDKMessages {
46
46
  login_selector_subtitle: string;
47
47
  login_selector_google: string;
48
48
  login_selector_apple: string;
49
+ /** 원아이디 로그인 버튼 (walletServer 'one-wallet', DEV2TF-2771) */
50
+ login_selector_oneid: string;
51
+ /** 원아이디만 고를 때 부제 */
52
+ login_selector_subtitle_oneid: string;
49
53
  login_selector_or: string;
50
54
  /** {tos}와 {pp} 자리표시자가 각각 Terms of Service / Privacy Policy 링크로 치환됩니다. */
51
55
  login_selector_terms_template: string;
@@ -92,11 +96,18 @@ export interface SDKMessages {
92
96
  pin_notice_next_button: string;
93
97
  pin_notice_submit_button: string;
94
98
  pin_setup_title: string;
99
+ /** PIN 입력 · 재입력 단계 제목 (OSG UID 11.16 「Set PIN」). `pin_setup_title` 은 안내 동의 단계 제목이다. */
100
+ pin_setup_enter_title: string;
95
101
  pin_setup_header_subtitle: string;
96
102
  pin_setup_subtitle: string;
97
103
  pin_setup_confirm_title: string;
98
104
  pin_setup_confirm_subtitle: string;
99
105
  pin_setup_mismatch_error: string;
106
+ /** 불일치 오류 둘째 줄 (UID 11.16 2.1 「Please try again.」) */
107
+ pin_setup_mismatch_detail: string;
108
+ pin_change_title: string;
109
+ pin_change_confirm_title: string;
110
+ pin_change_same_error: string;
100
111
  pin_validation_too_short: string;
101
112
  pin_validation_numbers_only: string;
102
113
  pin_validation_repeating_digit: string;
@@ -1,4 +1,4 @@
1
- import { ConnectOtherWalletItem, LoginSelectorResult, SDKThemeTokens, SelectWalletOptions } from '../types';
1
+ import { ConnectOtherWalletItem, LoginSelectorMethod, LoginSelectorResult, PinKeyboardOption, SDKThemeTokens, SelectWalletOptions } from '../types';
2
2
  import { SDKMessages } from '../i18n';
3
3
 
4
4
  /** 모든 컨펌 상세에 공통으로 포함되는 UI 메타 필드 */
@@ -92,10 +92,12 @@ export interface ConfirmationPort {
92
92
  /**
93
93
  * 로그인 프로바이더 선택 UI를 표시합니다.
94
94
  * @param options.connectOtherWallets 비어 있지 않으면 "Connect with Other Wallets" 카드(단일 버튼)와 지원 지갑 설명을 표시. 외부 지갑 선택 시 `walletId`는 목록의 첫 항목입니다.
95
- * @returns OAuth 선택, 외부 지갑 선택(`walletId`), 또는 null(취소)
95
+ * @param options.methods 보일 로그인 수단. 기본 `['apple', 'google']`. one-wallet 은 `['oneid']` (DEV2TF-2771)
96
+ * @returns OAuth 선택, 원아이디 선택, 외부 지갑 선택(`walletId`), 또는 null(취소)
96
97
  */
97
98
  showLoginSelector(options?: {
98
99
  connectOtherWallets?: ConnectOtherWalletItem[];
100
+ methods?: readonly LoginSelectorMethod[];
99
101
  }): Promise<LoginSelectorResult | null>;
100
102
  /**
101
103
  * 기존 지갑 발견 시 마이그레이션 안내 UI를 표시합니다.
@@ -161,6 +163,8 @@ export interface ConfirmationPort {
161
163
  */
162
164
  showPinSetupPrompt(options?: {
163
165
  errorMessage?: string;
166
+ /** 'change' 면 안내(동의) 단계 없이 새 PIN 입력 · 확인만 — PIN 변경용 (GASPQA-6804) */
167
+ mode?: 'create' | 'change';
164
168
  }): Promise<string | null>;
165
169
  /**
166
170
  * PIN 입력 UI를 표시합니다. (Enter PIN)
@@ -225,5 +229,32 @@ export interface ConfirmationPort {
225
229
  * 다음 모달이 열릴 때부터 적용됩니다.
226
230
  */
227
231
  setMessages(messages: SDKMessages): void;
232
+ /**
233
+ * 런타임에 PIN 키보드 방식을 변경합니다. 다음 PIN 모달부터 적용됩니다.
234
+ * 화면이 없는 구현은 생략할 수 있습니다.
235
+ */
236
+ setPinKeyboard?(option: PinKeyboardOption | undefined): void;
237
+ }
238
+ /**
239
+ * 화면(UI) 어댑터를 만들 때 core 가 넘기는 값 (DEV2TF-2321).
240
+ * UI 는 환경 · 테마를 스스로 정하지 않고 이 값만 쓴다.
241
+ */
242
+ export interface ConfirmationUIOptions {
243
+ theme: 'light' | 'dark';
244
+ themeTokens?: SDKThemeTokens;
245
+ displayDecimals?: number;
246
+ pinKeyboard?: PinKeyboardOption;
247
+ /** core 빌드 환경에서 정한 CDN 주소 */
248
+ endpoints: {
249
+ /** chains.json 등 정적 콘텐츠 (빈 문자열이면 사용 안 함) */
250
+ contentsBaseUrl: string;
251
+ /** 지갑 portrait 이미지 */
252
+ portraitBaseUrl: string;
253
+ };
228
254
  }
255
+ /**
256
+ * 화면(UI) 어댑터 생성 함수. `@nexus-cross/crossx-sdk-core/internal` 의 `createCROSSxSDKWithOverrides(config, { ui })` 로 넘긴다.
257
+ * 브라우저 기본 화면은 `@nexus-cross/crossx-sdk-ui` 의 `createBrowserUI` 다.
258
+ */
259
+ export type ConfirmationUIFactory = (options: ConfirmationUIOptions) => ConfirmationPort;
229
260
  export {};
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export interface TransportRequest {
6
6
  url: string;
7
- method: 'GET' | 'POST' | 'PUT' | 'DELETE';
7
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
8
8
  headers?: Record<string, string>;
9
9
  body?: any;
10
10
  /** 요청 타임아웃 (ms). 기본값은 어댑터 구현에 따라 다름. */
@@ -23,6 +23,14 @@ export interface WalletProviderPort {
23
23
  index: number;
24
24
  name?: string;
25
25
  }>>;
26
+ /**
27
+ * 주소 이름 저장 (PIN 불필요). 이름은 `getAddresses` 의 `name` 으로 내려온다.
28
+ * 지원하지 않는 지갑 서버(2.x 게이트웨이 · RN 브리지)는 두지 않는다 (GASPQA-6803)
29
+ */
30
+ setAddressNames?(userId: string, names: Array<{
31
+ address: string;
32
+ name: string;
33
+ }>): Promise<void>;
26
34
  /**
27
35
  * 특정 인덱스의 주소 조회
28
36
  */
@@ -75,6 +83,17 @@ export interface WalletProviderPort {
75
83
  * @returns PIN이 올바르면 true, 아니면 false
76
84
  */
77
85
  verifyPin?(pin: string): Promise<boolean>;
86
+ /**
87
+ * PIN 변경 전 현재 PIN 확인 (GASPQA-6804). 맞으면 끝나고, 틀리면 `PIN_WRONG`(details.remainingAttempts),
88
+ * 잠금이면 `PIN_LOCKED`(details.lockExpiresAt · permanent) 를 던진다. `verifyPin` 과 달리 세션 복원 흐름은 쓰지 않는다.
89
+ * 지원하는 지갑 서버만 둔다 (one-wallet).
90
+ */
91
+ checkPinForChange?(pin: string): Promise<void>;
92
+ /**
93
+ * PIN 변경 (GASPQA-6804). 현재 PIN 이 틀리면 `PIN_WRONG`, 잠금이면 `PIN_LOCKED`.
94
+ * 지원하는 지갑 서버만 둔다 — 2.x 게이트웨이(`/mnemonic/change-password`) · one-wallet(`PUT …/pin`).
95
+ */
96
+ changePin?(oldPin: string, newPin: string): Promise<void>;
78
97
  /**
79
98
  * Share-C 발급 — POST /mnemonic/share-c
80
99
  * 니모닉을 재분할하여 새로운 Share-C를 반환합니다. 기존 Share-C는 무효화됩니다.