@rhinestone/1auth 0.4.0 → 0.5.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.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
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';
1
+ import { O as OneAuthClient, I as IntentSigner, W as WebAuthnSignature, a as IntentCall, S as SendIntentResult } from './client-Di8SBnPO.mjs';
2
+ export { A as AuthResult, j as AuthenticateOptions, k as AuthenticateResult, B as BalanceRequirement, a0 as BatchIntentItem, a3 as BatchIntentItemResult, Y as CheckConsentOptions, Z as CheckConsentResult, F as CloseOnStatus, i as ConnectResult, X as ConsentData, V 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, L as IntentHistoryResult, x as IntentQuote, y as IntentStatus, v as IntentTokenRequest, z as OrchestratorStatus, h as PasskeyCredential, P as PasskeyProviderConfig, a5 as PrepareBatchIntentResponse, G as PrepareIntentResponse, a4 as PreparedBatchIntent, _ as RequestConsentOptions, $ as RequestConsentResult, a1 as SendBatchIntentOptions, a2 as SendBatchIntentResult, w as SendIntentOptions, M as SendSwapOptions, N 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, l as SigningResultBase, d as SigningSuccess, Q as SwapQuote, R as ThemeConfig, T as TransactionAction, u as TransactionDetails, t as TransactionFees, U as UserPasskeysResponse } from './client-Di8SBnPO.mjs';
3
+ export { O as OneAuthProvider, a as OneAuthProviderOptions, c as createOneAuthProvider } from './provider-8anOtc87.mjs';
4
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';
@@ -232,10 +232,6 @@ declare function isTokenAddressSupported(tokenAddress: Address, chainId: number)
232
232
  * This is the standard Ethereum message prefix for `personal_sign`.
233
233
  */
234
234
  declare const ETHEREUM_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
235
- /**
236
- * @deprecated Use ETHEREUM_MESSAGE_PREFIX instead. Kept for backwards compatibility.
237
- */
238
- declare const PASSKEY_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
239
235
  /**
240
236
  * Hash a message with the EIP-191 Ethereum prefix.
241
237
  *
@@ -277,4 +273,4 @@ declare function hashMessage(message: string): `0x${string}`;
277
273
  */
278
274
  declare function verifyMessageHash(message: string, signedHash: string | undefined): boolean;
279
275
 
280
- export { type BatchQueueContextValue, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type ChainFilterOptions, ETHEREUM_MESSAGE_PREFIX, IntentCall, IntentSigner, OneAuthClient, PASSKEY_MESSAGE_PREFIX, type PasskeyAccount, OneAuthClient as PasskeyProviderClient, type PasskeyWalletClient, type PasskeyWalletClientConfig, type SendCallsParams, SendIntentResult, type TokenConfig, type TransactionCall, WebAuthnSignature, createPasskeyAccount, createPasskeyWalletClient, encodeWebAuthnSignature, getAllSupportedChainsAndTokens, getChainById, getChainExplorerUrl, getChainName, getChainRpcUrl, getSupportedChainIds, getSupportedChains, getSupportedTokenSymbols, getSupportedTokens, getTokenSymbol, hashCalls, hashMessage, isTestnet, isTokenAddressSupported, resolveTokenAddress, useBatchQueue, verifyMessageHash };
276
+ export { type BatchQueueContextValue, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type ChainFilterOptions, ETHEREUM_MESSAGE_PREFIX, IntentCall, IntentSigner, OneAuthClient, type PasskeyAccount, type PasskeyWalletClient, type PasskeyWalletClientConfig, type SendCallsParams, SendIntentResult, type TokenConfig, type TransactionCall, WebAuthnSignature, createPasskeyAccount, createPasskeyWalletClient, encodeWebAuthnSignature, getAllSupportedChainsAndTokens, getChainById, getChainExplorerUrl, getChainName, getChainRpcUrl, getSupportedChainIds, getSupportedChains, getSupportedTokenSymbols, getSupportedTokens, getTokenSymbol, hashCalls, hashMessage, isTestnet, isTokenAddressSupported, resolveTokenAddress, useBatchQueue, verifyMessageHash };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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';
1
+ import { O as OneAuthClient, I as IntentSigner, W as WebAuthnSignature, a as IntentCall, S as SendIntentResult } from './client-Di8SBnPO.js';
2
+ export { A as AuthResult, j as AuthenticateOptions, k as AuthenticateResult, B as BalanceRequirement, a0 as BatchIntentItem, a3 as BatchIntentItemResult, Y as CheckConsentOptions, Z as CheckConsentResult, F as CloseOnStatus, i as ConnectResult, X as ConsentData, V 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, L as IntentHistoryResult, x as IntentQuote, y as IntentStatus, v as IntentTokenRequest, z as OrchestratorStatus, h as PasskeyCredential, P as PasskeyProviderConfig, a5 as PrepareBatchIntentResponse, G as PrepareIntentResponse, a4 as PreparedBatchIntent, _ as RequestConsentOptions, $ as RequestConsentResult, a1 as SendBatchIntentOptions, a2 as SendBatchIntentResult, w as SendIntentOptions, M as SendSwapOptions, N 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, l as SigningResultBase, d as SigningSuccess, Q as SwapQuote, R as ThemeConfig, T as TransactionAction, u as TransactionDetails, t as TransactionFees, U as UserPasskeysResponse } from './client-Di8SBnPO.js';
3
+ export { O as OneAuthProvider, a as OneAuthProviderOptions, c as createOneAuthProvider } from './provider-CFnLQt5m.js';
4
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';
@@ -232,10 +232,6 @@ declare function isTokenAddressSupported(tokenAddress: Address, chainId: number)
232
232
  * This is the standard Ethereum message prefix for `personal_sign`.
