@cauthyhq/node 1.2.1 → 1.3.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/CHANGELOG.md +21 -0
- package/README.md +13 -27
- package/dist/{cauthy-CCSSj3Lg.d.mts → cauthy-CsWUgyv_.d.mts} +42 -145
- package/dist/{cauthy-C7gZ-pbv.d.ts → cauthy-DHLBEuqP.d.ts} +42 -145
- package/dist/express.d.mts +2 -5
- package/dist/express.d.ts +2 -5
- package/dist/express.js +1 -2
- package/dist/express.js.map +1 -1
- package/dist/express.mjs +1 -2
- package/dist/express.mjs.map +1 -1
- package/dist/fastify.d.mts +1 -3
- package/dist/fastify.d.ts +1 -3
- package/dist/fastify.js +0 -2
- package/dist/fastify.js.map +1 -1
- package/dist/fastify.mjs +0 -2
- package/dist/fastify.mjs.map +1 -1
- package/dist/hono.d.mts +2 -5
- package/dist/hono.d.ts +2 -5
- package/dist/hono.js +1 -2
- package/dist/hono.js.map +1 -1
- package/dist/hono.mjs +1 -2
- package/dist/hono.mjs.map +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +169 -524
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +162 -514
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs.map +1 -1
- package/dist/next.d.mts +1 -3
- package/dist/next.d.ts +1 -3
- package/dist/testing.d.mts +11 -5
- package/dist/testing.d.ts +11 -5
- package/dist/testing.js +52 -50
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +52 -50
- package/dist/testing.mjs.map +1 -1
- package/package.json +4 -15
- package/dist/identity-BTJ8NB_w.d.mts +0 -27
- package/dist/identity-BTJ8NB_w.d.ts +0 -27
- package/dist/keys-D5k0omTb.d.mts +0 -64
- package/dist/keys-D5k0omTb.d.ts +0 -64
- package/dist/keys.d.mts +0 -8
- package/dist/keys.d.ts +0 -8
- package/dist/keys.js +0 -157
- package/dist/keys.js.map +0 -1
- package/dist/keys.mjs +0 -129
- package/dist/keys.mjs.map +0 -1
package/dist/hono.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hono.ts"],"sourcesContent":["// Hono: the routes, and who is signed in on every request.\n//\n// const app = new Hono<{ Variables: CauthyVariables }>()\n// app.use(cauthyHono(auth))\n//\n// app.get('/api/me', (c) => {\n// const session = c.get('session')\n// return session ? c.json(session.user) : c.json({ error: 'unauthenticated' }, 401)\n// })\n//\n// app.get('/api/books', requireSession, (c) => { … })\n//\n// A session that needs renewing is renewed on the spot, and its new cookie\n// leaves with whatever the route answers. It runs wherever Hono does.\n\nimport type { MiddlewareHandler } from 'hono'\nimport type { Cauthy } from './cauthy'\nimport type { Session } from './types'\n\n/** What the middleware keeps on the context: `new Hono<{ Variables: CauthyVariables }>()`. */\nexport interface CauthyVariables {\n /** Who is signed in, or null. */\n session: Session | null\n}\n\ntype Env = { Variables: CauthyVariables }\n\n/**\n * Serves the routes under the handler's `basePath
|
|
1
|
+
{"version":3,"sources":["../src/hono.ts"],"sourcesContent":["// Hono: the routes, and who is signed in on every request.\n//\n// const app = new Hono<{ Variables: CauthyVariables }>()\n// app.use(cauthyHono(auth))\n//\n// app.get('/api/me', (c) => {\n// const session = c.get('session')\n// return session ? c.json(session.user) : c.json({ error: 'unauthenticated' }, 401)\n// })\n//\n// app.get('/api/books', requireSession, (c) => { … })\n//\n// A session that needs renewing is renewed on the spot, and its new cookie\n// leaves with whatever the route answers. It runs wherever Hono does.\n\nimport type { MiddlewareHandler } from 'hono'\nimport type { Cauthy } from './cauthy'\nimport type { Session } from './types'\n\n/** What the middleware keeps on the context: `new Hono<{ Variables: CauthyVariables }>()`. */\nexport interface CauthyVariables {\n /** Who is signed in, or null. */\n session: Session | null\n}\n\ntype Env = { Variables: CauthyVariables }\n\n/**\n * Serves the routes under the handler's `basePath`, and sets `session` for\n * every other request. Mount it once, before the routes that use it.\n */\nexport function cauthyHono(auth: Cauthy): MiddlewareHandler<Env> {\n const base = auth.options.basePath\n return async (c, next) => {\n const path = new URL(c.req.url).pathname\n if (path === base || path.startsWith(`${base}/`)) return auth.handler(c.req.raw)\n\n const resolved = await auth.resolve(c.req.raw)\n c.set('session', resolved.session)\n await next()\n for (const cookie of resolved.cookies) c.header('set-cookie', cookie, { append: true })\n }\n}\n\n/** For a route only a signed-in person may call: answers 401 otherwise. Needs `cauthyHono` mounted before it. */\nexport const requireSession: MiddlewareHandler<Env> = async (c, next) => {\n if (c.get('session') === null || c.get('session') === undefined) {\n c.header('x-cauthy-session', 'none')\n return c.json({ error: 'unauthenticated' }, 401)\n }\n await next()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,SAAS,WAAW,MAAsC;AAC/D,QAAM,OAAO,KAAK,QAAQ;AAC1B,SAAO,OAAO,GAAG,SAAS;AACxB,UAAM,OAAO,IAAI,IAAI,EAAE,IAAI,GAAG,EAAE;AAChC,QAAI,SAAS,QAAQ,KAAK,WAAW,GAAG,IAAI,GAAG,EAAG,QAAO,KAAK,QAAQ,EAAE,IAAI,GAAG;AAE/E,UAAM,WAAW,MAAM,KAAK,QAAQ,EAAE,IAAI,GAAG;AAC7C,MAAE,IAAI,WAAW,SAAS,OAAO;AACjC,UAAM,KAAK;AACX,eAAW,UAAU,SAAS,QAAS,GAAE,OAAO,cAAc,QAAQ,EAAE,QAAQ,KAAK,CAAC;AAAA,EACxF;AACF;AAGO,IAAM,iBAAyC,OAAO,GAAG,SAAS;AACvE,MAAI,EAAE,IAAI,SAAS,MAAM,QAAQ,EAAE,IAAI,SAAS,MAAM,QAAW;AAC/D,MAAE,OAAO,oBAAoB,MAAM;AACnC,WAAO,EAAE,KAAK,EAAE,OAAO,kBAAkB,GAAG,GAAG;AAAA,EACjD;AACA,QAAM,KAAK;AACb;","names":[]}
|
package/dist/hono.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// src/hono.ts
|
|
2
2
|
function cauthyHono(auth) {
|
|
3
3
|
const base = auth.options.basePath;
|
|
4
|
-
const key = auth.pact?.contract.jwksPath;
|
|
5
4
|
return async (c, next) => {
|
|
6
5
|
const path = new URL(c.req.url).pathname;
|
|
7
|
-
if (path === base || path.startsWith(`${base}/`)
|
|
6
|
+
if (path === base || path.startsWith(`${base}/`)) return auth.handler(c.req.raw);
|
|
8
7
|
const resolved = await auth.resolve(c.req.raw);
|
|
9
8
|
c.set("session", resolved.session);
|
|
10
9
|
await next();
|
package/dist/hono.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hono.ts"],"sourcesContent":["// Hono: the routes, and who is signed in on every request.\n//\n// const app = new Hono<{ Variables: CauthyVariables }>()\n// app.use(cauthyHono(auth))\n//\n// app.get('/api/me', (c) => {\n// const session = c.get('session')\n// return session ? c.json(session.user) : c.json({ error: 'unauthenticated' }, 401)\n// })\n//\n// app.get('/api/books', requireSession, (c) => { … })\n//\n// A session that needs renewing is renewed on the spot, and its new cookie\n// leaves with whatever the route answers. It runs wherever Hono does.\n\nimport type { MiddlewareHandler } from 'hono'\nimport type { Cauthy } from './cauthy'\nimport type { Session } from './types'\n\n/** What the middleware keeps on the context: `new Hono<{ Variables: CauthyVariables }>()`. */\nexport interface CauthyVariables {\n /** Who is signed in, or null. */\n session: Session | null\n}\n\ntype Env = { Variables: CauthyVariables }\n\n/**\n * Serves the routes under the handler's `basePath
|
|
1
|
+
{"version":3,"sources":["../src/hono.ts"],"sourcesContent":["// Hono: the routes, and who is signed in on every request.\n//\n// const app = new Hono<{ Variables: CauthyVariables }>()\n// app.use(cauthyHono(auth))\n//\n// app.get('/api/me', (c) => {\n// const session = c.get('session')\n// return session ? c.json(session.user) : c.json({ error: 'unauthenticated' }, 401)\n// })\n//\n// app.get('/api/books', requireSession, (c) => { … })\n//\n// A session that needs renewing is renewed on the spot, and its new cookie\n// leaves with whatever the route answers. It runs wherever Hono does.\n\nimport type { MiddlewareHandler } from 'hono'\nimport type { Cauthy } from './cauthy'\nimport type { Session } from './types'\n\n/** What the middleware keeps on the context: `new Hono<{ Variables: CauthyVariables }>()`. */\nexport interface CauthyVariables {\n /** Who is signed in, or null. */\n session: Session | null\n}\n\ntype Env = { Variables: CauthyVariables }\n\n/**\n * Serves the routes under the handler's `basePath`, and sets `session` for\n * every other request. Mount it once, before the routes that use it.\n */\nexport function cauthyHono(auth: Cauthy): MiddlewareHandler<Env> {\n const base = auth.options.basePath\n return async (c, next) => {\n const path = new URL(c.req.url).pathname\n if (path === base || path.startsWith(`${base}/`)) return auth.handler(c.req.raw)\n\n const resolved = await auth.resolve(c.req.raw)\n c.set('session', resolved.session)\n await next()\n for (const cookie of resolved.cookies) c.header('set-cookie', cookie, { append: true })\n }\n}\n\n/** For a route only a signed-in person may call: answers 401 otherwise. Needs `cauthyHono` mounted before it. */\nexport const requireSession: MiddlewareHandler<Env> = async (c, next) => {\n if (c.get('session') === null || c.get('session') === undefined) {\n c.header('x-cauthy-session', 'none')\n return c.json({ error: 'unauthenticated' }, 401)\n }\n await next()\n}\n"],"mappings":";AA+BO,SAAS,WAAW,MAAsC;AAC/D,QAAM,OAAO,KAAK,QAAQ;AAC1B,SAAO,OAAO,GAAG,SAAS;AACxB,UAAM,OAAO,IAAI,IAAI,EAAE,IAAI,GAAG,EAAE;AAChC,QAAI,SAAS,QAAQ,KAAK,WAAW,GAAG,IAAI,GAAG,EAAG,QAAO,KAAK,QAAQ,EAAE,IAAI,GAAG;AAE/E,UAAM,WAAW,MAAM,KAAK,QAAQ,EAAE,IAAI,GAAG;AAC7C,MAAE,IAAI,WAAW,SAAS,OAAO;AACjC,UAAM,KAAK;AACX,eAAW,UAAU,SAAS,QAAS,GAAE,OAAO,cAAc,QAAQ,EAAE,QAAQ,KAAK,CAAC;AAAA,EACxF;AACF;AAGO,IAAM,iBAAyC,OAAO,GAAG,SAAS;AACvE,MAAI,EAAE,IAAI,SAAS,MAAM,QAAQ,EAAE,IAAI,SAAS,MAAM,QAAW;AAC/D,MAAE,OAAO,oBAAoB,MAAM;AACnC,WAAO,EAAE,KAAK,EAAE,OAAO,kBAAkB,GAAG,GAAG;AAAA,EACjD;AACA,QAAM,KAAK;AACb;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export { A as AttributeType, a as CatalogResource, C as Cauthy, b as CauthyApiError, c as CauthyConfigError, d as CauthyEvent, e as CauthyKeyError, f as CauthyKeyReason, g as CauthyOptions, h as
|
|
2
|
-
export { I as Identity } from './identity-BTJ8NB_w.mjs';
|
|
3
|
-
export { K as KeyStore, P as PactKeys, S as StoredKey } from './keys-D5k0omTb.mjs';
|
|
1
|
+
export { A as AttributeType, a as CatalogResource, C as Cauthy, b as CauthyApiError, c as CauthyConfigError, d as CauthyEvent, e as CauthyKeyError, f as CauthyKeyReason, g as CauthyOptions, h as CauthySystem, i as CauthyTokenError, j as CauthyUnavailableError, k as CauthyWebhookError, l as CheckOf, m as CheckQuestion, n as CheckResult, o as CheckRule, p as ConditionalPermission, I as Identity, J as JsonValue, M as MountTarget, N as NewMember, O as Organization, q as OrganizationMember, r as OrganizationRef, P as PermissionOf, s as Permitted, t as Policy, u as PolicyDefinition, v as PolicyPermission, w as PolicyRole, x as PublicSession, y as PushPolicyOptions, R as ReplayStore, z as Resolved, B as RoleOf, S as Session, D as SessionOrganization, E as SessionStatus, F as SessionUser, G as SystemKey, H as SystemOptions, K as SystemPolicy, T as TokenIdentity, L as TokenRefusal, V as VerifyTokenOptions, Q as VerifyWebhookOptions, U as can, W as createCauthy, X as createSystem, Y as createTokenVerifier, Z as createVerifierFromEnv, _ as definePolicy, $ as memoryReplayStore, a0 as policySource, a1 as pullCatalog, a2 as pullPolicy, a3 as pushCatalog, a4 as pushPolicy, a5 as remoteKeys, a6 as verifyToken, a7 as verifyWebhook } from './cauthy-CsWUgyv_.mjs';
|
|
4
2
|
export { CauthyTheme, ImportedTheme, PushThemeOptions, StackmythThemeOptions, StackmythTokens, ThemeFont, ThemeTexts, pushTheme, themeFromStackmyth, tokensFromStackmyth } from './theme.mjs';
|
|
5
3
|
import 'jose';
|
|
6
4
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export { A as AttributeType, a as CatalogResource, C as Cauthy, b as CauthyApiError, c as CauthyConfigError, d as CauthyEvent, e as CauthyKeyError, f as CauthyKeyReason, g as CauthyOptions, h as
|
|
2
|
-
export { I as Identity } from './identity-BTJ8NB_w.js';
|
|
3
|
-
export { K as KeyStore, P as PactKeys, S as StoredKey } from './keys-D5k0omTb.js';
|
|
1
|
+
export { A as AttributeType, a as CatalogResource, C as Cauthy, b as CauthyApiError, c as CauthyConfigError, d as CauthyEvent, e as CauthyKeyError, f as CauthyKeyReason, g as CauthyOptions, h as CauthySystem, i as CauthyTokenError, j as CauthyUnavailableError, k as CauthyWebhookError, l as CheckOf, m as CheckQuestion, n as CheckResult, o as CheckRule, p as ConditionalPermission, I as Identity, J as JsonValue, M as MountTarget, N as NewMember, O as Organization, q as OrganizationMember, r as OrganizationRef, P as PermissionOf, s as Permitted, t as Policy, u as PolicyDefinition, v as PolicyPermission, w as PolicyRole, x as PublicSession, y as PushPolicyOptions, R as ReplayStore, z as Resolved, B as RoleOf, S as Session, D as SessionOrganization, E as SessionStatus, F as SessionUser, G as SystemKey, H as SystemOptions, K as SystemPolicy, T as TokenIdentity, L as TokenRefusal, V as VerifyTokenOptions, Q as VerifyWebhookOptions, U as can, W as createCauthy, X as createSystem, Y as createTokenVerifier, Z as createVerifierFromEnv, _ as definePolicy, $ as memoryReplayStore, a0 as policySource, a1 as pullCatalog, a2 as pullPolicy, a3 as pushCatalog, a4 as pushPolicy, a5 as remoteKeys, a6 as verifyToken, a7 as verifyWebhook } from './cauthy-DHLBEuqP.js';
|
|
4
2
|
export { CauthyTheme, ImportedTheme, PushThemeOptions, StackmythThemeOptions, StackmythTokens, ThemeFont, ThemeTexts, pushTheme, themeFromStackmyth, tokensFromStackmyth } from './theme.js';
|
|
5
3
|
import 'jose';
|
|
6
4
|
|