@aura-stack/auth 0.1.0-rc.8 → 0.1.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 +7 -31
- package/dist/@types/index.js +1 -1
- package/dist/@types/router.d.cjs +1 -1
- package/dist/@types/router.d.d.ts +7 -7
- package/dist/@types/utility.cjs +15 -15
- package/dist/@types/utility.d.ts +6 -6
- package/dist/@types/utility.js +1 -1
- package/dist/actions/callback/access-token.cjs +143 -143
- package/dist/actions/callback/access-token.d.ts +15 -20
- package/dist/actions/callback/access-token.js +8 -4
- package/dist/actions/callback/callback.cjs +437 -455
- package/dist/actions/callback/callback.d.ts +10 -12
- package/dist/actions/callback/callback.js +16 -12
- package/dist/actions/callback/userinfo.cjs +131 -134
- package/dist/actions/callback/userinfo.d.ts +9 -9
- package/dist/actions/callback/userinfo.js +10 -6
- package/dist/actions/csrfToken/csrfToken.cjs +162 -171
- package/dist/actions/csrfToken/csrfToken.d.ts +3 -3
- package/dist/actions/csrfToken/csrfToken.js +12 -8
- package/dist/actions/index.cjs +746 -773
- package/dist/actions/index.d.ts +13 -13
- package/dist/actions/index.js +34 -18
- package/dist/actions/session/session.cjs +149 -155
- package/dist/actions/session/session.d.ts +3 -3
- package/dist/actions/session/session.js +11 -7
- package/dist/actions/signIn/authorization.cjs +231 -249
- package/dist/actions/signIn/authorization.d.ts +12 -18
- package/dist/actions/signIn/authorization.js +16 -6
- package/dist/actions/signIn/signIn.cjs +396 -423
- package/dist/actions/signIn/signIn.d.ts +10 -10
- package/dist/actions/signIn/signIn.js +14 -10
- package/dist/actions/signOut/signOut.cjs +417 -440
- package/dist/actions/signOut/signOut.d.ts +3 -3
- package/dist/actions/signOut/signOut.js +15 -11
- package/dist/assert.cjs +35 -36
- package/dist/assert.d.ts +4 -4
- package/dist/assert.js +10 -2
- package/dist/chunk-256KIVJL.js +85 -96
- package/dist/chunk-42XB3YCW.js +19 -17
- package/dist/chunk-6SM22VVJ.js +13 -10
- package/dist/chunk-CAKJT3KS.js +84 -69
- package/dist/chunk-E3OXBRYF.js +19 -17
- package/dist/chunk-EBPE35JT.js +28 -26
- package/dist/chunk-FIPU4MLT.js +18 -16
- package/dist/chunk-FJUDBLCP.js +50 -43
- package/dist/chunk-FKRDCWBF.js +19 -17
- package/dist/chunk-GZU3RBTB.js +51 -40
- package/dist/chunk-HGJ4TXY4.js +132 -100
- package/dist/chunk-HMRKN75I.js +63 -63
- package/dist/chunk-IKHPGFCW.js +11 -9
- package/dist/chunk-JAPMIE6S.js +7 -5
- package/dist/chunk-KRNOMBXQ.js +19 -17
- package/dist/chunk-LLR722CL.js +91 -70
- package/dist/chunk-RLT4RFKV.js +39 -30
- package/dist/chunk-SJPDVKUS.js +107 -88
- package/dist/chunk-SMQO5WD7.js +26 -16
- package/dist/chunk-STHEPPUZ.js +8 -6
- package/dist/chunk-UJJ7R56J.js +47 -37
- package/dist/chunk-UTDLUEEG.js +27 -21
- package/dist/chunk-VFTYH33W.js +54 -37
- package/dist/chunk-XXJKNKGQ.js +33 -23
- package/dist/chunk-ZV4BH47P.js +132 -134
- package/dist/cookie.cjs +169 -175
- package/dist/cookie.d.ts +23 -51
- package/dist/cookie.js +34 -34
- package/dist/error.cjs +75 -75
- package/dist/error.d.ts +30 -30
- package/dist/error.js +15 -8
- 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 +249 -298
- package/dist/index.cjs +936 -969
- package/dist/index.d.ts +10 -31
- package/dist/index.js +70 -50
- package/dist/jose.cjs +61 -64
- package/dist/jose.d.ts +8 -8
- package/dist/jose.js +9 -5
- package/dist/oauth/bitbucket.cjs +38 -38
- package/dist/oauth/bitbucket.d.ts +7 -7
- package/dist/oauth/bitbucket.js +6 -2
- package/dist/oauth/discord.cjs +48 -48
- package/dist/oauth/discord.d.ts +7 -7
- package/dist/oauth/discord.js +6 -2
- package/dist/oauth/figma.cjs +39 -39
- package/dist/oauth/figma.d.ts +7 -7
- package/dist/oauth/figma.js +6 -2
- package/dist/oauth/github.cjs +31 -31
- package/dist/oauth/github.d.ts +7 -7
- package/dist/oauth/github.js +6 -2
- package/dist/oauth/gitlab.cjs +39 -39
- package/dist/oauth/gitlab.d.ts +7 -7
- package/dist/oauth/gitlab.js +6 -2
- package/dist/oauth/index.cjs +180 -180
- package/dist/oauth/index.d.ts +7 -26
- package/dist/oauth/index.js +36 -9
- package/dist/oauth/spotify.cjs +39 -39
- package/dist/oauth/spotify.d.ts +7 -7
- package/dist/oauth/spotify.js +6 -2
- package/dist/oauth/x.cjs +39 -39
- package/dist/oauth/x.d.ts +7 -7
- package/dist/oauth/x.js +6 -2
- package/dist/response.cjs +27 -27
- package/dist/response.d.ts +2 -2
- package/dist/response.js +6 -2
- package/dist/schemas.cjs +91 -91
- package/dist/schemas.d.ts +93 -126
- package/dist/schemas.js +18 -18
- package/dist/secure.cjs +95 -98
- package/dist/secure.d.ts +17 -17
- package/dist/secure.js +18 -4
- package/dist/utils.cjs +119 -132
- package/dist/utils.d.ts +11 -26
- package/dist/utils.js +21 -21
- package/package.json +2 -2
package/dist/chunk-SJPDVKUS.js
CHANGED
|
@@ -1,93 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
createRedirectTo
|
|
3
|
+
} from "./chunk-CAKJT3KS.js";
|
|
4
|
+
import {
|
|
5
|
+
expireCookie,
|
|
6
|
+
getCookie,
|
|
7
|
+
secureCookieOptions
|
|
8
|
+
} from "./chunk-ZV4BH47P.js";
|
|
9
|
+
import {
|
|
10
|
+
cacheControl
|
|
11
|
+
} from "./chunk-STHEPPUZ.js";
|
|
12
|
+
import {
|
|
13
|
+
verifyCSRF
|
|
14
|
+
} from "./chunk-GZU3RBTB.js";
|
|
15
|
+
import {
|
|
16
|
+
getNormalizedOriginPath
|
|
17
|
+
} from "./chunk-256KIVJL.js";
|
|
18
|
+
import {
|
|
19
|
+
InvalidCsrfTokenError,
|
|
20
|
+
InvalidRedirectToError
|
|
21
|
+
} from "./chunk-FJUDBLCP.js";
|
|
22
|
+
import {
|
|
23
|
+
AuraResponse
|
|
24
|
+
} from "./chunk-JAPMIE6S.js";
|
|
8
25
|
|
|
9
26
|
// src/actions/signOut/signOut.ts
|
|
10
|
-
import z from "zod"
|
|
11
|
-
import { createEndpoint, createEndpointConfig, statusCode } from "@aura-stack/router"
|
|
27
|
+
import z from "zod";
|
|
28
|
+
import { createEndpoint, createEndpointConfig, statusCode } from "@aura-stack/router";
|
|
12
29
|
var config = createEndpointConfig({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})
|
|
30
|
+
schemas: {
|
|
31
|
+
searchParams: z.object({
|
|
32
|
+
token_type_hint: z.literal("session_token"),
|
|
33
|
+
redirectTo: z.string().optional()
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
});
|
|
20
37
|
var signOutAction = createEndpoint(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
)
|
|
38
|
+
"POST",
|
|
39
|
+
"/signOut",
|
|
40
|
+
async (ctx) => {
|
|
41
|
+
const {
|
|
42
|
+
request,
|
|
43
|
+
headers,
|
|
44
|
+
searchParams: { redirectTo },
|
|
45
|
+
context: { cookies, jose, trustedProxyHeaders }
|
|
46
|
+
} = ctx;
|
|
47
|
+
try {
|
|
48
|
+
const cookiesOptions = secureCookieOptions(request, cookies, trustedProxyHeaders);
|
|
49
|
+
const session = getCookie(request, "sessionToken", cookiesOptions);
|
|
50
|
+
const csrfToken = getCookie(request, "csrfToken", {
|
|
51
|
+
...cookiesOptions,
|
|
52
|
+
prefix: cookiesOptions.secure ? "__Host-" : ""
|
|
53
|
+
});
|
|
54
|
+
const header = headers.get("X-CSRF-Token");
|
|
55
|
+
if (!header || !session || !csrfToken) {
|
|
56
|
+
throw new Error("Missing CSRF token or session token");
|
|
57
|
+
}
|
|
58
|
+
await verifyCSRF(jose, csrfToken, header);
|
|
59
|
+
await jose.decodeJWT(session);
|
|
60
|
+
const normalizedOriginPath = getNormalizedOriginPath(request.url);
|
|
61
|
+
const location = createRedirectTo(
|
|
62
|
+
new Request(normalizedOriginPath, {
|
|
63
|
+
headers
|
|
64
|
+
}),
|
|
65
|
+
redirectTo
|
|
66
|
+
);
|
|
67
|
+
const responseHeaders = new Headers(cacheControl);
|
|
68
|
+
responseHeaders.append("Set-Cookie", expireCookie("sessionToken", cookiesOptions));
|
|
69
|
+
responseHeaders.append(
|
|
70
|
+
"Set-Cookie",
|
|
71
|
+
expireCookie("csrfToken", { ...cookiesOptions, prefix: cookiesOptions.secure ? "__Host-" : "" })
|
|
72
|
+
);
|
|
73
|
+
responseHeaders.append("Location", location);
|
|
74
|
+
return Response.json(
|
|
75
|
+
{ message: "Signed out successfully" },
|
|
76
|
+
{ status: statusCode.ACCEPTED, headers: responseHeaders }
|
|
77
|
+
);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (error instanceof InvalidCsrfTokenError) {
|
|
80
|
+
return AuraResponse.json(
|
|
81
|
+
{
|
|
82
|
+
error: "invalid_csrf_token",
|
|
83
|
+
error_description: "The provided CSRF token is invalid or has expired"
|
|
84
|
+
},
|
|
85
|
+
{ status: statusCode.UNAUTHORIZED }
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (error instanceof InvalidRedirectToError) {
|
|
89
|
+
const { type, message } = error;
|
|
90
|
+
return AuraResponse.json(
|
|
91
|
+
{
|
|
92
|
+
error: type,
|
|
93
|
+
error_description: message
|
|
94
|
+
},
|
|
95
|
+
{ status: statusCode.BAD_REQUEST }
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return AuraResponse.json(
|
|
99
|
+
{
|
|
100
|
+
error: "invalid_session_token",
|
|
101
|
+
error_description: "The provided sessionToken is invalid or has already expired"
|
|
102
|
+
},
|
|
103
|
+
{ status: statusCode.UNAUTHORIZED }
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
config
|
|
108
|
+
);
|
|
92
109
|
|
|
93
|
-
export {
|
|
110
|
+
export {
|
|
111
|
+
signOutAction
|
|
112
|
+
};
|
package/dist/chunk-SMQO5WD7.js
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
getCookie,
|
|
3
|
+
secureCookieOptions,
|
|
4
|
+
setCookie
|
|
5
|
+
} from "./chunk-ZV4BH47P.js";
|
|
6
|
+
import {
|
|
7
|
+
cacheControl
|
|
8
|
+
} from "./chunk-STHEPPUZ.js";
|
|
9
|
+
import {
|
|
10
|
+
createCSRF
|
|
11
|
+
} from "./chunk-GZU3RBTB.js";
|
|
4
12
|
|
|
5
13
|
// src/actions/csrfToken/csrfToken.ts
|
|
6
|
-
import { createEndpoint } from "@aura-stack/router"
|
|
14
|
+
import { createEndpoint } from "@aura-stack/router";
|
|
7
15
|
var csrfTokenAction = createEndpoint("GET", "/csrfToken", async (ctx) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
16
|
+
const {
|
|
17
|
+
request,
|
|
18
|
+
context: { cookies, jose, trustedProxyHeaders }
|
|
19
|
+
} = ctx;
|
|
20
|
+
const cookieOptions = secureCookieOptions(request, { ...cookies, strategy: "host" }, trustedProxyHeaders);
|
|
21
|
+
const existingCSRFToken = getCookie(request, "csrfToken", cookieOptions, true);
|
|
22
|
+
const csrfToken = await createCSRF(jose, existingCSRFToken);
|
|
23
|
+
const headers = new Headers(cacheControl);
|
|
24
|
+
headers.set("Set-Cookie", setCookie("csrfToken", csrfToken, cookieOptions));
|
|
25
|
+
return Response.json({ csrfToken }, { headers });
|
|
26
|
+
});
|
|
19
27
|
|
|
20
|
-
export {
|
|
28
|
+
export {
|
|
29
|
+
csrfTokenAction
|
|
30
|
+
};
|
package/dist/chunk-STHEPPUZ.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// src/headers.ts
|
|
2
2
|
var cacheControl = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
3
|
+
"Cache-Control": "no-store",
|
|
4
|
+
Pragma: "no-cache",
|
|
5
|
+
Expires: "0",
|
|
6
|
+
Vary: "Cookie"
|
|
7
|
+
};
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
cacheControl
|
|
11
|
+
};
|
package/dist/chunk-UJJ7R56J.js
CHANGED
|
@@ -1,42 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
AuthError,
|
|
3
|
+
ERROR_RESPONSE,
|
|
4
|
+
throwAuthError
|
|
5
|
+
} from "./chunk-FJUDBLCP.js";
|
|
6
|
+
import {
|
|
7
|
+
OAuthAccessToken,
|
|
8
|
+
OAuthAccessTokenErrorResponse,
|
|
9
|
+
OAuthAccessTokenResponse
|
|
10
|
+
} from "./chunk-HMRKN75I.js";
|
|
3
11
|
|
|
4
12
|
// src/actions/callback/access-token.ts
|
|
5
13
|
var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
const parsed = OAuthAccessToken.safeParse({ ...oauthConfig, redirectURI, code, codeVerifier });
|
|
15
|
+
if (!parsed.success) {
|
|
16
|
+
throw new AuthError(ERROR_RESPONSE.ACCESS_TOKEN.INVALID_REQUEST, "Invalid OAuth configuration");
|
|
17
|
+
}
|
|
18
|
+
const { accessToken, clientId, clientSecret, code: codeParsed, redirectURI: redirectParsed } = parsed.data;
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch(accessToken, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: {
|
|
23
|
+
Accept: "application/json",
|
|
24
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
25
|
+
},
|
|
26
|
+
body: new URLSearchParams({
|
|
27
|
+
client_id: clientId,
|
|
28
|
+
client_secret: clientSecret,
|
|
29
|
+
code: codeParsed,
|
|
30
|
+
redirect_uri: redirectParsed,
|
|
31
|
+
grant_type: "authorization_code",
|
|
32
|
+
code_verifier: codeVerifier
|
|
33
|
+
}).toString()
|
|
34
|
+
});
|
|
35
|
+
const json = await response.json();
|
|
36
|
+
const token = OAuthAccessTokenResponse.safeParse(json);
|
|
37
|
+
if (!token.success) {
|
|
38
|
+
const { success, data } = OAuthAccessTokenErrorResponse.safeParse(json);
|
|
39
|
+
if (!success) {
|
|
40
|
+
throw new AuthError(ERROR_RESPONSE.ACCESS_TOKEN.INVALID_GRANT, "Invalid access token response format");
|
|
41
|
+
}
|
|
42
|
+
throw new AuthError(data.error, data?.error_description ?? "Failed to retrieve access token");
|
|
9
43
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Accept: "application/json",
|
|
16
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
17
|
-
},
|
|
18
|
-
body: new URLSearchParams({
|
|
19
|
-
client_id: clientId,
|
|
20
|
-
client_secret: clientSecret,
|
|
21
|
-
code: codeParsed,
|
|
22
|
-
redirect_uri: redirectParsed,
|
|
23
|
-
grant_type: "authorization_code",
|
|
24
|
-
code_verifier: codeVerifier,
|
|
25
|
-
}).toString(),
|
|
26
|
-
})
|
|
27
|
-
const json = await response.json()
|
|
28
|
-
const token = OAuthAccessTokenResponse.safeParse(json)
|
|
29
|
-
if (!token.success) {
|
|
30
|
-
const { success, data } = OAuthAccessTokenErrorResponse.safeParse(json)
|
|
31
|
-
if (!success) {
|
|
32
|
-
throw new AuthError(ERROR_RESPONSE.ACCESS_TOKEN.INVALID_GRANT, "Invalid access token response format")
|
|
33
|
-
}
|
|
34
|
-
throw new AuthError(data.error, data?.error_description ?? "Failed to retrieve access token")
|
|
35
|
-
}
|
|
36
|
-
return token.data
|
|
37
|
-
} catch (error) {
|
|
38
|
-
throw throwAuthError(error, "Failed to create access token")
|
|
39
|
-
}
|
|
40
|
-
}
|
|
44
|
+
return token.data;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw throwAuthError(error, "Failed to create access token");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
41
49
|
|
|
42
|
-
export {
|
|
50
|
+
export {
|
|
51
|
+
createAccessToken
|
|
52
|
+
};
|
package/dist/chunk-UTDLUEEG.js
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createDerivedSalt
|
|
3
|
+
} from "./chunk-GZU3RBTB.js";
|
|
4
|
+
import {
|
|
5
|
+
AuthError
|
|
6
|
+
} from "./chunk-FJUDBLCP.js";
|
|
3
7
|
|
|
4
8
|
// src/jose.ts
|
|
5
|
-
import "dotenv/config"
|
|
6
|
-
import { createJWT, createJWS, createDeriveKey } from "@aura-stack/jose"
|
|
9
|
+
import "dotenv/config";
|
|
10
|
+
import { createJWT, createJWS, createDeriveKey } from "@aura-stack/jose";
|
|
7
11
|
var createJoseInstance = (secret) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
12
|
+
secret ?? (secret = process.env.AURA_AUTH_SECRET);
|
|
13
|
+
if (!secret) {
|
|
14
|
+
throw new AuthError("JOSE_INIT_ERROR", "AURA_AUTH_SECRET environment variable is not set and no secret was provided.");
|
|
15
|
+
}
|
|
16
|
+
const salt = process.env.AURA_AUTH_SALT ?? createDerivedSalt(secret);
|
|
17
|
+
const { derivedKey: derivedSessionKey } = createDeriveKey(secret, salt, "session");
|
|
18
|
+
const { derivedKey: derivedCsrfTokenKey } = createDeriveKey(secret, salt, "csrfToken");
|
|
19
|
+
const { decodeJWT, encodeJWT } = createJWT(derivedSessionKey);
|
|
20
|
+
const { signJWS, verifyJWS } = createJWS(derivedCsrfTokenKey);
|
|
21
|
+
return {
|
|
22
|
+
decodeJWT,
|
|
23
|
+
encodeJWT,
|
|
24
|
+
signJWS,
|
|
25
|
+
verifyJWS
|
|
26
|
+
};
|
|
27
|
+
};
|
|
24
28
|
|
|
25
|
-
export {
|
|
29
|
+
export {
|
|
30
|
+
createJoseInstance
|
|
31
|
+
};
|
package/dist/chunk-VFTYH33W.js
CHANGED
|
@@ -1,44 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
figma
|
|
3
|
+
} from "./chunk-FKRDCWBF.js";
|
|
4
|
+
import {
|
|
5
|
+
github
|
|
6
|
+
} from "./chunk-IKHPGFCW.js";
|
|
7
|
+
import {
|
|
8
|
+
gitlab
|
|
9
|
+
} from "./chunk-KRNOMBXQ.js";
|
|
10
|
+
import {
|
|
11
|
+
spotify
|
|
12
|
+
} from "./chunk-E3OXBRYF.js";
|
|
13
|
+
import {
|
|
14
|
+
x
|
|
15
|
+
} from "./chunk-42XB3YCW.js";
|
|
16
|
+
import {
|
|
17
|
+
bitbucket
|
|
18
|
+
} from "./chunk-FIPU4MLT.js";
|
|
19
|
+
import {
|
|
20
|
+
discord
|
|
21
|
+
} from "./chunk-EBPE35JT.js";
|
|
8
22
|
|
|
9
23
|
// src/oauth/index.ts
|
|
10
24
|
var builtInOAuthProviders = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
25
|
+
github,
|
|
26
|
+
bitbucket,
|
|
27
|
+
figma,
|
|
28
|
+
discord,
|
|
29
|
+
gitlab,
|
|
30
|
+
spotify,
|
|
31
|
+
x
|
|
32
|
+
};
|
|
19
33
|
var defineOAuthEnvironment = (oauth) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
34
|
+
const env = process.env;
|
|
35
|
+
return {
|
|
36
|
+
clientId: env[`AURA_AUTH_${oauth.toUpperCase()}_CLIENT_ID`],
|
|
37
|
+
clientSecret: env[`AURA_AUTH_${oauth.toUpperCase()}_CLIENT_SECRET`]
|
|
38
|
+
};
|
|
39
|
+
};
|
|
26
40
|
var defineOAuthProviderConfig = (config) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
41
|
+
if (typeof config === "string") {
|
|
42
|
+
const definition = defineOAuthEnvironment(config);
|
|
43
|
+
const oauthConfig = builtInOAuthProviders[config];
|
|
44
|
+
return {
|
|
45
|
+
...oauthConfig,
|
|
46
|
+
...definition
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return config;
|
|
50
|
+
};
|
|
37
51
|
var createBuiltInOAuthProviders = (oauth = []) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
52
|
+
return oauth.reduce((previous, config) => {
|
|
53
|
+
const oauthConfig = defineOAuthProviderConfig(config);
|
|
54
|
+
return { ...previous, [oauthConfig.id]: oauthConfig };
|
|
55
|
+
}, {});
|
|
56
|
+
};
|
|
43
57
|
|
|
44
|
-
export {
|
|
58
|
+
export {
|
|
59
|
+
builtInOAuthProviders,
|
|
60
|
+
createBuiltInOAuthProviders
|
|
61
|
+
};
|
package/dist/chunk-XXJKNKGQ.js
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
expireCookie,
|
|
3
|
+
getCookie,
|
|
4
|
+
secureCookieOptions
|
|
5
|
+
} from "./chunk-ZV4BH47P.js";
|
|
6
|
+
import {
|
|
7
|
+
cacheControl
|
|
8
|
+
} from "./chunk-STHEPPUZ.js";
|
|
9
|
+
import {
|
|
10
|
+
toISOString
|
|
11
|
+
} from "./chunk-256KIVJL.js";
|
|
4
12
|
|
|
5
13
|
// src/actions/session/session.ts
|
|
6
|
-
import { createEndpoint } from "@aura-stack/router"
|
|
14
|
+
import { createEndpoint } from "@aura-stack/router";
|
|
7
15
|
var sessionAction = createEndpoint("GET", "/session", async (ctx) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
16
|
+
const {
|
|
17
|
+
request,
|
|
18
|
+
context: { cookies, jose, trustedProxyHeaders }
|
|
19
|
+
} = ctx;
|
|
20
|
+
const cookieOptions = secureCookieOptions(request, cookies, trustedProxyHeaders);
|
|
21
|
+
try {
|
|
22
|
+
const session = getCookie(request, "sessionToken", cookieOptions);
|
|
23
|
+
const decoded = await jose.decodeJWT(session);
|
|
24
|
+
const { exp, iat, jti, nbf, ...user } = decoded;
|
|
25
|
+
const headers = new Headers(cacheControl);
|
|
26
|
+
return Response.json({ user, expires: toISOString(exp * 1e3) }, { headers });
|
|
27
|
+
} catch {
|
|
28
|
+
const headers = new Headers(cacheControl);
|
|
29
|
+
const sessionCookie = expireCookie("sessionToken", cookieOptions);
|
|
30
|
+
headers.set("Set-Cookie", sessionCookie);
|
|
31
|
+
return Response.json({ authenticated: false, message: "Unauthorized" }, { status: 401, headers });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
26
34
|
|
|
27
|
-
export {
|
|
35
|
+
export {
|
|
36
|
+
sessionAction
|
|
37
|
+
};
|