@absolutejs/auth 0.38.0 → 0.40.0-beta.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/index.js CHANGED
@@ -16,6 +16,141 @@ var __export = (target, all) => {
16
16
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
17
  var __require = import.meta.require;
18
18
 
19
+ // src/constants.ts
20
+ var SECONDS_IN_A_MINUTE = 60, MILLISECONDS_IN_A_SECOND = 1000, MILLISECONDS_IN_A_MINUTE, MINUTES_IN_AN_HOUR = 60, HOURS_IN_A_DAY = 24, MILLISECONDS_IN_A_DAY, MILLISECONDS_IN_AN_HOUR, COOKIE_MINUTES = 30, COOKIE_DURATION, DEFAULT_MAX_SESSIONS = 1e4;
21
+ var init_constants = __esm(() => {
22
+ MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
23
+ MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR * HOURS_IN_A_DAY;
24
+ MILLISECONDS_IN_AN_HOUR = MILLISECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR;
25
+ COOKIE_DURATION = SECONDS_IN_A_MINUTE * COOKIE_MINUTES;
26
+ });
27
+
28
+ // src/crypto.ts
29
+ var exports_crypto = {};
30
+ __export(exports_crypto, {
31
+ verifyTotp: () => verifyTotp,
32
+ verifyPassword: () => verifyPassword,
33
+ hashToken: () => hashToken,
34
+ hashPassword: () => hashPassword,
35
+ generateTotpSecret: () => generateTotpSecret,
36
+ generateTotp: () => generateTotp,
37
+ generateSecureToken: () => generateSecureToken,
38
+ generateEncryptionKey: () => generateEncryptionKey,
39
+ encryptSecret: () => encryptSecret,
40
+ decryptSecret: () => decryptSecret,
41
+ createTotpKeyUri: () => createTotpKeyUri,
42
+ constantTimeEqual: () => constantTimeEqual,
43
+ base32Encode: () => base32Encode,
44
+ base32Decode: () => base32Decode
45
+ });
46
+ var DEFAULT_TOKEN_BYTES = 32, AES_KEY_BYTES = 32, AES_IV_BYTES = 12, HOTP_COUNTER_BYTES = 8, TOTP_SECRET_BYTES = 20, TOTP_DIGITS = 6, TOTP_PERIOD_SECONDS = 30, DEFAULT_TOTP_WINDOW = 1, DECIMAL_RADIX = 10, LAST_NIBBLE_MASK = 15, SIGN_BIT_MASK = 2147483647, BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", BASE32_GROUP_BITS = 5, BASE32_MASK = 31, BYTE_BITS = 8, textEncoder, textDecoder, base64UrlEncode = (bytes) => Buffer.from(bytes).toString("base64url"), base64UrlDecode = (encoded) => new Uint8Array(Buffer.from(encoded, "base64url")), sha256 = async (input) => {
47
+ const digest = await crypto.subtle.digest("SHA-256", textEncoder.encode(input));
48
+ return new Uint8Array(digest);
49
+ }, hmacSha1 = async (key, message) => {
50
+ const cryptoKey = await crypto.subtle.importKey("raw", key, { hash: "SHA-1", name: "HMAC" }, false, ["sign"]);
51
+ const signature = await crypto.subtle.sign("HMAC", cryptoKey, message);
52
+ return new Uint8Array(signature);
53
+ }, counterToBytes = (counter) => {
54
+ const bytes = new Uint8Array(HOTP_COUNTER_BYTES);
55
+ new DataView(bytes.buffer).setBigUint64(0, BigInt(counter), false);
56
+ return bytes;
57
+ }, generateHotp = async (secret, counter, digits = TOTP_DIGITS) => {
58
+ const hmac = await hmacSha1(secret, counterToBytes(counter));
59
+ const view = new DataView(hmac.buffer, hmac.byteOffset, hmac.byteLength);
60
+ const offset = view.getUint8(hmac.byteLength - 1) & LAST_NIBBLE_MASK;
61
+ const truncated = view.getUint32(offset, false) & SIGN_BIT_MASK;
62
+ const otp = truncated % DECIMAL_RADIX ** digits;
63
+ return otp.toString().padStart(digits, "0");
64
+ }, importAesKey = (keyMaterial) => crypto.subtle.importKey("raw", base64UrlDecode(keyMaterial), { name: "AES-GCM" }, false, ["decrypt", "encrypt"]), base32Decode = (encoded) => {
65
+ const normalized = encoded.toUpperCase().replace(/[^A-Z2-7]/gu, "");
66
+ const bits = [...normalized].map((char) => BASE32_ALPHABET.indexOf(char).toString(2).padStart(BASE32_GROUP_BITS, "0")).join("");
67
+ const byteChunks = bits.match(/.{8}/gu) ?? [];
68
+ return new Uint8Array(byteChunks.map((chunk) => parseInt(chunk, 2)));
69
+ }, base32Encode = (bytes) => {
70
+ const bits = Array.from(bytes, (byte) => byte.toString(2).padStart(BYTE_BITS, "0")).join("");
71
+ const groups = bits.match(/.{1,5}/gu) ?? [];
72
+ return groups.map((group) => BASE32_ALPHABET[parseInt(group.padEnd(BASE32_GROUP_BITS, "0"), 2) & BASE32_MASK] ?? "").join("");
73
+ }, constantTimeEqual = async (left, right) => {
74
+ const [leftDigest, rightDigest] = await Promise.all([
75
+ sha256(left),
76
+ sha256(right)
77
+ ]);
78
+ const leftView = new DataView(leftDigest.buffer, leftDigest.byteOffset, leftDigest.byteLength);
79
+ const rightView = new DataView(rightDigest.buffer, rightDigest.byteOffset, rightDigest.byteLength);
80
+ let mismatch = 0;
81
+ for (let index = 0;index < leftDigest.byteLength; index += 1) {
82
+ mismatch |= leftView.getUint8(index) ^ rightView.getUint8(index);
83
+ }
84
+ return mismatch === 0;
85
+ }, createTotpKeyUri = ({
86
+ accountName,
87
+ digits = TOTP_DIGITS,
88
+ issuer,
89
+ period = TOTP_PERIOD_SECONDS,
90
+ secret
91
+ }) => {
92
+ const params = new URLSearchParams({
93
+ algorithm: "SHA1",
94
+ digits: `${digits}`,
95
+ issuer,
96
+ period: `${period}`,
97
+ secret
98
+ });
99
+ const label = encodeURIComponent(`${issuer}:${accountName}`);
100
+ return `otpauth://totp/${label}?${params.toString()}`;
101
+ }, decryptSecret = async (ciphertext, keyMaterial) => {
102
+ const key = await importAesKey(keyMaterial);
103
+ const combined = base64UrlDecode(ciphertext);
104
+ const nonce = combined.subarray(0, AES_IV_BYTES);
105
+ const data = combined.subarray(AES_IV_BYTES);
106
+ const plaintext = await crypto.subtle.decrypt({ iv: nonce, name: "AES-GCM" }, key, data);
107
+ return textDecoder.decode(plaintext);
108
+ }, encryptSecret = async (plaintext, keyMaterial) => {
109
+ const key = await importAesKey(keyMaterial);
110
+ const nonce = new Uint8Array(AES_IV_BYTES);
111
+ crypto.getRandomValues(nonce);
112
+ const ciphertext = await crypto.subtle.encrypt({ iv: nonce, name: "AES-GCM" }, key, textEncoder.encode(plaintext));
113
+ const combined = new Uint8Array(nonce.byteLength + ciphertext.byteLength);
114
+ combined.set(nonce, 0);
115
+ combined.set(new Uint8Array(ciphertext), nonce.byteLength);
116
+ return base64UrlEncode(combined);
117
+ }, generateEncryptionKey = () => generateSecureToken(AES_KEY_BYTES), generateSecureToken = (byteLength = DEFAULT_TOKEN_BYTES) => {
118
+ const bytes = new Uint8Array(byteLength);
119
+ crypto.getRandomValues(bytes);
120
+ return base64UrlEncode(bytes);
121
+ }, generateTotp = async ({
122
+ digits = TOTP_DIGITS,
123
+ now = Date.now(),
124
+ period = TOTP_PERIOD_SECONDS,
125
+ secret
126
+ }) => {
127
+ const counter = Math.floor(now / MILLISECONDS_IN_A_SECOND / period);
128
+ return generateHotp(base32Decode(secret), counter, digits);
129
+ }, generateTotpSecret = (byteLength = TOTP_SECRET_BYTES) => {
130
+ const bytes = new Uint8Array(byteLength);
131
+ crypto.getRandomValues(bytes);
132
+ return base32Encode(bytes);
133
+ }, hashPassword = (password) => Bun.password.hash(password, { algorithm: "argon2id" }), hashToken = async (token) => base64UrlEncode(await sha256(token)), verifyPassword = (password, hash) => Bun.password.verify(password, hash), verifyTotp = async ({
134
+ digits = TOTP_DIGITS,
135
+ now = Date.now(),
136
+ period = TOTP_PERIOD_SECONDS,
137
+ secret,
138
+ token,
139
+ window = DEFAULT_TOTP_WINDOW
140
+ }) => {
141
+ const secretBytes = base32Decode(secret);
142
+ const counter = Math.floor(now / MILLISECONDS_IN_A_SECOND / period);
143
+ const drifts = Array.from({ length: window * 2 + 1 }, (_, offset) => counter - window + offset);
144
+ const candidates = await Promise.all(drifts.map((value) => generateHotp(secretBytes, value, digits)));
145
+ const matches = await Promise.all(candidates.map((candidate) => constantTimeEqual(candidate, token)));
146
+ return matches.includes(true);
147
+ };
148
+ var init_crypto = __esm(() => {
149
+ init_constants();
150
+ textEncoder = new TextEncoder;
151
+ textDecoder = new TextDecoder;
152
+ });
153
+
19
154
  // node_modules/citra/dist/index.js
20
155
  var BASE64_BLOCK_SIZE = 4;
21
156
  var NUM_GENERATOR_BYTES = 32;
@@ -2537,165 +2672,14 @@ var createOAuth2Client = async (providerName, config) => {
2537
2672
  };
2538
2673
 
2539
2674
  // src/index.ts
2540
- import { Elysia as Elysia36 } from "elysia";
2675
+ import { Elysia as Elysia37 } from "elysia";
2541
2676
 
2542
2677
  // src/apikeys/routes.ts
