@aura-stack/auth 0.1.0-rc.1
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/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/@types/index.cjs +18 -0
- package/dist/@types/index.d.cts +9 -0
- package/dist/@types/index.d.ts +9 -0
- package/dist/@types/index.js +1 -0
- package/dist/@types/router.d.cjs +1 -0
- package/dist/@types/router.d.d.cts +16 -0
- package/dist/@types/router.d.d.ts +16 -0
- package/dist/@types/router.d.js +0 -0
- package/dist/@types/utility.cjs +18 -0
- package/dist/@types/utility.d.cts +6 -0
- package/dist/@types/utility.d.ts +6 -0
- package/dist/@types/utility.js +1 -0
- package/dist/actions/callback/access-token.cjs +170 -0
- package/dist/actions/callback/access-token.d.cts +30 -0
- package/dist/actions/callback/access-token.d.ts +30 -0
- package/dist/actions/callback/access-token.js +8 -0
- package/dist/actions/callback/callback.cjs +517 -0
- package/dist/actions/callback/callback.d.cts +13 -0
- package/dist/actions/callback/callback.d.ts +13 -0
- package/dist/actions/callback/callback.js +16 -0
- package/dist/actions/callback/userinfo.cjs +165 -0
- package/dist/actions/callback/userinfo.d.cts +22 -0
- package/dist/actions/callback/userinfo.d.ts +22 -0
- package/dist/actions/callback/userinfo.js +10 -0
- package/dist/actions/csrfToken/csrfToken.cjs +207 -0
- package/dist/actions/csrfToken/csrfToken.d.cts +5 -0
- package/dist/actions/csrfToken/csrfToken.d.ts +5 -0
- package/dist/actions/csrfToken/csrfToken.js +12 -0
- package/dist/actions/index.cjs +864 -0
- package/dist/actions/index.d.cts +14 -0
- package/dist/actions/index.d.ts +14 -0
- package/dist/actions/index.js +34 -0
- package/dist/actions/session/session.cjs +191 -0
- package/dist/actions/session/session.d.cts +5 -0
- package/dist/actions/session/session.d.ts +5 -0
- package/dist/actions/session/session.js +11 -0
- package/dist/actions/signIn/authorization.cjs +274 -0
- package/dist/actions/signIn/authorization.d.cts +45 -0
- package/dist/actions/signIn/authorization.d.ts +45 -0
- package/dist/actions/signIn/authorization.js +16 -0
- package/dist/actions/signIn/signIn.cjs +469 -0
- package/dist/actions/signIn/signIn.d.cts +13 -0
- package/dist/actions/signIn/signIn.d.ts +13 -0
- package/dist/actions/signIn/signIn.js +14 -0
- package/dist/actions/signOut/signOut.cjs +490 -0
- package/dist/actions/signOut/signOut.d.cts +8 -0
- package/dist/actions/signOut/signOut.d.ts +8 -0
- package/dist/actions/signOut/signOut.js +15 -0
- package/dist/assert.cjs +44 -0
- package/dist/assert.d.ts +5 -0
- package/dist/assert.js +10 -0
- package/dist/chunk-256KIVJL.js +99 -0
- package/dist/chunk-42XB3YCW.js +22 -0
- package/dist/chunk-6SM22VVJ.js +18 -0
- package/dist/chunk-CAKJT3KS.js +92 -0
- package/dist/chunk-E3OXBRYF.js +22 -0
- package/dist/chunk-EBPE35JT.js +31 -0
- package/dist/chunk-FIPU4MLT.js +21 -0
- package/dist/chunk-FJUDBLCP.js +59 -0
- package/dist/chunk-FKRDCWBF.js +22 -0
- package/dist/chunk-GZU3RBTB.js +62 -0
- package/dist/chunk-HGJ4TXY4.js +137 -0
- package/dist/chunk-HMRKN75I.js +74 -0
- package/dist/chunk-IKHPGFCW.js +14 -0
- package/dist/chunk-ITQ7352M.js +0 -0
- package/dist/chunk-JAPMIE6S.js +10 -0
- package/dist/chunk-KRNOMBXQ.js +22 -0
- package/dist/chunk-LLR722CL.js +96 -0
- package/dist/chunk-PG7UYFG5.js +0 -0
- package/dist/chunk-RLT4RFKV.js +45 -0
- package/dist/chunk-SJPDVKUS.js +112 -0
- package/dist/chunk-SMQO5WD7.js +30 -0
- package/dist/chunk-STHEPPUZ.js +11 -0
- package/dist/chunk-UJJ7R56J.js +52 -0
- package/dist/chunk-VFTYH33W.js +61 -0
- package/dist/chunk-X7M4CQTN.js +25 -0
- package/dist/chunk-XXJKNKGQ.js +37 -0
- package/dist/chunk-ZV4BH47P.js +154 -0
- package/dist/cookie.cjs +201 -0
- package/dist/cookie.d.ts +95 -0
- package/dist/cookie.js +36 -0
- package/dist/error.cjs +88 -0
- package/dist/error.d.ts +64 -0
- package/dist/error.js +16 -0
- package/dist/headers.cjs +35 -0
- package/dist/headers.d.ts +9 -0
- package/dist/headers.js +6 -0
- package/dist/index-CGRZ0wrw.d.ts +530 -0
- package/dist/index.cjs +1089 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +75 -0
- package/dist/jose.cjs +68 -0
- package/dist/jose.d.ts +20 -0
- package/dist/jose.js +9 -0
- package/dist/oauth/bitbucket.cjs +45 -0
- package/dist/oauth/bitbucket.d.cts +9 -0
- package/dist/oauth/bitbucket.d.ts +9 -0
- package/dist/oauth/bitbucket.js +6 -0
- package/dist/oauth/discord.cjs +55 -0
- package/dist/oauth/discord.d.cts +9 -0
- package/dist/oauth/discord.d.ts +9 -0
- package/dist/oauth/discord.js +6 -0
- package/dist/oauth/figma.cjs +46 -0
- package/dist/oauth/figma.d.cts +9 -0
- package/dist/oauth/figma.d.ts +9 -0
- package/dist/oauth/figma.js +6 -0
- package/dist/oauth/github.cjs +38 -0
- package/dist/oauth/github.d.cts +9 -0
- package/dist/oauth/github.d.ts +9 -0
- package/dist/oauth/github.js +6 -0
- package/dist/oauth/gitlab.cjs +46 -0
- package/dist/oauth/gitlab.d.cts +9 -0
- package/dist/oauth/gitlab.d.ts +9 -0
- package/dist/oauth/gitlab.js +6 -0
- package/dist/oauth/index.cjs +213 -0
- package/dist/oauth/index.d.cts +9 -0
- package/dist/oauth/index.d.ts +9 -0
- package/dist/oauth/index.js +36 -0
- package/dist/oauth/spotify.cjs +46 -0
- package/dist/oauth/spotify.d.cts +9 -0
- package/dist/oauth/spotify.d.ts +9 -0
- package/dist/oauth/spotify.js +6 -0
- package/dist/oauth/x.cjs +46 -0
- package/dist/oauth/x.d.cts +9 -0
- package/dist/oauth/x.d.ts +9 -0
- package/dist/oauth/x.js +6 -0
- package/dist/response.cjs +34 -0
- package/dist/response.d.ts +10 -0
- package/dist/response.js +6 -0
- package/dist/schemas.cjs +105 -0
- package/dist/schemas.d.ts +130 -0
- package/dist/schemas.js +20 -0
- package/dist/secure.cjs +120 -0
- package/dist/secure.d.ts +43 -0
- package/dist/secure.js +18 -0
- package/dist/utils.cjs +141 -0
- package/dist/utils.d.ts +45 -0
- package/dist/utils.js +23 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Auth Stack Js
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<h1><b>@aura-stack/auth</b></h1>
|
|
4
|
+
|
|
5
|
+
**Core authentication library for the Aura Stack ecosystem**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@aura-stack/auth)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
[Official Docs](https://aura-stack-auth.vercel.app/docs) · [Core Package Docs](https://aura-stack-auth.vercel.app/docs/packages/core)
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
`@aura-stack/auth` provides the **core logic and building blocks** for authentication and authorization within the **Aura Stack** ecosystem.
|
|
17
|
+
|
|
18
|
+
It offers a **framework-agnostic**, **type-safe**, and **secure** solution to handle authentication flows such as OAuth 2.0 and OpenID Connect.
|
|
19
|
+
Inspired by [Auth.js](https://authjs.dev/), Aura Auth focuses on simplicity, developer experience, and strong security practices.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **OAuth 2.0** — Native support for multiple OAuth providers.
|
|
24
|
+
- **Type-safe by design** — First-class TypeScript support with complete type inference.
|
|
25
|
+
- **Secure sessions** — Built-in JWT-based session management with encryption and signing.
|
|
26
|
+
- **Cookie handling** — Secure, configurable cookies for session persistence.
|
|
27
|
+
- **Extensible architecture** — Easily integrate with `@aura-stack/router` or custom routing layers.
|
|
28
|
+
- **Framework-agnostic** — Works seamlessly in any environment that supports the Web Request/Response APIs.
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
Visit the [**official documentation website**](https://aura-stack-auth.vercel.app).
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
Licensed under the [MIT License](LICENSE). © [Aura Stack](https://github.com/aura-stack-ts)
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
Made with ❤️ by <a href="https://github.com/aura-stack-ts">Aura Stack team</a>
|
|
42
|
+
</p>
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/@types/index.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import 'zod/v4';
|
|
2
|
+
import '../jose.cjs';
|
|
3
|
+
import '../schemas.cjs';
|
|
4
|
+
import '@aura-stack/router';
|
|
5
|
+
import 'cookie';
|
|
6
|
+
export { LiteralUnion, Prettify } from './utility.cjs';
|
|
7
|
+
export { w as AccessTokenError, c as AuthConfig, A as AuthRuntimeConfig, v as AuthorizationError, C as CookieConfig, a as CookieConfigInternal, b as CookieName, t as CookieStrategyOptions, E as ErrorType, H as HostCookie, m as JWTStandardClaims, J as JoseInstance, u as OAuthError, p as OAuthProvider, o as OAuthProviderConfig, O as OAuthProviderCredentials, q as SecureCookie, n as Session, r as StandardCookie, T as TokenRevocationError, U as User } from '../index-B1vDUGwh.cjs';
|
|
8
|
+
import '@aura-stack/jose/jose';
|
|
9
|
+
import 'zod/v4/core';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import 'zod/v4';
|
|
2
|
+
import '../jose.js';
|
|
3
|
+
import '../schemas.js';
|
|
4
|
+
import '@aura-stack/router';
|
|
5
|
+
import 'cookie';
|
|
6
|
+
export { LiteralUnion, Prettify } from './utility.js';
|
|
7
|
+
export { w as AccessTokenError, c as AuthConfig, A as AuthRuntimeConfig, v as AuthorizationError, C as CookieConfig, a as CookieConfigInternal, b as CookieName, t as CookieStrategyOptions, E as ErrorType, H as HostCookie, m as JWTStandardClaims, J as JoseInstance, u as OAuthError, p as OAuthProvider, o as OAuthProviderConfig, O as OAuthProviderCredentials, q as SecureCookie, n as Session, r as StandardCookie, T as TokenRevocationError, U as User } from '../index-CGRZ0wrw.js';
|
|
8
|
+
import '@aura-stack/jose/jose';
|
|
9
|
+
import 'zod/v4/core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../chunk-PG7UYFG5.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { c as AuthConfig, d as createBuiltInOAuthProviders, J as JoseInstance } from '../index-B1vDUGwh.cjs';
|
|
2
|
+
import 'zod/v4';
|
|
3
|
+
import '../jose.cjs';
|
|
4
|
+
import '@aura-stack/jose/jose';
|
|
5
|
+
import '../schemas.cjs';
|
|
6
|
+
import 'zod/v4/core';
|
|
7
|
+
import '@aura-stack/router';
|
|
8
|
+
import 'cookie';
|
|
9
|
+
import './utility.cjs';
|
|
10
|
+
|
|
11
|
+
declare module "@aura-stack/router" {
|
|
12
|
+
interface GlobalContext extends Required<Omit<AuthConfig, "secret" | "oauth">> {
|
|
13
|
+
oauth: ReturnType<typeof createBuiltInOAuthProviders>
|
|
14
|
+
jose: JoseInstance
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { c as AuthConfig, d as createBuiltInOAuthProviders, J as JoseInstance } from '../index-CGRZ0wrw.js';
|
|
2
|
+
import 'zod/v4';
|
|
3
|
+
import '../jose.js';
|
|
4
|
+
import '@aura-stack/jose/jose';
|
|
5
|
+
import '../schemas.js';
|
|
6
|
+
import 'zod/v4/core';
|
|
7
|
+
import '@aura-stack/router';
|
|
8
|
+
import 'cookie';
|
|
9
|
+
import './utility.js';
|
|
10
|
+
|
|
11
|
+
declare module "@aura-stack/router" {
|
|
12
|
+
interface GlobalContext extends Required<Omit<AuthConfig, "secret" | "oauth">> {
|
|
13
|
+
oauth: ReturnType<typeof createBuiltInOAuthProviders>
|
|
14
|
+
jose: JoseInstance
|
|
15
|
+
}
|
|
16
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/@types/utility.ts
|
|
17
|
+
var utility_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(utility_exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../chunk-PG7UYFG5.js";
|
|
@@ -0,0 +1,170 @@
|
|
|
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/actions/callback/access-token.ts
|
|
21
|
+
var access_token_exports = {};
|
|
22
|
+
__export(access_token_exports, {
|
|
23
|
+
createAccessToken: () => createAccessToken
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(access_token_exports);
|
|
26
|
+
|
|
27
|
+
// src/error.ts
|
|
28
|
+
var AuthError = class extends Error {
|
|
29
|
+
constructor(type, message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.type = type;
|
|
32
|
+
this.name = "AuthError";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var isAuthError = (error) => {
|
|
36
|
+
return error instanceof AuthError;
|
|
37
|
+
};
|
|
38
|
+
var throwAuthError = (error, message) => {
|
|
39
|
+
if (error instanceof Error) {
|
|
40
|
+
if (isAuthError(error)) {
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
throw new AuthError("invalid_request", error.message ?? message);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var ERROR_RESPONSE = {
|
|
47
|
+
AUTHORIZATION: {
|
|
48
|
+
INVALID_REQUEST: "invalid_request",
|
|
49
|
+
UNAUTHORIZED_CLIENT: "unauthorized_client",
|
|
50
|
+
ACCESS_DENIED: "access_denied",
|
|
51
|
+
UNSUPPORTED_RESPONSE_TYPE: "unsupported_response_type",
|
|
52
|
+
INVALID_SCOPE: "invalid_scope",
|
|
53
|
+
SERVER_ERROR: "server_error",
|
|
54
|
+
TEMPORARILY_UNAVAILABLE: "temporarily_unavailable"
|
|
55
|
+
},
|
|
56
|
+
ACCESS_TOKEN: {
|
|
57
|
+
INVALID_REQUEST: "invalid_request",
|
|
58
|
+
INVALID_CLIENT: "invalid_client",
|
|
59
|
+
INVALID_GRANT: "invalid_grant",
|
|
60
|
+
UNAUTHORIZED_CLIENT: "unauthorized_client",
|
|
61
|
+
UNSUPPORTED_GRANT_TYPE: "unsupported_grant_type",
|
|
62
|
+
INVALID_SCOPE: "invalid_scope"
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/schemas.ts
|
|
67
|
+
var import_v4 = require("zod/v4");
|
|
68
|
+
var OAuthProviderConfigSchema = (0, import_v4.object)({
|
|
69
|
+
authorizeURL: (0, import_v4.url)(),
|
|
70
|
+
accessToken: (0, import_v4.url)(),
|
|
71
|
+
scope: (0, import_v4.string)().optional(),
|
|
72
|
+
userInfo: (0, import_v4.url)(),
|
|
73
|
+
responseType: (0, import_v4.enum)(["code", "token", "id_token"]),
|
|
74
|
+
clientId: (0, import_v4.string)(),
|
|
75
|
+
clientSecret: (0, import_v4.string)()
|
|
76
|
+
});
|
|
77
|
+
var OAuthAuthorization = OAuthProviderConfigSchema.extend({
|
|
78
|
+
redirectURI: (0, import_v4.string)(),
|
|
79
|
+
state: (0, import_v4.string)(),
|
|
80
|
+
codeChallenge: (0, import_v4.string)(),
|
|
81
|
+
codeChallengeMethod: (0, import_v4.enum)(["plain", "S256"])
|
|
82
|
+
});
|
|
83
|
+
var OAuthAuthorizationResponse = (0, import_v4.object)({
|
|
84
|
+
state: (0, import_v4.string)(),
|
|
85
|
+
code: (0, import_v4.string)()
|
|
86
|
+
});
|
|
87
|
+
var OAuthAuthorizationErrorResponse = (0, import_v4.object)({
|
|
88
|
+
error: (0, import_v4.enum)([
|
|
89
|
+
"invalid_request",
|
|
90
|
+
"unauthorized_client",
|
|
91
|
+
"access_denied",
|
|
92
|
+
"unsupported_response_type",
|
|
93
|
+
"invalid_scope",
|
|
94
|
+
"server_error",
|
|
95
|
+
"temporarily_unavailable"
|
|
96
|
+
]),
|
|
97
|
+
error_description: (0, import_v4.string)().optional(),
|
|
98
|
+
error_uri: (0, import_v4.string)().optional(),
|
|
99
|
+
state: (0, import_v4.string)()
|
|
100
|
+
});
|
|
101
|
+
var OAuthAccessToken = OAuthProviderConfigSchema.extend({
|
|
102
|
+
redirectURI: (0, import_v4.string)(),
|
|
103
|
+
code: (0, import_v4.string)(),
|
|
104
|
+
codeVerifier: (0, import_v4.string)().min(43).max(128)
|
|
105
|
+
});
|
|
106
|
+
var OAuthAccessTokenResponse = (0, import_v4.object)({
|
|
107
|
+
access_token: (0, import_v4.string)(),
|
|
108
|
+
token_type: (0, import_v4.string)(),
|
|
109
|
+
expires_in: (0, import_v4.number)().optional(),
|
|
110
|
+
refresh_token: (0, import_v4.string)().optional(),
|
|
111
|
+
scope: (0, import_v4.string)().optional()
|
|
112
|
+
});
|
|
113
|
+
var OAuthAccessTokenErrorResponse = (0, import_v4.object)({
|
|
114
|
+
error: (0, import_v4.enum)([
|
|
115
|
+
"invalid_request",
|
|
116
|
+
"invalid_client",
|
|
117
|
+
"invalid_grant",
|
|
118
|
+
"unauthorized_client",
|
|
119
|
+
"unsupported_grant_type",
|
|
120
|
+
"invalid_scope"
|
|
121
|
+
]),
|
|
122
|
+
error_description: (0, import_v4.string)().optional(),
|
|
123
|
+
error_uri: (0, import_v4.string)().optional()
|
|
124
|
+
});
|
|
125
|
+
var OAuthErrorResponse = (0, import_v4.object)({
|
|
126
|
+
error: (0, import_v4.string)(),
|
|
127
|
+
error_description: (0, import_v4.string)().optional()
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// src/actions/callback/access-token.ts
|
|
131
|
+
var createAccessToken = async (oauthConfig, redirectURI, code, codeVerifier) => {
|
|
132
|
+
const parsed = OAuthAccessToken.safeParse({ ...oauthConfig, redirectURI, code, codeVerifier });
|
|
133
|
+
if (!parsed.success) {
|
|
134
|
+
throw new AuthError(ERROR_RESPONSE.ACCESS_TOKEN.INVALID_REQUEST, "Invalid OAuth configuration");
|
|
135
|
+
}
|
|
136
|
+
const { accessToken, clientId, clientSecret, code: codeParsed, redirectURI: redirectParsed } = parsed.data;
|
|
137
|
+
try {
|
|
138
|
+
const response = await fetch(accessToken, {
|
|
139
|
+
method: "POST",
|
|
140
|
+
headers: {
|
|
141
|
+
Accept: "application/json",
|
|
142
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
143
|
+
},
|
|
144
|
+
body: new URLSearchParams({
|
|
145
|
+
client_id: clientId,
|
|
146
|
+
client_secret: clientSecret,
|
|
147
|
+
code: codeParsed,
|
|
148
|
+
redirect_uri: redirectParsed,
|
|
149
|
+
grant_type: "authorization_code",
|
|
150
|
+
code_verifier: codeVerifier
|
|
151
|
+
}).toString()
|
|
152
|
+
});
|
|
153
|
+
const json = await response.json();
|
|
154
|
+
const token = OAuthAccessTokenResponse.safeParse(json);
|
|
155
|
+
if (!token.success) {
|
|
156
|
+
const { success, data } = OAuthAccessTokenErrorResponse.safeParse(json);
|
|
157
|
+
if (!success) {
|
|
158
|
+
throw new AuthError(ERROR_RESPONSE.ACCESS_TOKEN.INVALID_GRANT, "Invalid access token response format");
|
|
159
|
+
}
|
|
160
|
+
throw new AuthError(data.error, data?.error_description ?? "Failed to retrieve access token");
|
|
161
|
+
}
|
|
162
|
+
return token.data;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
throw throwAuthError(error, "Failed to create access token");
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
+
0 && (module.exports = {
|
|
169
|
+
createAccessToken
|
|
170
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { O as OAuthProviderCredentials } from '../../index-B1vDUGwh.cjs';
|
|
2
|
+
import 'zod/v4';
|
|
3
|
+
import '../../jose.cjs';
|
|
4
|
+
import '@aura-stack/jose/jose';
|
|
5
|
+
import '../../schemas.cjs';
|
|
6
|
+
import 'zod/v4/core';
|
|
7
|
+
import '@aura-stack/router';
|
|
8
|
+
import 'cookie';
|
|
9
|
+
import '../../@types/utility.cjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Make a request to the OAuth provider to the token endpoint to exchange the authorization code provided
|
|
13
|
+
* by the authorization server.
|
|
14
|
+
*
|
|
15
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3
|
|
16
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-5
|
|
17
|
+
* @param oauthConfig - OAuth provider configuration
|
|
18
|
+
* @param redirectURI - The redirect URI registered in the Resource Owner's authorization request and sent in the authorization code exchange
|
|
19
|
+
* @param code - The authorization code received from the OAuth server
|
|
20
|
+
* @returns The access token response from the OAuth server
|
|
21
|
+
*/
|
|
22
|
+
declare const createAccessToken: (oauthConfig: OAuthProviderCredentials, redirectURI: string, code: string, codeVerifier: string) => Promise<{
|
|
23
|
+
access_token: string;
|
|
24
|
+
token_type: string;
|
|
25
|
+
expires_in?: number | undefined;
|
|
26
|
+
refresh_token?: string | undefined;
|
|
27
|
+
scope?: string | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
|
|
30
|
+
export { createAccessToken };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { O as OAuthProviderCredentials } from '../../index-CGRZ0wrw.js';
|
|
2
|
+
import 'zod/v4';
|
|
3
|
+
import '../../jose.js';
|
|
4
|
+
import '@aura-stack/jose/jose';
|
|
5
|
+
import '../../schemas.js';
|
|
6
|
+
import 'zod/v4/core';
|
|
7
|
+
import '@aura-stack/router';
|
|
8
|
+
import 'cookie';
|
|
9
|
+
import '../../@types/utility.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Make a request to the OAuth provider to the token endpoint to exchange the authorization code provided
|
|
13
|
+
* by the authorization server.
|
|
14
|
+
*
|
|
15
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3
|
|
16
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-5
|
|
17
|
+
* @param oauthConfig - OAuth provider configuration
|
|
18
|
+
* @param redirectURI - The redirect URI registered in the Resource Owner's authorization request and sent in the authorization code exchange
|
|
19
|
+
* @param code - The authorization code received from the OAuth server
|
|
20
|
+
* @returns The access token response from the OAuth server
|
|
21
|
+
*/
|
|
22
|
+
declare const createAccessToken: (oauthConfig: OAuthProviderCredentials, redirectURI: string, code: string, codeVerifier: string) => Promise<{
|
|
23
|
+
access_token: string;
|
|
24
|
+
token_type: string;
|
|
25
|
+
expires_in?: number | undefined;
|
|
26
|
+
refresh_token?: string | undefined;
|
|
27
|
+
scope?: string | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
|
|
30
|
+
export { createAccessToken };
|