@jengolabs/auth-server-sdk 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.
@@ -0,0 +1,19 @@
1
+ import { AuthSessionWithGrant } from "./types";
2
+ export interface AuthClientConfig {
3
+ authServerUrl: string;
4
+ tenantApiKey: string;
5
+ appSlug: string;
6
+ cacheTtlMs?: number;
7
+ timeoutMs?: number;
8
+ onError?: (error: Error) => void;
9
+ }
10
+ export declare class AuthClient {
11
+ private config;
12
+ private cache;
13
+ constructor(config: AuthClientConfig);
14
+ verifySession(bearerTokenOrCookie: string): Promise<AuthSessionWithGrant>;
15
+ clearCache(): void;
16
+ private getFromCache;
17
+ private setCache;
18
+ }
19
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/C,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAOD,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,KAAK,CAA0B;gBAE3B,MAAM,EAAE,gBAAgB;IAK9B,aAAa,CACjB,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,oBAAoB,CAAC;IAgChC,UAAU,IAAI,IAAI;IAIlB,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,QAAQ;CAQjB"}
package/dist/client.js ADDED
@@ -0,0 +1,58 @@
1
+ import { AuthenticationError } from "./errors";
2
+ export class AuthClient {
3
+ config;
4
+ cache;
5
+ constructor(config) {
6
+ this.config = config;
7
+ this.cache = new Map();
8
+ }
9
+ async verifySession(bearerTokenOrCookie) {
10
+ const cached = this.getFromCache(bearerTokenOrCookie);
11
+ if (cached)
12
+ return cached;
13
+ const isBearer = bearerTokenOrCookie.startsWith("Bearer ");
14
+ const headers = {
15
+ "X-Tenant-Key": this.config.tenantApiKey,
16
+ "X-App-Slug": this.config.appSlug,
17
+ ...(isBearer
18
+ ? { Authorization: bearerTokenOrCookie }
19
+ : { Cookie: bearerTokenOrCookie }),
20
+ };
21
+ const response = await fetch(`${this.config.authServerUrl}/api/auth/session`, {
22
+ headers,
23
+ signal: AbortSignal.timeout(this.config.timeoutMs ?? 5000),
24
+ });
25
+ if (!response.ok) {
26
+ const error = new AuthenticationError("Invalid or expired session");
27
+ this.config.onError?.(error);
28
+ throw error;
29
+ }
30
+ const session = await response.json();
31
+ this.setCache(bearerTokenOrCookie, session);
32
+ return session;
33
+ }
34
+ clearCache() {
35
+ this.cache.clear();
36
+ }
37
+ getFromCache(key) {
38
+ if (!this.config.cacheTtlMs)
39
+ return null;
40
+ const entry = this.cache.get(key);
41
+ if (!entry)
42
+ return null;
43
+ if (Date.now() > entry.expiresAt) {
44
+ this.cache.delete(key);
45
+ return null;
46
+ }
47
+ return entry.session;
48
+ }
49
+ setCache(key, session) {
50
+ if (!this.config.cacheTtlMs)
51
+ return;
52
+ this.cache.set(key, {
53
+ session,
54
+ expiresAt: Date.now() + this.config.cacheTtlMs,
55
+ });
56
+ }
57
+ }
58
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAgB/C,MAAM,OAAO,UAAU;IACb,MAAM,CAAmB;IACzB,KAAK,CAA0B;IAEvC,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACr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,GAAW;QAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC;QAEzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAExB,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAEO,QAAQ,CAAC,GAAW,EAAE,OAA6B;QACzD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO;QAEpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YAClB,OAAO;YACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU;SAC/C,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ export declare class AuthenticationError extends Error {
2
+ readonly statusCode = 401;
3
+ constructor(message?: string);
4
+ }
5
+ export declare class AuthorizationError extends Error {
6
+ readonly statusCode = 403;
7
+ constructor(message?: string);
8
+ }
9
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAgB,UAAU,OAAO;gBAErB,OAAO,SAA4B;CAIhD;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAgB,UAAU,OAAO;gBAErB,OAAO,SAA6B;CAIjD"}
package/dist/errors.js ADDED
@@ -0,0 +1,15 @@
1
+ export class AuthenticationError extends Error {
2
+ statusCode = 401;
3
+ constructor(message = "Authentication required") {
4
+ super(message);
5
+ this.name = "AuthenticationError";
6
+ }
7
+ }
8
+ export class AuthorizationError extends Error {
9
+ statusCode = 403;
10
+ constructor(message = "Insufficient permissions") {
11
+ super(message);
12
+ this.name = "AuthorizationError";
13
+ }
14
+ }
15
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5B,UAAU,GAAG,GAAG,CAAC;IAEjC,YAAY,OAAO,GAAG,yBAAyB;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3B,UAAU,GAAG,GAAG,CAAC;IAEjC,YAAY,OAAO,GAAG,0BAA0B;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export { AuthClient } from "./client";
2
+ export type { AuthClientConfig } from "./client";
3
+ export { AuthenticationError, AuthorizationError, } from "./errors";
4
+ export type { AuthUser, AuthSession, AuthSessionData, AuthSessionWithGrant, AuthAppGrant, AuthOrganization, } from "./types";
5
+ export { createHonoAuthMiddleware, requireAppRole, } from "./middleware/hono";
6
+ export { verifyRequest } from "./middleware/generic";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,QAAQ,EACR,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,wBAAwB,EACxB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { AuthClient } from "./client";
2
+ export { AuthenticationError, AuthorizationError, } from "./errors";
3
+ export { createHonoAuthMiddleware, requireAppRole, } from "./middleware/hono";
4
+ export { verifyRequest } from "./middleware/generic";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAWlB,OAAO,EACL,wBAAwB,EACxB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { AuthClient } from "../client";
2
+ import { AuthSessionWithGrant } from "../types";
3
+ export declare function verifyRequest(authClient: AuthClient, headers: {
4
+ authorization?: string;
5
+ cookie?: string;
6
+ }): Promise<AuthSessionWithGrant>;
7
+ //# sourceMappingURL=generic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/middleware/generic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,wBAAsB,aAAa,CACjC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACnD,OAAO,CAAC,oBAAoB,CAAC,CAQ/B"}
@@ -0,0 +1,9 @@
1
+ import { AuthenticationError } from "../errors";
2
+ export async function verifyRequest(authClient, headers) {
3
+ const credential = headers.authorization ?? headers.cookie ?? null;
4
+ if (!credential) {
5
+ throw new AuthenticationError("No authentication credentials provided");
6
+ }
7
+ return authClient.verifySession(credential);
8
+ }
9
+ //# sourceMappingURL=generic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic.js","sourceRoot":"","sources":["../../src/middleware/generic.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAsB,EACtB,OAAoD;IAEpD,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC;IAEnE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,mBAAmB,CAAC,wCAAwC,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ import { AuthClient } from "../client";
3
+ interface HonoAuthOptions {
4
+ authClient: AuthClient;
5
+ publicPaths?: string[];
6
+ }
7
+ export declare function createHonoAuthMiddleware(options: HonoAuthOptions): MiddlewareHandler;
8
+ export declare function requireAppRole(...allowedRoles: string[]): MiddlewareHandler;
9
+ export {};
10
+ //# sourceMappingURL=hono.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../src/middleware/hono.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,UAAU,eAAe;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,eAAe,GACvB,iBAAiB,CAoCnB;AAED,wBAAgB,cAAc,CAC5B,GAAG,YAAY,EAAE,MAAM,EAAE,GACxB,iBAAiB,CAmBnB"}
@@ -0,0 +1,47 @@
1
+ import { AuthenticationError, AuthorizationError } from "../errors";
2
+ export function createHonoAuthMiddleware(options) {
3
+ return async (c, next) => {
4
+ if (options.publicPaths?.some((p) => c.req.path.startsWith(p))) {
5
+ return next();
6
+ }
7
+ const authHeader = c.req.header("Authorization");
8
+ const cookieHeader = c.req.header("Cookie");
9
+ const credential = authHeader ?? cookieHeader ?? null;
10
+ if (!credential) {
11
+ return c.json({ error: "Authentication required" }, 401);
12
+ }
13
+ try {
14
+ const session = await options.authClient.verifySession(credential);
15
+ if (!session.appGrant) {
16
+ return c.json({ error: "Access denied for this application" }, 403);
17
+ }
18
+ c.set("user", session.user);
19
+ c.set("session", session.session);
20
+ c.set("appGrant", session.appGrant);
21
+ c.set("organization", session.organization);
22
+ return next();
23
+ }
24
+ catch (error) {
25
+ if (error instanceof AuthorizationError) {
26
+ return c.json({ error: error.message }, 403);
27
+ }
28
+ if (error instanceof AuthenticationError) {
29
+ return c.json({ error: error.message }, 401);
30
+ }
31
+ throw error;
32
+ }
33
+ };
34
+ }
35
+ export function requireAppRole(...allowedRoles) {
36
+ return async (c, next) => {
37
+ const appGrant = c.get("appGrant");
38
+ if (!appGrant) {
39
+ return c.json({ error: "Access denied" }, 403);
40
+ }
41
+ if (!allowedRoles.includes(appGrant.role)) {
42
+ return c.json({ error: `Required role: ${allowedRoles.join(" or ")}` }, 403);
43
+ }
44
+ return next();
45
+ };
46
+ }
47
+ //# sourceMappingURL=hono.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hono.js","sourceRoot":"","sources":["../../src/middleware/hono.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAm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AAC,CAAC;YAC5C,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,kBAAkB,EAAE,CAAC;gBACxC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;YAC/C,CAAC;YACD,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;gBACzC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;YAC/C,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,GAAG,YAAsB;IAEzB,OAAO,KAAK,EAAE,CAAU,EAAE,IAAU,EAAE,EAAE;QACtC,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAEpB,CAAC;QAEd,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,GAAG,CAAC,CAAC;QACjD,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,CAAC,IAAI,CACX,EAAE,KAAK,EAAE,kBAAkB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EACxD,GAAG,CACJ,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ export interface AuthUser {
2
+ id: string;
3
+ email: string;
4
+ name: string;
5
+ emailVerified: boolean;
6
+ image?: string;
7
+ role?: string;
8
+ createdAt: string;
9
+ updatedAt: string;
10
+ }
11
+ export interface AuthSessionData {
12
+ id: string;
13
+ token: string;
14
+ expiresAt: string;
15
+ }
16
+ export interface AuthSession {
17
+ user: AuthUser;
18
+ session: AuthSessionData;
19
+ }
20
+ export interface AuthAppGrant {
21
+ appSlug: string;
22
+ role: string;
23
+ grantedAt: string;
24
+ }
25
+ export interface AuthSessionWithGrant extends AuthSession {
26
+ appGrant: AuthAppGrant | null;
27
+ organization?: {
28
+ id: string;
29
+ name: string;
30
+ role: string;
31
+ };
32
+ }
33
+ export interface AuthOrganization {
34
+ id: string;
35
+ name: string;
36
+ slug: string;
37
+ role: string;
38
+ members: Array<{
39
+ userId: string;
40
+ role: string;
41
+ }>;
42
+ }
43
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE;QACb,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@jengolabs/auth-server-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Server-side SDK for Jengo Auth — AuthClient, Hono/Express middleware, typed session verification",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*"
9
+ ],
10
+ "dependencies": {
11
+ "hono": "^4.7.8"
12
+ },
13
+ "devDependencies": {
14
+ "typescript": "^5.8.3",
15
+ "@types/node": "^22.15.21"
16
+ },
17
+ "peerDependencies": {
18
+ "hono": ">=4.0.0"
19
+ },
20
+ "peerDependenciesMeta": {
21
+ "hono": {
22
+ "optional": true
23
+ }
24
+ },
25
+ "license": "MIT",
26
+ "publishConfig": {
27
+ "registry": "https://registry.npmjs.org",
28
+ "access": "public"
29
+ },
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "dev": "tsc --watch",
33
+ "type-check": "tsc --noEmit",
34
+ "clean": "rm -rf dist"
35
+ }
36
+ }