@pofsis-nbt/pofsis-auth 2.0.0 → 2.1.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/Documentation.md +151 -143
- package/README.md +143 -130
- package/dist/PofsisAuth.d.ts +1 -1
- package/dist/PofsisAuth.d.ts.map +1 -1
- package/dist/{PofsisAuthClient-CEw_lL5S.js → PofsisAuthClient-Duybofpq.js} +162 -46
- package/dist/PofsisAuthClient-Duybofpq.js.map +1 -0
- package/dist/PofsisAuthClient-c4lzLzjV.cjs +2 -0
- package/dist/PofsisAuthClient-c4lzLzjV.cjs.map +1 -0
- package/dist/{RequireAuth-CPhXupYh.cjs → RequireAuth-BkYhk-9p.cjs} +2 -2
- package/dist/{RequireAuth-CPhXupYh.cjs.map → RequireAuth-BkYhk-9p.cjs.map} +1 -1
- package/dist/{RequireAuth-DFa8_MR1.js → RequireAuth-DroX56rd.js} +67 -62
- package/dist/{RequireAuth-DFa8_MR1.js.map → RequireAuth-DroX56rd.js.map} +1 -1
- package/dist/auth/authLaunch.d.ts.map +1 -1
- package/dist/auth/config.d.ts.map +1 -1
- package/dist/core/PofsisAuthClient.d.ts +2 -0
- package/dist/core/PofsisAuthClient.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/popupProtocol.d.ts +11 -1
- package/dist/core/popupProtocol.d.ts.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +2 -2
- package/dist/elements/index.d.ts.map +1 -1
- package/dist/elements.cjs +1 -1
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.js +8 -3
- package/dist/elements.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/pofsis-auth-elements.js +1 -1
- package/dist/pofsis-auth-elements.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/types.d.ts +13 -2
- package/dist/types.d.ts.map +1 -1
- package/docs/application-id-consumer-migration.md +180 -0
- package/docs/popup-integration.md +188 -162
- package/package.json +87 -87
- package/dist/PofsisAuthClient-B3YHqgZL.cjs +0 -2
- package/dist/PofsisAuthClient-B3YHqgZL.cjs.map +0 -1
- package/dist/PofsisAuthClient-CEw_lL5S.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, c as t,
|
|
1
|
+
import { a as e, c as t, l as n, o as r, r as i, s as a, t as o, u as s } from "./PofsisAuthClient-Duybofpq.js";
|
|
2
2
|
import { createContext as c, useCallback as l, useContext as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
3
3
|
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
4
4
|
//#region src/assets/auth-error-illustration.png
|
|
@@ -160,21 +160,21 @@ function A({ callback: e = !1 }) {
|
|
|
160
160
|
var j = c(null);
|
|
161
161
|
//#endregion
|
|
162
162
|
//#region src/components/AuthPathShell.tsx
|
|
163
|
-
function M({ auth:
|
|
163
|
+
function M({ auth: t, LoadingScreen: n }) {
|
|
164
164
|
let r = p(!1);
|
|
165
165
|
return d(() => {
|
|
166
|
-
r.current || (r.current = !0,
|
|
167
|
-
...
|
|
166
|
+
r.current || (r.current = !0, t.login({
|
|
167
|
+
...e(window.location.search),
|
|
168
168
|
presentation: "redirect"
|
|
169
169
|
}).catch(() => {
|
|
170
170
|
window.location.replace("/auth/error");
|
|
171
171
|
}));
|
|
172
|
-
}, [
|
|
172
|
+
}, [t]), /* @__PURE__ */ g(n, { callback: !0 });
|
|
173
173
|
}
|
|
174
174
|
function N({ auth: e, postLoginPath: t, returnPathKey: n, LoadingScreen: r }) {
|
|
175
|
-
let
|
|
175
|
+
let a = p(!1);
|
|
176
176
|
return d(() => {
|
|
177
|
-
if (
|
|
177
|
+
if (a.current || (a.current = !0, i())) return;
|
|
178
178
|
let r = new URLSearchParams(window.location.search), o = r.get("code"), s = r.get("state"), c = r.get("error");
|
|
179
179
|
if (c || !o || !s) {
|
|
180
180
|
window.location.replace(`/auth/error${c ? `?reason=${encodeURIComponent(c)}` : ""}`);
|
|
@@ -218,23 +218,23 @@ function R() {
|
|
|
218
218
|
localStorage.setItem(L, String(Date.now()));
|
|
219
219
|
} catch {}
|
|
220
220
|
}
|
|
221
|
-
function z({ children: e, client:
|
|
222
|
-
let [c, u] = m(
|
|
223
|
-
d(() =>
|
|
221
|
+
function z({ children: e, client: r, postLoginPath: i, components: o }) {
|
|
222
|
+
let [c, u] = m(r.getSession()), [p, h] = m(!0);
|
|
223
|
+
d(() => r.subscribe(u), [r]), d(() => () => r.destroy(), [r]), d(() => {
|
|
224
224
|
let e = !1;
|
|
225
|
-
if (window.location.pathname.startsWith(
|
|
225
|
+
if (window.location.pathname.startsWith(r.config.callbackPath)) {
|
|
226
226
|
h(!1);
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
|
-
return
|
|
229
|
+
return r.refreshSession().catch(() => void 0).finally(() => {
|
|
230
230
|
e || h(!1);
|
|
231
231
|
}), () => {
|
|
232
232
|
e = !0;
|
|
233
233
|
};
|
|
234
|
-
}, [
|
|
234
|
+
}, [r]);
|
|
235
235
|
let _ = l(() => {
|
|
236
|
-
|
|
237
|
-
}, [
|
|
236
|
+
r.getSession() && (r.clearSession(), r.getOAuthClient().then((e) => window.location.assign(e.logout_uri)));
|
|
237
|
+
}, [r]);
|
|
238
238
|
d(() => {
|
|
239
239
|
let e = null;
|
|
240
240
|
try {
|
|
@@ -252,104 +252,109 @@ function z({ children: e, client: n, postLoginPath: a, components: s }) {
|
|
|
252
252
|
};
|
|
253
253
|
}, [_]), d(() => {
|
|
254
254
|
let e = () => {
|
|
255
|
-
document.visibilityState !== "hidden" &&
|
|
255
|
+
document.visibilityState !== "hidden" && r.getSession() && r.isRemoteSessionActive().then((e) => {
|
|
256
256
|
e || _();
|
|
257
257
|
});
|
|
258
258
|
};
|
|
259
259
|
return window.addEventListener("focus", e), document.addEventListener("visibilitychange", e), () => {
|
|
260
260
|
window.removeEventListener("focus", e), document.removeEventListener("visibilitychange", e);
|
|
261
261
|
};
|
|
262
|
-
}, [
|
|
262
|
+
}, [r, _]);
|
|
263
263
|
let v = l(async () => {
|
|
264
|
-
let e = await
|
|
264
|
+
let e = await r.getOAuthClient();
|
|
265
265
|
try {
|
|
266
|
-
await
|
|
266
|
+
await r.logout();
|
|
267
267
|
} finally {
|
|
268
268
|
R(), window.location.assign(e.logout_uri || `${window.location.origin}/login`);
|
|
269
269
|
}
|
|
270
|
-
}, [
|
|
271
|
-
let t =
|
|
270
|
+
}, [r]), y = l((e) => {
|
|
271
|
+
let t = r.getUser();
|
|
272
272
|
if (!t) return e;
|
|
273
|
-
let
|
|
273
|
+
let n = [e.firstName, e.lastName].filter(Boolean).join(" "), i = {
|
|
274
274
|
...t,
|
|
275
275
|
accountId: e.accountId,
|
|
276
276
|
firstName: e.firstName || void 0,
|
|
277
277
|
lastName: e.lastName || void 0,
|
|
278
|
-
displayName:
|
|
278
|
+
displayName: n || t.email || t.displayName,
|
|
279
279
|
avatarUrl: e.profilePhotoUrl || void 0,
|
|
280
280
|
coverUrl: e.coverPhotoUrl || void 0
|
|
281
281
|
};
|
|
282
|
-
return
|
|
283
|
-
}, [
|
|
284
|
-
|
|
285
|
-
let e =
|
|
282
|
+
return r.replaceUser(i), e;
|
|
283
|
+
}, [r]), b = l(async () => {
|
|
284
|
+
r.getAccessToken() || await r.refreshSession();
|
|
285
|
+
let e = r.getAccessToken();
|
|
286
286
|
if (!e) throw Error("Authentication required");
|
|
287
287
|
return e;
|
|
288
|
-
}, [
|
|
288
|
+
}, [r]), x = f(() => ({
|
|
289
289
|
user: c?.user ?? null,
|
|
290
290
|
session: c,
|
|
291
291
|
isAuthenticated: !!c,
|
|
292
292
|
isLoading: p,
|
|
293
|
-
login:
|
|
294
|
-
signup:
|
|
295
|
-
resetPassword:
|
|
293
|
+
login: r.login.bind(r),
|
|
294
|
+
signup: r.signup.bind(r),
|
|
295
|
+
resetPassword: r.resetPassword.bind(r),
|
|
296
296
|
logout: v,
|
|
297
|
-
refreshSession: () =>
|
|
298
|
-
getAccessToken: () =>
|
|
299
|
-
getAccountProfile: async () => y(await
|
|
300
|
-
updateAccountProfile: async (e) => y(await
|
|
301
|
-
uploadAccountProfileImage: async (e, t) => y(await r
|
|
302
|
-
deleteAccountProfileImage: async (e) => y(await
|
|
303
|
-
completeCallback: (e, t) =>
|
|
297
|
+
refreshSession: () => r.refreshSession(),
|
|
298
|
+
getAccessToken: () => r.getAccessToken(),
|
|
299
|
+
getAccountProfile: async () => y(await t(r.config, await b())),
|
|
300
|
+
updateAccountProfile: async (e) => y(await n(r.config, await b(), e)),
|
|
301
|
+
uploadAccountProfileImage: async (e, t) => y(await s(r.config, await b(), e, t)),
|
|
302
|
+
deleteAccountProfileImage: async (e) => y(await a(r.config, await b(), e)),
|
|
303
|
+
completeCallback: (e, t) => r.completeRedirectCallback(e, t)
|
|
304
304
|
}), [
|
|
305
305
|
y,
|
|
306
|
-
|
|
306
|
+
r,
|
|
307
307
|
p,
|
|
308
308
|
v,
|
|
309
309
|
b,
|
|
310
310
|
c
|
|
311
311
|
]);
|
|
312
312
|
return /* @__PURE__ */ g(F.Provider, {
|
|
313
|
-
value:
|
|
313
|
+
value: o,
|
|
314
314
|
children: /* @__PURE__ */ g(j.Provider, {
|
|
315
315
|
value: x,
|
|
316
316
|
children: /* @__PURE__ */ g(P, {
|
|
317
|
-
callbackPath:
|
|
318
|
-
components:
|
|
319
|
-
postLoginPath:
|
|
320
|
-
returnPathKey: `${
|
|
317
|
+
callbackPath: r.config.callbackPath,
|
|
318
|
+
components: o,
|
|
319
|
+
postLoginPath: i,
|
|
320
|
+
returnPathKey: `${r.config.applicationId}.auth.return-path`,
|
|
321
321
|
children: e
|
|
322
322
|
})
|
|
323
323
|
})
|
|
324
324
|
});
|
|
325
325
|
}
|
|
326
|
-
function B({ children:
|
|
327
|
-
let
|
|
328
|
-
applicationId:
|
|
329
|
-
apiBaseUrl:
|
|
326
|
+
function B({ children: e, applicationId: t, apiBaseUrl: n, authUrl: i, scope: a, callbackPath: s, popup: c, modal: l, postLoginPath: u = "/", components: d }) {
|
|
327
|
+
let p = f(() => r({
|
|
328
|
+
applicationId: t,
|
|
329
|
+
apiBaseUrl: n,
|
|
330
330
|
authUrl: i,
|
|
331
331
|
scope: a,
|
|
332
|
-
callbackPath:
|
|
333
|
-
popup: c
|
|
332
|
+
callbackPath: s,
|
|
333
|
+
popup: c,
|
|
334
|
+
modal: l
|
|
334
335
|
}), [
|
|
336
|
+
t,
|
|
335
337
|
n,
|
|
336
|
-
r,
|
|
337
338
|
i,
|
|
338
339
|
a,
|
|
339
|
-
|
|
340
|
+
s,
|
|
340
341
|
c?.width,
|
|
341
342
|
c?.height,
|
|
342
343
|
c?.name,
|
|
343
|
-
c?.timeoutMs
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
344
|
+
c?.timeoutMs,
|
|
345
|
+
l?.width,
|
|
346
|
+
l?.height,
|
|
347
|
+
l?.timeoutMs,
|
|
348
|
+
l?.readyTimeoutMs
|
|
349
|
+
]), m = f(() => new o(p), [p]), h = f(() => ({
|
|
350
|
+
LoadingScreen: d?.LoadingScreen ?? A,
|
|
351
|
+
ErrorScreen: d?.ErrorScreen ?? E
|
|
352
|
+
}), [d?.ErrorScreen, d?.LoadingScreen]);
|
|
348
353
|
return /* @__PURE__ */ g(z, {
|
|
349
|
-
client:
|
|
350
|
-
postLoginPath:
|
|
351
|
-
components:
|
|
352
|
-
children:
|
|
354
|
+
client: m,
|
|
355
|
+
postLoginPath: u,
|
|
356
|
+
components: h,
|
|
357
|
+
children: e
|
|
353
358
|
});
|
|
354
359
|
}
|
|
355
360
|
//#endregion
|
|
@@ -400,4 +405,4 @@ function U({ children: e, fallback: t, onUnauthenticated: n }) {
|
|
|
400
405
|
//#endregion
|
|
401
406
|
export { A as a, B as i, H as n, E as o, V as r, U as t };
|
|
402
407
|
|
|
403
|
-
//# sourceMappingURL=RequireAuth-
|
|
408
|
+
//# sourceMappingURL=RequireAuth-DroX56rd.js.map
|