@iqauth/sdk 2.6.3 → 2.6.4
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/browser.mjs +7 -5
- package/dist/chunk-C2ZTBOAC.mjs +36 -0
- package/dist/{chunk-TKZTCPEK.mjs → chunk-DJIBN2N7.mjs} +3 -33
- package/dist/{chunk-76W5TLQQ.mjs → chunk-XAWYUPMO.mjs} +1 -1
- package/dist/pkce-7WKV4OIN.mjs +11 -0
- package/dist/react.js +30 -3
- package/dist/react.mjs +28 -6
- package/dist/{signIn-CCY4JE5G.mjs → signIn-4OKLDEIH.mjs} +2 -1
- package/package.json +1 -1
package/dist/browser.mjs
CHANGED
|
@@ -20,21 +20,23 @@ import {
|
|
|
20
20
|
signInWithPasskey,
|
|
21
21
|
unlinkProvider,
|
|
22
22
|
verifyMagicLink
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-XAWYUPMO.mjs";
|
|
24
24
|
import {
|
|
25
25
|
REFRESH_COOKIE,
|
|
26
26
|
buildSignInUrl,
|
|
27
27
|
clearCookie,
|
|
28
|
-
createPkcePair,
|
|
29
28
|
getCookie,
|
|
30
29
|
handleAuthCallback,
|
|
31
|
-
randomUrlSafe,
|
|
32
30
|
redirectToSignIn,
|
|
33
|
-
s256Challenge,
|
|
34
31
|
setCookie,
|
|
35
32
|
signIn,
|
|
36
33
|
signOut
|
|
37
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-DJIBN2N7.mjs";
|
|
35
|
+
import {
|
|
36
|
+
createPkcePair,
|
|
37
|
+
randomUrlSafe,
|
|
38
|
+
s256Challenge
|
|
39
|
+
} from "./chunk-C2ZTBOAC.mjs";
|
|
38
40
|
import {
|
|
39
41
|
encodePublishableKey,
|
|
40
42
|
isPublishableKey,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/browser/pkce.ts
|
|
2
|
+
function getCrypto() {
|
|
3
|
+
if (typeof globalThis !== "undefined" && globalThis.crypto) {
|
|
4
|
+
return globalThis.crypto;
|
|
5
|
+
}
|
|
6
|
+
throw new Error("WebCrypto is not available in this environment");
|
|
7
|
+
}
|
|
8
|
+
function base64UrlEncode(bytes) {
|
|
9
|
+
let bin = "";
|
|
10
|
+
for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);
|
|
11
|
+
const b64 = typeof btoa === "function" ? btoa(bin) : Buffer.from(bin, "binary").toString("base64");
|
|
12
|
+
return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
13
|
+
}
|
|
14
|
+
function randomUrlSafe(byteLength = 32) {
|
|
15
|
+
const bytes = new Uint8Array(byteLength);
|
|
16
|
+
getCrypto().getRandomValues(bytes);
|
|
17
|
+
return base64UrlEncode(bytes);
|
|
18
|
+
}
|
|
19
|
+
async function s256Challenge(verifier) {
|
|
20
|
+
const data = new TextEncoder().encode(verifier);
|
|
21
|
+
const digest = await getCrypto().subtle.digest("SHA-256", data);
|
|
22
|
+
return base64UrlEncode(new Uint8Array(digest));
|
|
23
|
+
}
|
|
24
|
+
async function createPkcePair() {
|
|
25
|
+
const codeVerifier = randomUrlSafe(32);
|
|
26
|
+
const codeChallenge = await s256Challenge(codeVerifier);
|
|
27
|
+
const state = randomUrlSafe(16);
|
|
28
|
+
const nonce = randomUrlSafe(16);
|
|
29
|
+
return { codeVerifier, codeChallenge, state, nonce };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
randomUrlSafe,
|
|
34
|
+
s256Challenge,
|
|
35
|
+
createPkcePair
|
|
36
|
+
};
|
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return globalThis.crypto;
|
|
5
|
-
}
|
|
6
|
-
throw new Error("WebCrypto is not available in this environment");
|
|
7
|
-
}
|
|
8
|
-
function base64UrlEncode(bytes) {
|
|
9
|
-
let bin = "";
|
|
10
|
-
for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);
|
|
11
|
-
const b64 = typeof btoa === "function" ? btoa(bin) : Buffer.from(bin, "binary").toString("base64");
|
|
12
|
-
return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
13
|
-
}
|
|
14
|
-
function randomUrlSafe(byteLength = 32) {
|
|
15
|
-
const bytes = new Uint8Array(byteLength);
|
|
16
|
-
getCrypto().getRandomValues(bytes);
|
|
17
|
-
return base64UrlEncode(bytes);
|
|
18
|
-
}
|
|
19
|
-
async function s256Challenge(verifier) {
|
|
20
|
-
const data = new TextEncoder().encode(verifier);
|
|
21
|
-
const digest = await getCrypto().subtle.digest("SHA-256", data);
|
|
22
|
-
return base64UrlEncode(new Uint8Array(digest));
|
|
23
|
-
}
|
|
24
|
-
async function createPkcePair() {
|
|
25
|
-
const codeVerifier = randomUrlSafe(32);
|
|
26
|
-
const codeChallenge = await s256Challenge(codeVerifier);
|
|
27
|
-
const state = randomUrlSafe(16);
|
|
28
|
-
const nonce = randomUrlSafe(16);
|
|
29
|
-
return { codeVerifier, codeChallenge, state, nonce };
|
|
30
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
createPkcePair
|
|
3
|
+
} from "./chunk-C2ZTBOAC.mjs";
|
|
31
4
|
|
|
32
5
|
// src/browser/storage.ts
|
|
33
6
|
var REFRESH_COOKIE = "iqauth_rt";
|
|
@@ -221,9 +194,6 @@ export {
|
|
|
221
194
|
setCookie,
|
|
222
195
|
getCookie,
|
|
223
196
|
clearCookie,
|
|
224
|
-
randomUrlSafe,
|
|
225
|
-
s256Challenge,
|
|
226
|
-
createPkcePair,
|
|
227
197
|
buildSignInUrl,
|
|
228
198
|
redirectToSignIn,
|
|
229
199
|
signIn,
|
package/dist/react.js
CHANGED
|
@@ -104,6 +104,12 @@ var init_storage = __esm({
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
// src/browser/pkce.ts
|
|
107
|
+
var pkce_exports = {};
|
|
108
|
+
__export(pkce_exports, {
|
|
109
|
+
createPkcePair: () => createPkcePair,
|
|
110
|
+
randomUrlSafe: () => randomUrlSafe,
|
|
111
|
+
s256Challenge: () => s256Challenge
|
|
112
|
+
});
|
|
107
113
|
function getCrypto() {
|
|
108
114
|
if (typeof globalThis !== "undefined" && globalThis.crypto) {
|
|
109
115
|
return globalThis.crypto;
|
|
@@ -2934,13 +2940,34 @@ function SignIn(props) {
|
|
|
2934
2940
|
if (!handlePayload(payload)) setFormError(localizeError(localeBundle, { code: payload.error, message: payload.error_description }));
|
|
2935
2941
|
setSubmitting(false);
|
|
2936
2942
|
};
|
|
2937
|
-
const startGoogleLogin = () => {
|
|
2943
|
+
const startGoogleLogin = async () => {
|
|
2938
2944
|
if (!ctx?.app.defaultClientId) {
|
|
2939
2945
|
setFormError("Application is not configured for hosted sign-in.");
|
|
2940
2946
|
return;
|
|
2941
2947
|
}
|
|
2942
|
-
|
|
2943
|
-
|
|
2948
|
+
let pkce;
|
|
2949
|
+
try {
|
|
2950
|
+
const mod = await Promise.resolve().then(() => (init_pkce(), pkce_exports));
|
|
2951
|
+
pkce = await mod.createPkcePair();
|
|
2952
|
+
} catch (err) {
|
|
2953
|
+
setFormError(err.message || "Unable to initialize Google sign-in");
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2956
|
+
if (typeof document !== "undefined") {
|
|
2957
|
+
const cookieAttrs = "; path=/; SameSite=Lax" + (window.location.protocol === "https:" ? "; Secure" : "");
|
|
2958
|
+
document.cookie = `iqauth_pkce=${pkce.codeVerifier}${cookieAttrs}`;
|
|
2959
|
+
document.cookie = `iqauth_state=${pkce.state}${cookieAttrs}`;
|
|
2960
|
+
}
|
|
2961
|
+
const params = new URLSearchParams({
|
|
2962
|
+
redirect_uri: returnTo,
|
|
2963
|
+
client_id: ctx.app.defaultClientId,
|
|
2964
|
+
state: pkce.state,
|
|
2965
|
+
nonce: pkce.nonce,
|
|
2966
|
+
code_challenge: pkce.codeChallenge,
|
|
2967
|
+
code_challenge_method: "S256",
|
|
2968
|
+
scope: "openid profile email"
|
|
2969
|
+
});
|
|
2970
|
+
const url2 = `${iqAuthBaseUrl.replace(/\/$/, "")}/api/v1/auth/google?${params.toString()}`;
|
|
2944
2971
|
window.location.href = url2;
|
|
2945
2972
|
};
|
|
2946
2973
|
(0, import_react.useEffect)(() => {
|
package/dist/react.mjs
CHANGED
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
requestMagicLink,
|
|
10
10
|
signInWithPasskey,
|
|
11
11
|
unlinkProvider
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XAWYUPMO.mjs";
|
|
13
13
|
import {
|
|
14
14
|
handleAuthCallback,
|
|
15
15
|
redirectToSignIn,
|
|
16
16
|
signIn,
|
|
17
17
|
signOut
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-DJIBN2N7.mjs";
|
|
19
|
+
import "./chunk-C2ZTBOAC.mjs";
|
|
19
20
|
import "./chunk-WQWBJSSS.mjs";
|
|
20
21
|
import {
|
|
21
22
|
defaultBundle,
|
|
@@ -1189,13 +1190,34 @@ function SignIn(props) {
|
|
|
1189
1190
|
if (!handlePayload(payload)) setFormError(localizeError(localeBundle, { code: payload.error, message: payload.error_description }));
|
|
1190
1191
|
setSubmitting(false);
|
|
1191
1192
|
};
|
|
1192
|
-
const startGoogleLogin = () => {
|
|
1193
|
+
const startGoogleLogin = async () => {
|
|
1193
1194
|
if (!ctx?.app.defaultClientId) {
|
|
1194
1195
|
setFormError("Application is not configured for hosted sign-in.");
|
|
1195
1196
|
return;
|
|
1196
1197
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1198
|
+
let pkce;
|
|
1199
|
+
try {
|
|
1200
|
+
const mod = await import("./pkce-7WKV4OIN.mjs");
|
|
1201
|
+
pkce = await mod.createPkcePair();
|
|
1202
|
+
} catch (err) {
|
|
1203
|
+
setFormError(err.message || "Unable to initialize Google sign-in");
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
if (typeof document !== "undefined") {
|
|
1207
|
+
const cookieAttrs = "; path=/; SameSite=Lax" + (window.location.protocol === "https:" ? "; Secure" : "");
|
|
1208
|
+
document.cookie = `iqauth_pkce=${pkce.codeVerifier}${cookieAttrs}`;
|
|
1209
|
+
document.cookie = `iqauth_state=${pkce.state}${cookieAttrs}`;
|
|
1210
|
+
}
|
|
1211
|
+
const params = new URLSearchParams({
|
|
1212
|
+
redirect_uri: returnTo,
|
|
1213
|
+
client_id: ctx.app.defaultClientId,
|
|
1214
|
+
state: pkce.state,
|
|
1215
|
+
nonce: pkce.nonce,
|
|
1216
|
+
code_challenge: pkce.codeChallenge,
|
|
1217
|
+
code_challenge_method: "S256",
|
|
1218
|
+
scope: "openid profile email"
|
|
1219
|
+
});
|
|
1220
|
+
const url = `${iqAuthBaseUrl.replace(/\/$/, "")}/api/v1/auth/google?${params.toString()}`;
|
|
1199
1221
|
window.location.href = url;
|
|
1200
1222
|
};
|
|
1201
1223
|
useEffect(() => {
|
|
@@ -1708,7 +1730,7 @@ function ImpersonationBanner({ render, onExit, className, style } = {}) {
|
|
|
1708
1730
|
const { exitImpersonation } = await import("./reverify-4UEJXUS6.mjs");
|
|
1709
1731
|
const restored = exitImpersonation(manager);
|
|
1710
1732
|
if (restored) return;
|
|
1711
|
-
const { signOut: signOut2 } = await import("./signIn-
|
|
1733
|
+
const { signOut: signOut2 } = await import("./signIn-4OKLDEIH.mjs");
|
|
1712
1734
|
await signOut2(manager);
|
|
1713
1735
|
}, [manager, onExit]);
|
|
1714
1736
|
if (!info.isImpersonating) return null;
|
package/package.json
CHANGED