@iqauth/sdk 2.0.0 → 2.0.1

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.
@@ -31,7 +31,7 @@ declare function clearCookie(name: string, opts?: CookieOptions): void;
31
31
 
32
32
  /**
33
33
  * Browser-safe PKCE + state/nonce generation using WebCrypto.
34
- * Falls back to Node's crypto.webcrypto for tests.
34
+ * `globalThis.crypto` is available in browsers and Node 19+.
35
35
  */
36
36
  declare function randomUrlSafe(byteLength?: number): string;
37
37
  declare function s256Challenge(verifier: string): Promise<string>;
package/dist/browser.d.ts CHANGED
@@ -31,7 +31,7 @@ declare function clearCookie(name: string, opts?: CookieOptions): void;
31
31
 
32
32
  /**
33
33
  * Browser-safe PKCE + state/nonce generation using WebCrypto.
34
- * Falls back to Node's crypto.webcrypto for tests.
34
+ * `globalThis.crypto` is available in browsers and Node 19+.
35
35
  */
36
36
  declare function randomUrlSafe(byteLength?: number): string;
37
37
  declare function s256Challenge(verifier: string): Promise<string>;
package/dist/browser.js CHANGED
@@ -600,11 +600,6 @@ function getCrypto() {
600
600
  if (typeof globalThis !== "undefined" && globalThis.crypto) {
601
601
  return globalThis.crypto;
602
602
  }
603
- try {
604
- const nodeCrypto = require("crypto").webcrypto;
605
- if (nodeCrypto) return nodeCrypto;
606
- } catch {
607
- }
608
603
  throw new Error("WebCrypto is not available in this environment");
609
604
  }
