@finueva/auth 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/LICENSE +21 -0
- package/README.md +50 -0
- package/THIRD_PARTY_NOTICES.md +100 -0
- package/dist/errors-C-cHFWC7.d.ts +55 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2438 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.js +711 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Finueva
|
|
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,50 @@
|
|
|
1
|
+
# @finueva/auth
|
|
2
|
+
|
|
3
|
+
Experimental public SDK for Finueva Auth. Version `0.x` may introduce breaking changes; `1.0.0` will mark the stable interface.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add @finueva/auth
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Browser
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createAuthClient } from "@finueva/auth";
|
|
13
|
+
|
|
14
|
+
const auth = createAuthClient({
|
|
15
|
+
authOrigin: "https://auth.finueva.com",
|
|
16
|
+
appOrigin: window.location.origin,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const session = await auth.getSession();
|
|
20
|
+
await auth.signIn({ email, password });
|
|
21
|
+
const credential = await auth.getDriveCredential({
|
|
22
|
+
workspace: { type: "personal" },
|
|
23
|
+
});
|
|
24
|
+
await auth.signOut();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The Auth session uses the Auth-owned HTTP-only cookie. Drive credentials are cached only in memory, shared across concurrent requests, and renewed once they have two minutes remaining. Passing `forceRefresh: true` requests a replacement after a Drive authentication failure; the SDK never replays a Drive request.
|
|
28
|
+
|
|
29
|
+
## Server
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { createServerAuth } from "@finueva/auth/server";
|
|
33
|
+
|
|
34
|
+
const auth = createServerAuth({
|
|
35
|
+
authOrigin: "https://auth.finueva.com",
|
|
36
|
+
appOrigin: "https://files.finueva.com",
|
|
37
|
+
request,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const session = await auth.getSession();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The server client is request-scoped. It forwards the incoming Auth cookie only to Auth and never sends it to Drive.
|
|
44
|
+
|
|
45
|
+
## Current Limits
|
|
46
|
+
|
|
47
|
+
- Only personal workspace credentials are supported.
|
|
48
|
+
- Cross-root SSO and organization switching are not part of `0.1.0`.
|
|
49
|
+
- The package does not persist Drive credentials or expose Better Auth internals.
|
|
50
|
+
- Public errors are `AuthError` instances with stable, value-free codes.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
`@finueva/auth` bundles browser/runtime code from the packages listed below.
|
|
4
|
+
|
|
5
|
+
## @chiballc/utils 2.2.22
|
|
6
|
+
|
|
7
|
+
Source: https://github.com/ChibaLLC/utils
|
|
8
|
+
|
|
9
|
+
ISC License
|
|
10
|
+
|
|
11
|
+
Copyright (c) AllanBosire
|
|
12
|
+
|
|
13
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
15
|
+
copyright notice and this permission notice appear in all copies.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
18
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
19
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
20
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
21
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
22
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
23
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
24
|
+
|
|
25
|
+
## Better Auth 1.6.22
|
|
26
|
+
|
|
27
|
+
Source: https://github.com/better-auth/better-auth
|
|
28
|
+
|
|
29
|
+
The MIT License (MIT)
|
|
30
|
+
|
|
31
|
+
Copyright (c) 2024 - present, Bereket Engida
|
|
32
|
+
|
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
34
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
35
|
+
the Software without restriction, including without limitation the rights to
|
|
36
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
37
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
38
|
+
subject to the following conditions:
|
|
39
|
+
|
|
40
|
+
The above copyright notice and this permission notice shall be included in all
|
|
41
|
+
copies or substantial portions of the Software.
|
|
42
|
+
|
|
43
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
44
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
45
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
46
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
47
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
48
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
49
|
+
|
|
50
|
+
## ofetch 1.5.1
|
|
51
|
+
|
|
52
|
+
Source: https://github.com/unjs/ofetch
|
|
53
|
+
|
|
54
|
+
MIT License
|
|
55
|
+
|
|
56
|
+
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
|
57
|
+
|
|
58
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
59
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
60
|
+
in the Software without restriction, including without limitation the rights
|
|
61
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
62
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
63
|
+
furnished to do so, subject to the following conditions:
|
|
64
|
+
|
|
65
|
+
The above copyright notice and this permission notice shall be included in all
|
|
66
|
+
copies or substantial portions of the Software.
|
|
67
|
+
|
|
68
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
69
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
70
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
71
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
72
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
73
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
74
|
+
SOFTWARE.
|
|
75
|
+
|
|
76
|
+
## ufo 1.6.4
|
|
77
|
+
|
|
78
|
+
Source: https://github.com/unjs/ufo
|
|
79
|
+
|
|
80
|
+
MIT License
|
|
81
|
+
|
|
82
|
+
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
|
83
|
+
|
|
84
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
85
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
86
|
+
in the Software without restriction, including without limitation the rights
|
|
87
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
88
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
89
|
+
furnished to do so, subject to the following conditions:
|
|
90
|
+
|
|
91
|
+
The above copyright notice and this permission notice shall be included in all
|
|
92
|
+
copies or substantial portions of the Software.
|
|
93
|
+
|
|
94
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
95
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
96
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
97
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
98
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
99
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
100
|
+
SOFTWARE.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
interface AuthUser {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
email: string;
|
|
6
|
+
emailVerified: boolean;
|
|
7
|
+
image: string | null;
|
|
8
|
+
}
|
|
9
|
+
interface AuthSession {
|
|
10
|
+
id: string;
|
|
11
|
+
expiresAt: Date;
|
|
12
|
+
user: AuthUser;
|
|
13
|
+
}
|
|
14
|
+
interface PersonalWorkspaceSelection {
|
|
15
|
+
type: "personal";
|
|
16
|
+
}
|
|
17
|
+
interface DriveCredential {
|
|
18
|
+
tokenType: "Bearer";
|
|
19
|
+
token: string;
|
|
20
|
+
expiresAt: Date;
|
|
21
|
+
}
|
|
22
|
+
interface SignInInput {
|
|
23
|
+
email: string;
|
|
24
|
+
password: string;
|
|
25
|
+
}
|
|
26
|
+
interface DriveCredentialInput {
|
|
27
|
+
workspace: PersonalWorkspaceSelection;
|
|
28
|
+
forceRefresh?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface AuthClientOptions {
|
|
31
|
+
authOrigin: string;
|
|
32
|
+
appOrigin: string;
|
|
33
|
+
fetch?: typeof globalThis.fetch;
|
|
34
|
+
now?: () => number;
|
|
35
|
+
timeoutMs?: number;
|
|
36
|
+
}
|
|
37
|
+
interface FinuevaAuthClient {
|
|
38
|
+
getSession(): Promise<AuthSession | null>;
|
|
39
|
+
signIn(input: SignInInput): Promise<AuthSession>;
|
|
40
|
+
signOut(): Promise<void>;
|
|
41
|
+
getDriveCredential(input: DriveCredentialInput): Promise<DriveCredential>;
|
|
42
|
+
onSessionChange(listener: (session: AuthSession | null) => void): () => void;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/errors.d.ts
|
|
46
|
+
type AuthErrorCode = "invalid_credentials" | "authentication_required" | "request_origin_denied" | "invalid_workspace_selection" | "credential_rate_limited" | "state_conflict" | "access_denied" | "identity_authority_unavailable";
|
|
47
|
+
type AuthErrorStatus = 401 | 403 | 409 | 422 | 429 | 503;
|
|
48
|
+
declare class AuthError extends Error {
|
|
49
|
+
readonly code: AuthErrorCode;
|
|
50
|
+
readonly status: AuthErrorStatus;
|
|
51
|
+
readonly retryAfterSeconds?: number;
|
|
52
|
+
constructor(code: AuthErrorCode, status: AuthErrorStatus, retryAfterSeconds?: number);
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { AuthSession as a, DriveCredentialInput as c, SignInInput as d, AuthClientOptions as i, FinuevaAuthClient as l, AuthErrorCode as n, AuthUser as o, AuthErrorStatus as r, DriveCredential as s, AuthError as t, PersonalWorkspaceSelection as u };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { a as AuthSession, c as DriveCredentialInput, d as SignInInput, i as AuthClientOptions, l as FinuevaAuthClient, n as AuthErrorCode, o as AuthUser, r as AuthErrorStatus, s as DriveCredential, t as AuthError, u as PersonalWorkspaceSelection } from "./errors-C-cHFWC7.js";
|
|
2
|
+
//#region src/client.d.ts
|
|
3
|
+
declare function createAuthClient(options: AuthClientOptions): FinuevaAuthClient;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { type AuthClientOptions, AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthSession, type AuthUser, type DriveCredential, type DriveCredentialInput, type FinuevaAuthClient, type PersonalWorkspaceSelection, type SignInInput, createAuthClient };
|