2543
2678
  import { Elysia, t } from "elysia";
2544
2679
 
2545
- // src/constants.ts
2546
- var SECONDS_IN_A_MINUTE = 60;
2547
- var MILLISECONDS_IN_A_SECOND = 1000;
2548
- var MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
2549
- var MINUTES_IN_AN_HOUR = 60;
2550
- var HOURS_IN_A_DAY = 24;
2551
- var MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR * HOURS_IN_A_DAY;
2552
- var MILLISECONDS_IN_AN_HOUR = MILLISECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR;
2553
- var COOKIE_MINUTES = 30;
2554
- var COOKIE_DURATION = SECONDS_IN_A_MINUTE * COOKIE_MINUTES;
2555
- var DEFAULT_MAX_SESSIONS = 1e4;
2556
-
2557
- // src/crypto.ts
2558
- var DEFAULT_TOKEN_BYTES = 32;
2559
- var AES_KEY_BYTES = 32;
2560
- var AES_IV_BYTES = 12;
2561
- var HOTP_COUNTER_BYTES = 8;
2562
- var TOTP_SECRET_BYTES = 20;
2563
- var TOTP_DIGITS = 6;
2564
- var TOTP_PERIOD_SECONDS = 30;
2565
- var DEFAULT_TOTP_WINDOW = 1;
2566
- var DECIMAL_RADIX = 10;
2567
- var LAST_NIBBLE_MASK = 15;
2568
- var SIGN_BIT_MASK = 2147483647;
2569
- var BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
2570
- var BASE32_GROUP_BITS = 5;
2571
- var BASE32_MASK = 31;
2572
- var BYTE_BITS = 8;
2573
- var textEncoder = new TextEncoder;
2574
- var textDecoder = new TextDecoder;
2575
- var base64UrlEncode = (bytes) => Buffer.from(bytes).toString("base64url");
2576
- var base64UrlDecode = (encoded) => new Uint8Array(Buffer.from(encoded, "base64url"));
2577
- var sha256 = async (input) => {
2578
- const digest = await crypto.subtle.digest("SHA-256", textEncoder.encode(input));
2579
- return new Uint8Array(digest);
2580
- };
2581
- var hmacSha1 = async (key, message) => {
2582
- const cryptoKey = await crypto.subtle.importKey("raw", key, { hash: "SHA-1", name: "HMAC" }, false, ["sign"]);
2583
- const signature = await crypto.subtle.sign("HMAC", cryptoKey, message);
2584
- return new Uint8Array(signature);
2585
- };
2586
- var counterToBytes = (counter) => {
2587
- const bytes = new Uint8Array(HOTP_COUNTER_BYTES);
2588
- new DataView(bytes.buffer).setBigUint64(0, BigInt(counter), false);
2589
- return bytes;
2590
- };
2591
- var generateHotp = async (secret, counter, digits = TOTP_DIGITS) => {
2592
- const hmac = await hmacSha1(secret, counterToBytes(counter));
2593
- const view = new DataView(hmac.buffer, hmac.byteOffset, hmac.byteLength);
2594
- const offset = view.getUint8(hmac.byteLength - 1) & LAST_NIBBLE_MASK;
2595
- const truncated = view.getUint32(offset, false) & SIGN_BIT_MASK;
2596
- const otp = truncated % DECIMAL_RADIX ** digits;
2597
- return otp.toString().padStart(digits, "0");
2598
- };
2599
- var importAesKey = (keyMaterial) => crypto.subtle.importKey("raw", base64UrlDecode(keyMaterial), { name: "AES-GCM" }, false, ["decrypt", "encrypt"]);
2600
- var base32Decode = (encoded) => {
2601
- const normalized = encoded.toUpperCase().replace(/[^A-Z2-7]/gu, "");
2602
- const bits = [...normalized].map((char) => BASE32_ALPHABET.indexOf(char).toString(2).padStart(BASE32_GROUP_BITS, "0")).join("");
2603
- const byteChunks = bits.match(/.{8}/gu) ?? [];
2604
- return new Uint8Array(byteChunks.map((chunk) => parseInt(chunk, 2)));
2605
- };
2606
- var base32Encode = (bytes) => {
2607
- const bits = Array.from(bytes, (byte) => byte.toString(2).padStart(BYTE_BITS, "0")).join("");
2608
- const groups = bits.match(/.{1,5}/gu) ?? [];
2609
- return groups.map((group) => BASE32_ALPHABET[parseInt(group.padEnd(BASE32_GROUP_BITS, "0"), 2) & BASE32_MASK] ?? "").join("");
2610
- };
2611
- var constantTimeEqual = async (left, right) => {
2612
- const [leftDigest, rightDigest] = await Promise.all([
2613
- sha256(left),
2614
- sha256(right)
2615
- ]);
2616
- const leftView = new DataView(leftDigest.buffer, leftDigest.byteOffset, leftDigest.byteLength);
2617
- const rightView = new DataView(rightDigest.buffer, rightDigest.byteOffset, rightDigest.byteLength);
2618
- let mismatch = 0;
2619
- for (let index = 0;index < leftDigest.byteLength; index += 1) {
2620
- mismatch |= leftView.getUint8(index) ^ rightView.getUint8(index);
2621
- }
2622
- return mismatch === 0;
2623
- };
2624
- var createTotpKeyUri = ({
2625
- accountName,
2626
- digits = TOTP_DIGITS,
2627
- issuer,
2628
- period = TOTP_PERIOD_SECONDS,
2629
- secret
2630
- }) => {
2631
- const params = new URLSearchParams({
2632
- algorithm: "SHA1",
2633
- digits: `${digits}`,
2634
- issuer,
2635
- period: `${period}`,
2636
- secret
2637
- });
2638
- const label = encodeURIComponent(`${issuer}:${accountName}`);
2639
- return `otpauth://totp/${label}?${params.toString()}`;
2640
- };
2641
- var decryptSecret = async (ciphertext, keyMaterial) => {
2642
- const key = await importAesKey(keyMaterial);
2643
- const combined = base64UrlDecode(ciphertext);
2644
- const nonce = combined.subarray(0, AES_IV_BYTES);
2645
- const data = combined.subarray(AES_IV_BYTES);
2646
- const plaintext = await crypto.subtle.decrypt({ iv: nonce, name: "AES-GCM" }, key, data);
2647
- return textDecoder.decode(plaintext);
2648
- };
2649
- var encryptSecret = async (plaintext, keyMaterial) => {
2650
- const key = await importAesKey(keyMaterial);
2651
- const nonce = new Uint8Array(AES_IV_BYTES);
2652
- crypto.getRandomValues(nonce);
2653
- const ciphertext = await crypto.subtle.encrypt({ iv: nonce, name: "AES-GCM" }, key, textEncoder.encode(plaintext));
2654
- const combined = new Uint8Array(nonce.byteLength + ciphertext.byteLength);
2655
- combined.set(nonce, 0);
2656
- combined.set(new Uint8Array(ciphertext), nonce.byteLength);
2657
- return base64UrlEncode(combined);
2658
- };
2659
- var generateEncryptionKey = () => generateSecureToken(AES_KEY_BYTES);
2660
- var generateSecureToken = (byteLength = DEFAULT_TOKEN_BYTES) => {
2661
- const bytes = new Uint8Array(byteLength);
2662
- crypto.getRandomValues(bytes);
2663
- return base64UrlEncode(bytes);
2664
- };
2665
- var generateTotp = async ({
2666
- digits = TOTP_DIGITS,
2667
- now = Date.now(),
2668
- period = TOTP_PERIOD_SECONDS,
2669
- secret
2670
- }) => {
2671
- const counter = Math.floor(now / MILLISECONDS_IN_A_SECOND / period);
2672
- return generateHotp(base32Decode(secret), counter, digits);
2673
- };
2674
- var generateTotpSecret = (byteLength = TOTP_SECRET_BYTES) => {
2675
- const bytes = new Uint8Array(byteLength);
2676
- crypto.getRandomValues(bytes);
2677
- return base32Encode(bytes);
2678
- };
2679
- var hashPassword = (password) => Bun.password.hash(password, { algorithm: "argon2id" });
2680
- var hashToken = async (token) => base64UrlEncode(await sha256(token));
2681
- var verifyPassword = (password, hash) => Bun.password.verify(password, hash);
2682
- var verifyTotp = async ({
2683
- digits = TOTP_DIGITS,
2684
- now = Date.now(),
2685
- period = TOTP_PERIOD_SECONDS,
2686
- secret,
2687
- token,
2688
- window = DEFAULT_TOTP_WINDOW
2689
- }) => {
2690
- const secretBytes = base32Decode(secret);
2691
- const counter = Math.floor(now / MILLISECONDS_IN_A_SECOND / period);
2692
- const drifts = Array.from({ length: window * 2 + 1 }, (_, offset) => counter - window + offset);
2693
- const candidates = await Promise.all(drifts.map((value) => generateHotp(secretBytes, value, digits)));
2694
- const matches = await Promise.all(candidates.map((candidate) => constantTimeEqual(candidate, token)));
2695
- return matches.includes(true);
2696
- };
2697
-
2698
2680
  // src/apikeys/config.ts
2681
+ init_constants();
2682
+ init_crypto();
2699
2683
  var DEFAULT_TOKEN_ROUTE = "/oauth2/token";
2700
2684
  var ACCESS_TOKEN_PREFIX = "at_";
2701
2685
  var API_KEY_PREFIX = "sk_";
