@stll/auth-model 0.2.5 → 0.2.7
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 +2 -1
- package/dist/contract.d.ts +37 -27
- package/dist/contract.js +7 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -20,13 +20,14 @@ product permissions. Every additional field, index, or plugin model must be
|
|
|
20
20
|
declared explicitly when comparing the normalized host schema.
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
+
import { createAccessControl } from "better-auth/plugins/access";
|
|
24
|
+
|
|
23
25
|
import {
|
|
24
26
|
BETTER_AUTH_ADAPTER_OPTIONS,
|
|
25
27
|
BETTER_AUTH_ORGANIZATION_OPTIONS,
|
|
26
28
|
BETTER_AUTH_ORGANIZATION_ROLE_GRANTS,
|
|
27
29
|
BETTER_AUTH_ORGANIZATION_STATEMENTS,
|
|
28
30
|
} from "@stll/auth-model";
|
|
29
|
-
import { createAccessControl } from "better-auth/plugins/access";
|
|
30
31
|
|
|
31
32
|
const statements = {
|
|
32
33
|
...BETTER_AUTH_ORGANIZATION_STATEMENTS,
|
package/dist/contract.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
/** Better Auth version whose logical schema this contract describes. */
|
|
3
3
|
export declare const BETTER_AUTH_CONTRACT_VERSION = "1.7.6";
|
|
4
4
|
export declare const AUTH_SESSION_STARTUP_HEADER = "x-stella-session-startup";
|
|
5
|
+
export declare const AUTH_SOCIAL_PROVIDER_IDS: readonly ["google", "microsoft"];
|
|
6
|
+
export declare const AUTH_ACCESS_RESET_ERROR_CODE = "confirm_access_reset";
|
|
5
7
|
export declare const ORGANIZATION_ROLE_NAMES: readonly ["owner", "admin", "member", "intern", "external"];
|
|
6
8
|
export type OrganizationRoleName = (typeof ORGANIZATION_ROLE_NAMES)[number];
|
|
7
9
|
/** Better Auth organization resources. Hosts extend this with product grants. */
|
|
@@ -17,18 +19,18 @@ export type BetterAuthOrganizationRoleGrants = Record<OrganizationRoleName, Orga
|
|
|
17
19
|
/** Core grants shared by every application; product grants remain host-owned. */
|
|
18
20
|
export declare const BETTER_AUTH_ORGANIZATION_ROLE_GRANTS: {
|
|
19
21
|
owner: {
|
|
20
|
-
organization: ("
|
|
21
|
-
member: ("
|
|
22
|
-
invitation: ("
|
|
23
|
-
team: ("
|
|
24
|
-
ac: ("
|
|
22
|
+
organization: ("delete" | "update")[];
|
|
23
|
+
member: ("create" | "delete" | "update")[];
|
|
24
|
+
invitation: ("cancel" | "create")[];
|
|
25
|
+
team: ("create" | "delete" | "update")[];
|
|
26
|
+
ac: ("create" | "delete" | "read" | "update")[];
|
|
25
27
|
};
|
|
26
28
|
admin: {
|
|
27
29
|
organization: "update"[];
|
|
28
|
-
member: ("
|
|
29
|
-
invitation: ("
|
|
30
|
-
team: ("
|
|
31
|
-
ac: ("
|
|
30
|
+
member: ("create" | "delete" | "update")[];
|
|
31
|
+
invitation: ("cancel" | "create")[];
|
|
32
|
+
team: ("create" | "delete" | "update")[];
|
|
33
|
+
ac: ("create" | "delete" | "read" | "update")[];
|
|
32
34
|
};
|
|
33
35
|
member: {
|
|
34
36
|
organization: never[];
|
|
@@ -84,7 +86,7 @@ export type BetterAuthFieldDefault = {
|
|
|
84
86
|
};
|
|
85
87
|
export type BetterAuthFieldReference = {
|
|
86
88
|
field: "id";
|
|
87
|
-
model: "organization" | "user";
|
|
89
|
+
model: "oauthConsent" | "organization" | "user";
|
|
88
90
|
onDelete: "cascade" | null;
|
|
89
91
|
};
|
|
90
92
|
export type BetterAuthLogicalFieldContract = {
|
|
@@ -142,6 +144,10 @@ export declare const BETTER_AUTH_CORE_SCHEMA: {
|
|
|
142
144
|
readonly primaryKey: readonly ["id"];
|
|
143
145
|
readonly fields: Record<string, BetterAuthFieldContract>;
|
|
144
146
|
readonly indexes: readonly [{
|
|
147
|
+
readonly fields: readonly ["id"];
|
|
148
|
+
readonly predicate: `"session"."id" LIKE 'synthetic-session-%'`;
|
|
149
|
+
readonly unique: false;
|
|
150
|
+
}, {
|
|
145
151
|
readonly fields: readonly ["userId", "activeOrganizationId"];
|
|
146
152
|
readonly predicate: null;
|
|
147
153
|
readonly unique: false;
|
|
@@ -222,6 +228,10 @@ export type BetterAuthAdapterContract = {
|
|
|
222
228
|
verificationStorage: "database";
|
|
223
229
|
};
|
|
224
230
|
export declare const BETTER_AUTH_ADAPTER_INVARIANTS: {
|
|
231
|
+
readonly camelCase: false;
|
|
232
|
+
readonly provider: "pg";
|
|
233
|
+
readonly transaction: true;
|
|
234
|
+
readonly usePlural: false;
|
|
225
235
|
readonly dateStorage: "timestamp-with-time-zone";
|
|
226
236
|
readonly idGeneration: "application-string";
|
|
227
237
|
readonly sessionStorage: "database";
|
|
@@ -235,10 +245,6 @@ export declare const BETTER_AUTH_ADAPTER_INVARIANTS: {
|
|
|
235
245
|
readonly member: "member";
|
|
236
246
|
readonly invitation: "invitation";
|
|
237
247
|
};
|
|
238
|
-
readonly camelCase: false;
|
|
239
|
-
readonly provider: "pg";
|
|
240
|
-
readonly transaction: true;
|
|
241
|
-
readonly usePlural: false;
|
|
242
248
|
};
|
|
243
249
|
export type BetterAuthSchemaCandidate = {
|
|
244
250
|
adapter: BetterAuthAdapterContract;
|
|
@@ -267,6 +273,10 @@ export type BetterAuthSchemaParityResult = {
|
|
|
267
273
|
export declare const compareBetterAuthSchema: (candidate: BetterAuthSchemaCandidate, extensions?: BetterAuthSchemaExtensions) => BetterAuthSchemaParityResult;
|
|
268
274
|
export declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
269
275
|
readonly adapterInvariants: {
|
|
276
|
+
readonly camelCase: false;
|
|
277
|
+
readonly provider: "pg";
|
|
278
|
+
readonly transaction: true;
|
|
279
|
+
readonly usePlural: false;
|
|
270
280
|
readonly dateStorage: "timestamp-with-time-zone";
|
|
271
281
|
readonly idGeneration: "application-string";
|
|
272
282
|
readonly sessionStorage: "database";
|
|
@@ -280,10 +290,6 @@ export declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
|
280
290
|
readonly member: "member";
|
|
281
291
|
readonly invitation: "invitation";
|
|
282
292
|
};
|
|
283
|
-
readonly camelCase: false;
|
|
284
|
-
readonly provider: "pg";
|
|
285
|
-
readonly transaction: true;
|
|
286
|
-
readonly usePlural: false;
|
|
287
293
|
};
|
|
288
294
|
readonly betterAuthVersion: "1.7.6";
|
|
289
295
|
readonly options: {
|
|
@@ -296,18 +302,18 @@ export declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
|
296
302
|
};
|
|
297
303
|
readonly roleGrants: {
|
|
298
304
|
owner: {
|
|
299
|
-
organization: ("
|
|
300
|
-
member: ("
|
|
301
|
-
invitation: ("
|
|
302
|
-
team: ("
|
|
303
|
-
ac: ("
|
|
305
|
+
organization: ("delete" | "update")[];
|
|
306
|
+
member: ("create" | "delete" | "update")[];
|
|
307
|
+
invitation: ("cancel" | "create")[];
|
|
308
|
+
team: ("create" | "delete" | "update")[];
|
|
309
|
+
ac: ("create" | "delete" | "read" | "update")[];
|
|
304
310
|
};
|
|
305
311
|
admin: {
|
|
306
312
|
organization: "update"[];
|
|
307
|
-
member: ("
|
|
308
|
-
invitation: ("
|
|
309
|
-
team: ("
|
|
310
|
-
ac: ("
|
|
313
|
+
member: ("create" | "delete" | "update")[];
|
|
314
|
+
invitation: ("cancel" | "create")[];
|
|
315
|
+
team: ("create" | "delete" | "update")[];
|
|
316
|
+
ac: ("create" | "delete" | "read" | "update")[];
|
|
311
317
|
};
|
|
312
318
|
member: {
|
|
313
319
|
organization: never[];
|
|
@@ -344,6 +350,10 @@ export declare const BETTER_AUTH_PARITY_MANIFEST: {
|
|
|
344
350
|
readonly primaryKey: readonly ["id"];
|
|
345
351
|
readonly fields: Record<string, BetterAuthFieldContract>;
|
|
346
352
|
readonly indexes: readonly [{
|
|
353
|
+
readonly fields: readonly ["id"];
|
|
354
|
+
readonly predicate: `"session"."id" LIKE 'synthetic-session-%'`;
|
|
355
|
+
readonly unique: false;
|
|
356
|
+
}, {
|
|
347
357
|
readonly fields: readonly ["userId", "activeOrganizationId"];
|
|
348
358
|
readonly predicate: null;
|
|
349
359
|
readonly unique: false;
|
package/dist/contract.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
/** Better Auth version whose logical schema this contract describes. */
|
|
3
3
|
const BETTER_AUTH_CONTRACT_VERSION = "1.7.6";
|
|
4
4
|
const AUTH_SESSION_STARTUP_HEADER = "x-stella-session-startup";
|
|
5
|
+
const AUTH_SOCIAL_PROVIDER_IDS = ["google", "microsoft"];
|
|
6
|
+
const AUTH_ACCESS_RESET_ERROR_CODE = "confirm_access_reset";
|
|
5
7
|
const ORGANIZATION_ROLE_NAMES = [
|
|
6
8
|
"owner",
|
|
7
9
|
"admin",
|
|
@@ -269,6 +271,10 @@ const BETTER_AUTH_CORE_SCHEMA = {
|
|
|
269
271
|
activeOrganizationId: field("string", { input: "server-managed" })
|
|
270
272
|
}),
|
|
271
273
|
indexes: [{
|
|
274
|
+
fields: ["id"],
|
|
275
|
+
predicate: `"session"."id" LIKE 'synthetic-session-%'`,
|
|
276
|
+
unique: false
|
|
277
|
+
}, {
|
|
272
278
|
fields: ["userId", "activeOrganizationId"],
|
|
273
279
|
predicate: null,
|
|
274
280
|
unique: false
|
|
@@ -534,4 +540,4 @@ const BETTER_AUTH_PARITY_MANIFEST = {
|
|
|
534
540
|
schema: BETTER_AUTH_CORE_SCHEMA
|
|
535
541
|
};
|
|
536
542
|
//#endregion
|
|
537
|
-
export { AUTH_SESSION_STARTUP_HEADER, BETTER_AUTH_ADAPTER_INVARIANTS, BETTER_AUTH_ADAPTER_OPTIONS, BETTER_AUTH_CONTRACT_VERSION, BETTER_AUTH_CORE_MODEL_NAMES, BETTER_AUTH_CORE_SCHEMA, BETTER_AUTH_ORGANIZATION_OPTIONS, BETTER_AUTH_ORGANIZATION_ROLE_GRANTS, BETTER_AUTH_ORGANIZATION_STATEMENTS, BETTER_AUTH_PARITY_MANIFEST, ORGANIZATION_ROLE_NAMES, compareBetterAuthSchema };
|
|
543
|
+
export { AUTH_ACCESS_RESET_ERROR_CODE, AUTH_SESSION_STARTUP_HEADER, AUTH_SOCIAL_PROVIDER_IDS, BETTER_AUTH_ADAPTER_INVARIANTS, BETTER_AUTH_ADAPTER_OPTIONS, BETTER_AUTH_CONTRACT_VERSION, BETTER_AUTH_CORE_MODEL_NAMES, BETTER_AUTH_CORE_SCHEMA, BETTER_AUTH_ORGANIZATION_OPTIONS, BETTER_AUTH_ORGANIZATION_ROLE_GRANTS, BETTER_AUTH_ORGANIZATION_STATEMENTS, BETTER_AUTH_PARITY_MANIFEST, ORGANIZATION_ROLE_NAMES, compareBetterAuthSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/auth-model",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Portable Better Auth core contract and parity checks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -39,16 +39,15 @@
|
|
|
39
39
|
"build": "tsdown",
|
|
40
40
|
"pack:dry-run": "bun pm pack --dry-run",
|
|
41
41
|
"test": "bun test src",
|
|
42
|
-
"typecheck": "bun
|
|
42
|
+
"typecheck": "bun check --no-pretty --all --project=tsconfig.json",
|
|
43
43
|
"lint": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --report-unused-disable-directives-severity=error --type-aware --type-check packages/auth-model",
|
|
44
44
|
"lint:fix": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --type-aware --fix packages/auth-model",
|
|
45
|
-
"format": "bun ../../scripts/run-oxfmt.ts .",
|
|
46
45
|
"prepack": "bun run build"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@stll/typescript-config": "0.0.0",
|
|
50
49
|
"better-auth": "1.7.6",
|
|
51
|
-
"bun-types": "1.4.
|
|
50
|
+
"bun-types": "1.4.4",
|
|
52
51
|
"tsdown": "0.23.0"
|
|
53
52
|
},
|
|
54
53
|
"main": "./dist/contract.js",
|