@ab-org/predicate-market-sdk 1.0.1 → 2.0.0

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 (3) hide show
  1. package/dist/index.d.ts +91 -57
  2. package/dist/index.js +40672 -2363
  3. package/package.json +7 -2
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { SessionCapabilityPolicy, CubeSignerConfig, WalletSession, SupportedToken, SupportedChain, WalletCapability, CubeSignerSession } from '@ab-org/sdk-core';
1
+ import { SessionCapabilityPolicy, CubeSignerConfig, CubeSignerSession, WalletSession, SupportedToken, SupportedChain, WalletCapability } from '@ab-org/sdk-core';
2
2
  import { ReactNode, ChangeEventHandler } from 'react';
3
+ import { SocialAccount } from '@ab-org/social-account-sdk';
4
+ import * as node_modules__types_react_jsx_runtime_js from 'node_modules/@types/react/jsx-runtime.js';
3
5
  import { AxiosInstance } from 'axios';
4
6
  import * as react_jsx_runtime_js from 'react/jsx-runtime.js';
5
7
  export { ClientIds, DEFAULT_FUNDING_CHAIN_ID, DEFAULT_FUNDING_TOKEN_ADDRESS, EvmChainInfo, getChainInfo, getFundingTokenAddress } from '@ab-org/wallet-utils';
