@seamless-auth/core 0.1.0 → 0.1.1-beta.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.
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
export interface GetSeamlessUserOptions {
|
|
2
2
|
authServerUrl: string;
|
|
3
3
|
cookieSecret: string;
|
|
4
|
+
authorization: string;
|
|
4
5
|
cookieName?: string;
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the authenticated Seamless Auth user from an access cookie.
|
|
9
|
+
*
|
|
10
|
+
* This function:
|
|
11
|
+
* - Verifies the access cookie locally
|
|
12
|
+
* - Uses the verified token to authenticate a request to the auth server
|
|
13
|
+
* - Returns the canonical user object, or null if authentication fails
|
|
14
|
+
*
|
|
15
|
+
* This is intended for server-side usage (SSR, API routes, edge functions).
|
|
16
|
+
*/
|
|
6
17
|
export declare function getSeamlessUser<T = any>(cookies: Record<string, string | undefined>, opts: GetSeamlessUserOptions): Promise<T | null>;
|
|
7
18
|
//# sourceMappingURL=getSeamlessUser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSeamlessUser.d.ts","sourceRoot":"","sources":["../src/getSeamlessUser.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,eAAe,CAAC,CAAC,GAAG,GAAG,EAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAC3C,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"getSeamlessUser.d.ts","sourceRoot":"","sources":["../src/getSeamlessUser.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,CAAC,GAAG,GAAG,EAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAC3C,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAoBnB"}
|
package/dist/getSeamlessUser.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import { authFetch } from "./authFetch.js";
|
|
2
1
|
import { verifyCookieJwt } from "./verifyCookieJwt.js";
|
|
2
|
+
import { authFetch } from "./authFetch.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the authenticated Seamless Auth user from an access cookie.
|
|
5
|
+
*
|
|
6
|
+
* This function:
|
|
7
|
+
* - Verifies the access cookie locally
|
|
8
|
+
* - Uses the verified token to authenticate a request to the auth server
|
|
9
|
+
* - Returns the canonical user object, or null if authentication fails
|
|
10
|
+
*
|
|
11
|
+
* This is intended for server-side usage (SSR, API routes, edge functions).
|
|
12
|
+
*/
|
|
3
13
|
export async function getSeamlessUser(cookies, opts) {
|
|
4
14
|
const cookieName = opts.cookieName ?? "seamless-access";
|
|
5
15
|
const token = cookies[cookieName];
|
|
@@ -10,6 +20,9 @@ export async function getSeamlessUser(cookies, opts) {
|
|
|
10
20
|
return null;
|
|
11
21
|
const response = await authFetch(`${opts.authServerUrl}/users/me`, {
|
|
12
22
|
method: "GET",
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: opts.authorization,
|
|
25
|
+
},
|
|
13
26
|
});
|
|
14
27
|
if (!response.ok)
|
|
15
28
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSeamlessUser.js","sourceRoot":"","sources":["../src/getSeamlessUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getSeamlessUser.js","sourceRoot":"","sources":["../src/getSeamlessUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAA2C,EAC3C,IAA4B;IAE5B,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,iBAAiB,CAAC;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAElC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1D,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,WAAW,EAAE;QACjE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,OAAO,IAAI,CAAC;IAE9B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;AAC3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamless-auth/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-beta.1",
|
|
4
4
|
"description": "Framework-agnostic core authentication logic for SeamlessAuth",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"author": "Fells Code, LLC",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"homepage": "https://seamlessauth.com",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/fells-code/seamless-auth-server/packages/core"
|
|
11
|
+
"url": "https://github.com/fells-code/seamless-auth-server/tree/main/packages/core"
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "./dist/index.js",
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|