authhero 0.96.0 → 0.98.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/authhero.cjs +4 -4
- package/dist/authhero.d.ts +11 -11
- package/dist/authhero.mjs +54 -41
- package/package.json +3 -3
package/dist/authhero.d.ts
CHANGED
|
@@ -2302,7 +2302,7 @@ export declare const loginSessionInsertSchema: z.ZodObject<{
|
|
|
2302
2302
|
deleted_at: z.ZodOptional<z.ZodString>;
|
|
2303
2303
|
ip: z.ZodOptional<z.ZodString>;
|
|
2304
2304
|
useragent: z.ZodOptional<z.ZodString>;
|
|
2305
|
-
|
|
2305
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
2306
2306
|
authorization_url: z.ZodOptional<z.ZodString>;
|
|
2307
2307
|
}, "strip", z.ZodTypeAny, {
|
|
2308
2308
|
expires_at: string;
|
|
@@ -2329,7 +2329,7 @@ export declare const loginSessionInsertSchema: z.ZodObject<{
|
|
|
2329
2329
|
deleted_at?: string | undefined;
|
|
2330
2330
|
ip?: string | undefined;
|
|
2331
2331
|
useragent?: string | undefined;
|
|
2332
|
-
|
|
2332
|
+
session_id?: string | undefined;
|
|
2333
2333
|
authorization_url?: string | undefined;
|
|
2334
2334
|
}, {
|
|
2335
2335
|
expires_at: string;
|
|
@@ -2356,7 +2356,7 @@ export declare const loginSessionInsertSchema: z.ZodObject<{
|
|
|
2356
2356
|
deleted_at?: string | undefined;
|
|
2357
2357
|
ip?: string | undefined;
|
|
2358
2358
|
useragent?: string | undefined;
|
|
2359
|
-
|
|
2359
|
+
session_id?: string | undefined;
|
|
2360
2360
|
authorization_url?: string | undefined;
|
|
2361
2361
|
}>;
|
|
2362
2362
|
export type LoginSessionInsert = z.infer<typeof loginSessionInsertSchema>;
|
|
@@ -2422,7 +2422,7 @@ export declare const loginSessionSchema: z.ZodObject<{
|
|
|
2422
2422
|
deleted_at: z.ZodOptional<z.ZodString>;
|
|
2423
2423
|
ip: z.ZodOptional<z.ZodString>;
|
|
2424
2424
|
useragent: z.ZodOptional<z.ZodString>;
|
|
2425
|
-
|
|
2425
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
2426
2426
|
authorization_url: z.ZodOptional<z.ZodString>;
|
|
2427
2427
|
}, "strip", z.ZodTypeAny, {
|
|
2428
2428
|
created_at: string;
|
|
@@ -2452,7 +2452,7 @@ export declare const loginSessionSchema: z.ZodObject<{
|
|
|
2452
2452
|
deleted_at?: string | undefined;
|
|
2453
2453
|
ip?: string | undefined;
|
|
2454
2454
|
useragent?: string | undefined;
|
|
2455
|
-
|
|
2455
|
+
session_id?: string | undefined;
|
|
2456
2456
|
authorization_url?: string | undefined;
|
|
2457
2457
|
}, {
|
|
2458
2458
|
created_at: string;
|
|
@@ -2482,7 +2482,7 @@ export declare const loginSessionSchema: z.ZodObject<{
|
|
|
2482
2482
|
deleted_at?: string | undefined;
|
|
2483
2483
|
ip?: string | undefined;
|
|
2484
2484
|
useragent?: string | undefined;
|
|
2485
|
-
|
|
2485
|
+
session_id?: string | undefined;
|
|
2486
2486
|
authorization_url?: string | undefined;
|
|
2487
2487
|
}>;
|
|
2488
2488
|
export type LoginSession = z.infer<typeof loginSessionSchema>;
|
|
@@ -4382,6 +4382,7 @@ export declare const refreshTokenInsertSchema: z.ZodObject<{
|
|
|
4382
4382
|
user_id: string;
|
|
4383
4383
|
id: string;
|
|
4384
4384
|
client_id: string;
|
|
4385
|
+
session_id: string;
|
|
4385
4386
|
device: {
|
|
4386
4387
|
last_ip: string;
|
|
4387
4388
|
initial_user_agent: string;
|
|
@@ -4390,7 +4391,6 @@ export declare const refreshTokenInsertSchema: z.ZodObject<{
|
|
|
4390
4391
|
last_user_agent: string;
|
|
4391
4392
|
last_asn: string;
|
|
4392
4393
|
};
|
|
4393
|
-
session_id: string;
|
|
4394
4394
|
resource_servers: {
|
|
4395
4395
|
audience: string;
|
|
4396
4396
|
scopes: string;
|
|
@@ -4403,6 +4403,7 @@ export declare const refreshTokenInsertSchema: z.ZodObject<{
|
|
|
4403
4403
|
user_id: string;
|
|
4404
4404
|
id: string;
|
|
4405
4405
|
client_id: string;
|
|
4406
|
+
session_id: string;
|
|
4406
4407
|
device: {
|
|
4407
4408
|
last_ip: string;
|
|
4408
4409
|
initial_user_agent: string;
|
|
@@ -4411,7 +4412,6 @@ export declare const refreshTokenInsertSchema: z.ZodObject<{
|
|
|
4411
4412
|
last_user_agent: string;
|
|
4412
4413
|
last_asn: string;
|
|
4413
4414
|
};
|
|
4414
|
-
session_id: string;
|
|
4415
4415
|
resource_servers: {
|
|
4416
4416
|
audience: string;
|
|
4417
4417
|
scopes: string;
|
|
@@ -4469,6 +4469,7 @@ export declare const refreshTokenSchema: z.ZodObject<{
|
|
|
4469
4469
|
user_id: string;
|
|
4470
4470
|
id: string;
|
|
4471
4471
|
client_id: string;
|
|
4472
|
+
session_id: string;
|
|
4472
4473
|
device: {
|
|
4473
4474
|
last_ip: string;
|
|
4474
4475
|
initial_user_agent: string;
|
|
@@ -4477,7 +4478,6 @@ export declare const refreshTokenSchema: z.ZodObject<{
|
|
|
4477
4478
|
last_user_agent: string;
|
|
4478
4479
|
last_asn: string;
|
|
4479
4480
|
};
|
|
4480
|
-
session_id: string;
|
|
4481
4481
|
resource_servers: {
|
|
4482
4482
|
audience: string;
|
|
4483
4483
|
scopes: string;
|
|
@@ -4491,6 +4491,7 @@ export declare const refreshTokenSchema: z.ZodObject<{
|
|
|
4491
4491
|
user_id: string;
|
|
4492
4492
|
id: string;
|
|
4493
4493
|
client_id: string;
|
|
4494
|
+
session_id: string;
|
|
4494
4495
|
device: {
|
|
4495
4496
|
last_ip: string;
|
|
4496
4497
|
initial_user_agent: string;
|
|
@@ -4499,7 +4500,6 @@ export declare const refreshTokenSchema: z.ZodObject<{
|
|
|
4499
4500
|
last_user_agent: string;
|
|
4500
4501
|
last_asn: string;
|
|
4501
4502
|
};
|
|
4502
|
-
session_id: string;
|
|
4503
4503
|
resource_servers: {
|
|
4504
4504
|
audience: string;
|
|
4505
4505
|
scopes: string;
|
|
@@ -4847,6 +4847,7 @@ export declare function init(config: AuthHeroConfig): {
|
|
|
4847
4847
|
user_id: string;
|
|
4848
4848
|
id: string;
|
|
4849
4849
|
client_id: string;
|
|
4850
|
+
session_id: string;
|
|
4850
4851
|
device: {
|
|
4851
4852
|
last_ip: string;
|
|
4852
4853
|
initial_user_agent: string;
|
|
@@ -4855,7 +4856,6 @@ export declare function init(config: AuthHeroConfig): {
|
|
|
4855
4856
|
last_user_agent: string;
|
|
4856
4857
|
last_asn: string;
|
|
4857
4858
|
};
|
|
4858
|
-
session_id: string;
|
|
4859
4859
|
resource_servers: {
|
|
4860
4860
|
audience: string;
|
|
4861
4861
|
scopes: string;
|
package/dist/authhero.mjs
CHANGED
|
@@ -1719,7 +1719,7 @@ const Pm = a.enum([
|
|
|
1719
1719
|
deleted_at: a.string().optional(),
|
|
1720
1720
|
ip: a.string().optional(),
|
|
1721
1721
|
useragent: a.string().optional(),
|
|
1722
|
-
|
|
1722
|
+
session_id: a.string().optional(),
|
|
1723
1723
|
authorization_url: a.string().optional()
|
|
1724
1724
|
}).openapi({
|
|
1725
1725
|
description: "This represents a login sesion"
|
|
@@ -5642,10 +5642,10 @@ async function Y0(t, e) {
|
|
|
5642
5642
|
}
|
|
5643
5643
|
);
|
|
5644
5644
|
}
|
|
5645
|
-
async function Ef(t, e) {
|
|
5646
|
-
const
|
|
5645
|
+
async function Ef(t, { user: e, client: n, loginSession: r }) {
|
|
5646
|
+
const i = await t.env.data.sessions.create(n.tenant.id, {
|
|
5647
5647
|
id: Ae(),
|
|
5648
|
-
user_id:
|
|
5648
|
+
user_id: e.user_id,
|
|
5649
5649
|
idle_expires_at: new Date(
|
|
5650
5650
|
Date.now() + Fs * 1e3
|
|
5651
5651
|
).toISOString(),
|
|
@@ -5658,14 +5658,19 @@ async function Ef(t, e) {
|
|
|
5658
5658
|
initial_asn: "",
|
|
5659
5659
|
last_asn: ""
|
|
5660
5660
|
},
|
|
5661
|
-
clients: [
|
|
5662
|
-
})
|
|
5663
|
-
|
|
5664
|
-
session_id:
|
|
5665
|
-
|
|
5666
|
-
|
|
5661
|
+
clients: [n.id]
|
|
5662
|
+
});
|
|
5663
|
+
await t.env.data.loginSessions.update(n.tenant.id, r.id, {
|
|
5664
|
+
session_id: i.id
|
|
5665
|
+
});
|
|
5666
|
+
const { scope: s, audience: o } = r.authParams, c = s != null && s.split(" ").includes("offline_access") ? await Y0(t, {
|
|
5667
|
+
session_id: i.id,
|
|
5668
|
+
user: e,
|
|
5669
|
+
client: n,
|
|
5670
|
+
scope: s,
|
|
5671
|
+
audience: o
|
|
5667
5672
|
}) : void 0;
|
|
5668
|
-
return { ...
|
|
5673
|
+
return { ...i, refresh_token: c };
|
|
5669
5674
|
}
|
|
5670
5675
|
async function sn(t, e) {
|
|
5671
5676
|
var v;
|
|
@@ -5702,6 +5707,10 @@ async function sn(t, e) {
|
|
|
5702
5707
|
}
|
|
5703
5708
|
let c = e.refreshToken, l = e.sessionId, u = r;
|
|
5704
5709
|
if (!l) {
|
|
5710
|
+
if (!e.loginSession)
|
|
5711
|
+
throw new N(500, {
|
|
5712
|
+
message: "Login session not found"
|
|
5713
|
+
});
|
|
5705
5714
|
u = await ty(t, t.env.data)(
|
|
5706
5715
|
i.tenant.id,
|
|
5707
5716
|
r
|
|
@@ -5709,8 +5718,7 @@ async function sn(t, e) {
|
|
|
5709
5718
|
const f = await Ef(t, {
|
|
5710
5719
|
user: r,
|
|
5711
5720
|
client: i,
|
|
5712
|
-
|
|
5713
|
-
audience: n.audience
|
|
5721
|
+
loginSession: e.loginSession
|
|
5714
5722
|
});
|
|
5715
5723
|
l = f.id, c = (v = f.refresh_token) == null ? void 0 : v.id;
|
|
5716
5724
|
}
|
|
@@ -19865,7 +19873,10 @@ async function Cb(t, e, n, r, i) {
|
|
|
19865
19873
|
const o = await s.data.codes.get(e, n, "ticket");
|
|
19866
19874
|
if (!o || o.used_at)
|
|
19867
19875
|
throw new N(403, { message: "Ticket not found" });
|
|
19868
|
-
const c = await s.data.loginSessions.get(
|
|
19876
|
+
const c = await s.data.loginSessions.get(
|
|
19877
|
+
e,
|
|
19878
|
+
o.login_id
|
|
19879
|
+
);
|
|
19869
19880
|
if (!c || !c.authParams.username)
|
|
19870
19881
|
throw new N(403, { message: "Session not found" });
|
|
19871
19882
|
const l = await s.data.clients.get(c.authParams.client_id);
|
|
@@ -19885,8 +19896,7 @@ async function Cb(t, e, n, r, i) {
|
|
|
19885
19896
|
const h = await Ef(t, {
|
|
19886
19897
|
user: p,
|
|
19887
19898
|
client: l,
|
|
19888
|
-
|
|
19889
|
-
audience: r.audience
|
|
19899
|
+
loginSession: c
|
|
19890
19900
|
});
|
|
19891
19901
|
return sn(t, {
|
|
19892
19902
|
authParams: {
|
|
@@ -20626,40 +20636,43 @@ async function cu(t, e, n) {
|
|
|
20626
20636
|
return console.error(i), qp;
|
|
20627
20637
|
}
|
|
20628
20638
|
}
|
|
20629
|
-
async function Ce(t, e) {
|
|
20630
|
-
var
|
|
20631
|
-
const { env:
|
|
20639
|
+
async function Ce(t, e, n = !1) {
|
|
20640
|
+
var u;
|
|
20641
|
+
const { env: r } = t, i = await r.data.loginSessions.get(
|
|
20632
20642
|
t.var.tenant_id || "",
|
|
20633
20643
|
e
|
|
20634
20644
|
);
|
|
20635
|
-
if (
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
r
|
|
20645
|
+
if (i)
|
|
20646
|
+
i.session_id;
|
|
20647
|
+
else throw new N(400, { message: "Login session not found" });
|
|
20648
|
+
t.set("loginSession", i);
|
|
20649
|
+
const s = await Mo(
|
|
20650
|
+
r,
|
|
20651
|
+
i.authParams.client_id
|
|
20641
20652
|
);
|
|
20642
|
-
t.set("client_id",
|
|
20643
|
-
const
|
|
20644
|
-
if (
|
|
20645
|
-
|
|
20646
|
-
|
|
20647
|
-
|
|
20648
|
-
|
|
20649
|
-
r
|
|
20650
|
-
|
|
20653
|
+
t.set("client_id", s.id), t.set("tenant_id", s.tenant.id);
|
|
20654
|
+
const o = await r.data.tenants.get(s.tenant.id);
|
|
20655
|
+
if (o) {
|
|
20656
|
+
if (i.session_id && !n)
|
|
20657
|
+
throw new N(400, { message: "Login session closed" });
|
|
20658
|
+
} else throw new N(400, { message: "Tenant not found" });
|
|
20659
|
+
const c = await cu(
|
|
20660
|
+
r,
|
|
20661
|
+
s.id,
|
|
20662
|
+
i.authParams.vendor_id
|
|
20663
|
+
), l = (u = i.authParams.ui_locales) == null ? void 0 : u.split(" ").map((p) => p.split("-")[0]).find((p) => {
|
|
20651
20664
|
if (Array.isArray(R.options.supportedLngs))
|
|
20652
|
-
return R.options.supportedLngs.includes(
|
|
20665
|
+
return R.options.supportedLngs.includes(p);
|
|
20653
20666
|
});
|
|
20654
|
-
return await R.changeLanguage(
|
|
20667
|
+
return await R.changeLanguage(l || o.language || "sv"), {
|
|
20655
20668
|
vendorSettings: {
|
|
20656
|
-
...
|
|
20669
|
+
...c,
|
|
20657
20670
|
// HACK: Change the terms and conditions for fokus app
|
|
20658
|
-
termsAndConditionsUrl:
|
|
20671
|
+
termsAndConditionsUrl: s.id === "fokus-app" ? "https://www.fokus.se/kopvillkor-app/" : c.termsAndConditionsUrl
|
|
20659
20672
|
},
|
|
20660
|
-
client:
|
|
20661
|
-
tenant:
|
|
20662
|
-
loginSession:
|
|
20673
|
+
client: s,
|
|
20674
|
+
tenant: o,
|
|
20675
|
+
loginSession: i
|
|
20663
20676
|
};
|
|
20664
20677
|
}
|
|
20665
20678
|
async function Xb(t, e, n, r) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "authhero",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"vite": "^5.4.11",
|
|
26
26
|
"vite-plugin-dts": "^4.3.0",
|
|
27
27
|
"vitest": "^2.1.5",
|
|
28
|
-
"@authhero/kysely-adapter": "^
|
|
28
|
+
"@authhero/kysely-adapter": "^10.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@peculiar/x509": "^1.12.3",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"i18next": "^24.2.0",
|
|
38
38
|
"nanoid": "^5.0.8",
|
|
39
39
|
"oslo": "^1.2.1",
|
|
40
|
-
"@authhero/adapter-interfaces": "^0.
|
|
40
|
+
"@authhero/adapter-interfaces": "^0.52.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@hono/zod-openapi": "^0.18.0",
|