@cobaltcore-dev/aurora 0.17.1 → 0.19.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/dist/client/AuthProvider-Cj_Btfnc.mjs +56 -0
- package/dist/client/AuthProvider-Cj_Btfnc.mjs.map +1 -0
- package/dist/client/{BucketToastNotifications-D2Cq2VrV.mjs → BucketToastNotifications-BGd2wVmh.mjs} +2 -2
- package/dist/client/{BucketToastNotifications-D2Cq2VrV.mjs.map → BucketToastNotifications-BGd2wVmh.mjs.map} +1 -1
- package/dist/client/DeletePcaModal-BU6kbKsw.mjs +80 -0
- package/dist/client/DeletePcaModal-BU6kbKsw.mjs.map +1 -0
- package/dist/client/DetailsInfo-BUyuYpJj.mjs +52 -0
- package/dist/client/DetailsInfo-BUyuYpJj.mjs.map +1 -0
- package/dist/client/{FloatingIpActionModals-BUc6yaQ8.mjs → FloatingIpActionModals-DAtZoYGS.mjs} +22 -22
- package/dist/client/{FloatingIpActionModals-BUc6yaQ8.mjs.map → FloatingIpActionModals-DAtZoYGS.mjs.map} +1 -1
- package/dist/client/{ImageToastNotifications-Dz-VsSwl.mjs → ImageToastNotifications-BhjU1bfT.mjs} +7 -7
- package/dist/client/{ImageToastNotifications-Dz-VsSwl.mjs.map → ImageToastNotifications-BhjU1bfT.mjs.map} +1 -1
- package/dist/client/{_auth-6uste_10.mjs → _auth-BtRCgHQe.mjs} +2 -2
- package/dist/client/{_auth-6uste_10.mjs.map → _auth-BtRCgHQe.mjs.map} +1 -1
- package/dist/client/{_flavorId-Cx5tf2KQ.mjs → _flavorId-BQY7YhNx.mjs} +2 -2
- package/dist/client/{_flavorId-Cx5tf2KQ.mjs.map → _flavorId-BQY7YhNx.mjs.map} +1 -1
- package/dist/client/{_flavorId-C6RJfhh8.mjs → _flavorId-sS1sg_DZ.mjs} +3 -3
- package/dist/client/{_flavorId-C6RJfhh8.mjs.map → _flavorId-sS1sg_DZ.mjs.map} +1 -1
- package/dist/client/{_floatingIpId-B0l4YNQc.mjs → _floatingIpId-BHZGh8U8.mjs} +2 -2
- package/dist/client/{_floatingIpId-B0l4YNQc.mjs.map → _floatingIpId-BHZGh8U8.mjs.map} +1 -1
- package/dist/client/{_floatingIpId-cpueAc2F2.mjs → _floatingIpId-CR3aD38l2.mjs} +5 -5
- package/dist/client/{_floatingIpId-cpueAc2F2.mjs.map → _floatingIpId-CR3aD38l2.mjs.map} +1 -1
- package/dist/client/{_imageId-Bv711w1n.mjs → _imageId-Cf-Xdksv.mjs} +3 -3
- package/dist/client/{_imageId-Bv711w1n.mjs.map → _imageId-Cf-Xdksv.mjs.map} +1 -1
- package/dist/client/_pcaId-B7j0sXnY.mjs +545 -0
- package/dist/client/_pcaId-B7j0sXnY.mjs.map +1 -0
- package/dist/client/{_projectId-fEA6fnFQ.mjs → _projectId-Cq9JnhRj.mjs} +3 -3
- package/dist/client/{_projectId-fEA6fnFQ.mjs.map → _projectId-Cq9JnhRj.mjs.map} +1 -1
- package/dist/client/{_projectId-w-tZz0FI.mjs → _projectId-D8FHe0gr.mjs} +2 -2
- package/dist/client/{_projectId-w-tZz0FI.mjs.map → _projectId-D8FHe0gr.mjs.map} +1 -1
- package/dist/client/{_projectId-qvINx3Dx.mjs → _projectId-Ig3QqYzt.mjs} +2 -2
- package/dist/client/{_projectId-qvINx3Dx.mjs.map → _projectId-Ig3QqYzt.mjs.map} +1 -1
- package/dist/client/{_projectId-BOaPmCuz.mjs → _projectId-b4NGeECR.mjs} +3 -3
- package/dist/client/{_projectId-BOaPmCuz.mjs.map → _projectId-b4NGeECR.mjs.map} +1 -1
- package/dist/client/{_securityGroupId-B-RYPDDc.mjs → _securityGroupId-BVSsCus9.mjs} +2 -2
- package/dist/client/{_securityGroupId-B-RYPDDc.mjs.map → _securityGroupId-BVSsCus9.mjs.map} +1 -1
- package/dist/client/{_securityGroupId-BC3KC6h5.mjs → _securityGroupId-gwV4eB0s.mjs} +16 -16
- package/dist/client/{_securityGroupId-BC3KC6h5.mjs.map → _securityGroupId-gwV4eB0s.mjs.map} +1 -1
- package/dist/client/{_storageType-ZFnIALny.mjs → _storageType-CH2khFcZ.mjs} +2 -2
- package/dist/client/{_storageType-ZFnIALny.mjs.map → _storageType-CH2khFcZ.mjs.map} +1 -1
- package/dist/client/{_storageType-MgntkZb6.mjs → _storageType-D-1H6SX1.mjs} +856 -856
- package/dist/client/{_storageType-MgntkZb6.mjs.map → _storageType-D-1H6SX1.mjs.map} +1 -1
- package/dist/client/{aurora-AAy9BJE7.mjs → aurora-Owys0YMN.mjs} +2 -2
- package/dist/client/{aurora-AAy9BJE7.mjs.map → aurora-Owys0YMN.mjs.map} +1 -1
- package/dist/client/build-DgeVmENN.mjs.map +1 -1
- package/dist/client/{floatingips-Bkk5-I_p.mjs → floatingips-DyBEotB8.mjs} +10 -10
- package/dist/client/{floatingips-Bkk5-I_p.mjs.map → floatingips-DyBEotB8.mjs.map} +1 -1
- package/dist/client/hooks-iGiEkLTp.mjs +12 -0
- package/dist/client/hooks-iGiEkLTp.mjs.map +1 -0
- package/dist/client/{images-FE3vJ6pP.mjs → images-BklbSacK.mjs} +2 -2
- package/dist/client/{images-FE3vJ6pP.mjs.map → images-BklbSacK.mjs.map} +1 -1
- package/dist/client/{images-DBLfzuJA.mjs → images-C3voJ3B1.mjs} +259 -259
- package/dist/client/{images-DBLfzuJA.mjs.map → images-C3voJ3B1.mjs.map} +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.js +370 -414
- package/dist/client/index.js.map +1 -1
- package/dist/client/md-CyCflQee.mjs.map +1 -1
- package/dist/client/{objects-DpgXMFrG.mjs → objects-B3Z8h4RU.mjs} +2 -2
- package/dist/client/{objects-DpgXMFrG.mjs.map → objects-B3Z8h4RU.mjs.map} +1 -1
- package/dist/client/{objects-Deo1Ic1A.mjs → objects-CGOfO00N.mjs} +499 -475
- package/dist/client/objects-CGOfO00N.mjs.map +1 -0
- package/dist/client/{pca-BkAJ5jvX.mjs → pca-72YR_Pk0.mjs} +3 -3
- package/dist/client/pca-72YR_Pk0.mjs.map +1 -0
- package/dist/client/pca-CsBx_IDO.mjs +251 -0
- package/dist/client/pca-CsBx_IDO.mjs.map +1 -0
- package/dist/client/pcaAccess-Br4kVjLQ.mjs +9 -0
- package/dist/client/pcaAccess-Br4kVjLQ.mjs.map +1 -0
- package/dist/client/{securitygroups-D14Jv1GQ.mjs → securitygroups-8vRbXmBL.mjs} +3 -3
- package/dist/client/{securitygroups-D14Jv1GQ.mjs.map → securitygroups-8vRbXmBL.mjs.map} +1 -1
- package/dist/client/trpcClient-BxcNKnhv.mjs +65 -0
- package/dist/client/trpcClient-BxcNKnhv.mjs.map +1 -0
- package/dist/client/trpcClient.d.ts +3014 -0
- package/dist/server/index.d.ts +3058 -1
- package/dist/server/index.js +53 -23
- package/package.json +4 -2
- package/dist/client/AuthProvider-BQSJk5R4.mjs +0 -63
- package/dist/client/AuthProvider-BQSJk5R4.mjs.map +0 -1
- package/dist/client/_pcaId-CPLb5J6d.mjs +0 -479
- package/dist/client/_pcaId-CPLb5J6d.mjs.map +0 -1
- package/dist/client/_pcaId-Hx_72pnp.mjs +0 -36
- package/dist/client/_pcaId-Hx_72pnp.mjs.map +0 -1
- package/dist/client/constants-BAqOfvr0.mjs +0 -153
- package/dist/client/constants-BAqOfvr0.mjs.map +0 -1
- package/dist/client/hooks-CnX5q5wN.mjs +0 -2
- package/dist/client/objects-Deo1Ic1A.mjs.map +0 -1
- package/dist/client/pca-BkAJ5jvX.mjs.map +0 -1
- package/dist/client/pca-P0ud1PA9.mjs +0 -202
- package/dist/client/pca-P0ud1PA9.mjs.map +0 -1
- package/dist/client/pcaAccess-BYUY700H.mjs +0 -9
- package/dist/client/pcaAccess-BYUY700H.mjs.map +0 -1
- package/dist/client/trpcClient-Dy_MP_Pv.mjs +0 -57
- package/dist/client/trpcClient-Dy_MP_Pv.mjs.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -34673,10 +34673,20 @@ var objectRouter = {
|
|
|
34673
34673
|
throw mappedError;
|
|
34674
34674
|
}
|
|
34675
34675
|
}, "emitMappedError");
|
|
34676
|
-
const response = await s3.send(
|
|
34677
|
-
|
|
34678
|
-
|
|
34679
|
-
|
|
34676
|
+
const response = await s3.send(
|
|
34677
|
+
new import_client_s33.GetObjectCommand({
|
|
34678
|
+
Bucket: containerName,
|
|
34679
|
+
Key: objectKey
|
|
34680
|
+
}),
|
|
34681
|
+
// AWS SDK v3's per-call cancellation option — the equivalent of passing
|
|
34682
|
+
// `{ signal }` to a raw fetch() (see 0010_abort_signal_propagation.md).
|
|
34683
|
+
// ctx.req.signal is aborted automatically when the client disconnects
|
|
34684
|
+
// (tab closed, navigated away) or explicitly via the cancel button,
|
|
34685
|
+
// which calls AbortController.abort() on the frontend.
|
|
34686
|
+
{
|
|
34687
|
+
abortSignal: ctx.req.signal
|
|
34688
|
+
}
|
|
34689
|
+
).catch(emitMappedError);
|
|
34680
34690
|
const body = response.Body;
|
|
34681
34691
|
if (!body) {
|
|
34682
34692
|
emitMappedError(new import_server13.TRPCError({
|
|
@@ -34695,8 +34705,13 @@ var objectRouter = {
|
|
|
34695
34705
|
});
|
|
34696
34706
|
let isFirst = true;
|
|
34697
34707
|
let downloaded = 0;
|
|
34708
|
+
let aborted = false;
|
|
34698
34709
|
try {
|
|
34699
34710
|
for await (const value of body) {
|
|
34711
|
+
if (ctx.req.signal?.aborted) {
|
|
34712
|
+
aborted = true;
|
|
34713
|
+
break;
|
|
34714
|
+
}
|
|
34700
34715
|
downloaded += value.byteLength;
|
|
34701
34716
|
const progress = downloadProgressMap2.get(scopedDownloadId);
|
|
34702
34717
|
progress.downloaded = downloaded;
|
|
@@ -34716,7 +34731,9 @@ var objectRouter = {
|
|
|
34716
34731
|
};
|
|
34717
34732
|
isFirst = false;
|
|
34718
34733
|
}
|
|
34719
|
-
|
|
34734
|
+
if (!aborted) {
|
|
34735
|
+
downloadProgressEmitter2.emit(`progress:${scopedDownloadId}:complete`);
|
|
34736
|
+
}
|
|
34720
34737
|
} catch (error) {
|
|
34721
34738
|
emitMappedError(error);
|
|
34722
34739
|
} finally {
|
|
@@ -37559,24 +37576,31 @@ var CertificateAuthorityAdditionalAttributeSchema = import_zod25.z.object({
|
|
|
37559
37576
|
key: import_zod25.z.array(import_zod25.z.number().int()),
|
|
37560
37577
|
value: import_zod25.z.string()
|
|
37561
37578
|
});
|
|
37579
|
+
var stringOrStringArray = import_zod25.z.union([
|
|
37580
|
+
import_zod25.z.array(import_zod25.z.string()),
|
|
37581
|
+
import_zod25.z.string().transform((s) => [
|
|
37582
|
+
s
|
|
37583
|
+
])
|
|
37584
|
+
]);
|
|
37562
37585
|
var CertificateAuthoritySubjectSchema = import_zod25.z.object({
|
|
37563
37586
|
additional_attribute: import_zod25.z.array(CertificateAuthorityAdditionalAttributeSchema).optional(),
|
|
37564
|
-
|
|
37565
|
-
|
|
37566
|
-
|
|
37567
|
-
|
|
37568
|
-
|
|
37569
|
-
|
|
37570
|
-
|
|
37571
|
-
|
|
37572
|
-
|
|
37573
|
-
|
|
37574
|
-
|
|
37575
|
-
|
|
37576
|
-
|
|
37577
|
-
|
|
37578
|
-
|
|
37579
|
-
|
|
37587
|
+
named_attributes: import_zod25.z.object({
|
|
37588
|
+
cn: import_zod25.z.string(),
|
|
37589
|
+
/** Country codes (ISO 3166-1 alpha-2). */
|
|
37590
|
+
c: stringOrStringArray.optional(),
|
|
37591
|
+
/** Locality/city names. */
|
|
37592
|
+
l: stringOrStringArray.optional(),
|
|
37593
|
+
/** Organization names. */
|
|
37594
|
+
o: stringOrStringArray.optional(),
|
|
37595
|
+
/** Organizational unit names. */
|
|
37596
|
+
ou: stringOrStringArray.optional(),
|
|
37597
|
+
/** Postal/ZIP codes. */
|
|
37598
|
+
postal_code: stringOrStringArray.optional(),
|
|
37599
|
+
/** State or province names. */
|
|
37600
|
+
st: stringOrStringArray.optional(),
|
|
37601
|
+
serial_number: import_zod25.z.string().optional(),
|
|
37602
|
+
street: stringOrStringArray.optional()
|
|
37603
|
+
})
|
|
37580
37604
|
});
|
|
37581
37605
|
var CertificateAuthorityStateSchema = import_zod25.z.enum([
|
|
37582
37606
|
"CREATING",
|
|
@@ -37594,6 +37618,8 @@ var CertificateAuthoritySchema = import_zod25.z.object({
|
|
|
37594
37618
|
subject: CertificateAuthoritySubjectSchema
|
|
37595
37619
|
}).optional(),
|
|
37596
37620
|
csr: import_zod25.z.string().optional(),
|
|
37621
|
+
/** Human-readable subject string, e.g. "CN=demo-ca.test.sci". */
|
|
37622
|
+
display_subject: import_zod25.z.string().optional(),
|
|
37597
37623
|
id: import_zod25.z.string(),
|
|
37598
37624
|
/**
|
|
37599
37625
|
* Required on import certificate operation.
|
|
@@ -37622,7 +37648,11 @@ var CertificateAuthoritiesListInputSchema = projectScopedInputSchema.extend({
|
|
|
37622
37648
|
});
|
|
37623
37649
|
var CertificateAuthorityCreateSchema = import_zod25.z.object({
|
|
37624
37650
|
configuration: import_zod25.z.object({
|
|
37625
|
-
subject:
|
|
37651
|
+
subject: import_zod25.z.object({
|
|
37652
|
+
named_attributes: import_zod25.z.object({
|
|
37653
|
+
cn: import_zod25.z.string().trim().min(1)
|
|
37654
|
+
})
|
|
37655
|
+
})
|
|
37626
37656
|
})
|
|
37627
37657
|
});
|
|
37628
37658
|
var CertificateAuthorityIdInputSchema = projectScopedInputSchema.extend({
|
|
@@ -37662,7 +37692,7 @@ var CertificatesListSchema = import_zod25.z.object({
|
|
|
37662
37692
|
});
|
|
37663
37693
|
|
|
37664
37694
|
// src/server/Services/routers/pcaRouter.ts
|
|
37665
|
-
var PCA_BASE_URL = "certificate-authorities";
|
|
37695
|
+
var PCA_BASE_URL = "v1/certificate-authorities";
|
|
37666
37696
|
var pcaRouter = {
|
|
37667
37697
|
list: projectScopedProcedure.input(CertificateAuthoritiesListInputSchema).query(async ({ input, ctx }) => {
|
|
37668
37698
|
return withErrorHandling3(async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobaltcore-dev/aurora",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Aurora OpenStack dashboard — server and client library",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@headlessui/react": "^2.2.2",
|
|
52
52
|
"@lingui/core": "^5.9.5",
|
|
53
53
|
"@lingui/react": "^5.9.5",
|
|
54
|
+
"@peculiar/x509": "^2.0.0",
|
|
54
55
|
"@tanstack/react-form": "^1.28.5",
|
|
55
56
|
"@tanstack/react-query": "^5.95.2",
|
|
56
57
|
"@tanstack/react-router": "^1.168.4",
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
"node-fetch": "^3.3.2",
|
|
66
67
|
"react-error-boundary": "^6.1.0",
|
|
67
68
|
"react-icons": "^5.6.0",
|
|
69
|
+
"reflect-metadata": "^0.2.2",
|
|
68
70
|
"tailwind-merge": "^3.2.0",
|
|
69
71
|
"zod": "^4.0.0"
|
|
70
72
|
},
|
|
@@ -106,8 +108,8 @@
|
|
|
106
108
|
"vite-plugin-svgr": "^5.0.0",
|
|
107
109
|
"vite-tsconfig-paths": "^6.1.1",
|
|
108
110
|
"vitest": "^4.1.2",
|
|
109
|
-
"@cobaltcore-dev/policy-engine": "2.0.0",
|
|
110
111
|
"@cobaltcore-dev/aurora-config": "0.0.1",
|
|
112
|
+
"@cobaltcore-dev/policy-engine": "2.0.0",
|
|
111
113
|
"@cobaltcore-dev/signal-openstack": "1.0.0"
|
|
112
114
|
},
|
|
113
115
|
"scripts": {
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import t, { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
|
|
3
|
-
//#region src/client/store/AuthProvider.tsx
|
|
4
|
-
var o = /*#__PURE__*/ t.createContext(null);
|
|
5
|
-
function s({ children: s, router: c }) {
|
|
6
|
-
let [l, u] = t.useState(null), [d, f] = t.useState(void 0), [p, m] = t.useState(void 0), [h, g] = a(!1), [_, v] = a(void 0), y = i(null), b = !!l, x = n(() => {
|
|
7
|
-
y.current &&= (clearTimeout(y.current), null);
|
|
8
|
-
}, []), S = n(() => {
|
|
9
|
-
g(!1), c.navigate({
|
|
10
|
-
to: "/",
|
|
11
|
-
search: _ ? { redirect: _ } : void 0
|
|
12
|
-
});
|
|
13
|
-
}, [c, _]), C = n(async (e = "manual") => {
|
|
14
|
-
if (x(), u(null), f(void 0), m(e), e === "expired") {
|
|
15
|
-
let e = window.location.pathname + window.location.search;
|
|
16
|
-
e && e.startsWith("/") && v(e), g(!0);
|
|
17
|
-
} else c.invalidate();
|
|
18
|
-
}, [c, x]), w = n(async (e, t) => {
|
|
19
|
-
u(e), m(void 0), g(!1), v(void 0), f(t ? new Date(t) : void 0);
|
|
20
|
-
}, []);
|
|
21
|
-
return r(() => {
|
|
22
|
-
if (x(), l && d) {
|
|
23
|
-
let e = d.getTime() - Date.now();
|
|
24
|
-
if (e <= 0) {
|
|
25
|
-
C("expired");
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
y.current = setTimeout(() => {
|
|
29
|
-
C("expired");
|
|
30
|
-
}, e);
|
|
31
|
-
}
|
|
32
|
-
return () => {
|
|
33
|
-
x();
|
|
34
|
-
};
|
|
35
|
-
}, [
|
|
36
|
-
l,
|
|
37
|
-
d,
|
|
38
|
-
C,
|
|
39
|
-
x
|
|
40
|
-
]), /*#__PURE__*/ e(o.Provider, {
|
|
41
|
-
value: {
|
|
42
|
-
isAuthenticated: b,
|
|
43
|
-
user: l,
|
|
44
|
-
login: w,
|
|
45
|
-
logout: C,
|
|
46
|
-
expiresAt: d,
|
|
47
|
-
logoutReason: p,
|
|
48
|
-
showInactivityModal: h,
|
|
49
|
-
closeInactivityModal: S,
|
|
50
|
-
redirectAfterModal: _
|
|
51
|
-
},
|
|
52
|
-
children: s
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function c() {
|
|
56
|
-
let e = t.useContext(o);
|
|
57
|
-
if (!e) throw Error("useAuth must be used within an AuthProvider");
|
|
58
|
-
return e;
|
|
59
|
-
}
|
|
60
|
-
//#endregion
|
|
61
|
-
export { c as n, s as t };
|
|
62
|
-
|
|
63
|
-
//# sourceMappingURL=AuthProvider-BQSJk5R4.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider-BQSJk5R4.mjs","names":["React","useEffect","useRef","useCallback","useState","AuthContext","createContext","AuthProvider","children","router","user","setUser","expiresAt","setExpiresAt","undefined","logoutReason","setLogoutReason","showInactivityModal","setShowInactivityModal","redirectAfterModal","setRedirectAfterModal","logoutTimerRef","isAuthenticated","clearLogoutTimer","current","clearTimeout","closeInactivityModal","navigate","to","search","redirect","logout","reason","currentPath","window","location","pathname","startsWith","invalidate","login","expires_at","expiration","Date","timeUntilExpiry","getTime","now","setTimeout","Provider","value","useAuth","context","useContext","Error"],"sources":["../../src/client/store/AuthProvider.tsx"],"sourcesContent":["import React, { useEffect, useRef, useCallback, useState } from \"react\"\nimport { TokenData } from \"../../server/Authentication/types/models\"\n\nexport type User = TokenData[\"user\"] | null\n\nexport interface AuthContext {\n isAuthenticated: boolean\n login: (user: User, expires_at?: string) => Promise<void>\n logout: (reason?: \"inactive\" | \"expired\" | \"manual\") => Promise<void>\n user?: User\n expiresAt?: Date\n logoutReason?: \"inactive\" | \"expired\" | \"manual\"\n showInactivityModal: boolean\n closeInactivityModal: () => void\n redirectAfterModal?: string\n}\n\ninterface RouterNavigation {\n navigate: (options: { to: string; search?: Record<string, unknown> }) => void\n invalidate: () => void\n}\n\nconst AuthContext = React.createContext<AuthContext | null>(null)\n\nexport function AuthProvider({ children, router }: { children: React.ReactNode; router: RouterNavigation }) {\n const [user, setUser] = React.useState<User | null>(null)\n const [expiresAt, setExpiresAt] = React.useState<Date | undefined>(undefined)\n const [logoutReason, setLogoutReason] = React.useState<\"inactive\" | \"expired\" | \"manual\" | undefined>(undefined)\n const [showInactivityModal, setShowInactivityModal] = useState(false)\n const [redirectAfterModal, setRedirectAfterModal] = useState<string | undefined>(undefined)\n\n const logoutTimerRef = useRef<NodeJS.Timeout | null>(null)\n\n const isAuthenticated = !!user\n\n const clearLogoutTimer = useCallback(() => {\n if (logoutTimerRef.current) {\n clearTimeout(logoutTimerRef.current)\n logoutTimerRef.current = null\n }\n }, [])\n\n const closeInactivityModal = useCallback(() => {\n setShowInactivityModal(false)\n\n router.navigate({\n to: \"/\",\n search: redirectAfterModal ? { redirect: redirectAfterModal } : undefined,\n })\n }, [router, redirectAfterModal])\n\n const logout = useCallback(\n async (reason: \"inactive\" | \"expired\" | \"manual\" = \"manual\") => {\n clearLogoutTimer()\n\n setUser(null)\n setExpiresAt(undefined)\n setLogoutReason(reason)\n\n // For expired: Show modal instead of direct navigation\n if (reason === \"expired\") {\n const currentPath = window.location.pathname + window.location.search\n if (currentPath && currentPath.startsWith(\"/\")) {\n setRedirectAfterModal(currentPath)\n }\n\n setShowInactivityModal(true)\n } else {\n // Manual logout: direct navigation\n router.invalidate()\n }\n },\n [router, clearLogoutTimer]\n )\n\n const login = useCallback(async (user: User, expires_at?: string) => {\n setUser(user)\n setLogoutReason(undefined)\n setShowInactivityModal(false)\n setRedirectAfterModal(undefined)\n\n if (expires_at) {\n const expiration = new Date(expires_at)\n setExpiresAt(expiration)\n } else {\n setExpiresAt(undefined)\n }\n }, [])\n\n useEffect(() => {\n clearLogoutTimer()\n\n if (user && expiresAt) {\n const timeUntilExpiry = expiresAt.getTime() - Date.now()\n\n if (timeUntilExpiry <= 0) {\n logout(\"expired\")\n return\n }\n\n logoutTimerRef.current = setTimeout(() => {\n logout(\"expired\")\n }, timeUntilExpiry)\n }\n\n return () => {\n clearLogoutTimer()\n }\n }, [user, expiresAt, logout, clearLogoutTimer])\n\n return (\n <AuthContext.Provider\n value={{\n isAuthenticated,\n user,\n login,\n logout,\n expiresAt,\n logoutReason,\n showInactivityModal,\n closeInactivityModal,\n redirectAfterModal,\n }}\n >\n {children}\n </AuthContext.Provider>\n )\n}\n\nexport function useAuth() {\n const context = React.useContext(AuthContext)\n if (!context) {\n throw new Error(\"useAuth must be used within an AuthProvider\")\n }\n return context\n}\n"],"mappings":";;;AAsBA,IAAMK,IAAcL,gBAAMM,cAAkC,IAAA;AAE5D,SAAgBC,EAAa,EAAEC,aAAUC,aAAiE;CACxG,IAAM,CAACC,GAAMC,KAAWX,EAAMI,SAAsB,IAAA,GAC9C,CAACQ,GAAWC,KAAgBb,EAAMI,SAA2BU,KAAAA,CAAAA,GAC7D,CAACC,GAAcC,KAAmBhB,EAAMI,SAAwDU,KAAAA,CAAAA,GAChG,CAACG,GAAqBC,KAA0Bd,EAAS,EAAA,GACzD,CAACe,GAAoBC,KAAyBhB,EAA6BU,KAAAA,CAAAA,GAE3EO,IAAiBnB,EAA8B,IAAA,GAE/CoB,IAAkB,CAAC,CAACZ,GAEpBa,IAAmBpB,QAAY;EACnC,AAEEkB,EAAeG,aADfC,aAAaJ,EAAeG,OAAO,GACV;CAE7B,GAAG,CAAA,CAAE,GAECE,IAAuBvB,QAAY;EAGvCM,AAFAS,EAAuB,EAAA,GAEvBT,EAAOkB,SAAS;GACdC,IAAI;GACJC,QAAQV,IAAqB,EAAEW,UAAUX,EAAmB,IAAIL,KAAAA;EAClE,CAAA;CACF,GAAG,CAACL,GAAQU,CAAAA,CAAmB,GAEzBY,IAAS5B,EACb,OAAO6B,IAA4C,aAAQ;EAQzD,IAPAT,EAAAA,GAEAZ,EAAQ,IAAA,GACRE,EAAaC,KAAAA,CAAAA,GACbE,EAAgBgB,CAAAA,GAGZA,MAAW,WAAW;GACxB,IAAMC,IAAcC,OAAOC,SAASC,WAAWF,OAAOC,SAASN;GAK/DX,AAJIe,KAAeA,EAAYI,WAAW,GAAA,KACxCjB,EAAsBa,CAAAA,GAGxBf,EAAuB,EAAA;EACzB,OAEET,EAAO6B,WAAU;CAErB,GACA,CAAC7B,GAAQc,CAAAA,CAAiB,GAGtBgB,IAAQpC,EAAY,OAAOO,GAAY8B,MAAAA;EAM3C,AALA7B,EAAQD,CAAAA,GACRM,EAAgBF,KAAAA,CAAAA,GAChBI,EAAuB,EAAA,GACvBE,EAAsBN,KAAAA,CAAAA,GAIpBD,EAFE2B,IAEWC,IADUC,KAAKF,CACfC,IAEA3B,KAAAA,CAAAA;CAEjB,GAAG,CAAA,CAAE;CAuBL,OArBAb,QAAU;EAGR,IAFAsB,EAAAA,GAEIb,KAAQE,GAAW;GACrB,IAAM+B,IAAkB/B,EAAUgC,QAAO,IAAKF,KAAKG,IAAG;GAEtD,IAAIF,KAAmB,GAAG;IACxBZ,EAAO,SAAA;IACP;GACF;GAEAV,EAAeG,UAAUsB,iBAAW;IAClCf,EAAO,SAAA;GACT,GAAGY,CAAAA;EACL;EAEA,aAAO;GACLpB,EAAAA;EACF;CACF,GAAG;EAACb;EAAME;EAAWmB;EAAQR;EAAiB,GAG5C,gBAAClB,EAAY0C,UAAQ;EACnBC,OAAO;GACL1B;GACAZ;GACA6B;GACAR;GACAnB;GACAG;GACAE;GACAS;GACAP;EACF;EAECX;;AAGP;AAEA,SAAgByC,IAAAA;CACd,IAAMC,IAAUlD,EAAMmD,WAAW9C,CAAAA;CACjC,IAAI,CAAC6C,GACH,MAAUE,MAAM,6CAAA;CAElB,OAAOF;AACT"}
|