@sparkstudio/authentication-ui 1.0.3 → 1.0.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/index.cjs +50 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +50 -63
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1362,7 +1362,7 @@ var require_react_development = __commonJS({
|
|
|
1362
1362
|
}
|
|
1363
1363
|
return dispatcher.useContext(Context);
|
|
1364
1364
|
}
|
|
1365
|
-
function
|
|
1365
|
+
function useState3(initialState) {
|
|
1366
1366
|
var dispatcher = resolveDispatcher();
|
|
1367
1367
|
return dispatcher.useState(initialState);
|
|
1368
1368
|
}
|
|
@@ -1370,7 +1370,7 @@ var require_react_development = __commonJS({
|
|
|
1370
1370
|
var dispatcher = resolveDispatcher();
|
|
1371
1371
|
return dispatcher.useReducer(reducer, initialArg, init);
|
|
1372
1372
|
}
|
|
1373
|
-
function
|
|
1373
|
+
function useRef(initialValue) {
|
|
1374
1374
|
var dispatcher = resolveDispatcher();
|
|
1375
1375
|
return dispatcher.useRef(initialValue);
|
|
1376
1376
|
}
|
|
@@ -2164,8 +2164,8 @@ var require_react_development = __commonJS({
|
|
|
2164
2164
|
exports2.useLayoutEffect = useLayoutEffect;
|
|
2165
2165
|
exports2.useMemo = useMemo;
|
|
2166
2166
|
exports2.useReducer = useReducer;
|
|
2167
|
-
exports2.useRef =
|
|
2168
|
-
exports2.useState =
|
|
2167
|
+
exports2.useRef = useRef;
|
|
2168
|
+
exports2.useState = useState3;
|
|
2169
2169
|
exports2.useSyncExternalStore = useSyncExternalStore;
|
|
2170
2170
|
exports2.useTransition = useTransition;
|
|
2171
2171
|
exports2.version = ReactVersion;
|
|
@@ -2221,7 +2221,7 @@ var require_react_jsx_runtime_development = __commonJS({
|
|
|
2221
2221
|
if (process.env.NODE_ENV !== "production") {
|
|
2222
2222
|
(function() {
|
|
2223
2223
|
"use strict";
|
|
2224
|
-
var
|
|
2224
|
+
var React = require_react();
|
|
2225
2225
|
var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.element");
|
|
2226
2226
|
var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
|
|
2227
2227
|
var REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
@@ -2247,7 +2247,7 @@ var require_react_jsx_runtime_development = __commonJS({
|
|
|
2247
2247
|
}
|
|
2248
2248
|
return null;
|
|
2249
2249
|
}
|
|
2250
|
-
var ReactSharedInternals =
|
|
2250
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
2251
2251
|
function error(format) {
|
|
2252
2252
|
{
|
|
2253
2253
|
{
|
|
@@ -3132,9 +3132,6 @@ __export(index_exports, {
|
|
|
3132
3132
|
});
|
|
3133
3133
|
module.exports = __toCommonJS(index_exports);
|
|
3134
3134
|
|
|
3135
|
-
// src/components/UserInfoCard.tsx
|
|
3136
|
-
var import_react3 = __toESM(require_react(), 1);
|
|
3137
|
-
|
|
3138
3135
|
// src/context/UserProvider.tsx
|
|
3139
3136
|
var import_react = __toESM(require_react(), 1);
|
|
3140
3137
|
|
|
@@ -3215,7 +3212,7 @@ var SparkStudioAuthenticationSDK = class {
|
|
|
3215
3212
|
// src/context/UserProvider.tsx
|
|
3216
3213
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
3217
3214
|
var UserContext = (0, import_react.createContext)(void 0);
|
|
3218
|
-
|
|
3215
|
+
function UserProvider({ children }) {
|
|
3219
3216
|
const [user, setUserState] = (0, import_react.useState)(null);
|
|
3220
3217
|
(0, import_react.useEffect)(() => {
|
|
3221
3218
|
const fetchUser = async () => {
|
|
@@ -3243,22 +3240,21 @@ var UserProvider = ({ children }) => {
|
|
|
3243
3240
|
setUserState(null);
|
|
3244
3241
|
};
|
|
3245
3242
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(UserContext.Provider, { value: { user, setUser, logout }, children });
|
|
3246
|
-
}
|
|
3247
|
-
|
|
3243
|
+
}
|
|
3244
|
+
function useUser() {
|
|
3248
3245
|
const context = (0, import_react.useContext)(UserContext);
|
|
3249
3246
|
if (!context) throw new Error("useUser must be used inside UserProvider");
|
|
3250
3247
|
return context;
|
|
3251
|
-
}
|
|
3248
|
+
}
|
|
3252
3249
|
|
|
3253
3250
|
// src/components/Buttons/LoginButton.tsx
|
|
3254
3251
|
var import_react2 = __toESM(require_react(), 1);
|
|
3255
3252
|
var import_google = require("@react-oauth/google");
|
|
3256
3253
|
var import_common_ui = require("@sparkstudio/common-ui");
|
|
3257
3254
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
3258
|
-
|
|
3255
|
+
function LoginButton({ onSuccess }) {
|
|
3259
3256
|
const { setUser } = useUser();
|
|
3260
|
-
const
|
|
3261
|
-
const rejectRef = (0, import_react2.useRef)(null);
|
|
3257
|
+
const [loading, setLoading] = (0, import_react2.useState)(false);
|
|
3262
3258
|
const login = (0, import_google.useGoogleLogin)({
|
|
3263
3259
|
flow: "implicit",
|
|
3264
3260
|
onSuccess: async (tokenResponse) => {
|
|
@@ -3269,62 +3265,54 @@ var LoginButton = ({ onSuccess }) => {
|
|
|
3269
3265
|
});
|
|
3270
3266
|
setUser(authentication?.User ?? null);
|
|
3271
3267
|
onSuccess?.(tokenResponse);
|
|
3272
|
-
resolveRef.current?.();
|
|
3273
3268
|
} catch (error) {
|
|
3274
3269
|
console.error("\u{1F534} Login failed (Google or backend SignIn)", error);
|
|
3275
|
-
rejectRef.current?.(error);
|
|
3276
3270
|
} finally {
|
|
3277
|
-
|
|
3278
|
-
rejectRef.current = null;
|
|
3271
|
+
setLoading(false);
|
|
3279
3272
|
}
|
|
3280
3273
|
},
|
|
3281
3274
|
onError: (error) => {
|
|
3282
3275
|
console.error("\u274C Google Login Failed", error);
|
|
3283
|
-
|
|
3284
|
-
resolveRef.current = null;
|
|
3285
|
-
rejectRef.current = null;
|
|
3276
|
+
setLoading(false);
|
|
3286
3277
|
}
|
|
3287
3278
|
});
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
login();
|
|
3297
|
-
}),
|
|
3298
|
-
renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3299
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3300
|
-
"img",
|
|
3301
|
-
{
|
|
3302
|
-
src: "../../assets/icons/google_icon.webp",
|
|
3303
|
-
alt: "Google",
|
|
3304
|
-
style: { width: "21px", height: "21px", margin: 0, padding: 0 }
|
|
3305
|
-
}
|
|
3306
|
-
),
|
|
3307
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "d-none d-sm-inline ms-2", children: "Login" })
|
|
3308
|
-
] }),
|
|
3309
|
-
renderLoading: () => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3310
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3311
|
-
"span",
|
|
3312
|
-
{
|
|
3313
|
-
className: "spinner-border spinner-border-sm me-2 async-btn__spinner",
|
|
3314
|
-
role: "status",
|
|
3315
|
-
"aria-hidden": "true"
|
|
3316
|
-
}
|
|
3317
|
-
),
|
|
3318
|
-
"Signing in..."
|
|
3319
|
-
] })
|
|
3279
|
+
const handleClick = () => {
|
|
3280
|
+
if (loading) return;
|
|
3281
|
+
setLoading(true);
|
|
3282
|
+
try {
|
|
3283
|
+
login();
|
|
3284
|
+
} catch (err) {
|
|
3285
|
+
console.error("Error starting Google login", err);
|
|
3286
|
+
setLoading(false);
|
|
3320
3287
|
}
|
|
3321
|
-
|
|
3322
|
-
|
|
3288
|
+
};
|
|
3289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_common_ui.Button, { onClick: handleClick, disabled: loading, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3290
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3291
|
+
"span",
|
|
3292
|
+
{
|
|
3293
|
+
className: "spinner-border spinner-border-sm me-2 async-btn__spinner",
|
|
3294
|
+
role: "status",
|
|
3295
|
+
"aria-hidden": "true"
|
|
3296
|
+
}
|
|
3297
|
+
),
|
|
3298
|
+
"Signing in..."
|
|
3299
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3300
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3301
|
+
"img",
|
|
3302
|
+
{
|
|
3303
|
+
src: "../../assets/icons/google_icon.webp",
|
|
3304
|
+
alt: "Google",
|
|
3305
|
+
style: { width: "21px", height: "21px", margin: 0, padding: 0 }
|
|
3306
|
+
}
|
|
3307
|
+
),
|
|
3308
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "d-none d-sm-inline ms-2", children: "Login" })
|
|
3309
|
+
] }) });
|
|
3310
|
+
}
|
|
3323
3311
|
|
|
3324
3312
|
// src/components/UserInfoCard.tsx
|
|
3325
3313
|
var import_common_ui2 = require("@sparkstudio/common-ui");
|
|
3326
3314
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
3327
|
-
|
|
3315
|
+
function UserInfoCard() {
|
|
3328
3316
|
const { user, logout } = useUser();
|
|
3329
3317
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: user ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
3330
3318
|
import_common_ui2.Button,
|
|
@@ -3356,18 +3344,17 @@ var UserInfoCard = () => {
|
|
|
3356
3344
|
] })
|
|
3357
3345
|
}
|
|
3358
3346
|
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LoginButton, {}) });
|
|
3359
|
-
}
|
|
3347
|
+
}
|
|
3360
3348
|
|
|
3361
3349
|
// src/components/AuthenticatorProvider.tsx
|
|
3362
|
-
var import_react4 = __toESM(require_react(), 1);
|
|
3363
3350
|
var import_google2 = require("@react-oauth/google");
|
|
3364
3351
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
3365
|
-
|
|
3352
|
+
function AuthenticatorProvider({
|
|
3366
3353
|
googleClientId,
|
|
3367
3354
|
children
|
|
3368
|
-
})
|
|
3355
|
+
}) {
|
|
3369
3356
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_google2.GoogleOAuthProvider, { clientId: googleClientId, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(UserProvider, { children }) });
|
|
3370
|
-
}
|
|
3357
|
+
}
|
|
3371
3358
|
|
|
3372
3359
|
// src/types/Guid.ts
|
|
3373
3360
|
var EMPTY_GUID = "00000000-0000-0000-0000-000000000000";
|