@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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +478 -0
  3. package/dist/_generated/component.d.ts +184 -0
  4. package/dist/_generated/component.d.ts.map +1 -0
  5. package/dist/_generated/component.js +11 -0
  6. package/dist/_generated/component.js.map +1 -0
  7. package/dist/checker/cli.d.ts +3 -0
  8. package/dist/checker/cli.d.ts.map +1 -0
  9. package/dist/checker/cli.js +71 -0
  10. package/dist/checker/cli.js.map +1 -0
  11. package/dist/checker/index.d.ts +28 -0
  12. package/dist/checker/index.d.ts.map +1 -0
  13. package/dist/checker/index.js +1928 -0
  14. package/dist/checker/index.js.map +1 -0
  15. package/dist/client/access-admin.d.ts +818 -0
  16. package/dist/client/access-admin.d.ts.map +1 -0
  17. package/dist/client/access-admin.js +1830 -0
  18. package/dist/client/access-admin.js.map +1 -0
  19. package/dist/client/http.d.ts +19 -0
  20. package/dist/client/http.d.ts.map +1 -0
  21. package/dist/client/http.js +76 -0
  22. package/dist/client/http.js.map +1 -0
  23. package/dist/client/index.d.ts +440 -0
  24. package/dist/client/index.d.ts.map +1 -0
  25. package/dist/client/index.js +654 -0
  26. package/dist/client/index.js.map +1 -0
  27. package/dist/component/authz.d.ts +114 -0
  28. package/dist/component/authz.d.ts.map +1 -0
  29. package/dist/component/authz.js +168 -0
  30. package/dist/component/authz.js.map +1 -0
  31. package/dist/component/checks.d.ts +86 -0
  32. package/dist/component/checks.d.ts.map +1 -0
  33. package/dist/component/checks.js +184 -0
  34. package/dist/component/checks.js.map +1 -0
  35. package/dist/component/convex.config.d.ts +3 -0
  36. package/dist/component/convex.config.d.ts.map +1 -0
  37. package/dist/component/convex.config.js +3 -0
  38. package/dist/component/convex.config.js.map +1 -0
  39. package/dist/component/effective.d.ts +82 -0
  40. package/dist/component/effective.d.ts.map +1 -0
  41. package/dist/component/effective.js +757 -0
  42. package/dist/component/effective.js.map +1 -0
  43. package/dist/component/queries.d.ts +170 -0
  44. package/dist/component/queries.d.ts.map +1 -0
  45. package/dist/component/queries.js +633 -0
  46. package/dist/component/queries.js.map +1 -0
  47. package/dist/component/schema.d.ts +258 -0
  48. package/dist/component/schema.d.ts.map +1 -0
  49. package/dist/component/schema.js +222 -0
  50. package/dist/component/schema.js.map +1 -0
  51. package/dist/component/sync.d.ts +85 -0
  52. package/dist/component/sync.d.ts.map +1 -0
  53. package/dist/component/sync.js +851 -0
  54. package/dist/component/sync.js.map +1 -0
  55. package/dist/shared/projection-protocol.d.ts +1624 -0
  56. package/dist/shared/projection-protocol.d.ts.map +1 -0
  57. package/dist/shared/projection-protocol.js +561 -0
  58. package/dist/shared/projection-protocol.js.map +1 -0
  59. package/dist/shared/sync.d.ts +24 -0
  60. package/dist/shared/sync.d.ts.map +1 -0
  61. package/dist/shared/sync.js +18 -0
  62. package/dist/shared/sync.js.map +1 -0
  63. package/dist/shared/token.d.ts +5 -0
  64. package/dist/shared/token.d.ts.map +1 -0
  65. package/dist/shared/token.js +19 -0
  66. package/dist/shared/token.js.map +1 -0
  67. 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,GAAG,IAAI,CAgBhC;AAED,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,WAAW,GAAG,YAAY,CAAC;CAC5C,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,WAAW,GAAG,YAAY,CAAC;CAC5C,CAAC;AAUF,KAAK,YAAY,GAA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