@aura-stack/auth 0.1.0-rc.9 → 0.2.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/@types/index.cjs +15 -15
- package/dist/@types/index.d.ts +6 -31
- package/dist/@types/index.js +1 -1
- package/dist/@types/router.d.cjs +1 -1
- package/dist/@types/router.d.d.ts +6 -7
- package/dist/@types/utility.cjs +15 -15
- package/dist/@types/utility.d.ts +4 -8
- package/dist/@types/utility.js +1 -1
- package/dist/actions/callback/access-token.cjs +159 -149
- package/dist/actions/callback/access-token.d.ts +14 -20
- package/dist/actions/callback/access-token.js +9 -4
- package/dist/actions/callback/callback.cjs +371 -484
- package/dist/actions/callback/callback.d.ts +9 -12
- package/dist/actions/callback/callback.js +15 -12
- package/dist/actions/callback/userinfo.cjs +149 -139
- package/dist/actions/callback/userinfo.d.ts +8 -9
- package/dist/actions/callback/userinfo.js +11 -6
- package/dist/actions/csrfToken/csrfToken.cjs +112 -190
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
- package/dist/actions/csrfToken/csrfToken.js +12 -8
- package/dist/actions/index.cjs +623 -807
- package/dist/actions/index.d.ts +12 -13
- package/dist/actions/index.js +33 -18
- package/dist/actions/session/session.cjs +86 -176
- package/dist/actions/session/session.d.ts +3 -3
- package/dist/actions/session/session.js +10 -7
- package/dist/actions/signIn/authorization.cjs +248 -257
- package/dist/actions/signIn/authorization.d.ts +11 -18
- package/dist/actions/signIn/authorization.js +16 -6
- package/dist/actions/signIn/signIn.cjs +302 -451
- package/dist/actions/signIn/signIn.d.ts +9 -10
- package/dist/actions/signIn/signIn.js +12 -10
- package/dist/actions/signOut/signOut.cjs +299 -468
- package/dist/actions/signOut/signOut.d.ts +3 -3
- package/dist/actions/signOut/signOut.js +14 -11
- package/dist/assert.cjs +40 -36
- package/dist/assert.d.ts +12 -4
- package/dist/assert.js +12 -2
- package/dist/chunk-2RXNXMCZ.js +55 -0
- package/dist/chunk-42XB3YCW.js +19 -17
- package/dist/chunk-4V4JNXVF.js +55 -0
- package/dist/chunk-6R2YZ4AC.js +22 -0
- package/dist/chunk-7H3OR6UU.js +81 -0
- package/dist/chunk-CXLATHS5.js +143 -0
- package/dist/chunk-E3OXBRYF.js +19 -17
- package/dist/chunk-EIL2FPSS.js +22 -0
- package/dist/chunk-FIPU4MLT.js +18 -16
- package/dist/chunk-FKRDCWBF.js +19 -17
- package/dist/chunk-IKHPGFCW.js +11 -9
- package/dist/chunk-IMICRJ5U.js +197 -0
- package/dist/chunk-IUYZQTJV.js +30 -0
- package/dist/chunk-KRNOMBXQ.js +19 -17
- package/dist/chunk-N2APGLXA.js +71 -0
- package/dist/chunk-NEVKX6K2.js +70 -0
- package/dist/chunk-PTJUYB33.js +33 -0
- package/dist/chunk-QDO2KSRJ.js +35 -0
- package/dist/chunk-QEZL7EYN.js +96 -0
- package/dist/chunk-RRLIF4PQ.js +55 -0
- package/dist/chunk-STHEPPUZ.js +8 -6
- package/dist/chunk-TLE4PXY3.js +39 -0
- package/dist/chunk-UEH3LVON.js +97 -0
- package/dist/chunk-WD7AUHQ5.js +79 -0
- package/dist/chunk-ZLR3LI6X.js +55 -0
- package/dist/cookie.cjs +222 -187
- package/dist/cookie.d.ts +38 -76
- package/dist/cookie.js +27 -34
- package/dist/errors.cjs +85 -0
- package/dist/errors.d.ts +48 -0
- package/dist/errors.js +18 -0
- package/dist/headers.cjs +28 -28
- package/dist/headers.d.ts +2 -2
- package/dist/headers.js +6 -2
- package/dist/{index-DpfbvTZ_.d.ts → index-EqsoyjrF.d.ts} +351 -318
- package/dist/index.cjs +1006 -1001
- package/dist/index.d.ts +9 -31
- package/dist/index.js +82 -51
- package/dist/jose.cjs +74 -66
- package/dist/jose.d.ts +11 -8
- package/dist/jose.js +10 -5
- package/dist/oauth/bitbucket.cjs +38 -38
- package/dist/oauth/bitbucket.d.ts +6 -7
- package/dist/oauth/bitbucket.js +6 -2
- package/dist/oauth/discord.cjs +47 -48
- package/dist/oauth/discord.d.ts +6 -7
- package/dist/oauth/discord.js +6 -2
- package/dist/oauth/figma.cjs +39 -39
- package/dist/oauth/figma.d.ts +6 -7
- package/dist/oauth/figma.js +6 -2
- package/dist/oauth/github.cjs +31 -31
- package/dist/oauth/github.d.ts +6 -7
- package/dist/oauth/github.js +6 -2
- package/dist/oauth/gitlab.cjs +39 -39
- package/dist/oauth/gitlab.d.ts +6 -7
- package/dist/oauth/gitlab.js +6 -2
- package/dist/oauth/index.cjs +306 -180
- package/dist/oauth/index.d.ts +6 -26
- package/dist/oauth/index.js +43 -9
- package/dist/oauth/spotify.cjs +39 -39
- package/dist/oauth/spotify.d.ts +6 -7
- package/dist/oauth/spotify.js +6 -2
- package/dist/oauth/strava.cjs +46 -0
- package/dist/oauth/strava.d.ts +6 -0
- package/dist/oauth/strava.js +6 -0
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +6 -7
- package/dist/oauth/x.js +6 -2
- package/dist/schemas.cjs +97 -91
- package/dist/schemas.d.ts +96 -126
- package/dist/schemas.js +20 -18
- package/dist/secure.cjs +106 -101
- package/dist/secure.d.ts +16 -17
- package/dist/secure.js +19 -4
- package/dist/utils.cjs +197 -135
- package/dist/utils.d.ts +20 -26
- package/dist/utils.js +25 -21
- package/package.json +5 -6
- package/dist/chunk-256KIVJL.js +0 -110
- package/dist/chunk-6SM22VVJ.js +0 -15
- package/dist/chunk-CAKJT3KS.js +0 -77
- package/dist/chunk-EBPE35JT.js +0 -29
- package/dist/chunk-FJUDBLCP.js +0 -52
- package/dist/chunk-GZU3RBTB.js +0 -51
- package/dist/chunk-HGJ4TXY4.js +0 -105
- package/dist/chunk-HMRKN75I.js +0 -74
- package/dist/chunk-JAPMIE6S.js +0 -8
- package/dist/chunk-LLR722CL.js +0 -75
- package/dist/chunk-RLT4RFKV.js +0 -36
- package/dist/chunk-SJPDVKUS.js +0 -93
- package/dist/chunk-SMQO5WD7.js +0 -20
- package/dist/chunk-UJJ7R56J.js +0 -42
- package/dist/chunk-UTDLUEEG.js +0 -25
- package/dist/chunk-VFTYH33W.js +0 -44
- package/dist/chunk-XXJKNKGQ.js +0 -27
- package/dist/chunk-ZV4BH47P.js +0 -156
- package/dist/error.cjs +0 -88
- package/dist/error.d.ts +0 -62
- package/dist/error.js +0 -9
- package/dist/response.cjs +0 -34
- package/dist/response.d.ts +0 -10
- package/dist/response.js +0 -2
package/dist/chunk-UTDLUEEG.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createDerivedSalt } from "./chunk-GZU3RBTB.js"
|
|
2
|
-
import { AuthError } from "./chunk-FJUDBLCP.js"
|
|
3
|
-
|
|
4
|
-
// src/jose.ts
|
|
5
|
-
import "dotenv/config"
|
|
6
|
-
import { createJWT, createJWS, createDeriveKey } from "@aura-stack/jose"
|
|
7
|
-
var createJoseInstance = (secret) => {
|
|
8
|
-
secret ?? (secret = process.env.AURA_AUTH_SECRET)
|
|
9
|
-
if (!secret) {
|
|
10
|
-
throw new AuthError("JOSE_INIT_ERROR", "AURA_AUTH_SECRET environment variable is not set and no secret was provided.")
|
|
11
|
-
}
|
|
12
|
-
const salt = process.env.AURA_AUTH_SALT ?? createDerivedSalt(secret)
|
|
13
|
-
const { derivedKey: derivedSessionKey } = createDeriveKey(secret, salt, "session")
|
|
14
|
-
const { derivedKey: derivedCsrfTokenKey } = createDeriveKey(secret, salt, "csrfToken")
|
|
15
|
-
const { decodeJWT, encodeJWT } = createJWT(derivedSessionKey)
|
|
16
|
-
const { signJWS, verifyJWS } = createJWS(derivedCsrfTokenKey)
|
|
17
|
-
return {
|
|
18
|
-
decodeJWT,
|
|
19
|
-
encodeJWT,
|
|
20
|
-
signJWS,
|
|
21
|
-
verifyJWS,
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { createJoseInstance }
|
package/dist/chunk-VFTYH33W.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { figma } from "./chunk-FKRDCWBF.js"
|
|
2
|
-
import { github } from "./chunk-IKHPGFCW.js"
|
|
3
|
-
import { gitlab } from "./chunk-KRNOMBXQ.js"
|
|
4
|
-
import { spotify } from "./chunk-E3OXBRYF.js"
|
|
5
|
-
import { x } from "./chunk-42XB3YCW.js"
|
|
6
|
-
import { bitbucket } from "./chunk-FIPU4MLT.js"
|
|
7
|
-
import { discord } from "./chunk-EBPE35JT.js"
|
|
8
|
-
|
|
9
|
-
// src/oauth/index.ts
|
|
10
|
-
var builtInOAuthProviders = {
|
|
11
|
-
github,
|
|
12
|
-
bitbucket,
|
|
13
|
-
figma,
|
|
14
|
-
discord,
|
|
15
|
-
gitlab,
|
|
16
|
-
spotify,
|
|
17
|
-
x,
|
|
18
|
-
}
|
|
19
|
-
var defineOAuthEnvironment = (oauth) => {
|
|
20
|
-
const env = process.env
|
|
21
|
-
return {
|
|
22
|
-
clientId: env[`AURA_AUTH_${oauth.toUpperCase()}_CLIENT_ID`],
|
|
23
|
-
clientSecret: env[`AURA_AUTH_${oauth.toUpperCase()}_CLIENT_SECRET`],
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
var defineOAuthProviderConfig = (config) => {
|
|
27
|
-
if (typeof config === "string") {
|
|
28
|
-
const definition = defineOAuthEnvironment(config)
|
|
29
|
-
const oauthConfig = builtInOAuthProviders[config]
|
|
30
|
-
return {
|
|
31
|
-
...oauthConfig,
|
|
32
|
-
...definition,
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return config
|
|
36
|
-
}
|
|
37
|
-
var createBuiltInOAuthProviders = (oauth = []) => {
|
|
38
|
-
return oauth.reduce((previous, config) => {
|
|
39
|
-
const oauthConfig = defineOAuthProviderConfig(config)
|
|
40
|
-
return { ...previous, [oauthConfig.id]: oauthConfig }
|
|
41
|
-
}, {})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { builtInOAuthProviders, createBuiltInOAuthProviders }
|
package/dist/chunk-XXJKNKGQ.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { expireCookie, getCookie, secureCookieOptions } from "./chunk-ZV4BH47P.js"
|
|
2
|
-
import { cacheControl } from "./chunk-STHEPPUZ.js"
|
|
3
|
-
import { toISOString } from "./chunk-256KIVJL.js"
|
|
4
|
-
|
|
5
|
-
// src/actions/session/session.ts
|
|
6
|
-
import { createEndpoint } from "@aura-stack/router"
|
|
7
|
-
var sessionAction = createEndpoint("GET", "/session", async (ctx) => {
|
|
8
|
-
const {
|
|
9
|
-
request,
|
|
10
|
-
context: { cookies, jose, trustedProxyHeaders },
|
|
11
|
-
} = ctx
|
|
12
|
-
const cookieOptions = secureCookieOptions(request, cookies, trustedProxyHeaders)
|
|
13
|
-
try {
|
|
14
|
-
const session = getCookie(request, "sessionToken", cookieOptions)
|
|
15
|
-
const decoded = await jose.decodeJWT(session)
|
|
16
|
-
const { exp, iat, jti, nbf, ...user } = decoded
|
|
17
|
-
const headers = new Headers(cacheControl)
|
|
18
|
-
return Response.json({ user, expires: toISOString(exp * 1e3) }, { headers })
|
|
19
|
-
} catch {
|
|
20
|
-
const headers = new Headers(cacheControl)
|
|
21
|
-
const sessionCookie = expireCookie("sessionToken", cookieOptions)
|
|
22
|
-
headers.set("Set-Cookie", sessionCookie)
|
|
23
|
-
return Response.json({ authenticated: false, message: "Unauthorized" }, { status: 401, headers })
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export { sessionAction }
|
package/dist/chunk-ZV4BH47P.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { isRequest } from "./chunk-6SM22VVJ.js"
|
|
2
|
-
import { AuthError } from "./chunk-FJUDBLCP.js"
|
|
3
|
-
|
|
4
|
-
// src/cookie.ts
|
|
5
|
-
import { parse, serialize } from "cookie"
|
|
6
|
-
import { parse as parse2 } from "cookie"
|
|
7
|
-
var COOKIE_NAME = "aura-auth"
|
|
8
|
-
var defaultCookieOptions = {
|
|
9
|
-
httpOnly: true,
|
|
10
|
-
sameSite: "lax",
|
|
11
|
-
path: "/",
|
|
12
|
-
maxAge: 60 * 60 * 24 * 15,
|
|
13
|
-
}
|
|
14
|
-
var defaultCookieConfig = {
|
|
15
|
-
strategy: "standard",
|
|
16
|
-
name: COOKIE_NAME,
|
|
17
|
-
options: defaultCookieOptions,
|
|
18
|
-
}
|
|
19
|
-
var defaultStandardCookieConfig = {
|
|
20
|
-
secure: false,
|
|
21
|
-
httpOnly: true,
|
|
22
|
-
prefix: "",
|
|
23
|
-
}
|
|
24
|
-
var defaultSecureCookieConfig = {
|
|
25
|
-
secure: true,
|
|
26
|
-
prefix: "__Secure-",
|
|
27
|
-
}
|
|
28
|
-
var defaultHostCookieConfig = {
|
|
29
|
-
secure: true,
|
|
30
|
-
prefix: "__Host-",
|
|
31
|
-
path: "/",
|
|
32
|
-
domain: void 0,
|
|
33
|
-
}
|
|
34
|
-
var expiredCookieOptions = {
|
|
35
|
-
...defaultCookieOptions,
|
|
36
|
-
expires: /* @__PURE__ */ new Date(0),
|
|
37
|
-
maxAge: 0,
|
|
38
|
-
}
|
|
39
|
-
var defineDefaultCookieOptions = (options) => {
|
|
40
|
-
return {
|
|
41
|
-
name: options?.name ?? COOKIE_NAME,
|
|
42
|
-
prefix: options?.prefix ?? (options?.secure ? "__Secure-" : ""),
|
|
43
|
-
...defaultCookieOptions,
|
|
44
|
-
...options,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
var setCookie = (cookieName, value, options) => {
|
|
48
|
-
const { prefix, name } = defineDefaultCookieOptions(options)
|
|
49
|
-
const cookieNameWithPrefix = `${prefix}${name}.${cookieName}`
|
|
50
|
-
return serialize(cookieNameWithPrefix, value, {
|
|
51
|
-
...defaultCookieOptions,
|
|
52
|
-
...options,
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
var getCookie = (petition, cookie, options, optional = false) => {
|
|
56
|
-
const cookies = isRequest(petition) ? petition.headers.get("Cookie") : petition.headers.getSetCookie().join("; ")
|
|
57
|
-
if (!cookies) {
|
|
58
|
-
if (optional) {
|
|
59
|
-
return ""
|
|
60
|
-
}
|
|
61
|
-
throw new AuthError("invalid_request", "No cookies found. There is no active session")
|
|
62
|
-
}
|
|
63
|
-
const { name, prefix } = defineDefaultCookieOptions(options)
|
|
64
|
-
const parsedCookies = parse(cookies)
|
|
65
|
-
const value = parsedCookies[`${prefix}${name}.${cookie}`]
|
|
66
|
-
if (value === void 0) {
|
|
67
|
-
if (optional) {
|
|
68
|
-
return ""
|
|
69
|
-
}
|
|
70
|
-
throw new AuthError("invalid_request", `Cookie "${cookie}" not found. There is no active session`)
|
|
71
|
-
}
|
|
72
|
-
return value
|
|
73
|
-
}
|
|
74
|
-
var createSessionCookie = async (session, cookieOptions, jose) => {
|
|
75
|
-
try {
|
|
76
|
-
const encoded = await jose.encodeJWT(session)
|
|
77
|
-
return setCookie("sessionToken", encoded, cookieOptions)
|
|
78
|
-
} catch (error) {
|
|
79
|
-
throw new AuthError("server_error", "Failed to create session cookie", { cause: error })
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
var secureCookieOptions = (request, cookieOptions, trustedProxyHeaders) => {
|
|
83
|
-
const name = cookieOptions.name ?? COOKIE_NAME
|
|
84
|
-
const isSecure = trustedProxyHeaders
|
|
85
|
-
? request.url.startsWith("https://") ||
|
|
86
|
-
request.headers.get("X-Forwarded-Proto") === "https" ||
|
|
87
|
-
request.headers.get("Forwarded")?.includes("proto=https")
|
|
88
|
-
: request.url.startsWith("https://")
|
|
89
|
-
if (!cookieOptions.options?.httpOnly) {
|
|
90
|
-
console.warn(
|
|
91
|
-
"[WARNING]: Cookie is configured without HttpOnly. This allows JavaScript access via document.cookie and increases XSS risk."
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
if (cookieOptions.options?.domain === "*") {
|
|
95
|
-
console.warn("[WARNING]: Cookie 'Domain' is set to '*', which is insecure. Avoid wildcard domains.")
|
|
96
|
-
}
|
|
97
|
-
if (!isSecure) {
|
|
98
|
-
const options = cookieOptions.options
|
|
99
|
-
if (options?.secure) {
|
|
100
|
-
console.warn(
|
|
101
|
-
"[WARNING]: The 'Secure' attribute will be disabled for this cookie. Serve over HTTPS to enforce Secure cookies."
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
if (options?.sameSite == "none") {
|
|
105
|
-
console.warn("[WARNING]: SameSite=None without a secure connection can be blocked by browsers.")
|
|
106
|
-
}
|
|
107
|
-
if (process.env.NODE_ENV === "production") {
|
|
108
|
-
console.warn("[WARNING]: In production, ensure cookies are served over HTTPS to maintain security.")
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
...defaultCookieOptions,
|
|
112
|
-
...cookieOptions.options,
|
|
113
|
-
sameSite: options?.sameSite === "none" ? "lax" : (options?.sameSite ?? "lax"),
|
|
114
|
-
...defaultStandardCookieConfig,
|
|
115
|
-
name,
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return cookieOptions.strategy === "host"
|
|
119
|
-
? {
|
|
120
|
-
...defaultCookieOptions,
|
|
121
|
-
...cookieOptions.options,
|
|
122
|
-
...defaultHostCookieConfig,
|
|
123
|
-
name,
|
|
124
|
-
}
|
|
125
|
-
: { ...defaultCookieOptions, ...cookieOptions.options, ...defaultSecureCookieConfig, name }
|
|
126
|
-
}
|
|
127
|
-
var expireCookie = (name, options) => {
|
|
128
|
-
return setCookie(name, "", { ...options, ...expiredCookieOptions })
|
|
129
|
-
}
|
|
130
|
-
var oauthCookie = (options) => {
|
|
131
|
-
return {
|
|
132
|
-
...options,
|
|
133
|
-
secure: options.secure,
|
|
134
|
-
httpOnly: options.httpOnly,
|
|
135
|
-
maxAge: 5 * 60,
|
|
136
|
-
expires: new Date(Date.now() + 5 * 60 * 1e3),
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export {
|
|
141
|
-
COOKIE_NAME,
|
|
142
|
-
defaultCookieOptions,
|
|
143
|
-
defaultCookieConfig,
|
|
144
|
-
defaultStandardCookieConfig,
|
|
145
|
-
defaultSecureCookieConfig,
|
|
146
|
-
defaultHostCookieConfig,
|
|
147
|
-
expiredCookieOptions,
|
|
148
|
-
defineDefaultCookieOptions,
|
|
149
|
-
setCookie,
|
|
150
|
-
getCookie,
|
|
151
|
-
createSessionCookie,
|
|
152
|
-
secureCookieOptions,
|
|
153
|
-
expireCookie,
|
|
154
|
-
oauthCookie,
|
|
155
|
-
parse2 as parse,
|
|
156
|
-
}
|
package/dist/error.cjs
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
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) __defProp(target, name, { get: all[name], enumerable: true })
|
|
8
|
-
}
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if ((from && typeof from === "object") || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })
|
|
14
|
-
}
|
|
15
|
-
return to
|
|
16
|
-
}
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod)
|
|
18
|
-
|
|
19
|
-
// src/error.ts
|
|
20
|
-
var error_exports = {}
|
|
21
|
-
__export(error_exports, {
|
|
22
|
-
AuthError: () => AuthError,
|
|
23
|
-
ERROR_RESPONSE: () => ERROR_RESPONSE,
|
|
24
|
-
InvalidCsrfTokenError: () => InvalidCsrfTokenError,
|
|
25
|
-
InvalidRedirectToError: () => InvalidRedirectToError,
|
|
26
|
-
isAuthError: () => isAuthError,
|
|
27
|
-
throwAuthError: () => throwAuthError,
|
|
28
|
-
})
|
|
29
|
-
module.exports = __toCommonJS(error_exports)
|
|
30
|
-
var AuthError = class extends Error {
|
|
31
|
-
constructor(type, message) {
|
|
32
|
-
super(message)
|
|
33
|
-
this.type = type
|
|
34
|
-
this.name = "AuthError"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
var InvalidCsrfTokenError = class extends AuthError {
|
|
38
|
-
constructor(message = "The provided CSRF token is invalid or has expired") {
|
|
39
|
-
super("invalid_csrf_token", message)
|
|
40
|
-
this.name = "InvalidCsrfTokenError"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
var InvalidRedirectToError = class extends AuthError {
|
|
44
|
-
constructor(message = "The redirectTo parameter does not match the hosted origin.") {
|
|
45
|
-
super("invalid_redirect_to", message)
|
|
46
|
-
this.name = "InvalidRedirectToError"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
var isAuthError = (error) => {
|
|
50
|
-
return error instanceof AuthError
|
|
51
|
-
}
|
|
52
|
-
var throwAuthError = (error, message) => {
|
|
53
|
-
if (error instanceof Error) {
|
|
54
|
-
if (isAuthError(error)) {
|
|
55
|
-
throw error
|
|
56
|
-
}
|
|
57
|
-
throw new AuthError("invalid_request", error.message ?? message)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
var ERROR_RESPONSE = {
|
|
61
|
-
AUTHORIZATION: {
|
|
62
|
-
INVALID_REQUEST: "invalid_request",
|
|
63
|
-
UNAUTHORIZED_CLIENT: "unauthorized_client",
|
|
64
|
-
ACCESS_DENIED: "access_denied",
|
|
65
|
-
UNSUPPORTED_RESPONSE_TYPE: "unsupported_response_type",
|
|
66
|
-
INVALID_SCOPE: "invalid_scope",
|
|
67
|
-
SERVER_ERROR: "server_error",
|
|
68
|
-
TEMPORARILY_UNAVAILABLE: "temporarily_unavailable",
|
|
69
|
-
},
|
|
70
|
-
ACCESS_TOKEN: {
|
|
71
|
-
INVALID_REQUEST: "invalid_request",
|
|
72
|
-
INVALID_CLIENT: "invalid_client",
|
|
73
|
-
INVALID_GRANT: "invalid_grant",
|
|
74
|
-
UNAUTHORIZED_CLIENT: "unauthorized_client",
|
|
75
|
-
UNSUPPORTED_GRANT_TYPE: "unsupported_grant_type",
|
|
76
|
-
INVALID_SCOPE: "invalid_scope",
|
|
77
|
-
},
|
|
78
|
-
}
|
|
79
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
-
0 &&
|
|
81
|
-
(module.exports = {
|
|
82
|
-
AuthError,
|
|
83
|
-
ERROR_RESPONSE,
|
|
84
|
-
InvalidCsrfTokenError,
|
|
85
|
-
InvalidRedirectToError,
|
|
86
|
-
isAuthError,
|
|
87
|
-
throwAuthError,
|
|
88
|
-
})
|
package/dist/error.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { E as ErrorType } from "./index-DpfbvTZ_.js"
|
|
2
|
-
import { LiteralUnion } from "./@types/utility.js"
|
|
3
|
-
import "zod/v4"
|
|
4
|
-
import "@aura-stack/jose/jose"
|
|
5
|
-
import "./schemas.js"
|
|
6
|
-
import "zod/v4/core"
|
|
7
|
-
import "cookie"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Error class for all Aura Auth errors.
|
|
11
|
-
*/
|
|
12
|
-
declare class AuthError extends Error {
|
|
13
|
-
readonly type: LiteralUnion<ErrorType>
|
|
14
|
-
constructor(type: LiteralUnion<ErrorType>, message: string)
|
|
15
|
-
}
|
|
16
|
-
declare class InvalidCsrfTokenError extends AuthError {
|
|
17
|
-
constructor(message?: string)
|
|
18
|
-
}
|
|
19
|
-
declare class InvalidRedirectToError extends AuthError {
|
|
20
|
-
constructor(message?: string)
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Verifies if the provided error is an instance of AuthError.
|
|
24
|
-
*
|
|
25
|
-
* @param error The error to be checked
|
|
26
|
-
* @returns True if the error is an instance of AuthError, false otherwise
|
|
27
|
-
*/
|
|
28
|
-
declare const isAuthError: (error: unknown) => error is AuthError
|
|
29
|
-
/**
|
|
30
|
-
* Captures and Error and verifies if it's an AuthError, rethrowing it if so.
|
|
31
|
-
* If it's a different type of error, it wraps it in a new AuthError with the provided message.
|
|
32
|
-
*
|
|
33
|
-
* @param error The error to be processed
|
|
34
|
-
* @param message The error message to be used if wrapping the error
|
|
35
|
-
*/
|
|
36
|
-
declare const throwAuthError: (error: unknown, message?: string) => void
|
|
37
|
-
/**
|
|
38
|
-
* Errores responses returned by the OAuth flows including Authorization and Access Token errors.
|
|
39
|
-
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1
|
|
40
|
-
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
41
|
-
*/
|
|
42
|
-
declare const ERROR_RESPONSE: {
|
|
43
|
-
AUTHORIZATION: {
|
|
44
|
-
INVALID_REQUEST: string
|
|
45
|
-
UNAUTHORIZED_CLIENT: string
|
|
46
|
-
ACCESS_DENIED: string
|
|
47
|
-
UNSUPPORTED_RESPONSE_TYPE: string
|
|
48
|
-
INVALID_SCOPE: string
|
|
49
|
-
SERVER_ERROR: string
|
|
50
|
-
TEMPORARILY_UNAVAILABLE: string
|
|
51
|
-
}
|
|
52
|
-
ACCESS_TOKEN: {
|
|
53
|
-
INVALID_REQUEST: string
|
|
54
|
-
INVALID_CLIENT: string
|
|
55
|
-
INVALID_GRANT: string
|
|
56
|
-
UNAUTHORIZED_CLIENT: string
|
|
57
|
-
UNSUPPORTED_GRANT_TYPE: string
|
|
58
|
-
INVALID_SCOPE: string
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export { AuthError, ERROR_RESPONSE, InvalidCsrfTokenError, InvalidRedirectToError, isAuthError, throwAuthError }
|
package/dist/error.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AuthError,
|
|
3
|
-
ERROR_RESPONSE,
|
|
4
|
-
InvalidCsrfTokenError,
|
|
5
|
-
InvalidRedirectToError,
|
|
6
|
-
isAuthError,
|
|
7
|
-
throwAuthError,
|
|
8
|
-
} from "./chunk-FJUDBLCP.js"
|
|
9
|
-
export { AuthError, ERROR_RESPONSE, InvalidCsrfTokenError, InvalidRedirectToError, isAuthError, throwAuthError }
|
package/dist/response.cjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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) __defProp(target, name, { get: all[name], enumerable: true })
|
|
8
|
-
}
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if ((from && typeof from === "object") || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })
|
|
14
|
-
}
|
|
15
|
-
return to
|
|
16
|
-
}
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod)
|
|
18
|
-
|
|
19
|
-
// src/response.ts
|
|
20
|
-
var response_exports = {}
|
|
21
|
-
__export(response_exports, {
|
|
22
|
-
AuraResponse: () => AuraResponse,
|
|
23
|
-
})
|
|
24
|
-
module.exports = __toCommonJS(response_exports)
|
|
25
|
-
var AuraResponse = class extends Response {
|
|
26
|
-
static json(body, init) {
|
|
27
|
-
return Response.json(body, init)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
-
0 &&
|
|
32
|
-
(module.exports = {
|
|
33
|
-
AuraResponse,
|
|
34
|
-
})
|
package/dist/response.d.ts
DELETED
package/dist/response.js
DELETED