@usehercules/convex 0.0.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/LICENSE +21 -0
- package/README.md +478 -0
- package/dist/_generated/component.d.ts +184 -0
- package/dist/_generated/component.d.ts.map +1 -0
- package/dist/_generated/component.js +11 -0
- package/dist/_generated/component.js.map +1 -0
- package/dist/checker/cli.d.ts +3 -0
- package/dist/checker/cli.d.ts.map +1 -0
- package/dist/checker/cli.js +71 -0
- package/dist/checker/cli.js.map +1 -0
- package/dist/checker/index.d.ts +28 -0
- package/dist/checker/index.d.ts.map +1 -0
- package/dist/checker/index.js +1928 -0
- package/dist/checker/index.js.map +1 -0
- package/dist/client/access-admin.d.ts +818 -0
- package/dist/client/access-admin.d.ts.map +1 -0
- package/dist/client/access-admin.js +1830 -0
- package/dist/client/access-admin.js.map +1 -0
- package/dist/client/http.d.ts +19 -0
- package/dist/client/http.d.ts.map +1 -0
- package/dist/client/http.js +76 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/index.d.ts +440 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +654 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/authz.d.ts +114 -0
- package/dist/component/authz.d.ts.map +1 -0
- package/dist/component/authz.js +168 -0
- package/dist/component/authz.js.map +1 -0
- package/dist/component/checks.d.ts +86 -0
- package/dist/component/checks.d.ts.map +1 -0
- package/dist/component/checks.js +184 -0
- package/dist/component/checks.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +3 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/effective.d.ts +82 -0
- package/dist/component/effective.d.ts.map +1 -0
- package/dist/component/effective.js +757 -0
- package/dist/component/effective.js.map +1 -0
- package/dist/component/queries.d.ts +170 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +633 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +258 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +222 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/sync.d.ts +85 -0
- package/dist/component/sync.d.ts.map +1 -0
- package/dist/component/sync.js +851 -0
- package/dist/component/sync.js.map +1 -0
- package/dist/shared/projection-protocol.d.ts +1624 -0
- package/dist/shared/projection-protocol.d.ts.map +1 -0
- package/dist/shared/projection-protocol.js +561 -0
- package/dist/shared/projection-protocol.js.map +1 -0
- package/dist/shared/sync.d.ts +24 -0
- package/dist/shared/sync.d.ts.map +1 -0
- package/dist/shared/sync.js +18 -0
- package/dist/shared/sync.js.map +1 -0
- package/dist/shared/token.d.ts +5 -0
- package/dist/shared/token.d.ts.map +1 -0
- package/dist/shared/token.js +19 -0
- package/dist/shared/token.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { DataModelFromSchemaDefinition, GenericQueryCtx } from "convex/server";
|
|
2
|
+
import { type ApplicableEntry, type WildcardMode } from "./authz";
|
|
3
|
+
import schema from "./schema";
|
|
4
|
+
type DataModel = DataModelFromSchemaDefinition<typeof schema>;
|
|
5
|
+
export type AuthorizationAncestor = {
|
|
6
|
+
resourceType: string;
|
|
7
|
+
resourceId: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function normalizeAuthorizationAncestors(ancestors: AuthorizationAncestor[] | undefined): AuthorizationAncestor[] | null;
|
|
10
|
+
type PermissionSummary = {
|
|
11
|
+
permissionId: string;
|
|
12
|
+
key: string;
|
|
13
|
+
resourceType: string;
|
|
14
|
+
action: string;
|
|
15
|
+
classification: "delegable" | "owner_only";
|
|
16
|
+
};
|
|
17
|
+
type CatalogPermission = {
|
|
18
|
+
permissionId: string;
|
|
19
|
+
key: string;
|
|
20
|
+
resourceType: string;
|
|
21
|
+
action: string;
|
|
22
|
+
classification: "delegable" | "owner_only";
|
|
23
|
+
};
|
|
24
|
+
type RuntimeEntry = ApplicableEntry & {
|
|
25
|
+
permissionId?: string;
|
|
26
|
+
};
|
|
27
|
+
export type EffectiveAccessEvaluation = {
|
|
28
|
+
allowed: boolean;
|
|
29
|
+
reasonCode: string;
|
|
30
|
+
sourceVersion?: number;
|
|
31
|
+
scopeId?: string;
|
|
32
|
+
principalId?: string;
|
|
33
|
+
effectiveRoleIds: string[];
|
|
34
|
+
catalogPermissions: CatalogPermission[];
|
|
35
|
+
wildcard: WildcardMode;
|
|
36
|
+
entries: RuntimeEntry[];
|
|
37
|
+
};
|
|
38
|
+
export declare function evaluateEffectiveAccess(ctx: GenericQueryCtx<DataModel>, args: {
|
|
39
|
+
tokenIdentifier?: string;
|
|
40
|
+
scopeId?: string;
|
|
41
|
+
resourceType?: string;
|
|
42
|
+
resourceId?: string;
|
|
43
|
+
ancestors?: AuthorizationAncestor[];
|
|
44
|
+
}): Promise<EffectiveAccessEvaluation>;
|
|
45
|
+
/**
|
|
46
|
+
* Grant-side superset action tokens (`manage`, `*`) are never runtime-
|
|
47
|
+
* checkable: can() requests carry concrete verbs only, so the authorize gate
|
|
48
|
+
* (checks.ts evaluatePermissionDecision) rejects a request whose resolved
|
|
49
|
+
* catalog action is a superset token with `invalid_request` — even for an
|
|
50
|
+
* Owner. Shared by that gate and {@link enumeratePermissions} so the two stay
|
|
51
|
+
* consistent by construction.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isSupersetAction(action: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Enumerate the catalog permissions this principal can exercise, by set-
|
|
56
|
+
* membership over the assembled entries — matching the canonical platform query
|
|
57
|
+
* (selectEffectivePermissionsByPrincipalIds). A catalog permission is reported
|
|
58
|
+
* when:
|
|
59
|
+
* - Owner (immutable) → always (the whole catalog).
|
|
60
|
+
* - Admin (default) → unless it is an Owner-only lever or is denied by a
|
|
61
|
+
* matching deny entry (a narrowing role-permission deny or a direct/resource
|
|
62
|
+
* deny).
|
|
63
|
+
* - else / additionally → there is a matching allow entry whose action
|
|
64
|
+
* covers the catalog permission, and no matching deny entry overrides it.
|
|
65
|
+
*
|
|
66
|
+
* Superset-action catalog keys (`:manage`, `:*`) are control-plane management
|
|
67
|
+
* gates, not runtime-checkable permissions: the authorize gate rejects them
|
|
68
|
+
* with `invalid_request` ({@link isSupersetAction}), so they are excluded here
|
|
69
|
+
* for every wildcard mode — getEffectivePermissions must never advertise a key
|
|
70
|
+
* the runtime will then deny. The capability such a grant confers is still
|
|
71
|
+
* fully reported: a `manage`/`*` allow entry expands onto the concrete-verb
|
|
72
|
+
* catalog keys it covers via actionMatches.
|
|
73
|
+
*/
|
|
74
|
+
export declare function enumeratePermissions(catalogPermissions: CatalogPermission[], wildcard: WildcardMode, entries: RuntimeEntry[], args: {
|
|
75
|
+
resourceId?: string;
|
|
76
|
+
}): PermissionSummary[];
|
|
77
|
+
export declare function collectPrincipalIds(ctx: GenericQueryCtx<DataModel>, args: {
|
|
78
|
+
principalId: string;
|
|
79
|
+
scopeId: string;
|
|
80
|
+
}): Promise<string[]>;
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=effective.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effective.d.ts","sourceRoot":"","sources":["../../src/component/effective.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,KAAK,SAAS,GAAG,6BAA6B,CAAC,OAAO,MAAM,CAAC,CAAC;AAK9D,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,qBAAqB,EAAE,GAAG,SAAS,GAC7C,qBAAqB,EAAE,GAA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