authhero 9.31.0 → 9.34.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/assets/u/widget/index.esm.js +1 -1
- package/dist/authhero.cjs +137 -137
- package/dist/authhero.d.ts +605 -392
- package/dist/authhero.mjs +16303 -15968
- package/dist/mfa-CDFRupfM.mjs +128 -0
- package/dist/mfa-DF3O3Z8H.js +1 -0
- package/dist/mfa-attempts-BOWgbEPg.js +275 -0
- package/dist/{mfa-attempts-Dl3I8pop.mjs → mfa-attempts-C06Bkdy9.mjs} +14352 -13847
- package/dist/{passkey-enrollment-2Toeaevy.js → passkey-enrollment-RGw-WaSq.js} +1 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/authentication-flows/common.d.ts +12 -1
- package/dist/types/authentication-flows/passwordless.d.ts +24 -11
- package/dist/types/authentication-flows/refresh-token.d.ts +1 -0
- package/dist/types/authentication-flows/remember-browser.d.ts +77 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/generated/locale-types.d.ts +6 -0
- package/dist/types/helpers/cimd.d.ts +8 -0
- package/dist/types/helpers/client.d.ts +25 -7
- package/dist/types/helpers/dcr/metadata-mapping.d.ts +1 -1
- package/dist/types/helpers/login-session-tenant.d.ts +22 -0
- package/dist/types/helpers/reserved-claims.d.ts +2 -2
- package/dist/types/helpers/session-transfer.d.ts +158 -0
- package/dist/types/hooks/lifecycle-codehooks.d.ts +1 -1
- package/dist/types/index.d.ts +536 -376
- package/dist/types/routes/auth-api/authorize.d.ts +6 -0
- package/dist/types/routes/auth-api/device.d.ts +8 -8
- package/dist/types/routes/auth-api/index.d.ts +49 -32
- package/dist/types/routes/auth-api/passwordless.d.ts +6 -6
- package/dist/types/routes/auth-api/register/index.d.ts +2 -2
- package/dist/types/routes/auth-api/revoke.d.ts +6 -6
- package/dist/types/routes/auth-api/token.d.ts +21 -10
- package/dist/types/routes/management-api/action-triggers.d.ts +25 -25
- package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
- package/dist/types/routes/management-api/clients.d.ts +100 -32
- package/dist/types/routes/management-api/connections.d.ts +25 -25
- package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
- package/dist/types/routes/management-api/email-templates.d.ts +18 -18
- package/dist/types/routes/management-api/failed-events.d.ts +2 -2
- package/dist/types/routes/management-api/forms.d.ts +144 -144
- package/dist/types/routes/management-api/guardian.d.ts +5 -5
- package/dist/types/routes/management-api/helpers.d.ts +11 -1
- package/dist/types/routes/management-api/hooks.d.ts +21 -21
- package/dist/types/routes/management-api/index.d.ts +480 -337
- package/dist/types/routes/management-api/jobs.d.ts +2 -2
- package/dist/types/routes/management-api/keys.d.ts +12 -12
- package/dist/types/routes/management-api/logs.d.ts +4 -4
- package/dist/types/routes/management-api/organizations.d.ts +7 -7
- package/dist/types/routes/management-api/prompts.d.ts +4 -4
- package/dist/types/routes/management-api/refresh_tokens.d.ts +5 -0
- package/dist/types/routes/management-api/rollouts.d.ts +6 -6
- package/dist/types/routes/management-api/sessions.d.ts +5 -0
- package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
- package/dist/types/routes/management-api/tenant-members.d.ts +8 -8
- package/dist/types/routes/management-api/tenant-operations.d.ts +4 -4
- package/dist/types/routes/management-api/tenants.d.ts +24 -16
- package/dist/types/routes/management-api/users.d.ts +84 -24
- package/dist/types/routes/universal-login/common.d.ts +57 -22
- package/dist/types/routes/universal-login/flow-api.d.ts +8 -8
- package/dist/types/routes/universal-login/identifier.d.ts +2 -2
- package/dist/types/routes/universal-login/index.d.ts +2 -2
- package/dist/types/routes/universal-login/screens/mfa-remember-browser.d.ts +28 -0
- package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
- package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
- package/dist/types/state-machines/login-session.d.ts +7 -2
- package/dist/types/types/GrantFlowResult.d.ts +13 -0
- package/dist/types/types/Hooks.d.ts +24 -0
- package/dist/types/types/Variables.d.ts +12 -1
- package/dist/types/utils/cookies.d.ts +29 -0
- package/dist/types/utils/session-transfer-token.d.ts +56 -0
- package/package.json +6 -6
- package/dist/mfa-attempts-DXiY4U74.js +0 -275
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Lu as e, Wu as t, au as n, bo as r, in as i, lc as a, r as o, ui as s } from "./mfa-attempts-C06Bkdy9.mjs";
|
|
2
|
+
import { HTTPException as c } from "hono/http-exception";
|
|
3
|
+
//#region src/utils/otp.ts
|
|
4
|
+
function l() {
|
|
5
|
+
let e = new Uint8Array(6);
|
|
6
|
+
crypto.getRandomValues(e);
|
|
7
|
+
let t = "";
|
|
8
|
+
for (let n = 0; n < 6; n += 1) t += (e[n] % 10).toString();
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/utils/totp.ts
|
|
13
|
+
var u = 30, d = 6;
|
|
14
|
+
async function f(e, t) {
|
|
15
|
+
let n = new Uint8Array(8);
|
|
16
|
+
new DataView(n.buffer).setBigUint64(0, BigInt(t));
|
|
17
|
+
let r = new ArrayBuffer(e.byteLength);
|
|
18
|
+
new Uint8Array(r).set(e);
|
|
19
|
+
let i = await crypto.subtle.importKey("raw", r, {
|
|
20
|
+
name: "HMAC",
|
|
21
|
+
hash: "SHA-1"
|
|
22
|
+
}, !1, ["sign"]), a = new Uint8Array(await crypto.subtle.sign("HMAC", i, n)), o = a[a.length - 1] & 15;
|
|
23
|
+
return (((a[o] & 127) << 24 | a[o + 1] << 16 | a[o + 2] << 8 | a[o + 3]) % 10 ** d).toString().padStart(d, "0");
|
|
24
|
+
}
|
|
25
|
+
async function p(e, t) {
|
|
26
|
+
let n = Math.floor(Date.now() / (u * 1e3));
|
|
27
|
+
for (let r of [
|
|
28
|
+
0,
|
|
29
|
+
-1,
|
|
30
|
+
1
|
|
31
|
+
]) if (await f(t, n + r) === e) return n + r;
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function m(e, t, r) {
|
|
35
|
+
let i = new URLSearchParams({
|
|
36
|
+
secret: n(r),
|
|
37
|
+
issuer: e
|
|
38
|
+
});
|
|
39
|
+
return `otpauth://totp/${encodeURIComponent(e)}:${encodeURIComponent(t)}?${i.toString()}`;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/authentication-flows/mfa.ts
|
|
43
|
+
var h = /* @__PURE__ */ t({
|
|
44
|
+
checkMfaRequired: () => v,
|
|
45
|
+
createTotpUri: () => C,
|
|
46
|
+
generateTotpSecret: () => S,
|
|
47
|
+
sendMfaOtp: () => y,
|
|
48
|
+
tenantPolicyRequiresMfa: () => _,
|
|
49
|
+
verifyMfaOtp: () => b,
|
|
50
|
+
verifyTotpCode: () => w
|
|
51
|
+
}), g = 600 * 1e3;
|
|
52
|
+
function _(e) {
|
|
53
|
+
return e !== void 0 && e !== "never";
|
|
54
|
+
}
|
|
55
|
+
async function v(e, t, n, r = {}) {
|
|
56
|
+
let i = await e.env.data.tenants.get(t);
|
|
57
|
+
if (!i || !r.force && !_(i.mfa?.policy)) return { required: !1 };
|
|
58
|
+
if (!(i.mfa?.factors?.sms === !0 || i.mfa?.factors?.otp === !0 || i.mfa?.factors?.webauthn_roaming === !0 || i.mfa?.factors?.webauthn_platform === !0)) throw new c(500, { message: "MFA is required (by the tenant policy or a post-login action) but no supported factors are enabled. Enable at least one factor (e.g. SMS, OTP, or WebAuthn) in the tenant MFA configuration." });
|
|
59
|
+
let a = i.mfa?.factors, o = a?.webauthn_roaming === !0 || a?.webauthn_platform === !0, s = [
|
|
60
|
+
"passkey",
|
|
61
|
+
"webauthn-roaming",
|
|
62
|
+
"webauthn-platform"
|
|
63
|
+
], l = (await e.env.data.authenticationMethods.list(t, n)).filter((e) => e.confirmed && (e.type === "phone" && a?.sms === !0 || e.type === "totp" && a?.otp === !0 || s.includes(e.type) && o));
|
|
64
|
+
return l.length > 0 ? {
|
|
65
|
+
required: !0,
|
|
66
|
+
enrolled: !0,
|
|
67
|
+
enrollment: l[0],
|
|
68
|
+
allEnrollments: l
|
|
69
|
+
} : {
|
|
70
|
+
required: !0,
|
|
71
|
+
enrolled: !1
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async function y(t, n, a, u, d) {
|
|
75
|
+
let f = n.tenant;
|
|
76
|
+
await o(t, f.id, a.id, u, d);
|
|
77
|
+
let p = l(), m = `mfa:${a.id}`;
|
|
78
|
+
await t.env.data.codes.remove(f.id, m), await t.env.data.codes.create(f.id, {
|
|
79
|
+
code_id: m,
|
|
80
|
+
code_type: "mfa_otp",
|
|
81
|
+
login_id: a.id,
|
|
82
|
+
otp: p,
|
|
83
|
+
expires_at: new Date(Date.now() + g).toISOString()
|
|
84
|
+
});
|
|
85
|
+
let h = n.connections.find((t) => t.strategy === e.SMS), _ = t.env.data.smsService;
|
|
86
|
+
if (!_) throw new c(500, { message: "SMS service not configured" });
|
|
87
|
+
let v = h?.options || f.mfa?.twilio || {};
|
|
88
|
+
try {
|
|
89
|
+
await _.send({
|
|
90
|
+
options: v,
|
|
91
|
+
to: u,
|
|
92
|
+
from: f.friendly_name,
|
|
93
|
+
text: `Your verification code is: ${p}`,
|
|
94
|
+
template: "mfa-code",
|
|
95
|
+
data: {
|
|
96
|
+
code: p,
|
|
97
|
+
tenantName: f.friendly_name || "",
|
|
98
|
+
tenantId: f.id
|
|
99
|
+
},
|
|
100
|
+
createServiceToken: async (e) => (await i(t, f.id, e, { allowControlPlaneFallback: !0 })).access_token
|
|
101
|
+
}), s(t, f.id, {
|
|
102
|
+
type: r.MFA_SMS_SENT,
|
|
103
|
+
description: "MFA SMS sent"
|
|
104
|
+
});
|
|
105
|
+
} catch (e) {
|
|
106
|
+
throw s(t, f.id, {
|
|
107
|
+
type: r.ERROR_SENDING_MFA_SMS,
|
|
108
|
+
description: `Failed to send MFA SMS: ${e instanceof Error ? e.message : String(e)}`
|
|
109
|
+
}), e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function b(e, t, n, r) {
|
|
113
|
+
let i = `mfa:${n}`, a = await e.env.data.codes.get(t, i, "mfa_otp");
|
|
114
|
+
return !a || new Date(a.expires_at) < /* @__PURE__ */ new Date() || a.otp !== r ? !1 : await e.env.data.codes.consume(t, i);
|
|
115
|
+
}
|
|
116
|
+
var x = 20;
|
|
117
|
+
function S() {
|
|
118
|
+
let e = new Uint8Array(x);
|
|
119
|
+
return crypto.getRandomValues(e), n(e);
|
|
120
|
+
}
|
|
121
|
+
function C(e, t, n) {
|
|
122
|
+
return m(e, t, a(n));
|
|
123
|
+
}
|
|
124
|
+
async function w(e, t) {
|
|
125
|
+
return p(t, a(e));
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { y as a, w as c, h as i, l, C as n, _ as o, S as r, b as s, v as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./mfa-attempts-BOWgbEPg.js");let t=require("hono/http-exception");function n(){let e=new Uint8Array(6);crypto.getRandomValues(e);let t=``;for(let n=0;n<6;n+=1)t+=(e[n]%10).toString();return t}var r=30,i=6;async function a(e,t){let n=new Uint8Array(8);new DataView(n.buffer).setBigUint64(0,BigInt(t));let r=new ArrayBuffer(e.byteLength);new Uint8Array(r).set(e);let a=await crypto.subtle.importKey(`raw`,r,{name:`HMAC`,hash:`SHA-1`},!1,[`sign`]),o=new Uint8Array(await crypto.subtle.sign(`HMAC`,a,n)),s=o[o.length-1]&15;return(((o[s]&127)<<24|o[s+1]<<16|o[s+2]<<8|o[s+3])%10**i).toString().padStart(i,`0`)}async function o(e,t){let n=Math.floor(Date.now()/(r*1e3));for(let r of[0,-1,1])if(await a(t,n+r)===e)return n+r;return null}function s(t,n,r){let i=new URLSearchParams({secret:e.au(r),issuer:t});return`otpauth://totp/${encodeURIComponent(t)}:${encodeURIComponent(n)}?${i.toString()}`}var c=e.Wu({checkMfaRequired:()=>d,createTotpUri:()=>g,generateTotpSecret:()=>h,sendMfaOtp:()=>f,tenantPolicyRequiresMfa:()=>u,verifyMfaOtp:()=>p,verifyTotpCode:()=>_}),l=600*1e3;function u(e){return e!==void 0&&e!==`never`}async function d(e,n,r,i={}){let a=await e.env.data.tenants.get(n);if(!a||!i.force&&!u(a.mfa?.policy))return{required:!1};if(!(a.mfa?.factors?.sms===!0||a.mfa?.factors?.otp===!0||a.mfa?.factors?.webauthn_roaming===!0||a.mfa?.factors?.webauthn_platform===!0))throw new t.HTTPException(500,{message:`MFA is required (by the tenant policy or a post-login action) but no supported factors are enabled. Enable at least one factor (e.g. SMS, OTP, or WebAuthn) in the tenant MFA configuration.`});let o=a.mfa?.factors,s=o?.webauthn_roaming===!0||o?.webauthn_platform===!0,c=[`passkey`,`webauthn-roaming`,`webauthn-platform`],l=(await e.env.data.authenticationMethods.list(n,r)).filter(e=>e.confirmed&&(e.type===`phone`&&o?.sms===!0||e.type===`totp`&&o?.otp===!0||c.includes(e.type)&&s));return l.length>0?{required:!0,enrolled:!0,enrollment:l[0],allEnrollments:l}:{required:!0,enrolled:!1}}async function f(r,i,a,o,s){let c=i.tenant;await e.r(r,c.id,a.id,o,s);let u=n(),d=`mfa:${a.id}`;await r.env.data.codes.remove(c.id,d),await r.env.data.codes.create(c.id,{code_id:d,code_type:`mfa_otp`,login_id:a.id,otp:u,expires_at:new Date(Date.now()+l).toISOString()});let f=i.connections.find(t=>t.strategy===e.Lu.SMS),p=r.env.data.smsService;if(!p)throw new t.HTTPException(500,{message:`SMS service not configured`});let m=f?.options||c.mfa?.twilio||{};try{await p.send({options:m,to:o,from:c.friendly_name,text:`Your verification code is: ${u}`,template:`mfa-code`,data:{code:u,tenantName:c.friendly_name||``,tenantId:c.id},createServiceToken:async t=>(await e.in(r,c.id,t,{allowControlPlaneFallback:!0})).access_token}),e.ui(r,c.id,{type:e.bo.MFA_SMS_SENT,description:`MFA SMS sent`})}catch(t){throw e.ui(r,c.id,{type:e.bo.ERROR_SENDING_MFA_SMS,description:`Failed to send MFA SMS: ${t instanceof Error?t.message:String(t)}`}),t}}async function p(e,t,n,r){let i=`mfa:${n}`,a=await e.env.data.codes.get(t,i,`mfa_otp`);return!a||new Date(a.expires_at)<new Date||a.otp!==r?!1:await e.env.data.codes.consume(t,i)}var m=20;function h(){let t=new Uint8Array(m);return crypto.getRandomValues(t),e.au(t)}function g(t,n,r){return s(t,n,e.lc(r))}async function _(t,n){return o(n,e.lc(t))}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
|