@ceebee/auth-contract 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/README.md +9 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/package.json +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# `@ceebee/auth-contract`
|
|
2
|
+
|
|
3
|
+
Home-owned Deep Module for the shared Auth.js session cookie and consumer-to-gateway destination.
|
|
4
|
+
It deliberately does not own Google OAuth, the email allowlist, callbacks, token issuance, or UI;
|
|
5
|
+
those remain Home Implementations behind this Interface.
|
|
6
|
+
|
|
7
|
+
Consumers must pin `next-auth` to `5.0.0-beta.32`. Migrate one product at a time after publishing
|
|
8
|
+
this package, retaining its existing `lib/auth-cookie.ts` and `lib/auth-gateway.ts` as compatibility
|
|
9
|
+
facades until browser login and logout pass on sibling subdomains.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const PRODUCTION_SESSION_COOKIE = "__Secure-authjs.session-token";
|
|
2
|
+
export declare const DEVELOPMENT_SESSION_COOKIE = "authjs.session-token";
|
|
3
|
+
export declare const CEEBEE_COOKIE_DOMAIN = ".ceebee.biz.id";
|
|
4
|
+
export interface SharedSessionCookie {
|
|
5
|
+
name: string;
|
|
6
|
+
options: {
|
|
7
|
+
domain?: string;
|
|
8
|
+
httpOnly: true;
|
|
9
|
+
sameSite: 'lax';
|
|
10
|
+
path: '/';
|
|
11
|
+
secure: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function sharedSessionCookie(domain?: string): SharedSessionCookie;
|
|
15
|
+
export declare function safeLocalPath(value: unknown): string;
|
|
16
|
+
export interface GatewayUrlOptions {
|
|
17
|
+
action: 'login' | 'logout';
|
|
18
|
+
path?: unknown;
|
|
19
|
+
appOrigin: string;
|
|
20
|
+
gatewayOrigin?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function authGatewayUrl({ action, path, appOrigin, gatewayOrigin, }: GatewayUrlOptions): string;
|
|
23
|
+
export declare function isSessionCookieName(name: string, sessionName: string): boolean;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,kCAAkC,CAAC;AACzE,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AACjE,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AAErD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,IAAI,CAAC;QACf,QAAQ,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,GAAG,CAAC;QACV,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC;CACH;AAED,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAqBxE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKpD;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,IAAU,EACV,SAAS,EACT,aAAuC,GACxC,EAAE,iBAAiB,GAAG,MAAM,CAI5B;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAE9E"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const PRODUCTION_SESSION_COOKIE = '__Secure-authjs.session-token';
|
|
2
|
+
export const DEVELOPMENT_SESSION_COOKIE = 'authjs.session-token';
|
|
3
|
+
export const CEEBEE_COOKIE_DOMAIN = '.ceebee.biz.id';
|
|
4
|
+
export function sharedSessionCookie(domain) {
|
|
5
|
+
const normalized = domain?.trim();
|
|
6
|
+
if (!normalized) {
|
|
7
|
+
return {
|
|
8
|
+
name: DEVELOPMENT_SESSION_COOKIE,
|
|
9
|
+
options: { httpOnly: true, sameSite: 'lax', path: '/', secure: false },
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (normalized !== CEEBEE_COOKIE_DOMAIN) {
|
|
13
|
+
throw new Error(`AUTH_COOKIE_DOMAIN must be ${CEEBEE_COOKIE_DOMAIN}`);
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
name: PRODUCTION_SESSION_COOKIE,
|
|
17
|
+
options: {
|
|
18
|
+
domain: normalized,
|
|
19
|
+
httpOnly: true,
|
|
20
|
+
sameSite: 'lax',
|
|
21
|
+
path: '/',
|
|
22
|
+
secure: true,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function safeLocalPath(value) {
|
|
27
|
+
const path = typeof value === 'string' ? value.trim() : '';
|
|
28
|
+
if (!path.startsWith('/') || path.startsWith('//') || path.startsWith('/\\'))
|
|
29
|
+
return '/';
|
|
30
|
+
if (/[\u0000-\u001f\u007f]/.test(path))
|
|
31
|
+
return '/';
|
|
32
|
+
return path;
|
|
33
|
+
}
|
|
34
|
+
export function authGatewayUrl({ action, path = '/', appOrigin, gatewayOrigin = 'https://ceebee.biz.id', }) {
|
|
35
|
+
const url = new URL(`/${action}`, gatewayOrigin);
|
|
36
|
+
url.searchParams.set('returnTo', new URL(safeLocalPath(path), appOrigin).toString());
|
|
37
|
+
return url.toString();
|
|
38
|
+
}
|
|
39
|
+
export function isSessionCookieName(name, sessionName) {
|
|
40
|
+
return name === sessionName || name.startsWith(`${sessionName}.`);
|
|
41
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ceebee/auth-contract",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared CeeBee session cookie and Auth Gateway destination contract.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": ["dist", "README.md"],
|
|
13
|
+
"engines": { "node": ">=20" },
|
|
14
|
+
"peerDependencies": { "next-auth": "5.0.0-beta.32" },
|
|
15
|
+
"devDependencies": { "typescript": "^5.7.2" },
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.json",
|
|
18
|
+
"test": "pnpm build && node --test test/*.test.mjs",
|
|
19
|
+
"prepublishOnly": "pnpm test"
|
|
20
|
+
}
|
|
21
|
+
}
|