@rhinestone/1auth 0.1.2 → 0.4.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.
@@ -25,6 +25,7 @@ interface LoginOptions {
25
25
  interface LoginResult {
26
26
  success: boolean;
27
27
  username?: string;
28
+ address?: string;
28
29
  user?: {
29
30
  id: string;
30
31
  username: string;
@@ -40,6 +41,7 @@ interface RegisterOptions {
40
41
  interface RegisterResult {
41
42
  success: boolean;
42
43
  username?: string;
44
+ address?: string;
43
45
  error?: {
44
46
  code: string;
45
47
  message: string;
@@ -52,6 +54,8 @@ interface ConnectResult {
52
54
  success: boolean;
53
55
  /** Username of the connected account */
54
56
  username?: string;
57
+ /** Account address */
58
+ address?: string;
55
59
  /** Whether this was auto-connected (user had auto-connect enabled) */
56
60
  autoConnected?: boolean;
57
61
  /** Action to take when connection was not successful */
@@ -105,8 +109,10 @@ interface AuthenticateResult {
105
109
  * Options for signMessage
106
110
  */
107
111
  interface SignMessageOptions {
108
- /** Username of the signer */
109
- username: string;
112
+ /** Username of the signer (required if accountAddress is not provided) */
113
+ username?: string;
114
+ /** Account address of the signer (alternative to username) */
115
+ accountAddress?: string;
110
116
  /** Human-readable message to sign */
111
117
  message: string;
112
118
  /** Optional custom challenge (defaults to message hash) */
@@ -141,12 +147,26 @@ interface SignMessageResult {
141
147
  message: string;
142
148
  };
143
149
  }
150
+ interface ClearSignData {
151
+ decoded: boolean;
152
+ verified: boolean;
153
+ functionName?: string;
154
+ intent?: string;
155
+ args?: Array<{
156
+ name: string;
157
+ type: string;
158
+ value: string;
159
+ label?: string;
160
+ }>;
161
+ selector?: string;
162
+ }
144
163
  interface TransactionAction {
145
- type: 'send' | 'receive' | 'approve' | 'swap' | 'mint' | 'custom';
164
+ type: 'send' | 'receive' | 'approve' | 'swap' | 'mint' | 'custom' | 'module_install';
146
165
  label: string;
147
166
  sublabel?: string;
148
167
  amount?: string;
149
168
  icon?: string;
169
+ clearSign?: ClearSignData;
150
170
  }
151
171
  interface TransactionFees {
152
172
  estimated: string;
@@ -311,6 +331,8 @@ type IntentSigner = (params: {
311
331
  interface SendIntentOptions {
312
332
  /** Username of the signer (for unsigned requests) */
313
333
  username?: string;
334
+ /** Account address of the signer (alternative to username for unsigned requests) */
335
+ accountAddress?: string;
314
336
  /** Target chain ID (for unsigned requests) */
315
337
  targetChain?: number;
316
338
  /** Calls to execute on the target chain (for unsigned requests) */
@@ -426,6 +448,8 @@ interface PrepareIntentResponse {
426
448
  chainId: number;
427
449
  messageHash: string;
428
450
  }>;
451
+ /** Serialized DigestResult from module SDK (EIP-712 wrapped challenge + merkle proofs) */
452
+ digestResult?: string;
429
453
  }
430
454
  /**
431
455
  * Execute intent response from auth service
@@ -536,8 +560,10 @@ type EIP712Types = {
536
560
  * Options for signTypedData
537
561
  */
538
562
  interface SignTypedDataOptions {
539
- /** Username of the signer */
540
- username: string;
563
+ /** Username of the signer (required if accountAddress is not provided) */
564
+ username?: string;
565
+ /** Account address of the signer (alternative to username) */
566
+ accountAddress?: string;
541
567
  /** EIP-712 domain parameters */
542
568
  domain: EIP712Domain;
543
569
  /** Type definitions for all types used in the message */
@@ -620,20 +646,28 @@ interface BatchIntentItem {
620
646
  /** Target chain ID */
621
647
  targetChain: number;
622
648
  /** Calls to execute on the target chain */
623
- calls: IntentCall[];
649
+ calls?: IntentCall[];
624
650
  /** Optional token requests */
625
651
  tokenRequests?: IntentTokenRequest[];
626
652
  /** Constrain which tokens can be used as input */
627
653
  sourceAssets?: string[];
628
654
  /** Source chain ID for the assets */
629
655
  sourceChainId?: number;
656
+ /** Install an ERC-7579 module instead of executing calls */
657
+ moduleInstall?: {
658
+ moduleType: "validator" | "executor" | "fallback" | "hook";
659
+ moduleAddress: string;
660
+ initData?: string;
661
+ };
630
662
  }
631
663
  /**
632
664
  * Options for sendBatchIntent
633
665
  */
634
666
  interface SendBatchIntentOptions {
635
667
  /** Username of the signer */
636
- username: string;
668
+ username?: string;
669
+ /** Account address of the signer (alternative to username) */
670
+ accountAddress?: string;
637
671
  /** Array of intents to execute as a batch */
638
672
  intents: BatchIntentItem[];
639
673
  /** When to close the dialog for each intent. Defaults to "preconfirmed" */
@@ -669,6 +703,8 @@ interface SendBatchIntentResult {
669
703
  successCount: number;
670
704
  /** Count of failed intents */
671
705
  failureCount: number;
706
+ /** Top-level error message when batch-prepare itself fails */
707
+ error?: string;
672
708
  }
673
709
  /**
674
710
  * Prepared intent data within a batch response
@@ -698,8 +734,14 @@ interface PreparedBatchIntent {
698
734
  * Prepare batch intent response from auth service
699
735
  */
700
736
  interface PrepareBatchIntentResponse {
701
- /** Per-intent prepared data */
737
+ /** Per-intent prepared data (successful quotes only) */
702
738
  intents: PreparedBatchIntent[];
739
+ /** Intents that failed to get quotes (unsupported chains, etc.) */
740
+ failedIntents?: Array<{
741
+ index: number;
742
+ targetChain: number;
743
+ error: string;
744
+ }>;
703
745
  /** Shared challenge (merkle root of ALL origin hashes across ALL intents) */
704
746
  challenge: string;
705
747
  /** User ID */
@@ -709,6 +751,61 @@ interface PrepareBatchIntentResponse {
709
751
  /** Global expiry (earliest of all intent expiries) */
710
752
  expiresAt: string;
711
753
  }
754
+ /** Fields available for consent sharing */
755
+ type ConsentField = "email" | "deviceNames";
756
+ /** Shared data returned from consent */
757
+ interface ConsentData {
758
+ email?: string;
759
+ deviceNames?: string[];
760
+ }
761
+ /** Options for checkConsent (read-only, no dialog) */
762
+ interface CheckConsentOptions {
763
+ /** Username of the account (required if accountAddress not provided) */
764
+ username?: string;
765
+ /** Account address (alternative to username) */
766
+ accountAddress?: string;
767
+ /** Fields to check */
768
+ fields: ConsentField[];
769
+ /** Override clientId from SDK config */
770
+ clientId?: string;
771
+ }
772
+ /** Result of checkConsent */
773
+ interface CheckConsentResult {
774
+ /** Whether consent has been granted for ALL requested fields */
775
+ hasConsent: boolean;
776
+ /** Shared data (present when hasConsent is true) */
777
+ data?: ConsentData;
778
+ /** When consent was granted (ISO timestamp) */
779
+ grantedAt?: string;
780
+ }
781
+ /** Options for requestConsent (opens dialog if needed) */
782
+ interface RequestConsentOptions {
783
+ /** Username of the account (required if accountAddress not provided) */
784
+ username?: string;
785
+ /** Account address (alternative to username) */
786
+ accountAddress?: string;
787
+ /** Fields to request access to */
788
+ fields: ConsentField[];
789
+ /** Override clientId from SDK config */
790
+ clientId?: string;
791
+ /** Theme configuration */
792
+ theme?: ThemeConfig;
793
+ }
794
+ /** Result of requestConsent */
795
+ interface RequestConsentResult {
796
+ success: boolean;
797
+ /** Shared data (present when success is true) */
798
+ data?: ConsentData;
799
+ /** When consent was granted (ISO timestamp) */
800
+ grantedAt?: string;
801
+ /** Whether data came from an existing grant (no dialog shown) */
802
+ cached?: boolean;
803
+ /** Error details */
804
+ error?: {
805
+ code: "USER_REJECTED" | "USER_CANCELLED" | "INVALID_REQUEST" | "NETWORK_ERROR" | "UNKNOWN";
806
+ message: string;
807
+ };
808
+ }
712
809
 
713
810
  declare class OneAuthClient {
714
811
  private config;
@@ -774,6 +871,41 @@ declare class OneAuthClient {
774
871
  connectWithModal(options?: {
775
872
  theme?: ThemeConfig;
776
873
  }): Promise<ConnectResult>;
874
+ /**
875
+ * Check if a user has already granted consent for the requested fields.
876
+ * This is a read-only check — no dialog is shown.
877
+ *
878
+ * @example
879
+ * ```typescript
880
+ * const result = await client.checkConsent({
881
+ * username: "alice",
882
+ * fields: ["email"],
883
+ * });
884
+ * if (result.hasConsent) {
885
+ * console.log(result.data?.email);
886
+ * }
887
+ * ```
888
+ */
889
+ checkConsent(options: CheckConsentOptions): Promise<CheckConsentResult>;
890
+ /**
891
+ * Request consent from the user to share their data.
892
+ *
893
+ * First checks if consent was already granted (returns cached data immediately).
894
+ * If not, opens the consent dialog where the user can review and approve sharing.
895
+ *
896
+ * @example
897
+ * ```typescript
898
+ * const result = await client.requestConsent({
899
+ * username: "alice",
900
+ * fields: ["email", "deviceNames"],
901
+ * });
902
+ * if (result.success) {
903
+ * console.log(result.data?.email);
904
+ * console.log(result.cached); // true if no dialog was shown
905
+ * }
906
+ * ```
907
+ */
908
+ requestConsent(options: RequestConsentOptions): Promise<RequestConsentResult>;
777
909
  /**
778
910
  * Authenticate a user with an optional challenge to sign.
779
911
  *
@@ -894,6 +1026,28 @@ declare class OneAuthClient {
894
1026
  * Wait for the dialog to be closed
895
1027
  */
896
1028
  private waitForDialogClose;
1029
+ /**
1030
+ * Inject a preconnect link tag to pre-warm DNS + TLS for a given URL.
1031
+ */
1032
+ private injectPreconnect;
1033
+ /**
1034
+ * Wait for the dialog iframe to signal ready without sending init data.
1035
+ * Returns a sendInit function the caller uses once prepare data is available.
1036
+ */
1037
+ private waitForDialogReadyDeferred;
1038
+ /**
1039
+ * Prepare an intent by calling the orchestrator for a quote.
1040
+ * Returns the prepare response and the origin tier from the response header.
1041
+ */
1042
+ private prepareIntent;
1043
+ /**
1044
+ * Prepare a batch intent by calling the orchestrator for quotes on all intents.
1045
+ */
1046
+ private prepareBatchIntent;
1047
+ /**
1048
+ * Send a prepare error message to the dialog iframe.
1049
+ */
1050
+ private sendPrepareError;
897
1051
  /**
898
1052
  * Poll for intent status
899
1053
  *
@@ -1057,9 +1211,10 @@ declare class OneAuthClient {
1057
1211
  private waitForPopupAuthResponse;
1058
1212
  private waitForAuthenticateResponse;
1059
1213
  private waitForConnectResponse;
1214
+ private waitForConsentResponse;
1060
1215
  private waitForModalSigningResponse;
1061
1216
  private waitForPopupResponse;
1062
1217
  private fetchSigningResult;
1063
1218
  }
1064
1219
 
1065
- export { type TransactionAction as $, type AuthenticateOptions as A, type BalanceRequirement as B, type CloseOnStatus as C, type DeveloperSignedIntent as D, type EIP712Domain as E, type SendSwapOptions as F, type SendSwapResult as G, type SignMessageOptions as H, type IntentSigner as I, type SignMessageResult as J, type SignTypedDataOptions as K, type LoginOptions as L, type MerchantSignedIntent as M, type SignTypedDataResult as N, OneAuthClient as O, type PasskeyCredential as P, type SigningError as Q, type RegisterOptions as R, type SendIntentResult as S, type SigningErrorCode as T, type SigningRequestOptions as U, type SigningRequestStatus as V, type WebAuthnSignature as W, type SigningResult as X, type SigningSuccess as Y, type SwapQuote as Z, type ThemeConfig as _, type IntentCall as a, type TransactionDetails as a0, type TransactionFees as a1, type UserPasskeysResponse as a2, type AuthenticateResult as b, type BatchIntentItem as c, type BatchIntentItemResult as d, type ConnectResult as e, type CreateSigningRequestResponse as f, type EIP712TypeField as g, type EIP712Types as h, type EmbedOptions as i, type ExecuteIntentResponse as j, type IntentHistoryItem as k, type IntentHistoryOptions as l, type IntentHistoryResult as m, type IntentQuote as n, type IntentStatus as o, type IntentTokenRequest as p, type LoginResult as q, type OrchestratorStatus as r, type PasskeyProviderConfig as s, type PrepareBatchIntentResponse as t, type PrepareIntentResponse as u, type PreparedBatchIntent as v, type RegisterResult as w, type SendBatchIntentOptions as x, type SendBatchIntentResult as y, type SendIntentOptions as z };
1220
+ export { type CheckConsentOptions as $, type AuthenticateOptions as A, type BalanceRequirement as B, type CreateSigningRequestResponse as C, type DeveloperSignedIntent as D, type EmbedOptions as E, type CloseOnStatus as F, type PrepareIntentResponse as G, type ExecuteIntentResponse as H, type IntentSigner as I, type IntentHistoryOptions as J, type IntentHistoryItem as K, type LoginOptions as L, type MerchantSignedIntent as M, type IntentHistoryResult as N, OneAuthClient as O, type PasskeyProviderConfig as P, type SendSwapOptions as Q, type RegisterOptions as R, type SendIntentResult as S, type TransactionAction as T, type UserPasskeysResponse as U, type SendSwapResult as V, type WebAuthnSignature as W, type SwapQuote as X, type ThemeConfig as Y, type ConsentField as Z, type ConsentData as _, type IntentCall as a, type CheckConsentResult as a0, type RequestConsentOptions as a1, type RequestConsentResult as a2, type BatchIntentItem as a3, type SendBatchIntentOptions as a4, type SendBatchIntentResult as a5, type BatchIntentItemResult as a6, type PreparedBatchIntent as a7, type PrepareBatchIntentResponse as a8, type SigningRequestOptions as b, type SigningResult as c, type SigningSuccess as d, type SigningError as e, type SigningErrorCode as f, type SigningRequestStatus as g, type PasskeyCredential as h, type RegisterResult as i, type LoginResult as j, type ConnectResult as k, type AuthenticateResult as l, type SignMessageOptions as m, type SignMessageResult as n, type SignTypedDataOptions as o, type SignTypedDataResult as p, type EIP712Domain as q, type EIP712Types as r, type EIP712TypeField as s, type TransactionFees as t, type TransactionDetails as u, type IntentTokenRequest as v, type SendIntentOptions as w, type IntentQuote as x, type IntentStatus as y, type OrchestratorStatus as z };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { O as OneAuthClient, I as IntentSigner, W as WebAuthnSignature, a as IntentCall, S as SendIntentResult } from './client-DyYGKWj3.mjs';
2
- export { A as AuthenticateOptions, b as AuthenticateResult, B as BalanceRequirement, c as BatchIntentItem, d as BatchIntentItemResult, C as CloseOnStatus, e as ConnectResult, f as CreateSigningRequestResponse, D as DeveloperSignedIntent, E as EIP712Domain, g as EIP712TypeField, h as EIP712Types, i as EmbedOptions, j as ExecuteIntentResponse, k as IntentHistoryItem, l as IntentHistoryOptions, m as IntentHistoryResult, n as IntentQuote, o as IntentStatus, p as IntentTokenRequest, L as LoginOptions, q as LoginResult, M as MerchantSignedIntent, r as OrchestratorStatus, P as PasskeyCredential, s as PasskeyProviderConfig, t as PrepareBatchIntentResponse, u as PrepareIntentResponse, v as PreparedBatchIntent, R as RegisterOptions, w as RegisterResult, x as SendBatchIntentOptions, y as SendBatchIntentResult, z as SendIntentOptions, F as SendSwapOptions, G as SendSwapResult, H as SignMessageOptions, J as SignMessageResult, K as SignTypedDataOptions, N as SignTypedDataResult, Q as SigningError, T as SigningErrorCode, U as SigningRequestOptions, V as SigningRequestStatus, X as SigningResult, Y as SigningSuccess, Z as SwapQuote, _ as ThemeConfig, $ as TransactionAction, a0 as TransactionDetails, a1 as TransactionFees, a2 as UserPasskeysResponse } from './client-DyYGKWj3.mjs';
3
- export { O as OneAuthProvider, a as OneAuthProviderOptions, P as PasskeyProvider, b as PasskeyProviderOptions, c as createOneAuthProvider, d as createPasskeyProvider } from './provider-Ctr7HQHR.mjs';
4
- import { LocalAccount, Address, Hex, Chain, Transport, WalletClient, Hash } from 'viem';
1
+ import { O as OneAuthClient, I as IntentSigner, W as WebAuthnSignature, a as IntentCall, S as SendIntentResult } from './client-DKuPEx83.mjs';
2
+ export { A as AuthenticateOptions, l as AuthenticateResult, B as BalanceRequirement, a3 as BatchIntentItem, a6 as BatchIntentItemResult, $ as CheckConsentOptions, a0 as CheckConsentResult, F as CloseOnStatus, k as ConnectResult, _ as ConsentData, Z as ConsentField, C as CreateSigningRequestResponse, D as DeveloperSignedIntent, q as EIP712Domain, s as EIP712TypeField, r as EIP712Types, E as EmbedOptions, H as ExecuteIntentResponse, K as IntentHistoryItem, J as IntentHistoryOptions, N as IntentHistoryResult, x as IntentQuote, y as IntentStatus, v as IntentTokenRequest, L as LoginOptions, j as LoginResult, M as MerchantSignedIntent, z as OrchestratorStatus, h as PasskeyCredential, P as PasskeyProviderConfig, a8 as PrepareBatchIntentResponse, G as PrepareIntentResponse, a7 as PreparedBatchIntent, R as RegisterOptions, i as RegisterResult, a1 as RequestConsentOptions, a2 as RequestConsentResult, a4 as SendBatchIntentOptions, a5 as SendBatchIntentResult, w as SendIntentOptions, Q as SendSwapOptions, V as SendSwapResult, m as SignMessageOptions, n as SignMessageResult, o as SignTypedDataOptions, p as SignTypedDataResult, e as SigningError, f as SigningErrorCode, b as SigningRequestOptions, g as SigningRequestStatus, c as SigningResult, d as SigningSuccess, X as SwapQuote, Y as ThemeConfig, T as TransactionAction, u as TransactionDetails, t as TransactionFees, U as UserPasskeysResponse } from './client-DKuPEx83.mjs';
3
+ export { O as OneAuthProvider, b as OneAuthProviderOptions, P as PasskeyProvider, d as PasskeyProviderOptions, c as createOneAuthProvider, a as createPasskeyProvider } from './provider-CmJarV7y.mjs';
4
+ import { Address, LocalAccount, Chain, Transport, Hex, WalletClient, Hash } from 'viem';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import * as React from 'react';
7
7
  export { getTokenAddress, getTokenDecimals } from '@rhinestone/sdk';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { O as OneAuthClient, I as IntentSigner, W as WebAuthnSignature, a as IntentCall, S as SendIntentResult } from './client-DyYGKWj3.js';
2
- export { A as AuthenticateOptions, b as AuthenticateResult, B as BalanceRequirement, c as BatchIntentItem, d as BatchIntentItemResult, C as CloseOnStatus, e as ConnectResult, f as CreateSigningRequestResponse, D as DeveloperSignedIntent, E as EIP712Domain, g as EIP712TypeField, h as EIP712Types, i as EmbedOptions, j as ExecuteIntentResponse, k as IntentHistoryItem, l as IntentHistoryOptions, m as IntentHistoryResult, n as IntentQuote, o as IntentStatus, p as IntentTokenRequest, L as LoginOptions, q as LoginResult, M as MerchantSignedIntent, r as OrchestratorStatus, P as PasskeyCredential, s as PasskeyProviderConfig, t as PrepareBatchIntentResponse, u as PrepareIntentResponse, v as PreparedBatchIntent, R as RegisterOptions, w as RegisterResult, x as SendBatchIntentOptions, y as SendBatchIntentResult, z as SendIntentOptions, F as SendSwapOptions, G as SendSwapResult, H as SignMessageOptions, J as SignMessageResult, K as SignTypedDataOptions, N as SignTypedDataResult, Q as SigningError, T as SigningErrorCode, U as SigningRequestOptions, V as SigningRequestStatus, X as SigningResult, Y as SigningSuccess, Z as SwapQuote, _ as ThemeConfig, $ as TransactionAction, a0 as TransactionDetails, a1 as TransactionFees, a2 as UserPasskeysResponse } from './client-DyYGKWj3.js';
3
- export { O as OneAuthProvider, a as OneAuthProviderOptions, P as PasskeyProvider, b as PasskeyProviderOptions, c as createOneAuthProvider, d as createPasskeyProvider } from './provider-CNTZPPFz.js';
4
- import { LocalAccount, Address, Hex, Chain, Transport, WalletClient, Hash } from 'viem';
1
+ import { O as OneAuthClient, I as IntentSigner, W as WebAuthnSignature, a as IntentCall, S as SendIntentResult } from './client-DKuPEx83.js';
2
+ export { A as AuthenticateOptions, l as AuthenticateResult, B as BalanceRequirement, a3 as BatchIntentItem, a6 as BatchIntentItemResult, $ as CheckConsentOptions, a0 as CheckConsentResult, F as CloseOnStatus, k as ConnectResult, _ as ConsentData, Z as ConsentField, C as CreateSigningRequestResponse, D as DeveloperSignedIntent, q as EIP712Domain, s as EIP712TypeField, r as EIP712Types, E as EmbedOptions, H as ExecuteIntentResponse, K as IntentHistoryItem, J as IntentHistoryOptions, N as IntentHistoryResult, x as IntentQuote, y as IntentStatus, v as IntentTokenRequest, L as LoginOptions, j as LoginResult, M as MerchantSignedIntent, z as OrchestratorStatus, h as PasskeyCredential, P as PasskeyProviderConfig, a8 as PrepareBatchIntentResponse, G as PrepareIntentResponse, a7 as PreparedBatchIntent, R as RegisterOptions, i as RegisterResult, a1 as RequestConsentOptions, a2 as RequestConsentResult, a4 as SendBatchIntentOptions, a5 as SendBatchIntentResult, w as SendIntentOptions, Q as SendSwapOptions, V as SendSwapResult, m as SignMessageOptions, n as SignMessageResult, o as SignTypedDataOptions, p as SignTypedDataResult, e as SigningError, f as SigningErrorCode, b as SigningRequestOptions, g as SigningRequestStatus, c as SigningResult, d as SigningSuccess, X as SwapQuote, Y as ThemeConfig, T as TransactionAction, u as TransactionDetails, t as TransactionFees, U as UserPasskeysResponse } from './client-DKuPEx83.js';
3
+ export { O as OneAuthProvider, b as OneAuthProviderOptions, P as PasskeyProvider, d as PasskeyProviderOptions, c as createOneAuthProvider, a as createPasskeyProvider } from './provider-Dj5l4bWn.js';
4
+ import { Address, LocalAccount, Chain, Transport, Hex, WalletClient, Hash } from 'viem';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import * as React from 'react';
7
7
  export { getTokenAddress, getTokenDecimals } from '@rhinestone/sdk';