@aura-stack/auth 0.4.0-rc.4 → 0.4.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.
Files changed (143) hide show
  1. package/dist/@types/index.d.ts +4 -3
  2. package/dist/@types/router.d.cjs +0 -17
  3. package/dist/@types/router.d.d.ts +3 -2
  4. package/dist/@types/router.d.js +0 -1
  5. package/dist/actions/callback/access-token.cjs +40 -25
  6. package/dist/actions/callback/access-token.d.ts +4 -3
  7. package/dist/actions/callback/access-token.js +3 -4
  8. package/dist/actions/callback/callback.cjs +287 -77
  9. package/dist/actions/callback/callback.d.ts +5 -26
  10. package/dist/actions/callback/callback.js +13 -10
  11. package/dist/actions/callback/userinfo.cjs +68 -7
  12. package/dist/actions/callback/userinfo.d.ts +4 -3
  13. package/dist/actions/callback/userinfo.js +8 -6
  14. package/dist/actions/csrfToken/csrfToken.cjs +63 -4
  15. package/dist/actions/csrfToken/csrfToken.d.ts +1 -3
  16. package/dist/actions/csrfToken/csrfToken.js +8 -6
  17. package/dist/actions/index.cjs +400 -175
  18. package/dist/actions/index.d.ts +3 -2
  19. package/dist/actions/index.js +21 -19
  20. package/dist/actions/session/session.cjs +40 -11
  21. package/dist/actions/session/session.d.ts +1 -3
  22. package/dist/actions/session/session.js +4 -4
  23. package/dist/actions/signIn/authorization.cjs +171 -132
  24. package/dist/actions/signIn/authorization.d.ts +21 -11
  25. package/dist/actions/signIn/authorization.js +8 -6
  26. package/dist/actions/signIn/signIn.cjs +220 -113
  27. package/dist/actions/signIn/signIn.d.ts +5 -25
  28. package/dist/actions/signIn/signIn.js +9 -7
  29. package/dist/actions/signOut/signOut.cjs +268 -119
  30. package/dist/actions/signOut/signOut.d.ts +1 -9
  31. package/dist/actions/signOut/signOut.js +10 -8
  32. package/dist/assert.cjs +117 -5
  33. package/dist/assert.d.ts +22 -3
  34. package/dist/assert.js +17 -3
  35. package/dist/chunk-4EKY7655.js +123 -0
  36. package/dist/chunk-4MYWAOLG.js +31 -0
  37. package/dist/chunk-4YHJ4IEQ.js +25 -0
  38. package/dist/chunk-54CZPKR4.js +25 -0
  39. package/dist/chunk-5LZ7TOM3.js +25 -0
  40. package/dist/{chunk-W6LG7BFW.js → chunk-5W4BRQYG.js} +24 -20
  41. package/dist/chunk-6MXFPFR3.js +143 -0
  42. package/dist/{chunk-3EUWD5BB.js → chunk-7QF22LHP.js} +13 -9
  43. package/dist/chunk-ALG3GIV4.js +95 -0
  44. package/dist/chunk-E6G5YCI6.js +25 -0
  45. package/dist/chunk-EBAMFRB7.js +34 -0
  46. package/dist/chunk-EEE7UM5T.js +25 -0
  47. package/dist/{chunk-TLE4PXY3.js → chunk-FRJFWTOY.js} +38 -7
  48. package/dist/chunk-FW4W3REU.js +25 -0
  49. package/dist/{chunk-HT4YLL7N.js → chunk-ICAZ4OVS.js} +10 -8
  50. package/dist/chunk-IPKO6UQN.js +25 -0
  51. package/dist/{chunk-YRCB5FLE.js → chunk-KJBAQZX2.js} +13 -0
  52. package/dist/chunk-KMMAZFSJ.js +25 -0
  53. package/dist/chunk-LDU7A2JE.js +25 -0
  54. package/dist/{chunk-N2APGLXA.js → chunk-NUDITUKX.js} +18 -16
  55. package/dist/chunk-OVHNRULD.js +33 -0
  56. package/dist/{chunk-JVFTCTTE.js → chunk-PHFH2MGS.js} +12 -9
  57. package/dist/chunk-QQVSRXGX.js +149 -0
  58. package/dist/chunk-TM5IPSNF.js +113 -0
  59. package/dist/{chunk-GA2SMTJO.js → chunk-TZB6MUXN.js} +33 -13
  60. package/dist/chunk-VNCNJKS2.js +267 -0
  61. package/dist/{chunk-IVET23KF.js → chunk-XGLBNXL4.js} +31 -14
  62. package/dist/chunk-XUP6KKNG.js +106 -0
  63. package/dist/cookie.cjs +24 -20
  64. package/dist/cookie.d.ts +4 -3
  65. package/dist/cookie.js +1 -1
  66. package/dist/env.cjs +56 -0
  67. package/dist/env.d.ts +7 -0
  68. package/dist/env.js +6 -0
  69. package/dist/errors.d.ts +4 -3
  70. package/dist/headers.cjs +28 -2
  71. package/dist/headers.d.ts +25 -1
  72. package/dist/headers.js +9 -3
  73. package/dist/{index-DkaLJFn8.d.ts → index-CSyIJmCM.d.ts} +373 -45
  74. package/dist/index.cjs +1128 -483
  75. package/dist/index.d.ts +6 -10
  76. package/dist/index.js +83 -42
  77. package/dist/jose.cjs +62 -25
  78. package/dist/jose.d.ts +7 -5
  79. package/dist/jose.js +8 -6
  80. package/dist/logger.cjs +292 -0
  81. package/dist/logger.d.ts +8 -0
  82. package/dist/logger.js +8 -0
  83. package/dist/oauth/bitbucket.cjs +19 -15
  84. package/dist/oauth/bitbucket.d.ts +3 -2
  85. package/dist/oauth/bitbucket.js +1 -1
  86. package/dist/oauth/discord.cjs +27 -24
  87. package/dist/oauth/discord.d.ts +3 -2
  88. package/dist/oauth/discord.js +1 -1
  89. package/dist/oauth/figma.cjs +19 -16
  90. package/dist/oauth/figma.d.ts +3 -2
  91. package/dist/oauth/figma.js +1 -1
  92. package/dist/oauth/github.cjs +19 -8
  93. package/dist/oauth/github.d.ts +3 -2
  94. package/dist/oauth/github.js +1 -1
  95. package/dist/oauth/gitlab.cjs +19 -16
  96. package/dist/oauth/gitlab.d.ts +3 -2
  97. package/dist/oauth/gitlab.js +1 -1
  98. package/dist/oauth/index.cjs +266 -166
  99. package/dist/oauth/index.d.ts +3 -2
  100. package/dist/oauth/index.js +22 -21
  101. package/dist/oauth/mailchimp.cjs +19 -16
  102. package/dist/oauth/mailchimp.d.ts +3 -2
  103. package/dist/oauth/mailchimp.js +1 -1
  104. package/dist/oauth/pinterest.cjs +19 -16
  105. package/dist/oauth/pinterest.d.ts +3 -2
  106. package/dist/oauth/pinterest.js +1 -1
  107. package/dist/oauth/spotify.cjs +19 -16
  108. package/dist/oauth/spotify.d.ts +3 -2
  109. package/dist/oauth/spotify.js +1 -1
  110. package/dist/oauth/strava.cjs +19 -16
  111. package/dist/oauth/strava.d.ts +3 -2
  112. package/dist/oauth/strava.js +1 -1
  113. package/dist/oauth/x.cjs +19 -16
  114. package/dist/oauth/x.d.ts +3 -2
  115. package/dist/oauth/x.js +1 -1
  116. package/dist/schemas.cjs +16 -2
  117. package/dist/schemas.d.ts +17 -1
  118. package/dist/schemas.js +5 -3
  119. package/dist/secure.cjs +58 -16
  120. package/dist/secure.d.ts +4 -10
  121. package/dist/secure.js +5 -5
  122. package/dist/utils.cjs +94 -87
  123. package/dist/utils.d.ts +9 -39
  124. package/dist/utils.js +11 -9
  125. package/package.json +3 -4
  126. package/dist/chunk-42XB3YCW.js +0 -22
  127. package/dist/chunk-6R2YZ4AC.js +0 -22
  128. package/dist/chunk-A3N4PVAT.js +0 -70
  129. package/dist/chunk-B737EUJV.js +0 -22
  130. package/dist/chunk-CXLATHS5.js +0 -143
  131. package/dist/chunk-DIVDFNAP.js +0 -0
  132. package/dist/chunk-E3OXBRYF.js +0 -22
  133. package/dist/chunk-EIL2FPSS.js +0 -22
  134. package/dist/chunk-EMKJA2GJ.js +0 -89
  135. package/dist/chunk-FIPU4MLT.js +0 -21
  136. package/dist/chunk-FKRDCWBF.js +0 -22
  137. package/dist/chunk-HP34YGGJ.js +0 -22
  138. package/dist/chunk-IKHPGFCW.js +0 -14
  139. package/dist/chunk-IUYZQTJV.js +0 -30
  140. package/dist/chunk-KRNOMBXQ.js +0 -22
  141. package/dist/chunk-KSWLO5ZU.js +0 -102
  142. package/dist/chunk-N4SX7TZT.js +0 -96
  143. package/dist/chunk-STHEPPUZ.js +0 -11
