@aventara/access 0.0.0-stage → 1.0.0-rc.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.
- package/CHANGELOG.md +877 -0
- package/LICENSE +91 -0
- package/LICENSE-ADDITIONAL-PERMISSION.md +9 -0
- package/README.md +2536 -2
- package/dist/access/access-options.d.ts +74 -0
- package/dist/access/access-options.js +5 -0
- package/dist/access/access.error.d.ts +35 -0
- package/dist/access/access.error.js +11 -0
- package/dist/access/access.factory.d.ts +275 -0
- package/dist/access/access.factory.js +440 -0
- package/dist/access/better-auth.hardening.d.ts +120 -0
- package/dist/access/better-auth.hardening.js +420 -0
- package/dist/access/better-auth.loader.d.ts +67 -0
- package/dist/access/better-auth.loader.js +65 -0
- package/dist/access/better-auth.range.d.ts +9 -0
- package/dist/access/better-auth.range.js +28 -0
- package/dist/access/better-auth.require.d.ts +90 -0
- package/dist/access/better-auth.require.js +6 -0
- package/dist/access/better-auth.require.node.d.ts +7 -0
- package/dist/access/better-auth.require.node.js +52 -0
- package/dist/access/claims.mapper.d.ts +79 -0
- package/dist/access/claims.mapper.js +152 -0
- package/dist/access/key-set.cache.d.ts +10 -0
- package/dist/access/key-set.cache.js +63 -0
- package/dist/access/policies-block.checker.d.ts +64 -0
- package/dist/access/policies-block.checker.js +138 -0
- package/dist/access/principal.subject.d.ts +22 -0
- package/dist/access/principal.subject.js +89 -0
- package/dist/access/profile.policy.d.ts +74 -0
- package/dist/access/profile.policy.js +110 -0
- package/dist/access/request.state.d.ts +89 -0
- package/dist/access/request.state.js +266 -0
- package/dist/access/session.hooks.d.ts +114 -0
- package/dist/access/session.hooks.js +258 -0
- package/dist/access/token.verifier.d.ts +35 -0
- package/dist/access/token.verifier.js +69 -0
- package/dist/access-schema.d.ts +48 -0
- package/dist/access-schema.js +5 -0
- package/dist/access-warning.emitter.d.ts +4 -0
- package/dist/access-warning.emitter.js +24 -0
- package/dist/access.builder.d.ts +340 -0
- package/dist/access.builder.js +75 -0
- package/dist/access.engine.d.ts +155 -0
- package/dist/access.engine.js +477 -0
- package/dist/audit/audit-event.d.ts +135 -0
- package/dist/audit/audit-event.js +8 -0
- package/dist/audit/audit.log.d.ts +122 -0
- package/dist/audit/audit.log.js +345 -0
- package/dist/audit/audit.schema.d.ts +143 -0
- package/dist/audit/audit.schema.js +50 -0
- package/dist/auth/index.d.ts +12 -0
- package/dist/auth/index.js +2 -0
- package/dist/aventara-where.translator.d.ts +19 -0
- package/dist/aventara-where.translator.js +87 -0
- package/dist/beacon/beacon.check.d.ts +59 -0
- package/dist/beacon/beacon.check.js +128 -0
- package/dist/beacon/beacon.schema.d.ts +41 -0
- package/dist/beacon/beacon.schema.js +48 -0
- package/dist/beacon/beacon.store.d.ts +29 -0
- package/dist/beacon/beacon.store.js +78 -0
- package/dist/better-auth/access.client-plugin.d.ts +75 -0
- package/dist/better-auth/access.client-plugin.js +133 -0
- package/dist/better-auth/access.plugin.d.ts +164 -0
- package/dist/better-auth/access.plugin.js +348 -0
- package/dist/better-auth/access.provider.d.ts +80 -0
- package/dist/better-auth/access.provider.js +100 -0
- package/dist/better-auth/index.d.ts +7 -0
- package/dist/better-auth/index.js +4 -0
- package/dist/better-auth/organization.bridge.d.ts +66 -0
- package/dist/better-auth/organization.bridge.js +144 -0
- package/dist/canonical-json.writer.d.ts +12 -0
- package/dist/canonical-json.writer.js +30 -0
- package/dist/cli/avaccess.bin.d.ts +2 -0
- package/dist/cli/avaccess.bin.js +26 -0
- package/dist/cli/avaccess.program.d.ts +15 -0
- package/dist/cli/avaccess.program.js +166 -0
- package/dist/cli/beacon-pins.file.d.ts +14 -0
- package/dist/cli/beacon-pins.file.js +62 -0
- package/dist/cli/beacon.loader.d.ts +20 -0
- package/dist/cli/beacon.loader.js +71 -0
- package/dist/cli/cli.context.d.ts +49 -0
- package/dist/cli/cli.context.js +66 -0
- package/dist/cli/diff.command.d.ts +2 -0
- package/dist/cli/diff.command.js +66 -0
- package/dist/cli/generate.command.d.ts +2 -0
- package/dist/cli/generate.command.js +82 -0
- package/dist/cli/keys.command.d.ts +2 -0
- package/dist/cli/keys.command.js +96 -0
- package/dist/cli/lock.file.d.ts +31 -0
- package/dist/cli/lock.file.js +181 -0
- package/dist/cli/module.loader.d.ts +13 -0
- package/dist/cli/module.loader.js +63 -0
- package/dist/cli/policies.diff.d.ts +16 -0
- package/dist/cli/policies.diff.js +101 -0
- package/dist/cli/pull.command.d.ts +2 -0
- package/dist/cli/pull.command.js +234 -0
- package/dist/cli/push.command.d.ts +2 -0
- package/dist/cli/push.command.js +59 -0
- package/dist/cli/registry.client.d.ts +63 -0
- package/dist/cli/registry.client.js +287 -0
- package/dist/cli/schema.command.d.ts +2 -0
- package/dist/cli/schema.command.js +60 -0
- package/dist/cli/serve.command.d.ts +6 -0
- package/dist/cli/serve.command.js +200 -0
- package/dist/cli/status.command.d.ts +2 -0
- package/dist/cli/status.command.js +31 -0
- package/dist/cli/translator.flag.d.ts +6 -0
- package/dist/cli/translator.flag.js +24 -0
- package/dist/cli/verify.command.d.ts +2 -0
- package/dist/cli/verify.command.js +40 -0
- package/dist/client/access-client.factory.d.ts +92 -0
- package/dist/client/access-client.factory.js +269 -0
- package/dist/client/access-verbs.schema.d.ts +66 -0
- package/dist/client/access-verbs.schema.js +159 -0
- package/dist/client/verb-rate.limiter.d.ts +116 -0
- package/dist/client/verb-rate.limiter.js +358 -0
- package/dist/foreign/foreign-facts.d.ts +30 -0
- package/dist/foreign/foreign-facts.js +75 -0
- package/dist/foreign/foreign.merger.d.ts +10 -0
- package/dist/foreign/foreign.merger.js +52 -0
- package/dist/foreign-references.check.d.ts +6 -0
- package/dist/foreign-references.check.js +131 -0
- package/dist/generator/client.emitter.d.ts +28 -0
- package/dist/generator/client.emitter.js +411 -0
- package/dist/generator/copied-modules.reader.d.ts +14 -0
- package/dist/generator/copied-modules.reader.js +80 -0
- package/dist/generator/namespace.facts.d.ts +28 -0
- package/dist/generator/namespace.facts.js +32 -0
- package/dist/generator/orm.translator.d.ts +48 -0
- package/dist/generator/orm.translator.js +29 -0
- package/dist/generator/prisma7/prisma-schema.reader.d.ts +9 -0
- package/dist/generator/prisma7/prisma-schema.reader.js +394 -0
- package/dist/generator/prisma7/prisma-where.translator.d.ts +73 -0
- package/dist/generator/prisma7/prisma-where.translator.js +138 -0
- package/dist/generator/prisma7/prisma7.translator.d.ts +2 -0
- package/dist/generator/prisma7/prisma7.translator.js +87 -0
- package/dist/generator/schema.emitter.d.ts +14 -0
- package/dist/generator/schema.emitter.js +23 -0
- package/dist/generator/tsconfig.reader.d.ts +44 -0
- package/dist/generator/tsconfig.reader.js +110 -0
- package/dist/generator/typescript-literal.writer.d.ts +5 -0
- package/dist/generator/typescript-literal.writer.js +42 -0
- package/dist/guardrails/guardrails-contract.d.ts +45 -0
- package/dist/guardrails/guardrails-contract.js +12 -0
- package/dist/guardrails/guardrails.builder.d.ts +48 -0
- package/dist/guardrails/guardrails.builder.js +32 -0
- package/dist/guardrails/guardrails.compiler.d.ts +10 -0
- package/dist/guardrails/guardrails.compiler.js +254 -0
- package/dist/guardrails/guardrails.composer.d.ts +7 -0
- package/dist/guardrails/guardrails.composer.js +95 -0
- package/dist/guardrails/guardrails.hash.d.ts +10 -0
- package/dist/guardrails/guardrails.hash.js +38 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +6 -0
- package/dist/kiosk/kiosk-verbs.schema.d.ts +19 -0
- package/dist/kiosk/kiosk-verbs.schema.js +61 -0
- package/dist/kiosk/kiosk.plugin.d.ts +217 -0
- package/dist/kiosk/kiosk.plugin.js +877 -0
- package/dist/kiosk/kiosk.schema.d.ts +176 -0
- package/dist/kiosk/kiosk.schema.js +101 -0
- package/dist/kiosk/kiosk.store.d.ts +171 -0
- package/dist/kiosk/kiosk.store.js +478 -0
- package/dist/kiosk/lan-range.policy.d.ts +31 -0
- package/dist/kiosk/lan-range.policy.js +113 -0
- package/dist/kiosk/pin.policy.d.ts +9 -0
- package/dist/kiosk/pin.policy.js +143 -0
- package/dist/kiosk/session-use.marker.d.ts +4 -0
- package/dist/kiosk/session-use.marker.js +16 -0
- package/dist/lock/lock-contract.d.ts +38 -0
- package/dist/lock/lock-contract.js +67 -0
- package/dist/lock/lock.verifier.d.ts +27 -0
- package/dist/lock/lock.verifier.js +62 -0
- package/dist/mcp/agent-scope.gate.d.ts +13 -0
- package/dist/mcp/agent-scope.gate.js +75 -0
- package/dist/mcp/agent.grant.d.ts +40 -0
- package/dist/mcp/agent.grant.js +92 -0
- package/dist/mcp/mcp-options.d.ts +60 -0
- package/dist/mcp/mcp-options.js +72 -0
- package/dist/oauth/access-token.verifier.d.ts +66 -0
- package/dist/oauth/access-token.verifier.js +201 -0
- package/dist/oauth/oauth-provider.hardening.d.ts +62 -0
- package/dist/oauth/oauth-provider.hardening.js +261 -0
- package/dist/passwords/argon2id.hasher.d.ts +97 -0
- package/dist/passwords/argon2id.hasher.js +256 -0
- package/dist/passwords/node-rs-argon2.adapter.d.ts +25 -0
- package/dist/passwords/node-rs-argon2.adapter.js +42 -0
- package/dist/passwords/passwords.options.d.ts +79 -0
- package/dist/passwords/passwords.options.js +212 -0
- package/dist/policies-contract.d.ts +219 -0
- package/dist/policies-contract.js +8 -0
- package/dist/policies.compiler.d.ts +38 -0
- package/dist/policies.compiler.js +1433 -0
- package/dist/policies.decider.d.ts +103 -0
- package/dist/policies.decider.js +390 -0
- package/dist/policies.hash.d.ts +10 -0
- package/dist/policies.hash.js +54 -0
- package/dist/predicate.evaluator.d.ts +62 -0
- package/dist/predicate.evaluator.js +378 -0
- package/dist/random-secret.generator.d.ts +2 -0
- package/dist/random-secret.generator.js +15 -0
- package/dist/read-governed-unique.check.d.ts +3 -0
- package/dist/read-governed-unique.check.js +21 -0
- package/dist/reference-reads.check.d.ts +16 -0
- package/dist/reference-reads.check.js +158 -0
- package/dist/registry/access.registry.d.ts +173 -0
- package/dist/registry/access.registry.js +865 -0
- package/dist/registry/beacon.ledger.d.ts +30 -0
- package/dist/registry/beacon.ledger.js +93 -0
- package/dist/registry/ownership.check.d.ts +54 -0
- package/dist/registry/ownership.check.js +221 -0
- package/dist/registry/registry.endpoints.d.ts +50 -0
- package/dist/registry/registry.endpoints.js +193 -0
- package/dist/registry/registry.key.d.ts +7 -0
- package/dist/registry/registry.key.js +13 -0
- package/dist/registry/registry.options.d.ts +13 -0
- package/dist/registry/registry.options.js +28 -0
- package/dist/registry/registry.refusal.d.ts +6 -0
- package/dist/registry/registry.refusal.js +11 -0
- package/dist/registry/registry.schema.d.ts +238 -0
- package/dist/registry/registry.schema.js +127 -0
- package/dist/resources/auth-tables.catalog.d.ts +96 -0
- package/dist/resources/auth-tables.catalog.js +110 -0
- package/dist/resources/auth-tables.guard.d.ts +106 -0
- package/dist/resources/auth-tables.guard.js +462 -0
- package/dist/scope.resolver.d.ts +144 -0
- package/dist/scope.resolver.js +529 -0
- package/dist/sha256.digest.d.ts +2 -0
- package/dist/sha256.digest.js +81 -0
- package/dist/standalone/access.server.d.ts +41 -0
- package/dist/standalone/access.server.js +301 -0
- package/dist/standalone/index.d.ts +1 -0
- package/dist/standalone/index.js +1 -0
- package/package.json +102 -3
- package/skill/SKILL.md +170 -0
- package/skill/reference/callers.md +99 -0
- package/skill/reference/errors.md +89 -0
- package/skill/reference/recipes.md +281 -0
- package/skill/reference/rules.md +153 -0
- package/skill/reference/setup.md +334 -0
- package/src/aventara-where.translator.ts +116 -0
- package/src/beacon/beacon.check.ts +204 -0
- package/src/canonical-json.writer.ts +51 -0
- package/src/generator/prisma7/prisma-where.translator.ts +243 -0
- package/src/policies-contract.ts +215 -0
- package/src/policies.decider.ts +662 -0
- package/src/predicate.evaluator.ts +574 -0
- package/src/scope.resolver.ts +819 -0
- package/src/sha256.digest.ts +85 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { BetterAuthOptions, betterAuth } from "better-auth";
|
|
2
|
+
import type { createAuthEndpoint } from "better-auth/api";
|
|
3
|
+
import type { jwt } from "better-auth/plugins/jwt";
|
|
4
|
+
import type { NodePasswordCrypto, PasswordHook } from "../passwords/argon2id.hasher.js";
|
|
5
|
+
/**
|
|
6
|
+
* Better Auth's `getBaseURL`: the base URL it resolves from the one given, else from
|
|
7
|
+
* its environment variables (`BETTER_AUTH_URL` first), with `basePath` added.
|
|
8
|
+
*/
|
|
9
|
+
export type BetterAuthBaseURL = (url: string | undefined, basePath: string | undefined) => string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Better Auth's `createAuthMiddleware`, as Access calls it: a hook's handler from a
|
|
12
|
+
* function of the endpoint's context. Typed as Access uses it, so its generic
|
|
13
|
+
* context types are not instantiated for Access's own hooks.
|
|
14
|
+
*/
|
|
15
|
+
export type BetterAuthMiddlewareFactory = (handler: (context: never) => Promise<unknown>) => unknown;
|
|
16
|
+
/** Better Auth's `APIError`, as Access throws it: a status (its name, or a number), an optional body (`message`, `code`) and headers. */
|
|
17
|
+
export type BetterAuthAPIError = new (status: string | number, body?: {
|
|
18
|
+
readonly message?: unknown;
|
|
19
|
+
readonly code?: unknown;
|
|
20
|
+
}, headers?: {
|
|
21
|
+
readonly [name: string]: string;
|
|
22
|
+
}) => Error;
|
|
23
|
+
/** Better Auth's `getSessionFromCtx`, as Access calls it: an endpoint's context in, its session (or `null`) out. */
|
|
24
|
+
export type BetterAuthSessionReader = (context: never, config?: {
|
|
25
|
+
readonly disableCookieCache?: boolean;
|
|
26
|
+
}) => Promise<unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Better Auth's `getOAuthState`: the OAuth sign-in state of the request being
|
|
29
|
+
* handled (on a social callback, the state it parsed, `serverContext` the part the
|
|
30
|
+
* server set when the sign-in began); `null` when there is none.
|
|
31
|
+
*/
|
|
32
|
+
export type BetterAuthOAuthStateReader = () => Promise<{
|
|
33
|
+
readonly serverContext?: {
|
|
34
|
+
readonly [key: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
} | null>;
|
|
37
|
+
/** Better Auth's `setSessionCookie` and `deleteSessionCookie`, as Access calls them on an endpoint's context. */
|
|
38
|
+
export type BetterAuthSessionCookies = {
|
|
39
|
+
readonly setSessionCookie: (context: never, session: {
|
|
40
|
+
readonly session: unknown;
|
|
41
|
+
readonly user: unknown;
|
|
42
|
+
}, dontRememberMe?: boolean) => Promise<void>;
|
|
43
|
+
readonly deleteSessionCookie: (context: never) => void;
|
|
44
|
+
};
|
|
45
|
+
/** What hashing passwords takes from Node.js and Better Auth. */
|
|
46
|
+
export type BetterAuthPasswords = {
|
|
47
|
+
/** Node.js's `node:crypto`; `argon2` is missing before Node.js 24.7.0. */
|
|
48
|
+
readonly crypto: Partial<NodePasswordCrypto>;
|
|
49
|
+
/** Better Auth's scrypt verify (`better-auth/crypto`), for hashes stored before argon2id. */
|
|
50
|
+
readonly verifyScrypt: PasswordHook["verify"];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* What loading Better Auth gave: its entry (with `getAuthTables` and its base URL
|
|
54
|
+
* rules), its `jwt()` plugin, its plugin API (endpoints, hooks and their error) and
|
|
55
|
+
* what hashing passwords takes (Node.js's `node:crypto` and Better Auth's scrypt
|
|
56
|
+
* verify), the error a `require` threw, or `undefined` where the runtime has no
|
|
57
|
+
* Node.js module loader.
|
|
58
|
+
*/
|
|
59
|
+
export type BetterAuthRequired = {
|
|
60
|
+
readonly core: {
|
|
61
|
+
readonly betterAuth: typeof betterAuth;
|
|
62
|
+
/** Better Auth's tables for a set of options: its own, and its plugins'. */
|
|
63
|
+
readonly getAuthTables: (options: BetterAuthOptions) => unknown;
|
|
64
|
+
readonly getBaseURL: BetterAuthBaseURL;
|
|
65
|
+
readonly isDynamicBaseURLConfig: (baseURL: unknown) => boolean;
|
|
66
|
+
};
|
|
67
|
+
readonly plugin: {
|
|
68
|
+
readonly jwt: typeof jwt;
|
|
69
|
+
};
|
|
70
|
+
readonly api: {
|
|
71
|
+
readonly createAuthEndpoint: typeof createAuthEndpoint;
|
|
72
|
+
readonly createAuthMiddleware: BetterAuthMiddlewareFactory;
|
|
73
|
+
readonly APIError: BetterAuthAPIError;
|
|
74
|
+
/** The origin check Better Auth's router runs before every route, as a hook's handler. */
|
|
75
|
+
readonly originCheckMiddleware: unknown;
|
|
76
|
+
/** The client address Better Auth's options read from a request's headers. */
|
|
77
|
+
readonly getIP: (headers: Headers, options: unknown) => string | null;
|
|
78
|
+
/** The session an endpoint's request carries, as Better Auth's own routes read it. */
|
|
79
|
+
readonly getSessionFromCtx: BetterAuthSessionReader;
|
|
80
|
+
/** The OAuth sign-in state of the request being handled. */
|
|
81
|
+
readonly getOAuthState: BetterAuthOAuthStateReader;
|
|
82
|
+
};
|
|
83
|
+
/** Better Auth's session cookies (`better-auth/cookies`). */
|
|
84
|
+
readonly cookies: BetterAuthSessionCookies;
|
|
85
|
+
readonly passwords: BetterAuthPasswords;
|
|
86
|
+
} | {
|
|
87
|
+
readonly error: unknown;
|
|
88
|
+
} | undefined;
|
|
89
|
+
/** No Node.js module loader here: nothing to load Better Auth with. */
|
|
90
|
+
export declare const requireBetterAuth: () => BetterAuthRequired;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Better Auth, where no Node.js module loader exists: a browser, an edge runtime.
|
|
2
|
+
// The package's `#better-auth.require` import resolves here under every condition
|
|
3
|
+
// but `node`, so the engine can be bundled for those runtimes without naming a
|
|
4
|
+
// Node.js API; `createAccess` there refuses, since Better Auth runs on Node.js.
|
|
5
|
+
/** No Node.js module loader here: nothing to load Better Auth with. */
|
|
6
|
+
export const requireBetterAuth = () => undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BetterAuthRequired } from "./better-auth.require.js";
|
|
2
|
+
/**
|
|
3
|
+
* Better Auth's entry, its `jwt()` plugin, its plugin API, and what hashing
|
|
4
|
+
* passwords takes (Node.js's `node:crypto`, Better Auth's scrypt verify), or the
|
|
5
|
+
* error loading them threw.
|
|
6
|
+
*/
|
|
7
|
+
export declare const requireBetterAuth: () => BetterAuthRequired;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Better Auth, required from Node.js's own module loader. This is the module the
|
|
2
|
+
// package's `#better-auth.require` import resolves to under the `node` condition:
|
|
3
|
+
// Node.js itself, and a bundler building for Node.js (Next.js's server, with
|
|
4
|
+
// Turbopack or webpack). A bundler reads `createRequire(import.meta.url)` and the
|
|
5
|
+
// `require` calls below as dependencies, so `better-auth` goes into the server bundle
|
|
6
|
+
// and its traced output with the rest of the app; inside `try`, a `better-auth` that
|
|
7
|
+
// is not installed is no build error, only the refusal `createAccess` reports.
|
|
8
|
+
// Browsers and edge runtimes resolve the other module, which names no Node.js API.
|
|
9
|
+
//
|
|
10
|
+
// Hashing passwords takes Node.js's `crypto.argon2` (Node.js 24.7.0 and later). On
|
|
11
|
+
// Node.js 22, which lacks it, `@node-rs/argon2` (an exact optional peer) stands in,
|
|
12
|
+
// required only then; not installed, `createAccess` refuses.
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import { passwordCryptoOf, } from "../passwords/node-rs-argon2.adapter.js";
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
/** `@node-rs/argon2`, or `undefined` when it is not installed. */
|
|
17
|
+
const requireNodeRsArgon2 = () => {
|
|
18
|
+
try {
|
|
19
|
+
return require("@node-rs/argon2");
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const { code, message } = (error ?? {});
|
|
23
|
+
if (code === "MODULE_NOT_FOUND" &&
|
|
24
|
+
typeof message === "string" &&
|
|
25
|
+
message.includes("'@node-rs/argon2'")) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Better Auth's entry, its `jwt()` plugin, its plugin API, and what hashing
|
|
33
|
+
* passwords takes (Node.js's `node:crypto`, Better Auth's scrypt verify), or the
|
|
34
|
+
* error loading them threw.
|
|
35
|
+
*/
|
|
36
|
+
export const requireBetterAuth = () => {
|
|
37
|
+
try {
|
|
38
|
+
return {
|
|
39
|
+
core: require("better-auth"),
|
|
40
|
+
plugin: require("better-auth/plugins/jwt"),
|
|
41
|
+
api: require("better-auth/api"),
|
|
42
|
+
cookies: require("better-auth/cookies"),
|
|
43
|
+
passwords: {
|
|
44
|
+
crypto: passwordCryptoOf(require("node:crypto"), requireNodeRsArgon2),
|
|
45
|
+
verifyScrypt: require("better-auth/crypto").verifyPassword,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return { error };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { AccessClaimType } from "../policies-contract.js";
|
|
2
|
+
/** `policies.claims`: each global claim the tokens carry, by its type. */
|
|
3
|
+
export type AccessClaimsDeclaration = {
|
|
4
|
+
readonly [claim: string]: "string" | "number" | "boolean";
|
|
5
|
+
};
|
|
6
|
+
/** The claims a declaration allows: each one optional, typed as declared. */
|
|
7
|
+
export type AccessClaimsOf<C extends AccessClaimsDeclaration> = {
|
|
8
|
+
readonly [K in keyof C]?: C[K] extends "string" ? string : C[K] extends "number" ? number : C[K] extends "boolean" ? boolean : never;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* What `policies.claimsOf` answers: the declared claims, each typed as declared,
|
|
12
|
+
* where every declared boolean claim is required. A token always carries its
|
|
13
|
+
* boolean claims, so one the answer forgot would be minted `false`: a ban it never
|
|
14
|
+
* read would read as no ban. The other claims stay optional.
|
|
15
|
+
*/
|
|
16
|
+
export type AccessClaimsAnswer<C extends AccessClaimsDeclaration> = AccessClaimsOf<C> & {
|
|
17
|
+
readonly [K in keyof C as C[K] extends "boolean" ? K : never]: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Who a verified token or session says the caller is: the login (`sub`) and its declared claims. */
|
|
20
|
+
export type AccessIdentity<C extends AccessClaimsDeclaration> = {
|
|
21
|
+
readonly sub: string;
|
|
22
|
+
readonly claims: AccessClaimsOf<C>;
|
|
23
|
+
};
|
|
24
|
+
/** What a claims function reads: Better Auth's user and session, as the session endpoint returns them. */
|
|
25
|
+
export type AccessClaimsSource = {
|
|
26
|
+
readonly user: {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
} & {
|
|
29
|
+
readonly [field: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
readonly session: {
|
|
32
|
+
readonly [field: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
type ClaimsMap = {
|
|
36
|
+
readonly [claim: string]: string | number | boolean;
|
|
37
|
+
};
|
|
38
|
+
/** `policies.claims`, checked: an object of claim names to `"string"`, `"number"` or `"boolean"`. */
|
|
39
|
+
export declare const checkClaimsDeclaration: (declared: unknown) => AccessClaimsDeclaration;
|
|
40
|
+
/**
|
|
41
|
+
* Refuses a file whose rules (a policies file) or guardrails (a guardrails file) read
|
|
42
|
+
* a claim the declaration does not have, or read it as another type.
|
|
43
|
+
*/
|
|
44
|
+
export declare const checkRulesClaims: (file: {
|
|
45
|
+
readonly claims: {
|
|
46
|
+
readonly [claim: string]: AccessClaimType;
|
|
47
|
+
};
|
|
48
|
+
}, declared: AccessClaimsDeclaration, reader?: "rules" | "guardrails") => void;
|
|
49
|
+
/** One field of Better Auth's user table, as `getAuthTables(options).user.fields` states it. */
|
|
50
|
+
type UserField = {
|
|
51
|
+
readonly input?: boolean;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Refuses a declared claim that the default mapping (no `claimsOf`) would read from
|
|
55
|
+
* a user field a user can set themselves: one without `input: false`, which Better
|
|
56
|
+
* Auth takes from the sign-up body and from `/update-user`. A claim from it would be
|
|
57
|
+
* whatever the user chose (`role: "admin"`). The fields are the user table's as
|
|
58
|
+
* Better Auth is built: its own, its plugins' and `user.additionalFields`.
|
|
59
|
+
*/
|
|
60
|
+
export declare const checkClaimSources: (declared: AccessClaimsDeclaration, userFields: {
|
|
61
|
+
readonly [field: string]: UserField;
|
|
62
|
+
} | undefined) => void;
|
|
63
|
+
/**
|
|
64
|
+
* The claims a signed-in user's token is issued with. With `claimsOf`, its answer,
|
|
65
|
+
* which must name every declared boolean claim; without, each declared claim is read
|
|
66
|
+
* from the user's field of the same name (a Better Auth `user.additionalFields`
|
|
67
|
+
* entry, say). Every declared boolean claim is issued: one left unset (`null` or
|
|
68
|
+
* `undefined`, or a field the user record lacks) is `false`.
|
|
69
|
+
*/
|
|
70
|
+
export declare const issuedClaims: (source: AccessClaimsSource, declared: AccessClaimsDeclaration, claimsOf: ((source: AccessClaimsSource) => unknown | Promise<unknown>) | undefined) => Promise<ClaimsMap>;
|
|
71
|
+
/**
|
|
72
|
+
* The claims a verified token's payload carries, or `undefined` when it carries
|
|
73
|
+
* anything beyond `sub`, the registered claims and the declared ones: an
|
|
74
|
+
* undeclared claim is a token Access did not issue, and is refused.
|
|
75
|
+
*/
|
|
76
|
+
export declare const acceptedClaims: (payload: {
|
|
77
|
+
readonly [key: string]: unknown;
|
|
78
|
+
}, declared: AccessClaimsDeclaration) => ClaimsMap | undefined;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Claims: the global facts about a user that travel in the token, beside `sub`.
|
|
2
|
+
// `policies.claims` declares each one's type; it is the one list three places are
|
|
3
|
+
// held to: the claims the rules read, the claims a token is issued with, and the
|
|
4
|
+
// claims a token is accepted with. Nothing undeclared passes any of the three.
|
|
5
|
+
import { isRecord } from "../policies.compiler.js";
|
|
6
|
+
import { AccessError } from "./access.error.js";
|
|
7
|
+
/** The JWT's registered claims, which no declaration may take. */
|
|
8
|
+
const REGISTERED = new Set(["sub", "iat", "exp", "nbf", "iss", "aud", "jti"]);
|
|
9
|
+
const SCALARS = new Set(["string", "number", "boolean"]);
|
|
10
|
+
const listed = (names) => names.length === 0 ? "none" : names.join(", ");
|
|
11
|
+
/**
|
|
12
|
+
* What a refused value is, never the value itself: a claim comes from a user's
|
|
13
|
+
* record, and an error's message reaches logs.
|
|
14
|
+
*/
|
|
15
|
+
const kindOf = (value) => Array.isArray(value)
|
|
16
|
+
? "an array"
|
|
17
|
+
: value === null
|
|
18
|
+
? "null"
|
|
19
|
+
: typeof value === "object"
|
|
20
|
+
? "an object"
|
|
21
|
+
: typeof value === "undefined"
|
|
22
|
+
? "undefined"
|
|
23
|
+
: `a ${typeof value}`;
|
|
24
|
+
/** `policies.claims`, checked: an object of claim names to `"string"`, `"number"` or `"boolean"`. */
|
|
25
|
+
export const checkClaimsDeclaration = (declared) => {
|
|
26
|
+
if (!isRecord(declared)) {
|
|
27
|
+
throw new AccessError("ACCESS_OPTIONS_INVALID", '`policies.claims` declares the token\'s claims by type, as an object: `{ role: "string" }`, or `{}` for none.');
|
|
28
|
+
}
|
|
29
|
+
for (const [claim, type] of Object.entries(declared)) {
|
|
30
|
+
if (claim === "__proto__") {
|
|
31
|
+
throw new AccessError("ACCESS_OPTIONS_INVALID", "`policies.claims.__proto__` names the prototype of a JavaScript object, which no claim can be; give the claim another name.");
|
|
32
|
+
}
|
|
33
|
+
if (REGISTERED.has(claim)) {
|
|
34
|
+
throw new AccessError("ACCESS_OPTIONS_INVALID", `\`policies.claims.${claim}\` is a registered JWT claim, which the token sets itself; declare only your own claims.`);
|
|
35
|
+
}
|
|
36
|
+
if (typeof type !== "string" || !SCALARS.has(type)) {
|
|
37
|
+
throw new AccessError("ACCESS_OPTIONS_INVALID", `\`policies.claims.${claim}\` is ${JSON.stringify(type)}; a claim is declared as "string", "number" or "boolean".`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return declared;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Refuses a file whose rules (a policies file) or guardrails (a guardrails file) read
|
|
44
|
+
* a claim the declaration does not have, or read it as another type.
|
|
45
|
+
*/
|
|
46
|
+
export const checkRulesClaims = (file, declared, reader = "rules") => {
|
|
47
|
+
const fix = reader === "rules" ? "correct the rule" : "correct the guardrails";
|
|
48
|
+
for (const [claim, { scalar }] of Object.entries(file.claims)) {
|
|
49
|
+
const type = declared[claim];
|
|
50
|
+
if (type === undefined) {
|
|
51
|
+
throw new AccessError("ACCESS_CLAIMS_UNDECLARED", `the ${reader} read the claim \`${claim}\`, which \`policies.claims\` does not declare (it declares ${listed(Object.keys(declared))}); declare it, or ${fix}.`);
|
|
52
|
+
}
|
|
53
|
+
if (type !== scalar) {
|
|
54
|
+
throw new AccessError("ACCESS_CLAIMS_UNDECLARED", `the ${reader} compare the claim \`${claim}\` with a ${scalar}, and \`policies.claims\` declares it as ${type}; make the two agree.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/** The declared claims of one map, each checked against its type; `null` and `undefined` mean the claim is absent. */
|
|
59
|
+
const declaredClaims = (from, values, declared) => {
|
|
60
|
+
const claims = {};
|
|
61
|
+
for (const [claim, value] of Object.entries(values)) {
|
|
62
|
+
const type = Object.hasOwn(declared, claim) ? declared[claim] : undefined;
|
|
63
|
+
if (type === undefined) {
|
|
64
|
+
throw new AccessError("ACCESS_CLAIMS_UNDECLARED", `${from} returned the claim \`${claim}\`, which \`policies.claims\` does not declare (it declares ${listed(Object.keys(declared))}); declare it, or leave it out.`);
|
|
65
|
+
}
|
|
66
|
+
if (value === null || value === undefined) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (typeof value !== type) {
|
|
70
|
+
throw new AccessError("ACCESS_CLAIMS_UNDECLARED", `${from} returned the claim \`${claim}\` as ${kindOf(value)}, and \`policies.claims\` declares it as ${type}.`);
|
|
71
|
+
}
|
|
72
|
+
claims[claim] = value;
|
|
73
|
+
}
|
|
74
|
+
return claims;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Refuses a declared claim that the default mapping (no `claimsOf`) would read from
|
|
78
|
+
* a user field a user can set themselves: one without `input: false`, which Better
|
|
79
|
+
* Auth takes from the sign-up body and from `/update-user`. A claim from it would be
|
|
80
|
+
* whatever the user chose (`role: "admin"`). The fields are the user table's as
|
|
81
|
+
* Better Auth is built: its own, its plugins' and `user.additionalFields`.
|
|
82
|
+
*/
|
|
83
|
+
export const checkClaimSources = (declared, userFields) => {
|
|
84
|
+
for (const claim of Object.keys(declared)) {
|
|
85
|
+
const field = userFields?.[claim];
|
|
86
|
+
if (field !== undefined && field.input !== false) {
|
|
87
|
+
throw new AccessError("ACCESS_OPTIONS_INVALID", `the claim \`${claim}\` is read from the user's field \`${claim}\`, which a user can set themselves (at sign-up, or with \`/update-user\`): a claim from it would be the user's own choice. Give the field \`input: false\` in Better Auth's options, or return the claim from \`policies.claimsOf\`.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Every declared boolean claim, `false` where the user has none: a flag that is not
|
|
93
|
+
* set is minted as not set. The engine reads a missing claim as unknown, so a deny
|
|
94
|
+
* such as `banned: true` matches a token that lacks it (a foreign or stale one); a
|
|
95
|
+
* token Access issues never lacks one.
|
|
96
|
+
*/
|
|
97
|
+
const withBooleans = (claims, declared) => {
|
|
98
|
+
const minted = { ...claims };
|
|
99
|
+
for (const [claim, type] of Object.entries(declared)) {
|
|
100
|
+
if (type === "boolean" && !Object.hasOwn(minted, claim)) {
|
|
101
|
+
minted[claim] = false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return minted;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The claims a signed-in user's token is issued with. With `claimsOf`, its answer,
|
|
108
|
+
* which must name every declared boolean claim; without, each declared claim is read
|
|
109
|
+
* from the user's field of the same name (a Better Auth `user.additionalFields`
|
|
110
|
+
* entry, say). Every declared boolean claim is issued: one left unset (`null` or
|
|
111
|
+
* `undefined`, or a field the user record lacks) is `false`.
|
|
112
|
+
*/
|
|
113
|
+
export const issuedClaims = async (source, declared, claimsOf) => {
|
|
114
|
+
if (claimsOf === undefined) {
|
|
115
|
+
const sameNamed = {};
|
|
116
|
+
for (const claim of Object.keys(declared)) {
|
|
117
|
+
sameNamed[claim] = source.user[claim];
|
|
118
|
+
}
|
|
119
|
+
return withBooleans(declaredClaims("the user's fields", sameNamed, declared), declared);
|
|
120
|
+
}
|
|
121
|
+
const answer = await claimsOf(source);
|
|
122
|
+
if (!isRecord(answer)) {
|
|
123
|
+
throw new AccessError("ACCESS_OPTIONS_INVALID", "`policies.claimsOf` returns the user's claims as an object: `{ role: user.role }`, or `{}` for none.");
|
|
124
|
+
}
|
|
125
|
+
// A boolean claim `claimsOf` forgot would be minted `false`: a ban it never read
|
|
126
|
+
// would read as no ban. Its key must be there; `null` or `undefined` is `false`.
|
|
127
|
+
for (const [claim, type] of Object.entries(declared)) {
|
|
128
|
+
if (type === "boolean" && !Object.hasOwn(answer, claim)) {
|
|
129
|
+
throw new AccessError("ACCESS_OPTIONS_INVALID", `\`policies.claimsOf\` returned no \`${claim}\`, a boolean claim \`policies.claims\` declares; every token carries it, so return it: \`${claim}: user.${claim} === true\`.`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return withBooleans(declaredClaims("`policies.claimsOf`", answer, declared), declared);
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* The claims a verified token's payload carries, or `undefined` when it carries
|
|
136
|
+
* anything beyond `sub`, the registered claims and the declared ones: an
|
|
137
|
+
* undeclared claim is a token Access did not issue, and is refused.
|
|
138
|
+
*/
|
|
139
|
+
export const acceptedClaims = (payload, declared) => {
|
|
140
|
+
const claims = {};
|
|
141
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
142
|
+
if (REGISTERED.has(key)) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const type = Object.hasOwn(declared, key) ? declared[key] : undefined;
|
|
146
|
+
if (type === undefined || typeof value !== type) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
claims[key] = value;
|
|
150
|
+
}
|
|
151
|
+
return claims;
|
|
152
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type JSONWebKeySet, type JWTVerifyGetKey } from "jose";
|
|
2
|
+
type KeySetCache = {
|
|
3
|
+
/**
|
|
4
|
+
* Runs `verify` with the current key set and, when the token names a key the set
|
|
5
|
+
* does not hold, once more with a fresh read of it. Rethrows what `verify` throws.
|
|
6
|
+
*/
|
|
7
|
+
withKeys<T>(verify: (keys: JWTVerifyGetKey) => Promise<T>): Promise<T>;
|
|
8
|
+
};
|
|
9
|
+
export declare const createKeySetCache: (keys: () => Promise<JSONWebKeySet>, now: () => number) => KeySetCache;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// The key set Better Auth's `jwt()` plugin publishes, as Access's verifiers read it:
|
|
2
|
+
// read once and kept, and read again when it is older than its TTL, so a key removed
|
|
3
|
+
// from the set stops verifying within that TTL. A token signed with a key the cache
|
|
4
|
+
// does not hold (a rotation) reads the set at once, no more often than every few
|
|
5
|
+
// seconds. A read that fails keeps the last good set, so a token keeps verifying
|
|
6
|
+
// while the key store is down. Each verifier builds its own cache (`createKeySetCache`
|
|
7
|
+
// per call): the session tokens' verifier, and each access-token verifier (the MCP
|
|
8
|
+
// endpoint's, the service's own audience), so each reads the one key set `jwt()`
|
|
9
|
+
// signs both kinds with on its own schedule.
|
|
10
|
+
import { createLocalJWKSet, errors, } from "jose";
|
|
11
|
+
/** How long a key set read is kept before it is read again. */
|
|
12
|
+
const KEY_SET_TTL_MS = 300_000;
|
|
13
|
+
/** How long after a read (or a failed one) the key set may be read again early. */
|
|
14
|
+
const REFRESH_AFTER_MS = 5_000;
|
|
15
|
+
export const createKeySetCache = (keys, now) => {
|
|
16
|
+
let keySet;
|
|
17
|
+
let readAt = Number.NEGATIVE_INFINITY;
|
|
18
|
+
let triedAt = Number.NEGATIVE_INFINITY;
|
|
19
|
+
let reading;
|
|
20
|
+
const read = () => {
|
|
21
|
+
reading ??= keys()
|
|
22
|
+
.then((set) => {
|
|
23
|
+
keySet = createLocalJWKSet(set);
|
|
24
|
+
readAt = now();
|
|
25
|
+
return keySet;
|
|
26
|
+
})
|
|
27
|
+
.finally(() => {
|
|
28
|
+
triedAt = now();
|
|
29
|
+
reading = undefined;
|
|
30
|
+
});
|
|
31
|
+
return reading;
|
|
32
|
+
};
|
|
33
|
+
/** The key set, read again once it is stale; the last good one when that read fails. */
|
|
34
|
+
const current = async () => {
|
|
35
|
+
const kept = keySet;
|
|
36
|
+
if (kept === undefined) {
|
|
37
|
+
return read();
|
|
38
|
+
}
|
|
39
|
+
if (now() - readAt >= KEY_SET_TTL_MS &&
|
|
40
|
+
now() - triedAt >= REFRESH_AFTER_MS) {
|
|
41
|
+
return read().catch(() => kept);
|
|
42
|
+
}
|
|
43
|
+
return kept;
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
async withKeys(verify) {
|
|
47
|
+
try {
|
|
48
|
+
return await verify(await current());
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (!(error instanceof errors.JWKSNoMatchingKey) ||
|
|
52
|
+
now() - triedAt < REFRESH_AFTER_MS) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
const refreshed = await read().catch(() => undefined);
|
|
56
|
+
if (refreshed === undefined) {
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
return verify(refreshed);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type AccessEngine, type PoliciesSource } from "../access.engine.js";
|
|
2
|
+
import { type AuditLog } from "../audit/audit.log.js";
|
|
3
|
+
import type { AccessGuardrails } from "../guardrails/guardrails-contract.js";
|
|
4
|
+
import type { AccessLock } from "../lock/lock-contract.js";
|
|
5
|
+
import type { AccessPolicies } from "../policies-contract.js";
|
|
6
|
+
import { type AuthTable, type AuthTableNaming } from "../resources/auth-tables.catalog.js";
|
|
7
|
+
import { type ResourcesChoice } from "../resources/auth-tables.guard.js";
|
|
8
|
+
import { type BetterAuthBlock } from "./better-auth.hardening.js";
|
|
9
|
+
import type { BetterAuthModules } from "./better-auth.loader.js";
|
|
10
|
+
import { type AccessClaimsDeclaration, type AccessClaimsSource } from "./claims.mapper.js";
|
|
11
|
+
/** The engine's options from the `policies` block: guardrails, lock, `requireLock`. */
|
|
12
|
+
type EngineOptions = {
|
|
13
|
+
readonly guardrails?: AccessGuardrails;
|
|
14
|
+
readonly lock?: AccessLock;
|
|
15
|
+
readonly requireLock?: boolean;
|
|
16
|
+
} | undefined;
|
|
17
|
+
/** The `policies` block and `principal`, checked. */
|
|
18
|
+
export type CheckedPolicies = {
|
|
19
|
+
readonly claims: AccessClaimsDeclaration;
|
|
20
|
+
/** The rules' file: the compiled builder, or the file given. */
|
|
21
|
+
readonly file: AccessPolicies;
|
|
22
|
+
readonly source: PoliciesSource;
|
|
23
|
+
readonly engineOptions: EngineOptions;
|
|
24
|
+
readonly claimsOf: ((source: AccessClaimsSource) => unknown) | undefined;
|
|
25
|
+
readonly tokenTtl: number;
|
|
26
|
+
readonly principal: ((identity: never) => unknown) | undefined;
|
|
27
|
+
};
|
|
28
|
+
/** Refuses a `policies` block (`given`) and a `principal` that Access does not take. */
|
|
29
|
+
export declare const checkPoliciesBlock: (given: unknown, principal: unknown) => CheckedPolicies;
|
|
30
|
+
/**
|
|
31
|
+
* The engine the framework asks, with Access's built-in rules over Better Auth's
|
|
32
|
+
* tables (as Better Auth is built: its plugins' tables and Access's own included),
|
|
33
|
+
* named as the app's schema names them, the audit log's observer when it is on, and
|
|
34
|
+
* the agent gate before it all (`mcp/agent-scope.gate.ts`): a principal an agent's
|
|
35
|
+
* access token yielded is held to that token's audience and scopes first.
|
|
36
|
+
*/
|
|
37
|
+
export declare const guardedPolicy: (input: {
|
|
38
|
+
readonly checked: CheckedPolicies;
|
|
39
|
+
readonly auditLog: AuditLog | undefined;
|
|
40
|
+
readonly resources: ResourcesChoice;
|
|
41
|
+
readonly tables: ReadonlyMap<string, AuthTable>;
|
|
42
|
+
readonly naming: AuthTableNaming;
|
|
43
|
+
}) => AccessEngine;
|
|
44
|
+
/** Better Auth's tables as the rules' schema names them, and how it names them. */
|
|
45
|
+
export type BetterAuthTablesFacts = {
|
|
46
|
+
readonly tables: ReadonlyMap<string, AuthTable>;
|
|
47
|
+
readonly naming: AuthTableNaming;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Better Auth's tables for the options it is built with (`options`, its plugins and
|
|
51
|
+
* Access's own included), checked against the claims and the rules: a declared
|
|
52
|
+
* claim the default mapping (no `claimsOf`) reads must come from a user field the
|
|
53
|
+
* user cannot set (`bridged`, the claims the organization bridge fills, are not read
|
|
54
|
+
* from the user); and the rules' schema names each table, on the Prisma adapter by
|
|
55
|
+
* the models it reads, on any other by `resources.authTables`.
|
|
56
|
+
*/
|
|
57
|
+
export declare const betterAuthTablesFor: (input: {
|
|
58
|
+
readonly options: BetterAuthBlock;
|
|
59
|
+
readonly modules: Pick<BetterAuthModules, "getAuthTables">;
|
|
60
|
+
readonly checked: CheckedPolicies;
|
|
61
|
+
readonly resources: ResourcesChoice;
|
|
62
|
+
readonly bridged?: readonly string[];
|
|
63
|
+
}) => BetterAuthTablesFacts;
|
|
64
|
+
export {};
|