@1sat/react 0.0.13 → 0.0.15

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.
@@ -2,8 +2,6 @@ import { type ReactNode } from 'react';
2
2
  export interface SigmaCallbackProps {
3
3
  /** Where to redirect after successful auth (default: '/') */
4
4
  redirectTo?: string;
5
- /** Server-side route that exchanges code for tokens (default: /api/auth/sigma/callback) */
6
- serverCallbackUrl?: string;
7
5
  /** Custom loading content */
8
6
  loadingContent?: ReactNode;
9
7
  /** Custom error render */
@@ -12,7 +10,9 @@ export interface SigmaCallbackProps {
12
10
  /**
13
11
  * Generic Sigma OAuth callback page component.
14
12
  *
15
- * Place this as the default export of your callback route page:
13
+ * Uses the better-auth-plugin's handleCallback() to complete the OAuth flow.
14
+ * Stores the result in WalletProvider's localStorage key for reconnection.
15
+ *
16
16
  * ```tsx
17
17
  * // app/auth/sigma/callback/page.tsx
18
18
  * import { SigmaCallback } from '@1sat/react'
@@ -21,5 +21,5 @@ export interface SigmaCallbackProps {
21
21
  * }
22
22
  * ```
23
23
  */
24
- export declare function SigmaCallback({ redirectTo, serverCallbackUrl, loadingContent, renderError, }: SigmaCallbackProps): import("react/jsx-runtime").JSX.Element;
24
+ export declare function SigmaCallback({ redirectTo, loadingContent, renderError, }: SigmaCallbackProps): import("react/jsx-runtime").JSX.Element;
25
25
  //# sourceMappingURL=SigmaCallback.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SigmaCallback.d.ts","sourceRoot":"","sources":["../src/SigmaCallback.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAA;AAI3D,MAAM,WAAW,kBAAkB;IAClC,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,6BAA6B;IAC7B,cAAc,CAAC,EAAE,SAAS,CAAA;IAC1B,0BAA0B;IAC1B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,KAAK,SAAS,CAAA;CAC9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,EAC7B,UAAgB,EAChB,iBAA8C,EAC9C,cAAc,EACd,WAAW,GACX,EAAE,kBAAkB,2CAoGpB"}
1
+ {"version":3,"file":"SigmaCallback.d.ts","sourceRoot":"","sources":["../src/SigmaCallback.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAA;AAI3D,MAAM,WAAW,kBAAkB;IAClC,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,6BAA6B;IAC7B,cAAc,CAAC,EAAE,SAAS,CAAA;IAC1B,0BAA0B;IAC1B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,KAAK,SAAS,CAAA;CAC9D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAC7B,UAAgB,EAChB,cAAc,EACd,WAAW,GACX,EAAE,kBAAkB,2CAoGpB"}
package/dist/index.js CHANGED
@@ -190,25 +190,20 @@ function useWallet() {
190
190
  return ctx;
191
191
  }
192
192
  // src/SigmaCallback.tsx
193
- import { completeSigmaOAuth, isSigmaCallback } from "@1sat/connect";
193
+ import { completeSigmaOAuth } from "@1sat/connect";
194
194
  import { useEffect as useEffect2, useState as useState2 } from "react";
195
195
  import { jsx as jsx2, jsxs, Fragment } from "react/jsx-runtime";
196
196
  "use client";
197
197
  var STORAGE_KEY2 = "onesat_wallet_provider";
198
198
  function SigmaCallback({
199
199
  redirectTo = "/",
200
- serverCallbackUrl = "/api/auth/sigma/callback",
201
200
  loadingContent,
202
201
  renderError
203
202
  }) {
204
203
  const [error, setError] = useState2(null);
205
204
  useEffect2(() => {
206
205
  const searchParams = new URLSearchParams(window.location.search);
207
- if (!isSigmaCallback(searchParams)) {
208
- setError("Invalid callback — missing or mismatched OAuth parameters.");
209
- return;
210
- }
211
- completeSigmaOAuth(searchParams, serverCallbackUrl).then((result) => {
206
+ completeSigmaOAuth(searchParams).then((result) => {
212
207
  localStorage.setItem(STORAGE_KEY2, JSON.stringify({
213
208
  providerType: "sigma",
214
209
  identityKey: result.pubkey,
@@ -219,9 +214,10 @@ function SigmaCallback({
219
214
  window.location.href = redirectTo;
220
215
  }).catch((err) => {
221
216
  console.error("Sigma OAuth callback error:", err);
222
- setError(err instanceof Error ? err.message : "Authentication failed");
217
+ const msg = err instanceof Error ? err.message : typeof err === "object" && err !== null && ("message" in err) ? String(err.message) : "Authentication failed";
218
+ setError(msg);
223
219
  });
224
- }, [redirectTo, serverCallbackUrl]);
220
+ }, [redirectTo]);
225
221
  if (error) {
226
222
  if (renderError) {
227
223
  return /* @__PURE__ */ jsx2(Fragment, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/react",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "React hooks and components for 1Sat wallet integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",