package/dist/index.d.ts CHANGED
@@ -1,12 +1,11 @@
1
- import { d as AuthConfig, e as AuthInstance, f as JoseInstance } from './index-DkaLJFn8.js';
2
- export { C as CookieConfig, E as ErrorType, O as OAuthProvider, g as OAuthProviderConfig, h as OAuthProviderCredentials, S as Session, U as User } from './index-DkaLJFn8.js';
3
- export { createClient } from '@aura-stack/router';
4
- import './@types/router.d.js';
1
+ import { d as AuthConfig, e as AuthInstance } from './index-CSyIJmCM.js';
2
+ export { C as CookieConfig, E as ErrorType, f as JoseInstance, i as LogLevel, L as Logger, O as OAuthProvider, g as OAuthProviderConfig, h as OAuthProviderCredentials, S as Session, T as TrustedOrigin, U as User } from './index-CSyIJmCM.js';
5
3
  import 'zod';
6
4
  import './schemas.js';
7
- import '@aura-stack/router/cookie';
5
+ import './jose.js';
8
6
  import '@aura-stack/jose';
9
7
  import '@aura-stack/jose/jose';
8
+ import '@aura-stack/router/cookie';
10
9
  import './@types/utility.js';
11
10
 
12
11
  /**
@@ -31,9 +30,6 @@ import './@types/utility.js';
31
30
  * }]
32
31
  * })
33
32
  */