233
233
  */
234
234
  declare const ETHEREUM_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
235
- /**
236
- * @deprecated Use ETHEREUM_MESSAGE_PREFIX instead. Kept for backwards compatibility.
237
- */
238
- declare const PASSKEY_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
239
235
  /**
240
236
  * Hash a message with the EIP-191 Ethereum prefix.
241
237
  *
@@ -277,4 +273,4 @@ declare function hashMessage(message: string): `0x${string}`;
277
273
  */
278
274
  declare function verifyMessageHash(message: string, signedHash: string | undefined): boolean;
279
275
 
280
- export { type BatchQueueContextValue, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type ChainFilterOptions, ETHEREUM_MESSAGE_PREFIX, IntentCall, IntentSigner, OneAuthClient, PASSKEY_MESSAGE_PREFIX, type PasskeyAccount, OneAuthClient as PasskeyProviderClient, type PasskeyWalletClient, type PasskeyWalletClientConfig, type SendCallsParams, SendIntentResult, type TokenConfig, type TransactionCall, WebAuthnSignature, createPasskeyAccount, createPasskeyWalletClient, encodeWebAuthnSignature, getAllSupportedChainsAndTokens, getChainById, getChainExplorerUrl, getChainName, getChainRpcUrl, getSupportedChainIds, getSupportedChains, getSupportedTokenSymbols, getSupportedTokens, getTokenSymbol, hashCalls, hashMessage, isTestnet, isTokenAddressSupported, resolveTokenAddress, useBatchQueue, verifyMessageHash };
276
+ export { type BatchQueueContextValue, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type ChainFilterOptions, ETHEREUM_MESSAGE_PREFIX, IntentCall, IntentSigner, OneAuthClient, type PasskeyAccount, type PasskeyWalletClient, type PasskeyWalletClientConfig, type SendCallsParams, SendIntentResult, type TokenConfig, type TransactionCall, WebAuthnSignature, createPasskeyAccount, createPasskeyWalletClient, encodeWebAuthnSignature, getAllSupportedChainsAndTokens, getChainById, getChainExplorerUrl, getChainName, getChainRpcUrl, getSupportedChainIds, getSupportedChains, getSupportedTokenSymbols, getSupportedTokens, getTokenSymbol, hashCalls, hashMessage, isTestnet, isTokenAddressSupported, resolveTokenAddress, useBatchQueue, verifyMessageHash };
package/dist/index.js CHANGED
@@ -34,11 +34,8 @@ __export(index_exports, {
34
34
  BatchQueueWidget: () => BatchQueueWidget,
35
35
  ETHEREUM_MESSAGE_PREFIX: () => ETHEREUM_MESSAGE_PREFIX,
36
36
  OneAuthClient: () => OneAuthClient,
37
- PASSKEY_MESSAGE_PREFIX: () => PASSKEY_MESSAGE_PREFIX,
38
- PasskeyProviderClient: () => OneAuthClient,
39
37
  createOneAuthProvider: () => createOneAuthProvider,
40
38
  createPasskeyAccount: () => createPasskeyAccount,
41
- createPasskeyProvider: () => createPasskeyProvider,
42
39
  createPasskeyWalletClient: () => createPasskeyWalletClient,
43
40
  encodeWebAuthnSignature: () => encodeWebAuthnSignature,
44
41
  getAllSupportedChainsAndTokens: () => getAllSupportedChainsAndTokens,
@@ -294,7 +291,28 @@ var OneAuthClient = class {
294
291
  return void 0;
295
292
  }
296
293
  /**
297
- * Open the auth dialog (sign in + sign up).
294
+ * Open the authentication modal (sign in + sign up).
295
+ *
296
+ * Handles both new user registration and returning user login in a single
297
+ * call — the modal shows the appropriate flow based on whether the user
298
+ * has a passkey registered.
299
+ *
300
+ * @param options.username - Pre-fill the username field
301
+ * @param options.theme - Override the theme for this modal invocation
302
+ * @param options.oauthEnabled - Set to false to hide OAuth sign-in buttons
303
+ * @returns {@link AuthResult} with user details and typed address
304
+ *
305
+ * @example
306
+ * ```typescript
307
+ * const result = await client.authWithModal();
308
+ *
309
+ * if (result.success) {
310
+ * console.log('Signed in as:', result.user?.username);
311
+ * console.log('Address:', result.user?.address); // typed `0x${string}`
312
+ * } else if (result.error?.code === 'USER_CANCELLED') {
313
+ * // User closed the modal
314
+ * }
315
+ * ```
298
316
  */
299
317
  async authWithModal(options) {
300
318
  const dialogUrl = this.getDialogUrl();
@@ -334,7 +352,7 @@ var OneAuthClient = class {
334
352
  * const result = await client.connectWithModal();
335
353
  *
336
354
  * if (result.success) {
337
- * console.log('Connected as:', result.username);
355
+ * console.log('Connected as:', result.user?.username);
338
356
  * } else if (result.action === 'switch') {
339
357
  * // User needs to sign in first
340
358
  * const authResult = await client.authWithModal();
@@ -512,17 +530,16 @@ var OneAuthClient = class {
512
530
  *
513
531
  * @example
514
532
  * ```typescript
515
- * // Authenticate with a login challenge
516
533
  * const result = await client.authenticate({
517
534
  * challenge: `Login to MyApp\nTimestamp: ${Date.now()}\nNonce: ${crypto.randomUUID()}`
518
535
  * });
519
536
  *
520
- * if (result.success && result.signature) {
537
+ * if (result.success && result.challenge) {
521
538
  * // Verify signature server-side
522
539
  * const isValid = await verifyOnServer(
523
- * result.username,
524
- * result.signature,
525
- * result.signedHash
540
+ * result.user?.username,
541
+ * result.challenge.signature,
542
+ * result.challenge.signedHash
526
543
  * );
527
544
  * }
528
545
  * ```
@@ -2304,24 +2321,11 @@ var OneAuthClient = class {
2304
2321
  if (data.success) {
2305
2322
  resolve({
2306
2323
  success: true,
2307
- username: data.data?.username,
2308
- address: data.data?.address,
2309
- user: data.data?.user
2310
- });
2311
- } else {
2312
- resolve({
2313
- success: false,
2314
- error: data.error
2315
- });
2316
- }
2317
- } else if (data?.type === "PASSKEY_REGISTER_RESULT") {
2318
- window.removeEventListener("message", handleMessage);
2319
- cleanup();
2320
- if (data.success) {
2321
- resolve({
2322
- success: true,
2323
- username: data.data?.username,
2324
- address: data.data?.address
2324
+ user: {
2325
+ id: data.data?.user?.id,
2326
+ username: data.data?.username,
2327
+ address: data.data?.address
2328
+ }
2325
2329
  });
2326
2330
  } else {
2327
2331
  resolve({
@@ -2380,25 +2384,11 @@ var OneAuthClient = class {
2380
2384
  if (data.success) {
2381
2385
  resolve({
2382
2386
  success: true,
2383
- username: data.data?.username,
2384
- address: data.data?.address,
2385
- user: data.data?.user
2386
- });
2387
- } else {
2388
- resolve({
2389
- success: false,
2390
- error: data.error
2391
- });
2392
- }
2393
- } else if (data?.type === "PASSKEY_REGISTER_RESULT") {
2394
- clearInterval(pollTimer);
2395
- window.removeEventListener("message", handleMessage);
2396
- popup?.close();
2397
- if (data.success) {
2398
- resolve({
2399
- success: true,
2400
- username: data.data?.username,
2401
- address: data.data?.address
2387
+ user: {
2388
+ id: data.data?.user?.id,
2389
+ username: data.data?.username,
2390
+ address: data.data?.address
2391
+ }
2402
2392
  });
2403
2393
  } else {
2404
2394
  resolve({
@@ -2434,11 +2424,15 @@ var OneAuthClient = class {
2434
2424
  if (data.success) {
2435
2425
  resolve({
2436
2426
  success: true,
2437
- username: data.data?.username,
2438
- user: data.data?.user,
2439
- accountAddress: data.data?.accountAddress,
2440
- signature: data.data?.signature,
2441
- signedHash: data.data?.signedHash
2427
+ user: {
2428
+ id: data.data?.user?.id,
2429
+ username: data.data?.username,
2430
+ address: data.data?.accountAddress
2431
+ },
2432
+ challenge: data.data?.signature ? {
2433
+ signature: data.data.signature,
2434
+ signedHash: data.data.signedHash
2435
+ } : void 0
2442
2436
  });
2443
2437
  } else {
2444
2438
  resolve({
@@ -2473,8 +2467,10 @@ var OneAuthClient = class {
2473
2467
  if (data.success) {
2474
2468
  resolve({
2475
2469
  success: true,
2476
- username: data.data?.username,
2477
- address: data.data?.address,
2470
+ user: {
2471
+ username: data.data?.username,
2472
+ address: data.data?.address
2473
+ },
2478
2474
  autoConnected: data.data?.autoConnected
2479
2475
  });
2480
2476
  } else {
@@ -2785,15 +2781,15 @@ function createOneAuthProvider(options) {
2785
2781
  let username;
2786
2782
  let address;
2787
2783
  if (connectResult.success) {
2788
- username = connectResult.username;
2789
- address = connectResult.address;
2784
+ username = connectResult.user?.username;
2785
+ address = connectResult.user?.address;
2790
2786
  } else if (connectResult.action === "switch") {
2791
2787
  const authResult = await client.authWithModal();
2792
2788
  if (!authResult.success) {
2793
2789
  throw new Error(authResult.error?.message || "Authentication failed");
2794
2790
  }
2795
- username = authResult.username;
2796
- address = authResult.address;
2791
+ username = authResult.user?.username;
2792
+ address = authResult.user?.address;
2797
2793
  } else {
2798
2794
  throw new Error(connectResult.error?.message || "Connection cancelled");
2799
2795
  }
@@ -3166,7 +3162,6 @@ function createOneAuthProvider(options) {
3166
3162
  disconnect
3167
3163
  };
3168
3164
  }
3169
- var createPasskeyProvider = createOneAuthProvider;
3170
3165
 
3171
3166
  // src/account.ts
3172
3167
  var import_viem5 = require("viem");
@@ -3837,7 +3832,6 @@ function BatchQueueWidget({ onSignAll }) {
3837
3832
  // src/verify.ts
3838
3833
  var import_viem7 = require("viem");
3839
3834
  var ETHEREUM_MESSAGE_PREFIX = "Ethereum Signed Message:\n";
3840
- var PASSKEY_MESSAGE_PREFIX = ETHEREUM_MESSAGE_PREFIX;
3841
3835
  function hashMessage2(message) {
3842
3836
  const prefixed = ETHEREUM_MESSAGE_PREFIX + message.length.toString() + message;
3843
3837
  return (0, import_viem7.keccak256)((0, import_viem7.toBytes)(prefixed));
@@ -3853,11 +3847,8 @@ function verifyMessageHash(message, signedHash) {
3853
3847
  BatchQueueWidget,
3854
3848
  ETHEREUM_MESSAGE_PREFIX,
3855
3849
  OneAuthClient,
3856
- PASSKEY_MESSAGE_PREFIX,
3857
- PasskeyProviderClient,
3858
3850
  createOneAuthProvider,
3859
3851
  createPasskeyAccount,
3860
- createPasskeyProvider,
3861
3852
  createPasskeyWalletClient,
3862
3853
  encodeWebAuthnSignature,
3863
3854
  getAllSupportedChainsAndTokens,