@@ -3202,6 +3186,7 @@ var protectPermissionPlugin = ({
3202
3186
  import { Elysia as Elysia4, t as t4 } from "elysia";
3203
3187
 
3204
3188
  // src/utils.ts
3189
+ init_constants();
3205
3190
  var defineAuthConfig = (configuration) => configuration;
3206
3191
  var defineAuthHtmxConfig = (htmxConfig) => htmxConfig;
3207
3192
  var defineAuthSettings = (settings) => settings;
@@ -3542,9 +3527,11 @@ var complianceRoutes = ({
3542
3527
  import { Elysia as Elysia9 } from "elysia";
3543
3528
 
3544
3529
  // src/credentials/emailVerification.ts
3530
+ init_crypto();
3545
3531
  import { Elysia as Elysia5, t as t5 } from "elysia";
3546
3532
 
3547
3533
  // src/credentials/config.ts
3534
+ init_constants();
3548
3535
  var DEFAULT_CREDENTIAL_SESSION_TTL_MS = MILLISECONDS_IN_A_DAY;
3549
3536
  var DEFAULT_RESET_TOKEN_TTL_MS = MILLISECONDS_IN_AN_HOUR;
3550
3537
  var DEFAULT_VERIFICATION_TOKEN_TTL_MS = MILLISECONDS_IN_A_DAY;
@@ -3586,9 +3573,12 @@ var credentialsEmailVerification = ({
3586
3573
  }, { body: t5.Object({ email: t5.String() }) });
3587
3574
 
3588
3575
  // src/credentials/login.ts
3576
+ init_constants();
3577
+ init_crypto();
3589
3578
  import { Elysia as Elysia6, t as t6 } from "elysia";
3590
3579
 
3591
3580
  // src/credentials/import.ts
3581
+ init_crypto();
3592
3582
  var normalizeEmail = (email) => email.trim().toLowerCase();
3593
3583
  var buildCredential = (email, emailVerified, passwordHash, userId) => ({
3594
3584
  createdAt: Date.now(),
@@ -3866,6 +3856,7 @@ var credentialsLogin = ({
3866
3856
  });
3867
3857
 
3868
3858
  // src/credentials/passwordReset.ts
3859
+ init_crypto();
3869
3860
  import { Elysia as Elysia7, t as t7 } from "elysia";
3870
3861
  var credentialsPasswordReset = ({
3871
3862
  credentialStore,
@@ -3924,6 +3915,7 @@ var credentialsPasswordReset = ({
3924
3915
  });
3925
3916
 
3926
3917
  // src/credentials/register.ts
3918
+ init_crypto();
3927
3919
  import { Elysia as Elysia8, t as t8 } from "elysia";
3928
3920
  var credentialsRegister = ({
3929
3921
  authSessionStore,
@@ -4201,6 +4193,7 @@ var createAuthHtmxRoutes = (config) => {
4201
4193
  };
4202
4194
 
4203
4195
  // src/lockout/config.ts
4196
+ init_constants();
4204
4197
  var DEFAULT_MAX_ATTEMPTS = 5;
4205
4198
  var LOCKOUT_WINDOW_MINUTES = 15;
4206
4199
  var DEFAULT_WINDOW_MS = MILLISECONDS_IN_A_MINUTE * LOCKOUT_WINDOW_MINUTES;
@@ -4237,9 +4230,11 @@ var createMfaGate = ({ getUserId, mfaStore }) => async (user) => isMfaEnrolled(a
4237
4230
  import { Elysia as Elysia14 } from "elysia";
4238
4231
 
4239
4232
  // src/mfa/challenge.ts
4233
+ init_crypto();
4240
4234
  import { Elysia as Elysia12, t as t10 } from "elysia";
4241
4235
 
4242
4236
  // src/mfa/backupCodes.ts
4237
+ init_crypto();
4243
4238
  var BACKUP_CODE_BYTES = 8;
4244
4239
  var consumeBackupCode = async (code, hashes) => {
4245
4240
  const codeHash = await hashToken(code);
@@ -4255,11 +4250,13 @@ var generateBackupCodes = async (count) => {
4255
4250
  };
4256
4251
 
4257
4252
  // src/mfa/config.ts
4253
+ init_constants();
4258
4254
  var DEFAULT_BACKUP_CODE_COUNT = 10;
4259
4255
  var DEFAULT_MFA_ISSUER = "AbsoluteAuth";
4260
4256
  var DEFAULT_MFA_SESSION_TTL_MS = MILLISECONDS_IN_A_DAY;
4261
4257
 
4262
4258
  // src/mfa/secret.ts
4259
+ init_crypto();
4263
4260
  var decryptTotpSecret = (ciphertext, encryptionKey) => encryptionKey ? decryptSecret(ciphertext, encryptionKey) : Promise.resolve(ciphertext);
4264
4261
  var encryptTotpSecret = (secret, encryptionKey) => encryptionKey ? encryptSecret(secret, encryptionKey) : Promise.resolve(secret);
4265
4262
 
@@ -4337,6 +4334,7 @@ var mfaChallenge = ({
4337
4334
  });
4338
4335
 
4339
4336
  // src/mfa/totp.ts
4337
+ init_crypto();
4340
4338
  import { Elysia as Elysia13, t as t11 } from "elysia";
4341
4339
  var mfaTotpRoutes = ({
4342
4340
  authSessionStore,
@@ -4423,8 +4421,14 @@ var mfaTotpRoutes = ({
4423
4421
  var mfaRoutes = (config) => new Elysia14().use(mfaTotpRoutes(config)).use(mfaChallenge(config));
4424
4422
 
4425
4423
  // src/oidc/routes.ts
4424
+ init_constants();
4425
+ init_crypto();
4426
4426
  import { Elysia as Elysia15, t as t12 } from "elysia";
4427
4427
 
4428
+ // src/oidc/config.ts
4429
+ init_constants();
4430
+ init_crypto();
4431
+
4428
4432
  // src/oidc/keys.ts
4429
4433
  var ENCODER = new TextEncoder;
4430
4434
  var ES256 = { hash: "SHA-256", name: "ECDSA" };
@@ -4939,6 +4943,7 @@ var exchangeBackchannelAuth = async ({
4939
4943
  };
4940
4944
 
4941
4945
  // src/oidc/clientAuth.ts
4946
+ init_constants();
4942
4947
  var CLIENT_ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
4943
4948
  var MAX_ASSERTION_LIFETIME_MINUTES = 5;
4944
4949
  var SECONDS_PER_MINUTE = 60;
@@ -5047,6 +5052,329 @@ var verifyJwtSignedByClient = ({
5047
5052
  client
5048
5053
  }) => verifyJwtSignedByClientImpl(client, jwt);
5049
5054
 
5055
+ // src/oidc/vci.ts
5056
+ init_crypto();
5057
+
5058
+ // src/vc/sdJwt.ts
5059
+ var SALT_BYTES = 16;
5060
+ var SD_ALG = "sha-256";
5061
+ var toBase64Url2 = (bytes) => Buffer.from(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)).toString("base64url");
5062
+ var fromBase64Url2 = (value) => new Uint8Array(Buffer.from(value, "base64url"));
5063
+ var randomSalt = () => {
5064
+ const bytes = new Uint8Array(SALT_BYTES);
5065
+ crypto.getRandomValues(bytes);
5066
+ return toBase64Url2(bytes);
5067
+ };
5068
+ var sha2562 = async (input) => {
5069
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(input));
5070
+ return toBase64Url2(digest);
5071
+ };
5072
+ var encodeDisclosure = (claimName, claimValue) => {
5073
+ const salt = randomSalt();
5074
+ const tuple = JSON.stringify([salt, claimName, claimValue]);
5075
+ const encoded = Buffer.from(tuple).toString("base64url");
5076
+ return { claimName, claimValue, encoded, salt };
5077
+ };
5078
+ var issueSdJwtVc = async (input) => {
5079
+ const disclosures = Object.entries(input.selective).map(([name, value]) => encodeDisclosure(name, value));
5080
+ const sdDigests = await Promise.all(disclosures.map((disclosure) => sha2562(disclosure.encoded)));
5081
+ const payload = {
5082
+ ...input.base,
5083
+ _sd: sdDigests,
5084
+ _sd_alg: SD_ALG
5085
+ };
5086
+ if (input.holderJwk !== undefined)
5087
+ payload.cnf = { jwk: input.holderJwk };
5088
+ const jwt = await signJwt(payload, input.signingKey);
5089
+ const tail = disclosures.map((disclosure) => disclosure.encoded).join("~");
5090
+ return `${jwt}~${tail}~`;
5091
+ };
5092
+ var parseSdJwtVc = (token) => {
5093
+ const segments = token.split("~");
5094
+ const jwt = segments[0] ?? "";
5095
+ const tail = segments.slice(1);
5096
+ const last = tail[tail.length - 1];
5097
+ const hasKeyBinding = last !== undefined && last !== "";
5098
+ const keyBindingJwt = hasKeyBinding ? last : undefined;
5099
+ const disclosureCount = hasKeyBinding ? tail.length - 1 : tail.length - 1;
5100
+ const disclosures = tail.slice(0, disclosureCount).filter((entry) => entry !== "");
5101
+ return { disclosures, jwt, keyBindingJwt };
5102
+ };
5103
+ var presentSdJwtVc = (parsed, selectedClaims, keyBindingJwt) => {
5104
+ const selectedSet = new Set(selectedClaims);
5105
+ const kept = parsed.disclosures.filter((encoded) => {
5106
+ const tuple = decodeDisclosure(encoded);
5107
+ return tuple !== undefined && selectedSet.has(tuple.claimName);
5108
+ });
5109
+ const tail = kept.join("~");
5110
+ const suffix = keyBindingJwt === undefined ? "" : keyBindingJwt;
5111
+ return `${parsed.jwt}~${tail}~${suffix}`;
5112
+ };
5113
+ var DISCLOSURE_TUPLE_LENGTH = 3;
5114
+ var decodeDisclosure = (encoded) => {
5115
+ try {
5116
+ const raw = Buffer.from(encoded, "base64url").toString("utf8");
5117
+ const tuple = JSON.parse(raw);
5118
+ if (!Array.isArray(tuple) || tuple.length !== DISCLOSURE_TUPLE_LENGTH) {
5119
+ return;
5120
+ }
5121
+ const [salt, claimName, claimValue] = tuple;
5122
+ if (typeof salt !== "string" || typeof claimName !== "string") {
5123
+ return;
5124
+ }
5125
+ const decoded = { claimName, claimValue, encoded, salt };
5126
+ return decoded;
5127
+ } catch {
5128
+ return;
5129
+ }
5130
+ };
5131
+ var verifySdJwtVc = async (input) => {
5132
+ const parsed = parseSdJwtVc(input.token);
5133
+ const decoded = await verifyJwt(parsed.jwt, input.issuerPublicJwk);
5134
+ if (decoded === undefined)
5135
+ return;
5136
+ const rawPayload = decoded.payload;
5137
+ if (typeof rawPayload !== "object" || rawPayload === null)
5138
+ return;
5139
+ const payload = { ...rawPayload };
5140
+ const sdArray = payload._sd;
5141
+ const sdAlg = payload._sd_alg;
5142
+ if (!Array.isArray(sdArray) || sdAlg !== SD_ALG)
5143
+ return;
5144
+ const acceptedHashes = new Set(sdArray.filter((entry) => typeof entry === "string"));
5145
+ const disclosedClaims = {};
5146
+ for (const encoded of parsed.disclosures) {
5147
+ const hash = await sha2562(encoded);
5148
+ if (!acceptedHashes.has(hash))
5149
+ return;
5150
+ const tuple = decodeDisclosure(encoded);
5151
+ if (tuple === undefined)
5152
+ return;
5153
+ disclosedClaims[tuple.claimName] = tuple.claimValue;
5154
+ }
5155
+ const protectedClaims = {};
5156
+ for (const [key, value] of Object.entries(payload)) {
5157
+ if (key === "_sd" || key === "_sd_alg" || key === "cnf")
5158
+ continue;
5159
+ protectedClaims[key] = value;
5160
+ }
5161
+ const cnf = extractCnf(payload.cnf);
5162
+ const result = {
5163
+ cnf,
5164
+ disclosedClaims,
5165
+ keyBindingJwt: parsed.keyBindingJwt,
5166
+ protectedClaims
5167
+ };
5168
+ return result;
5169
+ };
5170
+ var extractCnf = (value) => {
5171
+ if (typeof value !== "object" || value === null)
5172
+ return;
5173
+ const jwk = Reflect.get(value, "jwk");
5174
+ if (typeof jwk !== "object" || jwk === null)
5175
+ return;
5176
+ const candidate = jwk;
5177
+ const narrowed = {
5178
+ crv: typeof candidate.crv === "string" ? candidate.crv : undefined,
5179
+ kty: typeof candidate.kty === "string" ? candidate.kty : undefined,
5180
+ x: typeof candidate.x === "string" ? candidate.x : undefined,
5181
+ y: typeof candidate.y === "string" ? candidate.y : undefined
5182
+ };
5183
+ return { jwk: narrowed };
5184
+ };
5185
+
5186
+ // src/oidc/vci.ts
5187
+ var PRE_AUTHORIZED_CODE_GRANT = "urn:ietf:params:oauth:grant-type:pre-authorized_code";
5188
+ var MS_PER_SECOND2 = 1000;
5189
+ var DEFAULT_OFFER_TTL_MS = 600000;
5190
+ var DEFAULT_ACCESS_TTL_MS = 600000;
5191
+ var DEFAULT_NONCE_TTL_MS = 300000;
5192
+ var PRE_AUTH_CODE_BYTES = 32;
5193
+ var C_NONCE_BYTES = 16;
5194
+ var DEFAULT_VCI_ROUTE = "/vci";
5195
+ var nowSeconds2 = (timeMs) => Math.floor(timeMs / MS_PER_SECOND2);
5196
+ var createCredentialOffer = async ({
5197
+ clientId,
5198
+ configurationId,
5199
+ now = Date.now(),
5200
+ store,
5201
+ ttlMs = DEFAULT_OFFER_TTL_MS,
5202
+ userId
5203
+ }) => {
5204
+ const preAuthorizedCode = generateSecureToken(PRE_AUTH_CODE_BYTES);
5205
+ const preAuthorizedCodeHash = await hashToken(preAuthorizedCode);
5206
+ const offer = {
5207
+ clientId,
5208
+ configurationId,
5209
+ createdAt: now,
5210
+ expiresAt: now + ttlMs,
5211
+ preAuthorizedCodeHash,
5212
+ redeemed: false,
5213
+ userId
5214
+ };
5215
+ await store.saveOffer(offer);
5216
+ return { offer, preAuthorizedCode };
5217
+ };
5218
+ var exchangePreAuthorizedCode = async ({
5219
+ config,
5220
+ issuer,
5221
+ now = Date.now(),
5222
+ preAuthorizedCode,
5223
+ signingKey
5224
+ }) => {
5225
+ const failFor = (error) => {
5226
+ const failure = { error, ok: false };
5227
+ return failure;
5228
+ };
5229
+ const hash = await hashToken(preAuthorizedCode);
5230
+ const offer = await config.credentialOfferStore.consumeOffer(hash);
5231
+ if (offer === undefined || offer.redeemed)
5232
+ return failFor("invalid_grant");
5233
+ if (offer.expiresAt < now)
5234
+ return failFor("expired_token");
5235
+ const ttlMs = config.accessTokenTtlMs ?? DEFAULT_ACCESS_TTL_MS;
5236
+ const accessToken = await signJwt({
5237
+ aud: issuer,
5238
+ exp: nowSeconds2(now + ttlMs),
5239
+ iat: nowSeconds2(now),
5240
+ iss: issuer,
5241
+ scope: `openid_credential:${offer.configurationId}`,
5242
+ sub: offer.userId,
5243
+ vci_configuration_id: offer.configurationId
5244
+ }, signingKey);
5245
+ const result = {
5246
+ access_token: accessToken,
5247
+ expires_in: Math.floor(ttlMs / MS_PER_SECOND2),
5248
+ ok: true,
5249
+ token_type: "Bearer"
5250
+ };
5251
+ if (config.credentialNonceStore !== undefined) {
5252
+ const nonce = generateSecureToken(C_NONCE_BYTES);
5253
+ const nonceTtlMs = config.nonceTtlMs ?? DEFAULT_NONCE_TTL_MS;
5254
+ await config.credentialNonceStore.saveNonce({
5255
+ expiresAt: now + nonceTtlMs,
5256
+ nonceHash: await hashToken(nonce)
5257
+ });
5258
+ result.c_nonce = nonce;
5259
+ result.c_nonce_expires_in = Math.floor(nonceTtlMs / MS_PER_SECOND2);
5260
+ }
5261
+ return result;
5262
+ };
5263
+ var decodeJwtHeader = (jwt) => {
5264
+ const [header] = jwt.split(".");
5265
+ if (header === undefined)
5266
+ return;
5267
+ try {
5268
+ const decoded = JSON.parse(Buffer.from(header, "base64url").toString("utf8"));
5269
+ if (typeof decoded !== "object" || decoded === null)
5270
+ return;
5271
+ return decoded;
5272
+ } catch {
5273
+ return;
5274
+ }
5275
+ };
5276
+ var extractHolderJwk = (proofJwt) => {
5277
+ const header = decodeJwtHeader(proofJwt);
5278
+ if (header === undefined)
5279
+ return;
5280
+ const jwk = Reflect.get(header, "jwk");
5281
+ if (typeof jwk !== "object" || jwk === null)
5282
+ return;
5283
+ const candidate = jwk;
5284
+ return {
5285
+ crv: typeof candidate.crv === "string" ? candidate.crv : undefined,
5286
+ kty: typeof candidate.kty === "string" ? candidate.kty : undefined,
5287
+ x: typeof candidate.x === "string" ? candidate.x : undefined,
5288
+ y: typeof candidate.y === "string" ? candidate.y : undefined
5289
+ };
5290
+ };
5291
+ var buildIssuerMetadata = ({
5292
+ config,
5293
+ issuer,
5294
+ vciRoute
5295
+ }) => ({
5296
+ credential_configurations_supported: Object.fromEntries(config.credentialConfigurations.map((configuration) => [
5297
+ configuration.id,
5298
+ {
5299
+ claims: configuration.claims,
5300
+ credential_signing_alg_values_supported: ["ES256"],
5301
+ cryptographic_binding_methods_supported: ["jwk"],
5302
+ display: configuration.display,
5303
+ format: configuration.format,
5304
+ order: configuration.order,
5305
+ proof_types_supported: { jwt: { proof_signing_alg_values_supported: ["ES256"] } },
5306
+ vct: configuration.vct
5307
+ }
5308
+ ])),
5309
+ credential_endpoint: `${issuer}${vciRoute}/credential`,
5310
+ credential_issuer: issuer,
5311
+ nonce_endpoint: config.credentialNonceStore === undefined ? undefined : `${issuer}${vciRoute}/nonce`,
5312
+ token_endpoint: `${issuer}/oauth2/token`
5313
+ });
5314
+ var issueOk = (credential) => {
5315
+ const success = {
5316
+ credential,
5317
+ format: "vc+sd-jwt",
5318
+ ok: true
5319
+ };
5320
+ return success;
5321
+ };
5322
+ var issueFail = (error) => {
5323
+ const failure = { error, ok: false };
5324
+ return failure;
5325
+ };
5326
+ var issueCredential = async ({
5327
+ config,
5328
+ input,
5329
+ issuer,
5330
+ now = Date.now(),
5331
+ signingKey
5332
+ }) => {
5333
+ const requested = input.requestedFormat ?? "vc+sd-jwt";
5334
+ if (requested !== "vc+sd-jwt")
5335
+ return issueFail("unsupported_credential_format");
5336
+ const decoded = await verifyJwt(input.accessToken, signingKey.publicJwk);
5337
+ if (decoded === undefined)
5338
+ return issueFail("invalid_token");
5339
+ const rawPayload = decoded.payload;
5340
+ if (typeof rawPayload !== "object" || rawPayload === null) {
5341
+ return issueFail("invalid_token");
5342
+ }
5343
+ const payload = { ...rawPayload };
5344
+ if (typeof payload.exp === "number" && payload.exp * MS_PER_SECOND2 < now) {
5345
+ return issueFail("invalid_token");
5346
+ }
5347
+ const userId = payload.sub;
5348
+ const configurationId = payload.vci_configuration_id;
5349
+ if (typeof userId !== "string" || typeof configurationId !== "string") {
5350
+ return issueFail("invalid_token");
5351
+ }
5352
+ const configuration = config.credentialConfigurations.find((entry) => entry.id === configurationId);
5353
+ if (configuration === undefined)
5354
+ return issueFail("invalid_credential_request");
5355
+ const holderJwk = input.proofJwt === undefined ? undefined : extractHolderJwk(input.proofJwt);
5356
+ if (input.proofJwt !== undefined && holderJwk === undefined) {
5357
+ return issueFail("invalid_proof");
5358
+ }
5359
+ const selective = await config.resolveCredentialClaims({
5360
+ configurationId,
5361
+ userId
5362
+ });
5363
+ const protectedClaims = config.resolveProtectedClaims ? await config.resolveProtectedClaims({ configurationId, userId }) : {};
5364
+ const credential = await issueSdJwtVc({
5365
+ base: {
5366
+ iat: nowSeconds2(now),
5367
+ iss: issuer,
5368
+ ...protectedClaims,
5369
+ vct: configuration.vct
5370
+ },
5371
+ holderJwk,
5372
+ selective,
5373
+ signingKey
5374
+ });
5375
+ return issueOk(credential);
5376
+ };
5377
+
5050
5378
  // src/oidc/mtls.ts
5051
5379
  var RFC9440_HEADER = "client-cert";
5052
5380
  var SF_BINARY_PREFIX = ":";
@@ -5097,6 +5425,7 @@ var verifyCertificateBoundToken = async ({
5097
5425
  };
5098
5426
 
5099
5427
  // src/oidc/dpop.ts
5428
+ init_constants();
5100
5429
  var DEFAULT_MAX_AGE_MS = 60000;
5101
5430
  var SECONDS_TO_MS = 1000;
5102
5431
  var NONCE_WINDOW_SECONDS = 120;
@@ -5180,6 +5509,7 @@ var verifyDpopProof = async ({
5180
5509
  };
5181
5510
 
5182
5511
  // src/oidc/logout.ts
5512
+ init_constants();
5183
5513
  var BACKCHANNEL_LOGOUT_EVENT = "http://schemas.openid.net/event/backchannel-logout";
5184
5514
  var buildLogoutClaims = ({
5185
5515
  clientId,
@@ -5312,7 +5642,7 @@ var fanOutBackchannelLogout = async ({
5312
5642
  };
5313
5643
 
5314
5644
  // src/oidc/jar.ts
5315
- var MS_PER_SECOND2 = 1000;
5645
+ var MS_PER_SECOND3 = 1000;
5316
5646
  var numberClaim = (value) => typeof value === "number" ? value : undefined;
5317
5647
  var stringClaim = (value) => typeof value === "string" ? value : undefined;
5318
5648
  var arrayClaim = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string") ? value : undefined;
@@ -5337,7 +5667,7 @@ var parseSignedRequestObject = async ({
5337
5667
  if (!audMatches) {
5338
5668
  return { error: "invalid_request_object", ok: false };
5339
5669
  }
5340
- if (exp !== undefined && exp * MS_PER_SECOND2 <= now) {
5670
+ if (exp !== undefined && exp * MS_PER_SECOND3 <= now) {
5341
5671
  return { error: "invalid_request_object", ok: false };
5342
5672
  }
5343
5673
  const envelope = new Set(["aud", "exp", "iat", "iss", "jti", "nbf"]);
@@ -5346,6 +5676,8 @@ var parseSignedRequestObject = async ({
5346
5676
  };
5347
5677
 
5348
5678
  // src/oidc/par.ts
5679
+ init_constants();
5680
+ init_crypto();
5349
5681
  var REQUEST_URI_BYTES = 32;
5350
5682
  var DEFAULT_PAR_TTL_SECONDS = 90;
5351
5683
  var DEFAULT_PAR_TTL_MS = DEFAULT_PAR_TTL_SECONDS * MILLISECONDS_IN_A_SECOND;
@@ -5455,6 +5787,7 @@ var fetchUserInfo = async ({
5455
5787
  var userInfoChallengeHeader = (error) => `Bearer realm="userinfo", error="${error}"`;
5456
5788
 
5457
5789
  // src/oidc/registration.ts
5790
+ init_crypto();
5458
5791
  var REG_TOKEN_BYTES = 32;
5459
5792
  var CLIENT_ID_BYTES = 16;
5460
5793
  var mintRegistrationToken = async (clientId) => {
@@ -5976,6 +6309,9 @@ var oidcProviderRoutes = (config) => {
5976
6309
  if (config.backchannelAuthStore) {
5977
6310
  grantTypes.push(CIBA_GRANT_TYPE);
5978
6311
  }
6312
+ if (config.vciConfig !== undefined) {
6313
+ grantTypes.push(PRE_AUTHORIZED_CODE_GRANT);
6314
+ }
5979
6315
  const discovery = {
5980
6316
  authorization_endpoint: `${issuer}${authorizeRoute}`,
5981
6317
  backchannel_logout_session_supported: false,
@@ -6209,6 +6545,27 @@ var oidcProviderRoutes = (config) => {
6209
6545
  state: t12.Optional(t12.String())
6210
6546
  })
6211
6547
  }).post(tokenRoute, async ({ body, headers, request }) => {
6548
+ if (body.grant_type === PRE_AUTHORIZED_CODE_GRANT && config.vciConfig !== undefined) {
6549
+ const preAuthorizedCode = body["pre-authorized_code"];
6550
+ if (typeof preAuthorizedCode !== "string") {
6551
+ return oauthError2(HTTP_BAD_REQUEST2, "invalid_request");
6552
+ }
6553
+ const result = await exchangePreAuthorizedCode({
6554
+ config: config.vciConfig,
6555
+ issuer: config.issuer,
6556
+ preAuthorizedCode,
6557
+ signingKey: config.vciConfig.signingKey ?? config.signingKey
6558
+ });
6559
+ if (!result.ok)
6560
+ return oauthError2(HTTP_BAD_REQUEST2, result.error);
6561
+ return jsonResponse({
6562
+ access_token: result.access_token,
6563
+ c_nonce: result.c_nonce,
6564
+ c_nonce_expires_in: result.c_nonce_expires_in,
6565
+ expires_in: result.expires_in,
6566
+ token_type: result.token_type
6567
+ }, HTTP_OK2);
6568
+ }
6212
6569
  const basic = readBasicAuth2(headers.authorization);
6213
6570
  const auth = await authenticateTokenClient({
6214
6571
  basicClientId: basic.clientId,
@@ -6254,6 +6611,7 @@ var oidcProviderRoutes = (config) => {
6254
6611
  code_verifier: t12.Optional(t12.String()),
6255
6612
  device_code: t12.Optional(t12.String()),
6256
6613
  grant_type: t12.Optional(t12.String()),
6614
+ "pre-authorized_code": t12.Optional(t12.String()),
6257
6615
  redirect_uri: t12.Optional(t12.String()),
6258
6616
  refresh_token: t12.Optional(t12.String()),
6259
6617
  resource: t12.Optional(t12.String()),
@@ -6638,12 +6996,14 @@ var oidcProviderRoutes = (config) => {
6638
6996
  import { Elysia as Elysia16, t as t13 } from "elysia";
6639
6997
 
6640
6998
  // src/organizations/config.ts
6999
+ init_constants();
6641
7000
  var INVITATION_TTL_DAYS = 7;
6642
7001
  var DEFAULT_INVITATION_TTL_MS = MILLISECONDS_IN_A_DAY * INVITATION_TTL_DAYS;
6643
7002
  var DEFAULT_ORGANIZATIONS_ROUTE = "/auth/organizations";
6644
7003
  var DEFAULT_OWNER_ROLES = ["owner"];
6645
7004
 
6646
7005
  // src/organizations/operations.ts
7006
+ init_crypto();
6647
7007
  var acceptInvitation = async ({
6648
7008
  organizationStore,
6649
7009
  token,
@@ -6996,9 +7356,11 @@ var organizationRoutes = ({
6996
7356
  };
6997
7357
 
6998
7358
  // src/passwordless/routes.ts
7359
+ init_crypto();
6999
7360
  import { Elysia as Elysia17, t as t14 } from "elysia";
7000
7361
 
7001
7362
  // src/passwordless/config.ts
7363
+ init_constants();
7002
7364
  var SECONDS_IN_TEN_MINUTES = 600;
7003
7365
  var DEFAULT_OTP_DIGITS = 6;
7004
7366
  var DEFAULT_MAGIC_LINK_TTL_MS = MILLISECONDS_IN_A_SECOND * SECONDS_IN_TEN_MINUTES;
@@ -7132,6 +7494,7 @@ var passwordlessRoutes = ({
7132
7494
  import { Elysia as Elysia18, t as t15 } from "elysia";
7133
7495
 
7134
7496
  // src/scim/config.ts
7497
+ init_crypto();
7135
7498
  var DEFAULT_SCIM_ROUTE = "/scim/v2";
7136
7499
  var SCIM_TOKEN_BYTES = 32;
7137
7500
  var BEARER_PREFIX3 = "Bearer ";
@@ -7158,15 +7521,18 @@ var resolveScimOrganization = async (scimTokenStore, authorization) => {
7158
7521
  };
7159
7522
 
7160
7523
  // src/sso/config.ts
7524
+ init_constants();
7161
7525
  var DEFAULT_SSO_ROUTE = "/sso";
7162
7526
  var DEFAULT_SSO_SESSION_TTL_MS = MILLISECONDS_IN_A_DAY;
7163
7527
 
7164
7528
  // src/portal/config.ts
7529
+ init_constants();
7165
7530
  var SETUP_TTL_DAYS = 3;
7166
7531
  var DEFAULT_PORTAL_ROUTE = "/auth/portal";
7167
7532
  var DEFAULT_SETUP_SESSION_TTL_MS = MILLISECONDS_IN_A_DAY * SETUP_TTL_DAYS;
7168
7533
 
7169
7534
  // src/portal/operations.ts
7535
+ init_crypto();
7170
7536
  var BEARER_PREFIX4 = "Bearer ";
7171
7537
  var createSetupSession = async ({
7172
7538
  capabilities,
@@ -7593,6 +7959,7 @@ var resolveProviderClientConfiguration = ({
7593
7959
  };
7594
7960
 
7595
7961
  // src/routes/authorize.ts
7962
+ init_constants();
7596
7963
  import { Elysia as Elysia20, t as t17 } from "elysia";
7597
7964
  var parseReferer = (headerReferer) => {
7598
7965
  if (!headerReferer)
@@ -7968,6 +8335,7 @@ var profile = ({
7968
8335
  });
7969
8336
 
7970
8337
  // src/routes/refresh.ts
8338
+ init_constants();
7971
8339
  import { Elysia as Elysia23, t as t20 } from "elysia";
7972
8340
  var refresh = ({
7973
8341
  authSessionStore,
@@ -8936,6 +9304,7 @@ var scimRoutes = ({
8936
9304
  };
8937
9305
 
8938
9306
  // src/session/cleanup.ts
9307
+ init_constants();
8939
9308
  import { Elysia as Elysia30 } from "elysia";
8940
9309
  var sessionCleanup = ({
8941
9310
  authSessionStore,
@@ -9184,6 +9553,7 @@ var ssoDiscoveryRoute = ({
9184
9553
  };
9185
9554
 
9186
9555
  // src/sso/oidcRoutes.ts
9556
+ init_constants();
9187
9557
  import { Elysia as Elysia32, t as t28 } from "elysia";
9188
9558
  var makeSsoCookieOptions = (secure) => ({
9189
9559
  httpOnly: true,
@@ -9604,9 +9974,11 @@ var samlSsoRoutes = ({
9604
9974
  };
9605
9975
 
9606
9976
  // src/webauthn/routes.ts
9977
+ init_constants();
9607
9978
  import { Elysia as Elysia34, t as t30 } from "elysia";
9608
9979
 
9609
9980
  // src/webauthn/config.ts
9981
+ init_constants();
9610
9982
  var FIVE_MINUTES_MS = 300000;
9611
9983
  var DEFAULT_WEBAUTHN_CHALLENGE_TTL_MS = FIVE_MINUTES_MS;
9612
9984
  var DEFAULT_WEBAUTHN_ROUTE = "/auth/webauthn";
@@ -9792,7 +10164,11 @@ var webauthnRoutes = ({
9792
10164
  });
9793
10165
  };
9794
10166
 
10167
+ // src/webhooks/dispatcher.ts
10168
+ init_constants();
10169
+
9795
10170
  // src/webhooks/config.ts
10171
+ init_constants();
9796
10172
  var DEFAULT_TIMEOUT_SECONDS = 5;
9797
10173
  var DEFAULT_RETRY_ATTEMPTS = 3;
9798
10174
  var DEFAULT_RETRY_INITIAL_DELAY_MS = MILLISECONDS_IN_A_SECOND;
@@ -9805,6 +10181,7 @@ var DEFAULT_WEBHOOK_RETRY = {
9805
10181
  var DEFAULT_WEBHOOK_TIMEOUT_MS = MILLISECONDS_IN_A_SECOND * DEFAULT_TIMEOUT_SECONDS;
9806
10182
 
9807
10183
  // src/webhooks/sign.ts
10184
+ init_crypto();
9808
10185
  var textEncoder2 = new TextEncoder;
9809
10186
  var importHmacKey = (secret) => crypto.subtle.importKey("raw", textEncoder2.encode(secret), { hash: "SHA-256", name: "HMAC" }, false, ["sign"]);
9810
10187
  var signWebhook = async ({
@@ -10032,6 +10409,7 @@ var createActionPipeline = (actions) => ({
10032
10409
  }
10033
10410
  });
10034
10411
  // src/compliance/cipher.ts
10412
+ init_crypto();
10035
10413
  var createSecretCipher = (keyMaterial) => ({
10036
10414
  decrypt: (ciphertext) => decryptSecret(ciphertext, keyMaterial),
10037
10415
  encrypt: (plaintext) => encryptSecret(plaintext, keyMaterial)
@@ -20791,6 +21169,7 @@ var createInMemoryLinkedProviderStores = (input = {}) => {
20791
21169
  return { bindingStore, grantStore };
20792
21170
  };
20793
21171
  // src/session/impersonation.ts
21172
+ init_constants();
20794
21173
  var DEFAULT_IMPERSONATION_TTL_MS = MILLISECONDS_IN_AN_HOUR;
20795
21174
  var endImpersonation = async ({
20796
21175
  authSessionStore,
@@ -20873,6 +21252,7 @@ var startImpersonation = async ({
20873
21252
  return sessionId;
20874
21253
  };
20875
21254
  // src/session/anonymous.ts
21255
+ init_constants();
20876
21256
  var DEFAULT_GUEST_TTL_MS = MILLISECONDS_IN_A_DAY;
20877
21257
  var createAnonymousSession = async ({
20878
21258
  authSessionStore,
@@ -20960,6 +21340,10 @@ var switchActiveSession = ({
20960
21340
  });
20961
21341
  return true;
20962
21342
  };
21343
+
21344
+ // src/index.ts
21345
+ init_crypto();
21346
+
20963
21347
  // src/tenancy.ts
20964
21348
  var hasOrganizationScope = (value) => typeof value.organizationId === "string" && value.organizationId.length > 0;
20965
21349
  // src/credentials/backgroundOps.ts
@@ -20969,7 +21353,7 @@ var DEFAULT_PAUSE_MS = 1700;
20969
21353
  var HIBP_NOT_FOUND = 404;
20970
21354
  var HIBP_RATE_LIMITED = 429;
20971
21355
  var MS_PER_DAY = 86400000;
20972
- var MS_PER_SECOND3 = 1000;
21356
+ var MS_PER_SECOND4 = 1000;
20973
21357
  var sleep = (delayMs) => new Promise((resolve) => {
20974
21358
  setTimeout(resolve, delayMs);
20975
21359
  });
@@ -20995,7 +21379,7 @@ var checkEmailBreaches = async (email, apiKey, truncate) => {
20995
21379
  if (response.status === HIBP_RATE_LIMITED) {
20996
21380
  const retryAfter = Number(response.headers.get("retry-after") ?? "0");
20997
21381
  if (retryAfter > 0)
20998
- await sleep(retryAfter * MS_PER_SECOND3);
21382
+ await sleep(retryAfter * MS_PER_SECOND4);
20999
21383
  return [];
21000
21384
  }
21001
21385
  if (!response.ok)
@@ -21650,6 +22034,7 @@ var defaultBotClassifier = (context) => {
21650
22034
  return "human";
21651
22035
  };
21652
22036
  // src/compliance/redaction.ts
22037
+ init_crypto();
21653
22038
  var createAuditRedactor = ({
21654
22039
  dropFields = [],
21655
22040
  hashFields = [],
@@ -21900,6 +22285,105 @@ var diffScimGroupMembers = (current, next) => {
21900
22285
  const removed = current.filter((member) => !nextValues.has(member.value));
21901
22286
  return { added, removed };
21902
22287
  };
22288
+ // src/oidc/inMemoryVciStores.ts
22289
+ var createInMemoryCredentialNonceStore = () => {
22290
+ const nonces = new Map;
22291
+ return {
22292
+ consumeNonce: async (nonceHash) => {
22293
+ const record = nonces.get(nonceHash);
22294
+ if (record === undefined)
22295
+ return;
22296
+ nonces.delete(nonceHash);
22297
+ return record;
22298
+ },
22299
+ saveNonce: async (record) => {
22300
+ nonces.set(record.nonceHash, record);
22301
+ }
22302
+ };
22303
+ };
22304
+ var createInMemoryCredentialOfferStore = () => {
22305
+ const offers = new Map;
22306
+ return {
22307
+ consumeOffer: async (preAuthorizedCodeHash) => {
22308
+ const offer = offers.get(preAuthorizedCodeHash);
22309
+ if (offer === undefined)
22310
+ return;
22311
+ offers.set(preAuthorizedCodeHash, { ...offer, redeemed: true });
22312
+ return offer;
22313
+ },
22314
+ saveOffer: async (offer) => {
22315
+ offers.set(offer.preAuthorizedCodeHash, offer);
22316
+ }
22317
+ };
22318
+ };
22319
+ // src/oidc/vciRoutes.ts
22320
+ import { Elysia as Elysia35, t as t31 } from "elysia";
22321
+ var HTTP_OK3 = 200;
22322
+ var HTTP_BAD_REQUEST3 = 400;
22323
+ var HTTP_UNAUTHORIZED3 = 401;
22324
+ var BEARER_PREFIX5 = "Bearer ";
22325
+ var errorBody = (error, status) => new Response(JSON.stringify({ error }), {
22326
+ headers: { "content-type": "application/json" },
22327
+ status
22328
+ });
22329
+ var extractBearer = (authorization) => {
22330
+ if (authorization === undefined || !authorization.startsWith(BEARER_PREFIX5)) {
22331
+ return;
22332
+ }
22333
+ const value = authorization.slice(BEARER_PREFIX5.length).trim();
22334
+ return value.length === 0 ? undefined : value;
22335
+ };
22336
+ var vciRoutes = ({
22337
+ issuerUrl,
22338
+ signingKey,
22339
+ vciConfig
22340
+ }) => {
22341
+ const vciRoute = vciConfig.vciRoute ?? DEFAULT_VCI_ROUTE;
22342
+ const credentialRoute = `${vciRoute}/credential`;
22343
+ const nonceRoute = `${vciRoute}/nonce`;
22344
+ const vciSigningKey = vciConfig.signingKey ?? signingKey;
22345
+ return new Elysia35().get("/.well-known/openid-credential-issuer", () => Response.json(buildIssuerMetadata({ config: vciConfig, issuer: issuerUrl, vciRoute }))).post(credentialRoute, async ({ body, headers }) => {
22346
+ const accessToken = extractBearer(headers.authorization);
22347
+ if (accessToken === undefined) {
22348
+ return errorBody("invalid_token", HTTP_UNAUTHORIZED3);
22349
+ }
22350
+ const result = await issueCredential({
22351
+ config: vciConfig,
22352
+ input: {
22353
+ accessToken,
22354
+ proofJwt: body.proof?.jwt,
22355
+ requestedFormat: body.format
22356
+ },
22357
+ issuer: issuerUrl,
22358
+ signingKey: vciSigningKey
22359
+ });
22360
+ if (!result.ok)
22361
+ return errorBody(result.error, HTTP_BAD_REQUEST3);
22362
+ return Response.json({ credential: result.credential, format: result.format }, { status: HTTP_OK3 });
22363
+ }, {
22364
+ body: t31.Object({
22365
+ format: t31.Optional(t31.Union([t31.Literal("vc+sd-jwt")])),
22366
+ proof: t31.Optional(t31.Object({
22367
+ jwt: t31.String(),
22368
+ proof_type: t31.Literal("jwt")
22369
+ }))
22370
+ })
22371
+ }).post(nonceRoute, async () => {
22372
+ if (vciConfig.credentialNonceStore === undefined) {
22373
+ return errorBody("not_supported", HTTP_BAD_REQUEST3);
22374
+ }
22375
+ const { generateSecureToken: generateSecureToken2, hashToken: hashToken2 } = await Promise.resolve().then(() => (init_crypto(), exports_crypto));
22376
+ const nonceBytes = 16;
22377
+ const nonce = generateSecureToken2(nonceBytes);
22378
+ const ttlMs = vciConfig.nonceTtlMs ?? 300000;
22379
+ await vciConfig.credentialNonceStore.saveNonce({
22380
+ expiresAt: Date.now() + ttlMs,
22381
+ nonceHash: await hashToken2(nonce)
22382
+ });
22383
+ const msPerSecond = 1000;
22384
+ return Response.json({ c_nonce: nonce, c_nonce_expires_in: Math.floor(ttlMs / msPerSecond) }, { status: HTTP_OK3 });
22385
+ });
22386
+ };
21903
22387
  // src/scim/inMemoryScimTokenStore.ts
21904
22388
  var createInMemoryScimTokenStore = () => {
21905
22389
  const tokens = new Map;
@@ -22770,6 +23254,7 @@ var createPostgresBackchannelAuthStore = (db) => ({
22770
23254
  }
22771
23255
  });
22772
23256
  // src/adaptive/config.ts
23257
+ init_constants();
22773
23258
  var DEFAULT_HISTORY_LIMIT = 50;
22774
23259
  var DEFAULT_MAX_TRAVEL_KMH = 900;
22775
23260
  var DEFAULT_VELOCITY_MAX_ATTEMPTS = 5;
@@ -22944,6 +23429,7 @@ var trustDevice = async (config, userId, deviceId, label) => {
22944
23429
  });
22945
23430
  };
22946
23431
  // src/adaptive/fingerprint.ts
23432
+ init_crypto();
22947
23433
  var canonical = (signals) => JSON.stringify(signals, (_key, value) => value === null || typeof value !== "object" || Array.isArray(value) ? value : Object.fromEntries(Object.entries(value).sort((left, right) => left[0].localeCompare(right[0]))));
22948
23434
  var fingerprintDevice = (signals) => hashToken(canonical(signals));
22949
23435
  // src/adaptive/inMemoryStores.ts
@@ -24061,18 +24547,18 @@ var blockMigrations = {
24061
24547
  webhooks: initMigration("webhooks", [webhookDeliveriesTable])
24062
24548
  };
24063
24549
  // src/sso/samlIdpRoutes.ts
24064
- import { Elysia as Elysia35, t as t31 } from "elysia";
24065
- var HTTP_BAD_REQUEST3 = 400;
24066
- var HTTP_UNAUTHORIZED3 = 401;
24550
+ import { Elysia as Elysia36, t as t32 } from "elysia";
24551
+ var HTTP_BAD_REQUEST4 = 400;
24552
+ var HTTP_UNAUTHORIZED4 = 401;
24067
24553
  var HTTP_FOUND2 = 302;
24068
- var HTTP_OK3 = 200;
24554
+ var HTTP_OK4 = 200;
24069
24555
  var xmlResponse = (body) => new Response(body, {
24070
24556
  headers: { "content-type": "application/samlmetadata+xml" },
24071
- status: HTTP_OK3
24557
+ status: HTTP_OK4
24072
24558
  });
24073
24559
  var htmlResponse = (body) => new Response(body, {
24074
24560
  headers: { "content-type": "text/html; charset=utf-8" },
24075
- status: HTTP_OK3
24561
+ status: HTTP_OK4
24076
24562
  });
24077
24563
  var redirectTo2 = (url) => new Response(null, { headers: { location: url }, status: HTTP_FOUND2 });
24078
24564
  var errorJson = (status, error) => new Response(JSON.stringify({ error }), {
@@ -24124,7 +24610,7 @@ var samlIdpRoutes = ({
24124
24610
  userSessionIdValue
24125
24611
  }) => {
24126
24612
  if (body.SAMLRequest === undefined) {
24127
- return errorJson(HTTP_BAD_REQUEST3, "missing_saml_request");
24613
+ return errorJson(HTTP_BAD_REQUEST4, "missing_saml_request");
24128
24614
  }
24129
24615
  let firstPass;
24130
24616
  try {
@@ -24133,11 +24619,11 @@ var samlIdpRoutes = ({
24133
24619
  samlRequest: body.SAMLRequest
24134
24620
  });
24135
24621
  } catch {
24136
- return errorJson(HTTP_BAD_REQUEST3, "invalid_authn_request");
24622
+ return errorJson(HTTP_BAD_REQUEST4, "invalid_authn_request");
24137
24623
  }
24138
24624
  const serviceProvider = await samlServiceProviderStore.findServiceProvider(firstPass.issuer);
24139
24625
  if (serviceProvider === undefined) {
24140
- return errorJson(HTTP_BAD_REQUEST3, "unknown_service_provider");
24626
+ return errorJson(HTTP_BAD_REQUEST4, "unknown_service_provider");
24141
24627
  }
24142
24628
  let parsed;
24143
24629
  try {
@@ -24150,7 +24636,7 @@ var samlIdpRoutes = ({
24150
24636
  signedQueryString: binding === "Redirect" ? new URL(request.url).search.slice(1) : undefined
24151
24637
  });
24152
24638
  } catch {
24153
- return errorJson(HTTP_BAD_REQUEST3, "invalid_authn_request");
24639
+ return errorJson(HTTP_BAD_REQUEST4, "invalid_authn_request");
24154
24640
  }
24155
24641
  const userSession = await loadSessionFromSource({
24156
24642
  authSessionStore,
@@ -24159,7 +24645,7 @@ var samlIdpRoutes = ({
24159
24645
  });
24160
24646
  if (userSession === undefined || parsed.forceAuthn === true) {
24161
24647
  if (loginUrl === undefined) {
24162
- return errorJson(HTTP_UNAUTHORIZED3, "login_required");
24648
+ return errorJson(HTTP_UNAUTHORIZED4, "login_required");
24163
24649
  }
24164
24650
  return redirectTo2(`${loginUrl}?return_to=${encodeURIComponent(request.url)}`);
24165
24651
  }
@@ -24171,7 +24657,7 @@ var samlIdpRoutes = ({
24171
24657
  user: userSession.user
24172
24658
  });
24173
24659
  };
24174
- return new Elysia35().use(sessionStore()).post(ssoIdpRoute, async ({
24660
+ return new Elysia36().use(sessionStore()).post(ssoIdpRoute, async ({
24175
24661
  body,
24176
24662
  cookie: { user_session_id },
24177
24663
  request,
@@ -24183,12 +24669,12 @@ var samlIdpRoutes = ({
24183
24669
  request,
24184
24670
  userSessionIdValue: user_session_id.value
24185
24671
  }), {
24186
- body: t31.Object({
24187
- RelayState: t31.Optional(t31.String()),
24188
- SAMLRequest: t31.Optional(t31.String())
24672
+ body: t32.Object({
24673
+ RelayState: t32.Optional(t32.String()),
24674
+ SAMLRequest: t32.Optional(t32.String())
24189
24675
  }),
24190
- cookie: t31.Cookie({
24191
- user_session_id: t31.Optional(userSessionIdTypebox)
24676
+ cookie: t32.Cookie({
24677
+ user_session_id: t32.Optional(userSessionIdTypebox)
24192
24678
  })
24193
24679
  }).get(ssoIdpRoute, async ({
24194
24680
  cookie: { user_session_id },
@@ -24202,14 +24688,14 @@ var samlIdpRoutes = ({
24202
24688
  request,
24203
24689
  userSessionIdValue: user_session_id.value
24204
24690
  }), {
24205
- cookie: t31.Cookie({
24206
- user_session_id: t31.Optional(userSessionIdTypebox)
24691
+ cookie: t32.Cookie({
24692
+ user_session_id: t32.Optional(userSessionIdTypebox)
24207
24693
  }),
24208
- query: t31.Object({
24209
- RelayState: t31.Optional(t31.String()),
24210
- SAMLRequest: t31.Optional(t31.String()),
24211
- SigAlg: t31.Optional(t31.String()),
24212
- Signature: t31.Optional(t31.String())
24694
+ query: t32.Object({
24695
+ RelayState: t32.Optional(t32.String()),
24696
+ SAMLRequest: t32.Optional(t32.String()),
24697
+ SigAlg: t32.Optional(t32.String()),
24698
+ Signature: t32.Optional(t32.String())
24213
24699
  })
24214
24700
  }).get(idpInitiateRoute, async ({
24215
24701
  cookie: { user_session_id },
@@ -24218,11 +24704,11 @@ var samlIdpRoutes = ({
24218
24704
  store
24219
24705
  }) => {
24220
24706
  if (serviceProviderEntityId === undefined) {
24221
- return errorJson(HTTP_BAD_REQUEST3, "missing_sp");
24707
+ return errorJson(HTTP_BAD_REQUEST4, "missing_sp");
24222
24708
  }
24223
24709
  const serviceProvider = await samlServiceProviderStore.findServiceProvider(serviceProviderEntityId);
24224
24710
  if (serviceProvider === undefined) {
24225
- return errorJson(HTTP_BAD_REQUEST3, "unknown_service_provider");
24711
+ return errorJson(HTTP_BAD_REQUEST4, "unknown_service_provider");
24226
24712
  }
24227
24713
  const userSession = authSessionStore === undefined ? await loadSessionFromSource({
24228
24714
  session: store.session,
@@ -24234,7 +24720,7 @@ var samlIdpRoutes = ({
24234
24720
  });
24235
24721
  if (userSession === undefined) {
24236
24722
  if (loginUrl === undefined) {
24237
- return errorJson(HTTP_UNAUTHORIZED3, "login_required");
24723
+ return errorJson(HTTP_UNAUTHORIZED4, "login_required");
24238
24724
  }
24239
24725
  return redirectTo2(`${loginUrl}?return_to=${encodeURIComponent(request.url)}`);
24240
24726
  }
@@ -24245,12 +24731,12 @@ var samlIdpRoutes = ({
24245
24731
  user: userSession.user
24246
24732
  });
24247
24733
  }, {
24248
- cookie: t31.Cookie({
24249
- user_session_id: t31.Optional(userSessionIdTypebox)
24734
+ cookie: t32.Cookie({
24735
+ user_session_id: t32.Optional(userSessionIdTypebox)
24250
24736
  }),
24251
- query: t31.Object({
24252
- RelayState: t31.Optional(t31.String()),
24253
- sp: t31.Optional(t31.String())
24737
+ query: t32.Object({
24738
+ RelayState: t32.Optional(t32.String()),
24739
+ sp: t32.Optional(t32.String())
24254
24740
  })
24255
24741
  }).get(idpMetadataRoute, async ({ request }) => xmlResponse(await idpAdapter.getIdpMetadata({
24256
24742
  entityId: idpEntityId,
@@ -24548,7 +25034,7 @@ var auth = async ({
24548
25034
  const auditedOnCallbackSuccess = auditEmit ? composeCallbackAudit(onCallbackSuccess, auditEmit) : onCallbackSuccess;
24549
25035
  const auditedOnRevocationSuccess = auditEmit ? composeRevocationAudit(onRevocationSuccess, auditEmit) : onRevocationSuccess;
24550
25036
  const auditedOnSignOut = auditEmit ? composeSignOutAudit(onSignOut, auditEmit) : onSignOut;
24551
- return new Elysia36().use(sessionCleanup({
25037
+ return new Elysia37().use(sessionCleanup({
24552
25038
  authSessionStore,
24553
25039
  cleanupIntervalMs,
24554
25040
  maxSessions,
@@ -24596,53 +25082,53 @@ var auth = async ({
24596
25082
  authSessionStore,
24597
25083
  cookieSecure: resolvedCookieSecure,
24598
25084
  lockoutGuard
24599
- }) : new Elysia36).use(auditedMfa ? mfaRoutes({
25085
+ }) : new Elysia37).use(auditedMfa ? mfaRoutes({
24600
25086
  ...auditedMfa,
24601
25087
  authSessionStore,
24602
25088
  cookieSecure: resolvedCookieSecure
24603
- }) : new Elysia36).use(passwordless ? passwordlessRoutes({
25089
+ }) : new Elysia37).use(passwordless ? passwordlessRoutes({
24604
25090
  ...passwordless,
24605
25091
  authSessionStore,
24606
25092
  cookieSecure: resolvedCookieSecure,
24607
25093
  emit: auditEmit
24608
- }) : new Elysia36).use(sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia36).use(sso ? oidcSsoRoutes({
25094
+ }) : new Elysia37).use(sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia37).use(sso ? oidcSsoRoutes({
24609
25095
  ...sso,
24610
25096
  authSessionStore,
24611
25097
  cookieSecure: resolvedCookieSecure
24612
- }) : new Elysia36).use(sso && sso.samlAdapter ? samlSsoRoutes({
25098
+ }) : new Elysia37).use(sso && sso.samlAdapter ? samlSsoRoutes({
24613
25099
  ...sso,
24614
25100
  authSessionStore,
24615
25101
  cookieSecure: resolvedCookieSecure,
24616
25102
  samlAdapter: sso.samlAdapter
24617
- }) : new Elysia36).use(sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
25103
+ }) : new Elysia37).use(sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
24618
25104
  getOrganizationByEmailDomain: sso.getOrganizationByEmailDomain,
24619
25105
  ssoConnectionStore: sso.ssoConnectionStore,
24620
25106
  ssoRoute: sso.ssoRoute
24621
- }) : new Elysia36).use(scim ? scimRoutes(scim) : new Elysia36).use(apikeys ? apiKeysRoutes(apikeys) : new Elysia36).use(oidc ? oidcProviderRoutes({ ...oidc, authSessionStore }) : new Elysia36).use(organizations ? organizationRoutes({
25107
+ }) : new Elysia37).use(scim ? scimRoutes(scim) : new Elysia37).use(apikeys ? apiKeysRoutes(apikeys) : new Elysia37).use(oidc ? oidcProviderRoutes({ ...oidc, authSessionStore }) : new Elysia37).use(organizations ? organizationRoutes({
24622
25108
  ...organizations,
24623
25109
  authSessionStore,
24624
25110
  emit: auditEmit
24625
- }) : new Elysia36).use(roles ? roleRoutes({
25111
+ }) : new Elysia37).use(roles ? roleRoutes({
24626
25112
  ...roles,
24627
25113
  authSessionStore,
24628
25114
  emit: auditEmit
24629
- }) : new Elysia36).use(portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia36).use(webauthn ? webauthnRoutes({
25115
+ }) : new Elysia37).use(portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia37).use(webauthn ? webauthnRoutes({
24630
25116
  ...webauthn,
24631
25117
  authSessionStore,
24632
25118
  cookieSecure: resolvedCookieSecure,
24633
25119
  emit: auditEmit
24634
- }) : new Elysia36).use(compliance ? complianceRoutes({
25120
+ }) : new Elysia37).use(compliance ? complianceRoutes({
24635
25121
  ...compliance,
24636
25122
  authSessionStore,
24637
25123
  emit: auditEmit
24638
- }) : new Elysia36).use(protectRoutePlugin({ authSessionStore })).use(stepUpPlugin({ authSessionStore })).use(authorization ? protectPermissionPlugin({
25124
+ }) : new Elysia37).use(protectRoutePlugin({ authSessionStore })).use(stepUpPlugin({ authSessionStore })).use(authorization ? protectPermissionPlugin({
24639
25125
  ...authorization,
24640
25126
  authSessionStore,
24641
25127
  emit: auditEmit
24642
- }) : new Elysia36).use(htmx ? createAuthHtmxRoutes({
25128
+ }) : new Elysia37).use(htmx ? createAuthHtmxRoutes({
24643
25129
  ...htmx,
24644
25130
  authSessionStore
24645
- }) : new Elysia36);
25131
+ }) : new Elysia37);
24646
25132
  };
24647
25133
  export {
24648
25134
  writeWarrant,
@@ -24655,6 +25141,7 @@ export {
24655
25141
  verifyWebhookSignature,
24656
25142
  verifyTurnstile,
24657
25143
  verifyTotp,
25144
+ verifySdJwtVc,
24658
25145
  verifyRecaptcha,
24659
25146
  verifyPkce,
24660
25147
  verifyPassword,
@@ -24671,6 +25158,7 @@ export {
24671
25158
  verifyAuditChain,
24672
25159
  verifyApiKey,
24673
25160
  verifyAccessToken,
25161
+ vciRoutes,
24674
25162
  vaultEntriesTable,
24675
25163
  validateSession,
24676
25164
  validateEmailDeliverability,
@@ -24679,6 +25167,7 @@ export {
24679
25167
  updateRegisteredClient,
24680
25168
  trustDevice,
24681
25169
  toPublicJwk,
25170
+ toBase64Url2 as toBase64Url,
24682
25171
  switchActiveSession,
24683
25172
  stepUpPlugin,
24684
25173
  startImpersonation,
@@ -24732,11 +25221,13 @@ export {
24732
25221
  providerOptions,
24733
25222
  protectRoutePlugin,
24734
25223
  protectPermissionPlugin,
25224
+ presentSdJwtVc,
24735
25225
  portalRoutes,
24736
25226
  pkceProviderOptions,
24737
25227
  passwordlessTokensTable,
24738
25228
  passwordlessRoutes,
24739
25229
  parseSignedRequestObject,
25230
+ parseSdJwtVc,
24740
25231
  parseSchema,
24741
25232
  organizationsTable,
24742
25233
  organizationRoutes,
@@ -24772,7 +25263,9 @@ export {
24772
25263
  knownDevicesTable,
24773
25264
  jwkThumbprint,
24774
25265
  issueTokenSet,
25266
+ issueSdJwtVc,
24775
25267
  issueDeviceAuthorization,
25268
+ issueCredential,
24776
25269
  issueBackchannelAuth,
24777
25270
  isValidUser,
24778
25271
  isValidProviderOption,
@@ -24811,6 +25304,7 @@ export {
24811
25304
  generateSecureToken,
24812
25305
  generateEncryptionKey,
24813
25306
  generateBackupCodes,
25307
+ fromBase64Url2 as fromBase64Url,
24814
25308
  fingerprintDevice,
24815
25309
  fetchUserInfo,
24816
25310
  fanOutBackchannelLogout,
@@ -24819,6 +25313,7 @@ export {
24819
25313
  extractDpopNonceClaim,
24820
25314
  exportAuditCsv,
24821
25315
  exchangeToken,
25316
+ exchangePreAuthorizedCode,
24822
25317
  exchangeDeviceCode,
24823
25318
  exchangeClientCredentials,
24824
25319
  exchangeBackchannelAuth,
@@ -24953,6 +25448,8 @@ export {
24953
25448
  createInMemoryInitialAccessTokenStore,
24954
25449
  createInMemoryDeviceAuthorizationStore,
24955
25450
  createInMemoryCredentialStore,
25451
+ createInMemoryCredentialOfferStore,
25452
+ createInMemoryCredentialNonceStore,
24956
25453
  createInMemoryClientRegistrationTokenStore,
24957
25454
  createInMemoryClientAssertionJtiStore,
24958
25455
  createInMemoryCheckCache,
@@ -24965,6 +25462,7 @@ export {
24965
25462
  createInMemoryAccessTokenStore,
24966
25463
  createFgaEngine,
24967
25464
  createFederatedTokenStore,
25465
+ createCredentialOffer,
24968
25466
  createAuthHtmxRoutes,
24969
25467
  createAuditRedactor,
24970
25468
  createAuditEmitter,
@@ -24979,6 +25477,7 @@ export {
24979
25477
  computeCertThumbprint,
24980
25478
  complianceRoutes,
24981
25479
  check,
25480
+ buildIssuerMetadata,
24982
25481
  buildClientProviders,
24983
25482
  blockMigrations,
24984
25483
  base32Encode,
@@ -25000,12 +25499,14 @@ export {
25000
25499
  acceptInvitation,
25001
25500
  WEBAUTHN_CHALLENGE_COOKIE,
25002
25501
  REQUEST_URI_PREFIX,
25502
+ PRE_AUTHORIZED_CODE_GRANT,
25003
25503
  DEFAULT_WEBHOOK_TIMEOUT_MS,
25004
25504
  DEFAULT_WEBHOOK_RETRY,
25005
25505
  DEFAULT_WEBAUTHN_SESSION_TTL_MS,
25006
25506
  DEFAULT_WEBAUTHN_ROUTE,
25007
25507
  DEFAULT_WEBAUTHN_CHALLENGE_TTL_MS,
25008
25508
  DEFAULT_VERIFICATION_TOKEN_TTL_MS,
25509
+ DEFAULT_VCI_ROUTE,
25009
25510
  DEFAULT_TOKEN_ROUTE,
25010
25511
  DEFAULT_SSO_SESSION_TTL_MS,
25011
25512
  DEFAULT_SSO_ROUTE,
@@ -25033,5 +25534,5 @@ export {
25033
25534
  AuthIdentityConflictError
25034
25535
  };
25035
25536
 
25036
- //# debugId=5A0B79F67182545764756E2164756E21
25537
+ //# debugId=72970D27E7C7DE2F64756E2164756E21
25037
25538
  //# sourceMappingURL=index.js.map