34
- declare const createAuth: (authConfig: AuthConfig) => {
35
- handlers: AuthInstance["handlers"];
36
- jose: JoseInstance;
37
- };
33
+ declare const createAuth: (authConfig: AuthConfig) => AuthInstance;
38
34
 
39
- export { AuthConfig, AuthInstance, JoseInstance, createAuth };
35
+ export { AuthConfig, AuthInstance, createAuth };
package/dist/index.js CHANGED
@@ -1,73 +1,115 @@
1
1
  import {
2
2
  createBuiltInOAuthProviders
3
- } from "./chunk-EMKJA2GJ.js";
4
- import "./chunk-42XB3YCW.js";
5
- import "./chunk-FKRDCWBF.js";
6
- import "./chunk-IKHPGFCW.js";
7
- import "./chunk-KRNOMBXQ.js";
8
- import "./chunk-B737EUJV.js";
9
- import "./chunk-HP34YGGJ.js";
10
- import "./chunk-E3OXBRYF.js";
11
- import "./chunk-6R2YZ4AC.js";
12
- import "./chunk-DIVDFNAP.js";
3
+ } from "./chunk-TM5IPSNF.js";
4
+ import "./chunk-IPKO6UQN.js";
5
+ import "./chunk-54CZPKR4.js";
6
+ import "./chunk-EEE7UM5T.js";
7
+ import "./chunk-4YHJ4IEQ.js";
8
+ import "./chunk-OVHNRULD.js";
9
+ import "./chunk-KMMAZFSJ.js";
10
+ import "./chunk-FW4W3REU.js";
11
+ import "./chunk-5LZ7TOM3.js";
12
+ import "./chunk-LDU7A2JE.js";
13
+ import "./chunk-E6G5YCI6.js";
13
14
  import "./chunk-ITQ7352M.js";
15
+ import {
16
+ signInAction
17
+ } from "./chunk-7QF22LHP.js";
18
+ import {
19
+ csrfTokenAction
20
+ } from "./chunk-ICAZ4OVS.js";
14
21
  import {
15
22
  signOutAction
16
- } from "./chunk-A3N4PVAT.js";
23
+ } from "./chunk-ALG3GIV4.js";
17
24
  import {
18
25
  callbackAction
19
- } from "./chunk-KSWLO5ZU.js";
20
- import "./chunk-GA2SMTJO.js";
21
- import "./chunk-IVET23KF.js";
22
- import {
23
- csrfTokenAction
24
- } from "./chunk-HT4YLL7N.js";
26
+ } from "./chunk-6MXFPFR3.js";
27
+ import "./chunk-TZB6MUXN.js";
28
+ import "./chunk-XGLBNXL4.js";
25
29
  import {
26
30
  sessionAction
27
- } from "./chunk-JVFTCTTE.js";
31
+ } from "./chunk-PHFH2MGS.js";
32
+ import "./chunk-XUP6KKNG.js";
33
+ import "./chunk-ZNCZVF6U.js";
34
+ import "./chunk-KJBAQZX2.js";
35
+ import "./chunk-NUDITUKX.js";
36
+ import "./chunk-4EKY7655.js";
28
37
  import {
29
- signInAction
30
- } from "./chunk-3EUWD5BB.js";
31
- import "./chunk-N4SX7TZT.js";
32
- import "./chunk-FIPU4MLT.js";
33
- import "./chunk-IUYZQTJV.js";
38
+ createErrorHandler,
39
+ useSecureCookies
40
+ } from "./chunk-QQVSRXGX.js";
34
41
  import {
35
42
  createCookieStore
36
- } from "./chunk-W6LG7BFW.js";
37
- import "./chunk-STHEPPUZ.js";
43
+ } from "./chunk-5W4BRQYG.js";
44
+ import "./chunk-EBAMFRB7.js";
38
45
  import {
39
46
  createJoseInstance
40
- } from "./chunk-TLE4PXY3.js";
41
- import "./chunk-N2APGLXA.js";
42
- import {
43
- onErrorHandler,
44
- useSecureCookies
45
- } from "./chunk-CXLATHS5.js";
46
- import "./chunk-EIL2FPSS.js";
47
+ } from "./chunk-FRJFWTOY.js";
48
+ import "./chunk-4MYWAOLG.js";
47
49
  import "./chunk-RRLIF4PQ.js";
