cauthy-auth 0.38.1 → 0.39.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 +1 -1
- package/dist/{cauthy-C-GoRXy9.d.mts → cauthy-3h6d8YXl.d.mts} +1 -1
- package/dist/{cauthy-BUozWD72.d.ts → cauthy-C-_Bj6-L.d.ts} +1 -1
- package/dist/cli.js +3 -2
- package/dist/client.d.mts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/express.d.mts +2 -2
- package/dist/express.d.ts +2 -2
- package/dist/fastify.d.mts +2 -2
- package/dist/fastify.d.ts +2 -2
- package/dist/hono.d.mts +2 -2
- package/dist/hono.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -4
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +2 -2
- package/dist/next.d.ts +2 -2
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/{system-DUGV040y.d.mts → system-CqPa5xR5.d.mts} +6 -0
- package/dist/{system-Bz4haPrI.d.ts → system-Dssq1JUJ.d.ts} +6 -0
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -235,7 +235,7 @@ npx cauthy-auth init
|
|
|
235
235
|
npx cauthy-auth init --system ledger --app-url https://app.example.com # production
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
-
The same client is your application's own identity: it manages its organizations with no person's token.
|
|
238
|
+
The same client is your application's own identity: it manages its organizations with no person's token. When people sign in with a public client (no secret) and the application's identity is a confidential client beside it, give the key that client's id: `systemKey: { privateKey, keyId, clientId }`. Its sign-ins then carry the proof that tells Cauthy which application signed the person in, and from what address.
|
|
239
239
|
|
|
240
240
|
```ts
|
|
241
241
|
const org = await auth.system.organizations.create({ name: 'Acme' })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-
|
|
1
|
+
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-CqPa5xR5.mjs';
|
|
2
2
|
import { JWTVerifyGetKey } from 'jose';
|
|
3
3
|
|
|
4
4
|
/** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-
|
|
1
|
+
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-Dssq1JUJ.js';
|
|
2
2
|
import { JWTVerifyGetKey } from 'jose';
|
|
3
3
|
|
|
4
4
|
/** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
|
package/dist/cli.js
CHANGED
|
@@ -1013,9 +1013,10 @@ function createSystem(given = {}) {
|
|
|
1013
1013
|
let asking;
|
|
1014
1014
|
async function ask() {
|
|
1015
1015
|
configured();
|
|
1016
|
-
const
|
|
1016
|
+
const self = key?.clientId || clientId;
|
|
1017
|
+
const form = new URLSearchParams({ grant_type: "client_credentials", client_id: self });
|
|
1017
1018
|
if (key) {
|
|
1018
|
-
const assertion = await new import_jose.SignJWT({}).setProtectedHeader({ alg: "RS256", kid: key.keyId }).setIssuer(
|
|
1019
|
+
const assertion = await new import_jose.SignJWT({}).setProtectedHeader({ alg: "RS256", kid: key.keyId }).setIssuer(self).setSubject(self).setAudience(tokenEndpoint).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("2m").sign(await signingKey());
|
|
1019
1020
|
form.set("client_assertion_type", ASSERTION_TYPE);
|
|
1020
1021
|
form.set("client_assertion", assertion);
|
|
1021
1022
|
} else {
|
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.mjs';
|
|
2
|
-
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-
|
|
3
|
-
export { h as CheckRule } from './system-
|
|
2
|
+
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-CqPa5xR5.mjs';
|
|
3
|
+
export { h as CheckRule } from './system-CqPa5xR5.mjs';
|
|
4
4
|
import { A as AuthField, b as PasswordPolicy } from './validate-sEXG82po.mjs';
|
|
5
5
|
export { D as DEFAULT_PASSWORD_POLICY, F as FieldProblem, M as MIN_PASSWORD, P as PasswordClass, a as PasswordLocale, c as PasswordReason, d as checkCode, e as checkEmail, f as checkName, g as checkNewPassword, h as checkPassword, i as describePasswordPolicy, j as explainPasswordProblems, p as passwordPolicyOf, k as passwordProblems } from './validate-sEXG82po.mjs';
|
|
6
6
|
import 'jose';
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.js';
|
|
2
|
-
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-
|
|
3
|
-
export { h as CheckRule } from './system-
|
|
2
|
+
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-Dssq1JUJ.js';
|
|
3
|
+
export { h as CheckRule } from './system-Dssq1JUJ.js';
|
|
4
4
|
import { A as AuthField, b as PasswordPolicy } from './validate-sEXG82po.js';
|
|
5
5
|
export { D as DEFAULT_PASSWORD_POLICY, F as FieldProblem, M as MIN_PASSWORD, P as PasswordClass, a as PasswordLocale, c as PasswordReason, d as checkCode, e as checkEmail, f as checkName, g as checkNewPassword, h as checkPassword, i as describePasswordPolicy, j as explainPasswordProblems, p as passwordPolicyOf, k as passwordProblems } from './validate-sEXG82po.js';
|
|
6
6
|
import 'jose';
|
package/dist/express.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { C as Cauthy } from './cauthy-
|
|
3
|
-
import { S as Session } from './system-
|
|
2
|
+
import { C as Cauthy } from './cauthy-3h6d8YXl.mjs';
|
|
3
|
+
import { S as Session } from './system-CqPa5xR5.mjs';
|
|
4
4
|
import 'jose';
|
|
5
5
|
import './theme.mjs';
|
|
6
6
|
|
package/dist/express.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { C as Cauthy } from './cauthy-
|
|
3
|
-
import { S as Session } from './system-
|
|
2
|
+
import { C as Cauthy } from './cauthy-C-_Bj6-L.js';
|
|
3
|
+
import { S as Session } from './system-Dssq1JUJ.js';
|
|
4
4
|
import 'jose';
|
|
5
5
|
import './theme.js';
|
|
6
6
|
|
package/dist/fastify.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FastifyReply, FastifyPluginAsync } from 'fastify';
|
|
2
|
-
import { C as Cauthy } from './cauthy-
|
|
3
|
-
import { S as Session } from './system-
|
|
2
|
+
import { C as Cauthy } from './cauthy-3h6d8YXl.mjs';
|
|
3
|
+
import { S as Session } from './system-CqPa5xR5.mjs';
|
|
4
4
|
import 'jose';
|
|
5
5
|
import './theme.mjs';
|
|
6
6
|
|
package/dist/fastify.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FastifyReply, FastifyPluginAsync } from 'fastify';
|
|
2
|
-
import { C as Cauthy } from './cauthy-
|
|
3
|
-
import { S as Session } from './system-
|
|
2
|
+
import { C as Cauthy } from './cauthy-C-_Bj6-L.js';
|
|
3
|
+
import { S as Session } from './system-Dssq1JUJ.js';
|
|
4
4
|
import 'jose';
|
|
5
5
|
import './theme.js';
|
|
6
6
|
|
package/dist/hono.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MiddlewareHandler } from 'hono';
|
|
2
|
-
import { C as Cauthy } from './cauthy-
|
|
3
|
-
import { S as Session } from './system-
|
|
2
|
+
import { C as Cauthy } from './cauthy-3h6d8YXl.mjs';
|
|
3
|
+
import { S as Session } from './system-CqPa5xR5.mjs';
|
|
4
4
|
import 'jose';
|
|
5
5
|
import './theme.mjs';
|
|
6
6
|
|
package/dist/hono.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MiddlewareHandler } from 'hono';
|
|
2
|
-
import { C as Cauthy } from './cauthy-
|
|
3
|
-
import { S as Session } from './system-
|
|
2
|
+
import { C as Cauthy } from './cauthy-C-_Bj6-L.js';
|
|
3
|
+
import { S as Session } from './system-Dssq1JUJ.js';
|
|
4
4
|
import 'jose';
|
|
5
5
|
import './theme.js';
|
|
6
6
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { C as Cauthy, a as CauthyEvent, b as CauthyWebhookError, R as Resolved, V as VerifyWebhookOptions, c as createCauthy, v as verifyWebhook } from './cauthy-
|
|
2
|
-
export { A as AttributeType, C as CatalogResource, a as CauthyApiError, b as CauthyConfigError, c as CauthyOptions, d as CauthySystem, e as CheckOf, f as CheckQuestion, g as CheckResult, h as CheckRule, i as ConditionalPermission, J as JsonValue, N as NewMember, O as Organization, j as OrganizationMember, k as OrganizationRef, P as PermissionOf, l as Permitted, m as Policy, n as PolicyDefinition, o as PolicyPermission, p as PolicyRole, q as PublicSession, r as PushPolicyOptions, R as RoleOf, S as Session, s as SessionOrganization, t as SessionStatus, u as SessionUser, v as SystemKey, w as SystemOptions, x as SystemPolicy, y as can, z as createSystem, B as definePolicy, D as policySource, E as pullCatalog, F as pullPolicy, G as pushCatalog, H as pushPolicy } from './system-
|
|
1
|
+
export { C as Cauthy, a as CauthyEvent, b as CauthyWebhookError, R as Resolved, V as VerifyWebhookOptions, c as createCauthy, v as verifyWebhook } from './cauthy-3h6d8YXl.mjs';
|
|
2
|
+
export { A as AttributeType, C as CatalogResource, a as CauthyApiError, b as CauthyConfigError, c as CauthyOptions, d as CauthySystem, e as CheckOf, f as CheckQuestion, g as CheckResult, h as CheckRule, i as ConditionalPermission, J as JsonValue, N as NewMember, O as Organization, j as OrganizationMember, k as OrganizationRef, P as PermissionOf, l as Permitted, m as Policy, n as PolicyDefinition, o as PolicyPermission, p as PolicyRole, q as PublicSession, r as PushPolicyOptions, R as RoleOf, S as Session, s as SessionOrganization, t as SessionStatus, u as SessionUser, v as SystemKey, w as SystemOptions, x as SystemPolicy, y as can, z as createSystem, B as definePolicy, D as policySource, E as pullCatalog, F as pullPolicy, G as pushCatalog, H as pushPolicy } from './system-CqPa5xR5.mjs';
|
|
3
3
|
export { CauthyTheme, ImportedTheme, PushThemeOptions, StackmythThemeOptions, StackmythTokens, ThemeFont, ThemeTexts, pushTheme, themeFromStackmyth, tokensFromStackmyth } from './theme.mjs';
|
|
4
4
|
export { A as AuthField, D as DEFAULT_PASSWORD_POLICY, F as FieldProblem, M as MIN_PASSWORD, P as PasswordClass, a as PasswordLocale, b as PasswordPolicy, c as PasswordReason, d as checkCode, e as checkEmail, f as checkName, g as checkNewPassword, h as checkPassword, i as describePasswordPolicy, j as explainPasswordProblems, p as passwordPolicyOf, k as passwordProblems } from './validate-sEXG82po.mjs';
|
|
5
5
|
import { JWTVerifyGetKey } from 'jose';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { C as Cauthy, a as CauthyEvent, b as CauthyWebhookError, R as Resolved, V as VerifyWebhookOptions, c as createCauthy, v as verifyWebhook } from './cauthy-
|
|
2
|
-
export { A as AttributeType, C as CatalogResource, a as CauthyApiError, b as CauthyConfigError, c as CauthyOptions, d as CauthySystem, e as CheckOf, f as CheckQuestion, g as CheckResult, h as CheckRule, i as ConditionalPermission, J as JsonValue, N as NewMember, O as Organization, j as OrganizationMember, k as OrganizationRef, P as PermissionOf, l as Permitted, m as Policy, n as PolicyDefinition, o as PolicyPermission, p as PolicyRole, q as PublicSession, r as PushPolicyOptions, R as RoleOf, S as Session, s as SessionOrganization, t as SessionStatus, u as SessionUser, v as SystemKey, w as SystemOptions, x as SystemPolicy, y as can, z as createSystem, B as definePolicy, D as policySource, E as pullCatalog, F as pullPolicy, G as pushCatalog, H as pushPolicy } from './system-
|
|
1
|
+
export { C as Cauthy, a as CauthyEvent, b as CauthyWebhookError, R as Resolved, V as VerifyWebhookOptions, c as createCauthy, v as verifyWebhook } from './cauthy-C-_Bj6-L.js';
|
|
2
|
+
export { A as AttributeType, C as CatalogResource, a as CauthyApiError, b as CauthyConfigError, c as CauthyOptions, d as CauthySystem, e as CheckOf, f as CheckQuestion, g as CheckResult, h as CheckRule, i as ConditionalPermission, J as JsonValue, N as NewMember, O as Organization, j as OrganizationMember, k as OrganizationRef, P as PermissionOf, l as Permitted, m as Policy, n as PolicyDefinition, o as PolicyPermission, p as PolicyRole, q as PublicSession, r as PushPolicyOptions, R as RoleOf, S as Session, s as SessionOrganization, t as SessionStatus, u as SessionUser, v as SystemKey, w as SystemOptions, x as SystemPolicy, y as can, z as createSystem, B as definePolicy, D as policySource, E as pullCatalog, F as pullPolicy, G as pushCatalog, H as pushPolicy } from './system-Dssq1JUJ.js';
|
|
3
3
|
export { CauthyTheme, ImportedTheme, PushThemeOptions, StackmythThemeOptions, StackmythTokens, ThemeFont, ThemeTexts, pushTheme, themeFromStackmyth, tokensFromStackmyth } from './theme.js';
|
|
4
4
|
export { A as AuthField, D as DEFAULT_PASSWORD_POLICY, F as FieldProblem, M as MIN_PASSWORD, P as PasswordClass, a as PasswordLocale, b as PasswordPolicy, c as PasswordReason, d as checkCode, e as checkEmail, f as checkName, g as checkNewPassword, h as checkPassword, i as describePasswordPolicy, j as explainPasswordProblems, p as passwordPolicyOf, k as passwordProblems } from './validate-sEXG82po.js';
|
|
5
5
|
import { JWTVerifyGetKey } from 'jose';
|
package/dist/index.js
CHANGED
|
@@ -770,9 +770,10 @@ function createSystem(given = {}) {
|
|
|
770
770
|
let asking;
|
|
771
771
|
async function ask() {
|
|
772
772
|
configured();
|
|
773
|
-
const
|
|
773
|
+
const self = key?.clientId || clientId;
|
|
774
|
+
const form = new URLSearchParams({ grant_type: "client_credentials", client_id: self });
|
|
774
775
|
if (key) {
|
|
775
|
-
const assertion = await new import_jose2.SignJWT({}).setProtectedHeader({ alg: "RS256", kid: key.keyId }).setIssuer(
|
|
776
|
+
const assertion = await new import_jose2.SignJWT({}).setProtectedHeader({ alg: "RS256", kid: key.keyId }).setIssuer(self).setSubject(self).setAudience(tokenEndpoint).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("2m").sign(await signingKey());
|
|
776
777
|
form.set("client_assertion_type", ASSERTION_TYPE);
|
|
777
778
|
form.set("client_assertion", assertion);
|
|
778
779
|
} else {
|
|
@@ -1560,13 +1561,13 @@ function createCauthy(given = {}) {
|
|
|
1560
1561
|
return null;
|
|
1561
1562
|
}
|
|
1562
1563
|
}
|
|
1563
|
-
const clientIp = given.clientIp ?? ((request) => request.headers.get("x-forwarded-for")?.split(",").
|
|
1564
|
+
const clientIp = given.clientIp ?? ((request) => request.headers.get("x-forwarded-for")?.split(",").map((a) => a.trim()).reverse().find((a) => a !== "" && !ownNetwork(a)));
|
|
1564
1565
|
let noProofUntil = 0;
|
|
1565
1566
|
async function passedOn(request) {
|
|
1566
1567
|
if (Date.now() < noProofUntil) return {};
|
|
1567
1568
|
const ip = clientIp(request);
|
|
1568
1569
|
try {
|
|
1569
|
-
const proof = { "x-cauthy-system-token": await ownSystem.token() };
|
|
1570
|
+
const proof = { "x-cauthy-system-token": await ownSystem.token(), "x-cauthy-app-origin": originOf(request) };
|
|
1570
1571
|
return ip ? { ...proof, "x-cauthy-client-ip": ip } : proof;
|
|
1571
1572
|
} catch {
|
|
1572
1573
|
noProofUntil = Date.now() + 5 * 6e4;
|
|
@@ -2471,6 +2472,10 @@ function legalOf(raw) {
|
|
|
2471
2472
|
consentPurposes: purposes.map((p) => ({ key: String(p.key ?? ""), label: String(p.label ?? ""), required: p.required === true }))
|
|
2472
2473
|
};
|
|
2473
2474
|
}
|
|
2475
|
+
function ownNetwork(address) {
|
|
2476
|
+
const a = address.toLowerCase();
|
|
2477
|
+
return /^(127\.|10\.|192\.168\.|169\.254\.|0\.)/.test(a) || /^172\.(1[6-9]|2\d|3[01])\./.test(a) || a === "::1" || /^f[cd]/.test(a) || /^fe[89ab]/.test(a) || a.startsWith("::ffff:127.") || a === "localhost";
|
|
2478
|
+
}
|
|
2474
2479
|
|
|
2475
2480
|
// src/connect.ts
|
|
2476
2481
|
function sessionSecret() {
|