610
605
  function base64UrlEncode(bytes) {
package/dist/browser.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  setCookie,
13
13
  signIn,
14
14
  signOut
15
- } from "./chunk-E46DKOVI.mjs";
15
+ } from "./chunk-YDO2RDWQ.mjs";
16
16
  import {
17
17
  encodePublishableKey,
18
18
  isPublishableKey,
@@ -4,9 +4,6 @@ import {
4
4
  import {
5
5
  IQAuthError
6
6
  } from "./chunk-6I6RM4MN.mjs";
7
- import {
8
- __require
9
- } from "./chunk-Y6FXYEAI.mjs";
10
7
 
11
8
  // src/browser/storage.ts
12
9
  var REFRESH_COOKIE = "iqauth_rt";
@@ -470,11 +467,6 @@ function getCrypto() {
470
467
  if (typeof globalThis !== "undefined" && globalThis.crypto) {
471
468
  return globalThis.crypto;
472
469
  }
473
- try {
474
- const nodeCrypto = __require("crypto").webcrypto;
475
- if (nodeCrypto) return nodeCrypto;
476
- } catch {
477
- }
478
470
  throw new Error("WebCrypto is not available in this environment");
479
471
  }
480
472
  function base64UrlEncode(bytes) {
package/dist/react.d.mts CHANGED
@@ -91,7 +91,20 @@ declare function SignedOut({ children }: {
91
91
  }> | null;
92
92
  interface RedirectToSignInProps extends SignInOptions {
93
93
  }
94
- declare function RedirectToSignIn(props?: RedirectToSignInProps): null;
94
+ declare function RedirectToSignIn(props?: RedirectToSignInProps): React.DetailedReactHTMLElement<{
95
+ role: "alert";
96
+ style: {
97
+ maxWidth: number;
98
+ margin: string;
99
+ padding: number;
100
+ border: string;
101
+ background: string;
102
+ borderRadius: number;
103
+ fontFamily: "system-ui, sans-serif";
104
+ fontSize: number;
105
+ color: "#7a1f1f";
106
+ };
107
+ }, HTMLElement> | null;
95
108
  /**
96
109
  * Drop-in callback route. Mount at the path you registered as your
97
110
  * `redirect_uri` (e.g. `/auth/callback`) and the SDK will exchange the code
package/dist/react.d.ts CHANGED
@@ -91,7 +91,20 @@ declare function SignedOut({ children }: {
91
91
  }> | null;
92
92
  interface RedirectToSignInProps extends SignInOptions {
93
93
  }
94
- declare function RedirectToSignIn(props?: RedirectToSignInProps): null;
94
+ declare function RedirectToSignIn(props?: RedirectToSignInProps): React.DetailedReactHTMLElement<{
95
+ role: "alert";
96
+ style: {
97
+ maxWidth: number;
98
+ margin: string;
99
+ padding: number;
100
+ border: string;
101
+ background: string;
102
+ borderRadius: number;
103
+ fontFamily: "system-ui, sans-serif";
104
+ fontSize: number;
105
+ color: "#7a1f1f";
106
+ };
107
+ }, HTMLElement> | null;
95
108
  /**
96
109
  * Drop-in callback route. Mount at the path you registered as your
97
110
  * `redirect_uri` (e.g. `/auth/callback`) and the SDK will exchange the code
package/dist/react.js CHANGED
@@ -545,11 +545,6 @@ function getCrypto() {
545
545
  if (typeof globalThis !== "undefined" && globalThis.crypto) {
546
546
  return globalThis.crypto;
547
547
  }
548
- try {
549
- const nodeCrypto = require("crypto").webcrypto;
550
- if (nodeCrypto) return nodeCrypto;
551
- } catch {
552
- }
553
548
  throw new Error("WebCrypto is not available in this environment");
554
549
  }
555
550
  function base64UrlEncode(bytes) {
@@ -815,11 +810,45 @@ function SignedOut({ children }) {
815
810
  }
816
811
  function RedirectToSignIn(props = {}) {
817
812
  const { manager, snapshot } = useCtx();
813
+ const [error, setError] = (0, import_react.useState)(null);
818
814
  (0, import_react.useEffect)(() => {
819
815
  if (snapshot.status === "unauthenticated") {
820
- void redirectToSignIn(manager, props);
816
+ redirectToSignIn(manager, props).catch((err) => {
817
+ const message = err instanceof Error ? err.message : String(err);
818
+ console.error("[IQAuth] RedirectToSignIn failed:", err, {
819
+ issuer: manager.issuerUrl,
820
+ appKey: manager.appKey
821
+ });
822
+ setError(message);
823
+ });
821
824
  }
822
825
  }, [manager, snapshot.status]);
826
+ if (error) {
827
+ return (0, import_react.createElement)(
828
+ "div",
829
+ {
830
+ role: "alert",
831
+ style: {
832
+ maxWidth: 520,
833
+ margin: "48px auto",
834
+ padding: 16,
835
+ border: "1px solid #f0c0c0",
836
+ background: "#fff5f5",
837
+ borderRadius: 8,
838
+ fontFamily: "system-ui, sans-serif",
839
+ fontSize: 14,
840
+ color: "#7a1f1f"
841
+ }
842
+ },
843
+ (0, import_react.createElement)("strong", null, "IQAuth: sign-in redirect failed"),
844
+ (0, import_react.createElement)("div", { style: { marginTop: 8, fontSize: 13 } }, error),
845
+ (0, import_react.createElement)(
846
+ "div",
847
+ { style: { marginTop: 12, fontSize: 12, color: "#5a4a4a" } },
848
+ `Issuer: ${manager.issuerUrl} \xB7 App: ${manager.appKey}. Check browser console for details.`
849
+ )
850
+ );
851
+ }
823
852
  return null;
824
853
  }
825
854
  function AuthCallback({ onComplete, fallback } = {}) {
package/dist/react.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  redirectToSignIn,
5
5
  signIn,
6
6
  signOut
7
- } from "./chunk-E46DKOVI.mjs";
7
+ } from "./chunk-YDO2RDWQ.mjs";
8
8
  import "./chunk-5WFR6Y33.mjs";
9
9
  import "./chunk-6I6RM4MN.mjs";
10
10
  import "./chunk-Y6FXYEAI.mjs";
@@ -146,11 +146,45 @@ function SignedOut({ children }) {
146
146
  }
147
147
  function RedirectToSignIn(props = {}) {
148
148
  const { manager, snapshot } = useCtx();
149
+ const [error, setError] = useState(null);
149
150
  useEffect(() => {
150
151
  if (snapshot.status === "unauthenticated") {
151
- void redirectToSignIn(manager, props);
152
+ redirectToSignIn(manager, props).catch((err) => {
153
+ const message = err instanceof Error ? err.message : String(err);
154
+ console.error("[IQAuth] RedirectToSignIn failed:", err, {
155
+ issuer: manager.issuerUrl,
156
+ appKey: manager.appKey
157
+ });
158
+ setError(message);
159
+ });
152
160
  }
153
161
  }, [manager, snapshot.status]);
162
+ if (error) {
163
+ return createElement(
164
+ "div",
165
+ {
166
+ role: "alert",
167
+ style: {
168
+ maxWidth: 520,
169
+ margin: "48px auto",
170
+ padding: 16,
171
+ border: "1px solid #f0c0c0",
172
+ background: "#fff5f5",
173
+ borderRadius: 8,
174
+ fontFamily: "system-ui, sans-serif",
175
+ fontSize: 14,
176
+ color: "#7a1f1f"
177
+ }
178
+ },
179
+ createElement("strong", null, "IQAuth: sign-in redirect failed"),
180
+ createElement("div", { style: { marginTop: 8, fontSize: 13 } }, error),
181
+ createElement(
182
+ "div",
183
+ { style: { marginTop: 12, fontSize: 12, color: "#5a4a4a" } },
184
+ `Issuer: ${manager.issuerUrl} \xB7 App: ${manager.appKey}. Check browser console for details.`
185
+ )
186
+ );
187
+ }
154
188
  return null;
155
189
  }
156
190
  function AuthCallback({ onComplete, fallback } = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iqauth/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "TypeScript SDK for IQAuth — the canonical way for all IQ projects to integrate with IQAuthService",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",