48
- import "./chunk-ZNCZVF6U.js";
49
- import "./chunk-YRCB5FLE.js";
50
+ import {
51
+ createLogEntry
52
+ } from "./chunk-VNCNJKS2.js";
50
53
 
51
54
  // src/index.ts
52
- import "dotenv/config";
53
- import { createRouter, createClient } from "@aura-stack/router";
55
+ import { createRouter } from "@aura-stack/router";
56
+ var logLevelToSeverity = {
57
+ debug: ["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"],
58
+ info: ["info", "notice", "warning", "error", "critical", "alert", "emergency"],
59
+ warn: ["warning", "error", "critical", "alert", "emergency"],
60
+ error: ["error", "critical", "alert", "emergency"]
61
+ };
62
+ var createLoggerProxy = (logger) => {
63
+ if (!logger) return void 0;
64
+ const level = logger.level;
65
+ const allowedSeverities = logLevelToSeverity[level] ?? [];
66
+ const internalLogger = {
67
+ level,
68
+ log(key, overrides) {
69
+ const entry = createLogEntry(key, overrides);
70
+ if (!allowedSeverities.includes(entry.severity)) return entry;
71
+ logger.log({
72
+ timestamp: entry.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
73
+ appName: entry.appName ?? "aura-auth",
74
+ hostname: entry.hostname ?? "aura-auth",
75
+ ...entry
76
+ });
77
+ return entry;
78
+ }
79
+ };
80
+ return internalLogger;
81
+ };
54
82
  var createInternalConfig = (authConfig) => {
55
83
  const useSecure = authConfig?.trustedProxyHeaders ?? false;
84
+ const logger = authConfig?.logger;
85
+ const internalLogger = createLoggerProxy(logger);
56
86
  return {
57
87
  basePath: authConfig?.basePath ?? "/auth",
58
- onError: onErrorHandler,
88
+ onError: createErrorHandler(internalLogger),
59
89
  context: {
60
90
  oauth: createBuiltInOAuthProviders(authConfig?.oauth),
61
- cookies: createCookieStore(useSecure, authConfig?.cookies?.prefix, authConfig?.cookies?.overrides ?? {}),
91
+ cookies: createCookieStore(
92
+ useSecure,
93
+ authConfig?.cookies?.prefix,
94
+ authConfig?.cookies?.overrides ?? {},
95
+ internalLogger
96
+ ),
62
97
  jose: createJoseInstance(authConfig?.secret),
63
98
  secret: authConfig?.secret,
64
99
  basePath: authConfig?.basePath ?? "/auth",
65
- trustedProxyHeaders: useSecure
100
+ trustedProxyHeaders: useSecure,
101
+ trustedOrigins: authConfig?.trustedOrigins,
102
+ logger: internalLogger
66
103
  },
67
104
  middlewares: [
68
105
  (ctx) => {
69
106
  const useSecure2 = useSecureCookies(ctx.request, ctx.context.trustedProxyHeaders);
70
- const cookies = createCookieStore(useSecure2, authConfig?.cookies?.prefix, authConfig?.cookies?.overrides ?? {});
107
+ const cookies = createCookieStore(
108
+ useSecure2,
109
+ authConfig?.cookies?.prefix,
110
+ authConfig?.cookies?.overrides ?? {},
111
+ internalLogger
112
+ );
71
113
  ctx.context.cookies = cookies;
72
114
  return ctx;
73
115
  }
@@ -86,6 +128,5 @@ var createAuth = (authConfig) => {
86
128
  };
87
129
  };
88
130
  export {
89
- createAuth,
90
- createClient
131
+ createAuth
91
132
  };
package/dist/jose.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,30 +15,48 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/jose.ts
31
21
  var jose_exports = {};
32
22
  __export(jose_exports, {
33
- createJoseInstance: () => createJoseInstance
23
+ createJoseInstance: () => createJoseInstance,
24
+ decodeJWTOptions: () => decodeJWTOptions,
25
+ jwtVerificationOptions: () => jwtVerificationOptions
34
26
  });
35
27
  module.exports = __toCommonJS(jose_exports);
36
- var import_config = require("dotenv/config");
37
- var import_jose = require("@aura-stack/jose");
38
28
 
39
- // src/secure.ts
40
- var import_crypto = __toESM(require("crypto"), 1);
29
+ // src/env.ts
30
+ var import_meta = {};
31
+ var env = new Proxy({}, {
32
+ get(_, prop) {
33
+ if (typeof prop !== "string") return void 0;
34
+ const hasProperty = (process2) => {
35
+ return process2 && Object.prototype.hasOwnProperty.call(process2, prop);
36
+ };
37
+ try {
38
+ if (typeof process !== "undefined" && hasProperty(process.env)) {
39
+ return process.env[prop];
40
+ }
41
+ if (typeof import_meta !== "undefined" && hasProperty(import_meta.env)) {
42
+ return import_meta.env[prop];
43
+ }
44
+ if (typeof Deno !== "undefined" && Deno.env?.get) {
45
+ return Deno.env.get(prop);
46
+ }
47
+ if (typeof Bun !== "undefined" && hasProperty(Bun.env)) {
48
+ return Bun.env[prop];
49
+ }
50
+ const globalValue = globalThis[prop];
51
+ return typeof globalValue === "string" ? globalValue : void 0;
52
+ } catch {
53
+ return void 0;
54
+ }
55
+ }
56
+ });
41
57
 
42
- // src/utils.ts
43
- var import_router = require("@aura-stack/router");
58
+ // src/jose.ts
59
+ var import_jose = require("@aura-stack/jose");
44
60
 
45
61
  // src/errors.ts
46
62
  var AuthInternalError = class extends Error {
@@ -54,14 +70,8 @@ var AuthInternalError = class extends Error {
54
70
  }
55
71
  };
56
72
 
57
- // src/secure.ts
58
- var createDerivedSalt = (secret) => {
59
- return import_crypto.default.createHash("sha256").update(secret).update("aura-auth-salt").digest("hex");
60
- };
61
-
62
73
  // src/jose.ts
63
74
  var createJoseInstance = (secret) => {
64
- const env = process.env;
65
75
  secret ??= env.AURA_AUTH_SECRET ?? env.AUTH_SECRET;
66
76
  if (!secret) {
67
77
  throw new AuthInternalError(
@@ -69,7 +79,22 @@ var createJoseInstance = (secret) => {
69
79
  "AURA_AUTH_SECRET environment variable is not set and no secret was provided."
70
80
  );
71
81
  }
72
- const salt = env.AURA_AUTH_SALT ?? env.AUTH_SALT ?? createDerivedSalt(secret);
82
+ const salt = env.AURA_AUTH_SALT ?? env.AUTH_SALT;
83
+ if (!salt) {
84
+ throw new AuthInternalError(
85
+ "JOSE_INITIALIZATION_FAILED",
86
+ "AURA_AUTH_SALT or AUTH_SALT environment variable is not set. A salt value is required for key derivation."
87
+ );
88
+ }
89
+ try {
90
+ (0, import_jose.createSecret)(salt);
91
+ } catch (error) {
92
+ throw new AuthInternalError(
93
+ "INVALID_SALT_SECRET_VALUE",
94
+ "AURA_AUTH_SALT/AUTH_SALT is invalid. It must be at least 32 bytes long and meet entropy requirements.",
95
+ { cause: error }
96
+ );
97
+ }
73
98
  const { derivedKey: derivedSigningKey } = (0, import_jose.createDeriveKey)(secret, salt, "signing");
74
99
  const { derivedKey: derivedEncryptionKey } = (0, import_jose.createDeriveKey)(secret, salt, "encryption");
75
100
  const { derivedKey: derivedCsrfTokenKey } = (0, import_jose.createDeriveKey)(secret, salt, "csrfToken");
@@ -85,7 +110,19 @@ var createJoseInstance = (secret) => {
85
110
  decryptJWE
86
111
  };
87
112
  };
113
+ var jwtVerificationOptions = {
114
+ algorithms: ["HS256"],
115
+ typ: "JWT"
116
+ };
117
+ var decodeJWTOptions = {
118
+ jws: jwtVerificationOptions,
119
+ jwt: {
120
+ typ: "JWT"
121
+ }
122
+ };
88
123
  // Annotate the CommonJS export names for ESM import in node:
89
124
  0 && (module.exports = {
90
- createJoseInstance
125
+ createJoseInstance,
126
+ decodeJWTOptions,
127
+ jwtVerificationOptions
91
128
  });
package/dist/jose.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as _aura_stack_jose from '@aura-stack/jose';
2
+ import { JWTVerifyOptions, DecodedJWTPayloadOptions } from '@aura-stack/jose';
2
3
  import * as _aura_stack_jose_jose from '@aura-stack/jose/jose';
3
4
  export { JWTPayload } from '@aura-stack/jose/jose';
4
5
 
5
6
  /**
6
7
  * Creates the JOSE instance used for signing and verifying tokens. It derives keys
7
- * for session tokens and CSRF tokens. For security and determinism, it uses the
8
- * `AURA_AUTH_SALT` environment variable if available; otherwise,it uses a derived
9
- * salt based on the provided secret.
8
+ * for session tokens and CSRF tokens. For security and determinism, it's required
9
+ * to set a salt value in `AURA_AUTH_SALT` or `AUTH_SALT` env.
10
10
  *
11
11
  * @param secret the base secret for key derivation
12
12
  * @returns jose instance with methods for encoding/decoding JWTs and signing/verifying JWSs
@@ -15,9 +15,11 @@ declare const createJoseInstance: (secret?: string) => {
15
15
  decodeJWT: (token: string) => Promise<_aura_stack_jose_jose.JWTPayload>;
16
16
  encodeJWT: (payload: _aura_stack_jose_jose.JWTPayload) => Promise<string>;
17
17
  signJWS: (payload: _aura_stack_jose_jose.JWTPayload) => Promise<string>;
18
- verifyJWS: (payload: string, options?: _aura_stack_jose.JWTVerifyOptions) => Promise<_aura_stack_jose_jose.JWTPayload>;
18
+ verifyJWS: (payload: string, options?: JWTVerifyOptions) => Promise<_aura_stack_jose_jose.JWTPayload>;
19
19
  encryptJWE: (payload: string, options?: _aura_stack_jose.EncryptOptions) => Promise<string>;
20
20
  decryptJWE: (payload: string, options?: _aura_stack_jose.JWTDecryptOptions) => Promise<string>;
21
21
  };
22
+ declare const jwtVerificationOptions: JWTVerifyOptions;
23
+ declare const decodeJWTOptions: DecodedJWTPayloadOptions;
22
24
 
23
- export { createJoseInstance };
25
+ export { createJoseInstance, decodeJWTOptions, jwtVerificationOptions };
package/dist/jose.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import {
2
- createJoseInstance
3
- } from "./chunk-TLE4PXY3.js";
4
- import "./chunk-N2APGLXA.js";
5
- import "./chunk-CXLATHS5.js";
6
- import "./chunk-EIL2FPSS.js";
2
+ createJoseInstance,
3
+ decodeJWTOptions,
4
+ jwtVerificationOptions
5
+ } from "./chunk-FRJFWTOY.js";
6
+ import "./chunk-4MYWAOLG.js";
7
7
  import "./chunk-RRLIF4PQ.js";
8
8
  export {
9
- createJoseInstance
9
+ createJoseInstance,
10
+ decodeJWTOptions,
11
+ jwtVerificationOptions
10
12
  };
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/logger.ts
21
+ var logger_exports = {};
22
+ __export(logger_exports, {
23
+ createLogEntry: () => createLogEntry,
24
+ logMessages: () => logMessages
25
+ });
26
+ module.exports = __toCommonJS(logger_exports);
27
+ var logMessages = {
28
+ ROUTER_INTERNAL_ERROR: {
29
+ facility: 10,
30
+ severity: "error",
31
+ msgId: "ROUTER_INTERNAL_ERROR",
32
+ message: "Unhandled router error while processing the request"
33
+ },
34
+ INVALID_REQUEST: {
35
+ facility: 10,
36
+ severity: "warning",
37
+ msgId: "INVALID_REQUEST",
38
+ message: "Request validation failed against the expected schema"
39
+ },
40
+ SERVER_ERROR: {
41
+ facility: 10,
42
+ severity: "error",
43
+ msgId: "SERVER_ERROR",
44
+ message: "Unexpected internal server error during authentication"
45
+ },
46
+ OAUTH_PROTOCOL_ERROR: {
47
+ facility: 10,
48
+ severity: "warning",
49
+ msgId: "OAUTH_PROTOCOL_ERROR",
50
+ message: "OAuth provider returned an invalid or unexpected protocol response"
51
+ },
52
+ OAUTH_AUTHORIZATION_ERROR: {
53
+ facility: 10,
54
+ severity: "error",
55
+ msgId: "OAUTH_AUTHORIZATION_ERROR",
56
+ message: "OAuth authorization request was rejected or failed"
57
+ },
58
+ INVALID_OAUTH_CONFIGURATION: {
59
+ facility: 10,
60
+ severity: "error",
61
+ msgId: "INVALID_OAUTH_CONFIGURATION",
62
+ message: "The OAuth provider configuration is invalid or incomplete"
63
+ },
64
+ OAUTH_ACCESS_TOKEN_REQUEST_INITIATED: {
65
+ facility: 10,
66
+ severity: "debug",
67
+ msgId: "OAUTH_ACCESS_TOKEN_REQUEST_INITIATED",
68
+ message: "Starting OAuth access token request to the provider"
69
+ },
70
+ INVALID_OAUTH_ACCESS_TOKEN_RESPONSE: {
71
+ facility: 10,
72
+ severity: "error",
73
+ msgId: "INVALID_OAUTH_ACCESS_TOKEN_RESPONSE",
74
+ message: "OAuth access token endpoint returned an invalid or malformed response"
75
+ },
76
+ OAUTH_ACCESS_TOKEN_ERROR: {
77
+ facility: 10,
78
+ severity: "error",
79
+ msgId: "OAUTH_ACCESS_TOKEN_ERROR",
80
+ message: "OAuth access token endpoint returned an error response"
81
+ },
82
+ OAUTH_ACCESS_TOKEN_SUCCESS: {
83
+ facility: 10,
84
+ severity: "info",
85
+ msgId: "OAUTH_ACCESS_TOKEN_SUCCESS",
86
+ message: "Successfully retrieved OAuth access token from the provider"
87
+ },
88
+ OAUTH_ACCESS_TOKEN_REQUEST_FAILED: {
89
+ facility: 10,
90
+ severity: "error",
91
+ msgId: "OAUTH_ACCESS_TOKEN_REQUEST_FAILED",
92
+ message: "Network or server error while requesting OAuth access token"
93
+ },
94
+ OAUTH_USERINFO_REQUEST_INITIATED: {
95
+ facility: 10,
96
+ severity: "debug",
97
+ msgId: "OAUTH_USERINFO_REQUEST_INITIATED",
98
+ message: "Starting OAuth userinfo request to the provider"
99
+ },
100
+ OAUTH_USERINFO_INVALID_RESPONSE: {
101
+ facility: 10,
102
+ severity: "error",
103
+ msgId: "OAUTH_USERINFO_INVALID_RESPONSE",
104
+ message: "OAuth userinfo endpoint returned an invalid or malformed response"
105
+ },
106
+ OAUTH_USERINFO_ERROR: {
107
+ facility: 10,
108
+ severity: "error",
109
+ msgId: "OAUTH_USERINFO_ERROR",
110
+ message: "OAuth userinfo endpoint returned an error response"
111
+ },
112
+ OAUTH_USERINFO_SUCCESS: {
113
+ facility: 10,
114
+ severity: "info",
115
+ msgId: "OAUTH_USERINFO_SUCCESS",
116
+ message: "Successfully retrieved user information from the OAuth provider"
117
+ },
118
+ OAUTH_USERINFO_REQUEST_FAILED: {
119
+ facility: 10,
120
+ severity: "error",
121
+ msgId: "OAUTH_USERINFO_REQUEST_FAILED",
122
+ message: "Network or server error while requesting user information from the OAuth provider"
123
+ },
124
+ OAUTH_CALLBACK_SUCCESS: {
125
+ facility: 4,
126
+ severity: "info",
127
+ msgId: "OAUTH_CALLBACK_SUCCESS",
128
+ message: "OAuth callback completed successfully and session was created"
129
+ },
130
+ MISMATCHING_STATE: {
131
+ facility: 4,
132
+ severity: "critical",
133
+ msgId: "MISMATCHING_STATE",
134
+ message: "OAuth response state parameter does not match the stored state value"
135
+ },
136
+ POTENTIAL_OPEN_REDIRECT_ATTACK_DETECTED: {
137
+ facility: 4,
138
+ severity: "critical",
139
+ msgId: "POTENTIAL_OPEN_REDIRECT_ATTACK_DETECTED",
140
+ message: "Blocked redirect to untrusted or external URL (potential open redirect attack)"
141
+ },
142
+ OPEN_REDIRECT_ATTACK: {
143
+ facility: 4,
144
+ severity: "warning",
145
+ msgId: "OPEN_REDIRECT_ATTACK",
146
+ message: "Detected redirect target that does not match the trusted origin"
147
+ },
148
+ SESSION_TOKEN_MISSING: {
149
+ facility: 4,
150
+ severity: "warning",
151
+ msgId: "SESSION_TOKEN_MISSING",
152
+ message: "Session cookie is missing from the request"
153
+ },
154
+ CSRF_TOKEN_MISSING: {
155
+ facility: 4,
156
+ severity: "warning",
157
+ msgId: "CSRF_TOKEN_MISSING",
158
+ message: "CSRF token cookie is missing from the request"
159
+ },
160
+ CSRF_HEADER_MISSING: {
161
+ facility: 4,
162
+ severity: "warning",
163
+ msgId: "CSRF_HEADER_MISSING",
164
+ message: "CSRF header is missing from the request"
165
+ },
166
+ CSRF_TOKEN_INVALID: {
167
+ facility: 4,
168
+ severity: "error",
169
+ msgId: "CSRF_TOKEN_INVALID",
170
+ message: "CSRF token verification failed or token is invalid"
171
+ },
172
+ SIGN_IN_INITIATED: {
173
+ facility: 4,
174
+ severity: "info",
175
+ msgId: "SIGN_IN_INITIATED",
176
+ message: "Starting OAuth sign-in flow for the selected provider"
177
+ },
178
+ SIGN_OUT_ATTEMPT: {
179
+ facility: 4,
180
+ severity: "debug",
181
+ msgId: "SIGN_OUT_ATTEMPT",
182
+ message: "Received sign-out request from client"
183
+ },
184
+ SIGN_OUT_CSRF_VERIFIED: {
185
+ facility: 4,
186
+ severity: "info",
187
+ msgId: "SIGN_OUT_CSRF_VERIFIED",
188
+ message: "CSRF token was successfully verified during sign-out"
189
+ },
190
+ SIGN_OUT_SUCCESS: {
191
+ facility: 4,
192
+ severity: "info",
193
+ msgId: "SIGN_OUT_SUCCESS",
194
+ message: "User session was cleared and sign-out completed successfully"
195
+ },
196
+ SIGN_OUT_REDIRECT: {
197
+ facility: 4,
198
+ severity: "debug",
199
+ msgId: "SIGN_OUT_REDIRECT",
200
+ message: "Redirecting client after successful sign-out"
201
+ },
202
+ AUTH_SESSION_VALID: {
203
+ facility: 4,
204
+ severity: "info",
205
+ msgId: "AUTH_SESSION_VALID",
206
+ message: "Session token is valid and user session was returned"
207
+ },
208
+ AUTH_SESSION_INVALID: {
209
+ facility: 4,
210
+ severity: "notice",
211
+ msgId: "AUTH_SESSION_INVALID",
212
+ message: "Session token is missing, expired, or invalid"
213
+ },
214
+ INVALID_JWT_TOKEN: {
215
+ facility: 4,
216
+ severity: "warning",
217
+ msgId: "INVALID_JWT_TOKEN",
218
+ message: "JWT session token failed validation during sign-out"
219
+ },
220
+ CSRF_TOKEN_REQUESTED: {
221
+ facility: 4,
222
+ severity: "debug",
223
+ msgId: "CSRF_TOKEN_REQUESTED",
224
+ message: "Client requested a CSRF token"
225
+ },
226
+ CSRF_TOKEN_ISSUED: {
227
+ facility: 4,
228
+ severity: "debug",
229
+ msgId: "CSRF_TOKEN_ISSUED",
230
+ message: "Issued a new CSRF token to the client"
231
+ },
232
+ INVALID_URL: {
233
+ facility: 10,
234
+ severity: "error",
235
+ msgId: "INVALID_URL",
236
+ message: "Derived origin URL is invalid or malformed"
237
+ },
238
+ COOKIE_HTTPONLY_DISABLED: {
239
+ facility: 10,
240
+ severity: "critical",
241
+ msgId: "COOKIE_HTTPONLY_DISABLED",
242
+ message: "Cookie is configured without HttpOnly. This allows JavaScript access via document.cookie and increases XSS exposure."
243
+ },
244
+ COOKIE_WILDCARD_DOMAIN: {
245
+ facility: 10,
246
+ severity: "critical",
247
+ msgId: "COOKIE_WILDCARD_DOMAIN",
248
+ message: "Cookie 'Domain' is set to a wildcard, which is insecure and should be avoided."
249
+ },
250
+ COOKIE_SECURE_DISABLED: {
251
+ facility: 10,
252
+ severity: "warning",
253
+ msgId: "COOKIE_SECURE_DISABLED",
254
+ message: "Cookie is configured with 'Secure' but the request is not HTTPS. The 'Secure' attribute will be ignored by the browser."
255
+ },
256
+ COOKIE_SAMESITE_NONE_WITHOUT_SECURE: {
257
+ facility: 10,
258
+ severity: "warning",
259
+ msgId: "COOKIE_SAMESITE_NONE_WITHOUT_SECURE",
260
+ message: "Cookie uses SameSite=None without Secure. Falling back to SameSite=Lax for safer defaults."
261
+ },
262
+ COOKIE_INSECURE_IN_PRODUCTION: {
263
+ facility: 10,
264
+ severity: "critical",
265
+ msgId: "COOKIE_INSECURE_IN_PRODUCTION",
266
+ message: "Cookies are being served over an insecure connection in production, which is a serious security risk."
267
+ },
268
+ COOKIE_HOST_STRATEGY_INSECURE: {
269
+ facility: 10,
270
+ severity: "critical",
271
+ msgId: "COOKIE_HOST_STRATEGY_INSECURE",
272
+ message: "__Host- cookies require a secure HTTPS context. Falling back to standard cookie settings."
273
+ },
274
+ UNTRUSTED_ORIGIN: {
275
+ facility: 10,
276
+ severity: "error",
277
+ msgId: "UNTRUSTED_ORIGIN",
278
+ message: "The constructed origin URL is not trusted."
279
+ }
280
+ };
281
+ var createLogEntry = (key, overrides) => {
282
+ const message = logMessages[key];
283
+ return {
284
+ ...message,
285
+ ...overrides
286
+ };
287
+ };
288
+ // Annotate the CommonJS export names for ESM import in node:
289
+ 0 && (module.exports = {
290
+ createLogEntry,
291
+ logMessages
292
+ });
@@ -0,0 +1,8 @@
1
+ export { m as createLogEntry, l as logMessages } from './index-CSyIJmCM.js';
2
+ import 'zod';
3
+ import './schemas.js';
4
+ import './jose.js';
5
+ import '@aura-stack/jose';
6
+ import '@aura-stack/jose/jose';
7
+ import '@aura-stack/router/cookie';
8
+ import './@types/utility.js';
package/dist/logger.js ADDED
@@ -0,0 +1,8 @@
1
+ import {
2
+ createLogEntry,
3
+ logMessages
4
+ } from "./chunk-VNCNJKS2.js";
5
+ export {
6
+ createLogEntry,
7
+ logMessages
8
+ };