@@ -83,9 +85,6 @@ interface SignInUiConfig {
83
85
  socialProviders?: SocialProvider[];
84
86
  wallets?: WalletItem[];
85
87
  initialVisibleCount?: number;
86
- /**
87
- * @deprecated Ignored by `SignInModal` / `useSignInModalController`: social login creates the session without `window.confirm`.
88
- */
89
88
  sessionConfirmation?: {
90
89
  enabled?: boolean;
91
90
  title?: string;
@@ -94,44 +93,13 @@ interface SignInUiConfig {
94
93
  sessionPolicy?: Partial<SessionCapabilityPolicy>;
95
94
  }
96
95
 
97
- interface SDKConfig {
96
+ interface SDKConfig$1 {
98
97
  googleClientId?: string;
99
98
  twitterClientId?: string;
100
99
  twitterRedirectUri?: string;
101
100
  cubeSigner?: CubeSignerConfig;
102
101
  signIn?: SignInUiConfig;
103
102
  }
104
- /**
105
- * Fixed auth config: built-in bundled defaults (see bundledConfig.ts) with optional
106
- * overrides from environment (server / `NEXT_PUBLIC_*` client). Used as defaults in initSDK.
107
- */
108
- declare function getFixedAuthConfig(): Partial<SDKConfig>;
109
- /**
110
- * Config for initializing the predicate SDK. Defaults come from bundled config
111
- * (and env overrides); you may override any of them here. Optional top-level
112
- * `registerUser` is merged into `cubeSigner.oidcLoginHooks` when cubeSigner is present.
113
- */
114
- interface PredicateSDKConfig extends Partial<SDKConfig> {
115
- /**
116
- * Optional hook to register the user on your backend when CubeSigner proof
117
- * indicates the user is not initialized. Used when cubeSigner is available
118
- * (from env or override).
119
- */
120
- registerUser?: (oidcToken: string) => Promise<void>;
121
- }
122
- declare function initSDK(config?: PredicateSDKConfig): void;
123
- declare function getSDKConfig(): Readonly<SDKConfig>;
124
-
125
- /**
126
- * Attempt to silently reconnect a wallet whose session was restored
127
- * from localStorage cache. Creates a temporary `WalletConnector` with
128
- * the default adapter registry (injected wallets + Cubist if configured)
129
- * and delegates to `WalletConnector.tryAutoReconnect()`.
130
- *
131
- * Safe to call multiple times — concurrent calls share the same promise.
132
- * Returns the fresh session on success, or `null` if reconnection failed.
133
- */
134
- declare function tryAutoReconnect(): Promise<WalletSession | null>;
135
103
 
136
104
  declare global {
137
105
  interface Window {
@@ -156,16 +124,25 @@ interface GISInitConfig {
156
124
  }
157
125
  interface GISCredentialResponse {
158
126
  credential: string;
127
+ select_by?: string;
128
+ clientId?: string;
159
129
  }
160
130
  interface GISPromptMoment {
131
+ isDisplayMoment(): boolean;
132
+ isDisplayed(): boolean;
133
+ isNotDisplayed(): boolean;
161
134
  isSkippedMoment(): boolean;
162
135
  isDismissedMoment(): boolean;
163
- isNotDisplayed(): boolean;
136
+ getNotDisplayedReason(): string;
164
137
  getDismissedReason(): string;
138
+ getSkippedReason(): string;
165
139
  }
166
140
  interface GISButtonConfig {
167
141
  type?: "standard" | "icon";
142
+ theme?: "outline" | "filled_blue" | "filled_black";
168
143
  size?: "large" | "medium" | "small";
144
+ text?: "signin_with" | "signup_with" | "continue_with" | "signin";
145
+ width?: number;
169
146
  }
170
147
  interface GoogleCredential {
171
148
  idToken: string;
@@ -173,6 +150,13 @@ interface GoogleCredential {
173
150
  name?: string;
174
151
  picture?: string;
175
152
  }
153
+ /**
154
+ * Whether the browser can use FedCM with Google Identity Services (GIS).
155
+ * Requires a secure context (HTTPS or localhost) and Credentials Management `get()`.
156
+ * When `false`, `signInWithGoogle` uses classic GIS One Tap / button flow (OAuth2-style credential via GIS).
157
+ *
158
+ * @see packages/sign_in_sdk/docs/fed-cm.md
159
+ */
176
160
  declare function isFedCMSupported(): boolean;
177
161
  declare function signInWithGoogle(clientId: string): Promise<GoogleCredential>;
178
162
 
@@ -184,6 +168,75 @@ interface TwitterAuthResult {
184
168
  declare function notifyTwitterCallback(): void;
185
169
  declare function signInWithTwitter(clientId: string, redirectUri: string): Promise<TwitterAuthResult>;
186
170
 
171
+ /** Instance returned by SocialAccount (EvmService | DogecoinService | SolanaService) */
172
+ type SocialAccountInstance = ReturnType<typeof SocialAccount>;
173
+ declare class WalletAccount {
174
+ static instance: SocialAccountInstance | null;
175
+ private static instanceToken;
176
+ /** Clear cached instance so next login (e.g. with a different provider) creates a fresh account. */
177
+ static clearInstance(): void;
178
+ static getInstance(oidcToken: string): Promise<SocialAccountInstance>;
179
+ }
180
+ declare function clearSocialAccountInstance(): void;
181
+
182
+ interface SignInModalProps {
183
+ title?: string;
184
+ socialProviders?: SocialProvider[];
185
+ wallets?: WalletItem[];
186
+ initialVisibleCount?: number;
187
+ privacyPolicyUrl?: string;
188
+ termsOfUseUrl?: string;
189
+ onGoogleLogin?: (credential: GoogleCredential) => void;
190
+ onTwitterLogin?: (result: TwitterAuthResult) => void;
191
+ onCubeSignerSession?: (session: CubeSignerSession) => void;
192
+ onWalletConnected?: (session: WalletSession, walletId: string) => void;
193
+ onSocialLogin?: (providerId: string) => void;
194
+ onWalletSelect?: (walletId: string) => void | Promise<void>;
195
+ /** 仅关闭弹窗(点 X 或遮罩时调用),不传 session */
196
+ onDismiss?: () => void;
197
+ /** 登录成功后调用,传入 session;调用方在此回调里更新 session 并自行关闭弹窗 */
198
+ onSuccess?: (session: WalletSession) => void;
199
+ }
200
+ declare const SignInModal: ({ title, socialProviders, wallets, initialVisibleCount, privacyPolicyUrl, termsOfUseUrl, onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess, }: SignInModalProps) => node_modules__types_react_jsx_runtime_js.JSX.Element;
201
+
202
+ type ToastVariant = "success" | "error" | "info";
203
+ interface ToastProps {
204
+ message: string;
205
+ variant?: ToastVariant;
206
+ /** Auto-dismiss after ms. Omit for no auto-dismiss. */
207
+ duration?: number;
208
+ onClose?: () => void;
209
+ }
210
+ declare const Toast: ({ message, variant, duration, onClose }: ToastProps) => node_modules__types_react_jsx_runtime_js.JSX.Element;
211
+
212
+ /** Public shape matches `@ab-org/sign-in-sdk` (single source of truth for runtime config). */
213
+ type SDKConfig = SDKConfig$1;
214
+ /**
215
+ * Fixed auth config: bundled defaults (see bundledConfig.ts) with optional
216
+ * overrides from environment (`NEXT_PUBLIC_*` / server). Used as defaults in {@link initSDK}.
217
+ */
218
+ declare function getFixedAuthConfig(): Partial<SDKConfig>;
219
+ /**
220
+ * Predicate SDK init: merges env/bundled defaults into `@ab-org/sign-in-sdk` config.
221
+ * Optional `registerUser` is merged into `cubeSigner.oidcLoginHooks` when `cubeSigner` is set.
222
+ */
223
+ interface PredicateSDKConfig extends Partial<SDKConfig> {
224
+ registerUser?: (oidcToken: string) => Promise<void>;
225
+ }
226
+ declare function initSDK(config?: PredicateSDKConfig): void;
227
+ declare function getSDKConfig(): Readonly<SDKConfig>;
228
+
229
+ /**
230
+ * Attempt to silently reconnect a wallet whose session was restored
231
+ * from localStorage cache. Creates a temporary `WalletConnector` with
232
+ * the default adapter registry (injected wallets + Cubist if configured)
233
+ * and delegates to `WalletConnector.tryAutoReconnect()`.
234
+ *
235
+ * Safe to call multiple times — concurrent calls share the same promise.
236
+ * Returns the fresh session on success, or `null` if reconnection failed.
237
+ */
238
+ declare function tryAutoReconnect(): Promise<WalletSession | null>;
239
+
187
240
  interface DepositModalConfig {
188
241
  preferredToken?: string;
189
242
  preferredChain?: string;
@@ -513,25 +566,6 @@ declare const createPredicateMarketPolicyAdapter: (options?: PredicateMarketPoli
513
566
  trade(chain: SupportedChain, capabilities?: WalletCapability[]): SessionCapabilityPolicy;
514
567
  };
515
568
 
516
- interface SignInModalProps {
517
- title?: string;
518
- socialProviders?: SocialProvider[];
519
- wallets?: WalletItem[];
520
- initialVisibleCount?: number;
521
- privacyPolicyUrl?: string;
522
- termsOfUseUrl?: string;
523
- onGoogleLogin?: (credential: GoogleCredential) => void;
524
- onTwitterLogin?: (result: TwitterAuthResult) => void;
525
- onCubeSignerSession?: (session: CubeSignerSession) => void;
526
- onWalletConnected?: (session: WalletSession, walletId: string) => void;
527
- onSocialLogin?: (providerId: string) => void;
528
- onWalletSelect?: (walletId: string) => void | Promise<void>;
529
- onDismiss?: () => void;
530
- onSuccess?: (session: WalletSession) => void;
531
- }
532
- declare function clearSocialAccountInstance(): void;
533
- declare const SignInModal: ({ title, socialProviders, wallets, initialVisibleCount, privacyPolicyUrl, termsOfUseUrl, onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess, }: SignInModalProps) => react_jsx_runtime_js.JSX.Element;
534
-
535
569
  interface WalletOption {
536
570
  id: string;
537
571
  label: string;
@@ -669,4 +703,4 @@ declare function getExplorerUrl(chainId: string, data: {
669
703
  txId: string;
670
704
  }): string;
671
705
 
672
- export { type ApiResponse, type ChainData, type ChainInfo, type ChainsResponseData, type CreateOrderRequest, type CreateOrderResponseData, type CustodyAdapter, type DepositAddressResult, type DepositController, DepositDetailsPanel, type DepositDetailsPanelProps, DepositModal, type DepositModalConfig, type DepositModalProps, type DepositOrderResponseData, type DepositOrderStatus, type DepositStatus, DropdownField, type DropdownFieldProps, type Erc20BalanceResult, type FundingTokenBalanceOptions, type FundingWithdrawExecutorOptions, type GoogleCredential, type MarketDataProvider, type ModalController, type NativeSwapPayload, type PaymentPairData, type PaymentSessionResponseData, type PaymentSessionStatus, type PlatformRegisterRequest, type PlatformRegisterResponseData, type PredicateMarketPolicyAdapterOptions, type PredicateSDKConfig, type QuoteDirection, type QuoteRequest$1 as QuoteRequest, type QuoteResponseData, type QuoteResult, type SDKConfig, type SelectOption, SignInModal, type SignInModalProps, type SignInUiConfig, type SocialProvider, type TokenData, type TokenInfo, type TwitterAuthResult, type WalletItem, type WalletOption, WalletSelectionModal, type WalletSelectionModalProps, type WithdrawController, type WithdrawExecutor, WithdrawModal, type WithdrawModalConfig, type WithdrawModalProps, type WithdrawOrderResponseData, type WithdrawOrderStatus, type WithdrawRequest, type WithdrawResult, type WithdrawStatus, type WithdrawUiStatus, clearSocialAccountInstance, configureMerchantApi, createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createOrder, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, getChains, getDepositOrder, getEnv, getExplorerUrl, getFixedAuthConfig, getMerchantApiClient, getSDKConfig, getWithdrawOrder, initSDK, isFedCMSupported, isUsdtWithdrawDirect, notifyTwitterCallback, parseUnits, quote, registerPlatform, signInWithGoogle, signInWithTwitter, tryAutoReconnect };
706
+ export { type ApiResponse, type ChainData, type ChainInfo, type ChainsResponseData, type CreateOrderRequest, type CreateOrderResponseData, type CustodyAdapter, type DepositAddressResult, type DepositController, DepositDetailsPanel, type DepositDetailsPanelProps, DepositModal, type DepositModalConfig, type DepositModalProps, type DepositOrderResponseData, type DepositOrderStatus, type DepositStatus, DropdownField, type DropdownFieldProps, type Erc20BalanceResult, type FundingTokenBalanceOptions, type FundingWithdrawExecutorOptions, type GoogleCredential, type MarketDataProvider, type ModalController, type NativeSwapPayload, type PaymentPairData, type PaymentSessionResponseData, type PaymentSessionStatus, type PlatformRegisterRequest, type PlatformRegisterResponseData, type PredicateMarketPolicyAdapterOptions, type PredicateSDKConfig, type QuoteDirection, type QuoteRequest$1 as QuoteRequest, type QuoteResponseData, type QuoteResult, type SDKConfig, type SelectOption, SignInModal, type SignInModalProps, type SignInUiConfig, type SocialProvider, Toast, type TokenData, type TokenInfo, type TwitterAuthResult, WalletAccount, type WalletItem, type WalletOption, WalletSelectionModal, type WalletSelectionModalProps, type WithdrawController, type WithdrawExecutor, WithdrawModal, type WithdrawModalConfig, type WithdrawModalProps, type WithdrawOrderResponseData, type WithdrawOrderStatus, type WithdrawRequest, type WithdrawResult, type WithdrawStatus, type WithdrawUiStatus, clearSocialAccountInstance, configureMerchantApi, createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createOrder, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, getChains, getDepositOrder, getEnv, getExplorerUrl, getFixedAuthConfig, getMerchantApiClient, getSDKConfig, getWithdrawOrder, initSDK, isFedCMSupported, isUsdtWithdrawDirect, notifyTwitterCallback, parseUnits, quote, registerPlatform, signInWithGoogle, signInWithTwitter, tryAutoReconnect };