@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 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/_generated/component.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/checker/cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { checkAccessControlSource, formatAccessControlCheckResult } from "./index.js";
|
|
3
|
+
const parsedArgs = parseArgs(process.argv.slice(2));
|
|
4
|
+
if (!parsedArgs.ok) {
|
|
5
|
+
console.error(parsedArgs.message);
|
|
6
|
+
console.error(helpText());
|
|
7
|
+
process.exitCode = 2;
|
|
8
|
+
}
|
|
9
|
+
else if (parsedArgs.help) {
|
|
10
|
+
console.log(helpText());
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const result = checkAccessControlSource({
|
|
14
|
+
cwd: process.cwd(),
|
|
15
|
+
convexDir: parsedArgs.convexDir,
|
|
16
|
+
fixAuthenticated: parsedArgs.fixAuthenticated,
|
|
17
|
+
});
|
|
18
|
+
if (parsedArgs.json) {
|
|
19
|
+
console.log(JSON.stringify(result, null, 2));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.log(formatAccessControlCheckResult(result));
|
|
23
|
+
}
|
|
24
|
+
process.exitCode = result.ok ? 0 : 1;
|
|
25
|
+
}
|
|
26
|
+
function parseArgs(args) {
|
|
27
|
+
let convexDir;
|
|
28
|
+
let json = false;
|
|
29
|
+
let fixAuthenticated = false;
|
|
30
|
+
let help = false;
|
|
31
|
+
for (const arg of args) {
|
|
32
|
+
if (arg === "--json") {
|
|
33
|
+
json = true;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (arg === "--fix-authenticated") {
|
|
37
|
+
fixAuthenticated = true;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (arg === "--help" || arg === "-h") {
|
|
41
|
+
help = true;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (arg.startsWith("-")) {
|
|
45
|
+
return { ok: false, message: `Unknown option: ${arg}` };
|
|
46
|
+
}
|
|
47
|
+
if (convexDir) {
|
|
48
|
+
return { ok: false, message: `Unexpected argument: ${arg}` };
|
|
49
|
+
}
|
|
50
|
+
convexDir = arg;
|
|
51
|
+
}
|
|
52
|
+
return { ok: true, convexDir, json, fixAuthenticated, help };
|
|
53
|
+
}
|
|
54
|
+
function helpText() {
|
|
55
|
+
return [
|
|
56
|
+
"Usage: hercules-convex-access-check [convex-dir] [--json] [--fix-authenticated]",
|
|
57
|
+
"",
|
|
58
|
+
"Checks exported Convex functions for raw query(), mutation(), or action()",
|
|
59
|
+
"builders that should use Hercules Access Control builders from convex/hercules.ts.",
|
|
60
|
+
"Also checks common managed organization mistakes such as placeholder scope ids,",
|
|
61
|
+
"app-local org membership tables, unsafe org slug lookups,",
|
|
62
|
+
"and access* permission keys that are not declared in hercules/iam.jsonc.",
|
|
63
|
+
"Apps that do not use the @usehercules/convex Access Control SDK in their Convex",
|
|
64
|
+
"functions pass unchanged: raw Convex builders stay allowed there.",
|
|
65
|
+
"",
|
|
66
|
+
"--fix-authenticated rewrites exported raw builders to authenticated* builders",
|
|
67
|
+
"as a conservative migration starting point. Review public and permissioned",
|
|
68
|
+
"handlers afterward and switch them to public* or access* deliberately.",
|
|
69
|
+
].join("\n");
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/checker/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAMtF,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpD,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;IACnB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1B,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC;KAAM,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;IAC3B,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC1B,CAAC;KAAM,CAAC;IACN,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;KAC9C,CAAC,CAAC;IAEH,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC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F,2EAA2E;QAC3E,oFAAoF;QACpF,iFAAiF;QACjF,2DAA2D;QAC3D,0EAA0E;QAC1E,iFAAiF;QACjF,mEAAmE;QACnE,EAAE;QACF,+EAA+E;QAC/E,4EAA4E;QAC5E,wEAAwE;KACzE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type RawConvexBuilder = "query" | "mutation" | "action";
|
|
2
|
+
export type AccessControlCheckFinding = {
|
|
3
|
+
code: "convex_dir_missing" | "raw_exported_convex_builder" | "placeholder_access_scope_id" | "hardcoded_access_scope_id" | "local_org_membership_table" | "optional_org_scope_id" | "org_scoped_global_slug_lookup" | "org_row_scope_from_arg" | "authenticated_org_data_read" | "privileged_resource_permission_rule" | "public_service_authority_call" | "noncanonical_permission_key";
|
|
4
|
+
severity: "error";
|
|
5
|
+
filePath: string;
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
functionName?: string;
|
|
9
|
+
builder?: RawConvexBuilder;
|
|
10
|
+
message: string;
|
|
11
|
+
suggestion?: string;
|
|
12
|
+
};
|
|
13
|
+
export type AccessControlCheckResult = {
|
|
14
|
+
ok: boolean;
|
|
15
|
+
convexDir: string;
|
|
16
|
+
filesChecked: number;
|
|
17
|
+
fixedFiles: number;
|
|
18
|
+
findings: AccessControlCheckFinding[];
|
|
19
|
+
};
|
|
20
|
+
export type CheckAccessControlSourceOptions = {
|
|
21
|
+
cwd?: string;
|
|
22
|
+
convexDir?: string;
|
|
23
|
+
fixAuthenticated?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare function checkAccessControlSource(options?: CheckAccessControlSourceOptions): AccessControlCheckResult;
|
|
26
|
+
export declare function formatAccessControlCheckResult(result: AccessControlCheckResult): string;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/checker/index.ts"],"names":[],"mappings":"AAUA,KAAK,gBAAgB,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;AAUxD,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EACA,oBAAoB,GACpB,6BAA6B,GAC7B,6BAA6B,GAC7B,2BAA2B,GAC3B,4BAA4B,GAC5B,uBAAuB,GACvB,+BAA+B,GAC/B,wBAAwB,GACxB,6BAA6B,GAC7B,qCAAqC,GACrC,+BAA+B,GAC/B,6BAA6B,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,yBAAyB,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AA+EF,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,+BAAoC,GAC5C,wBAAwB,CA4F1B;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,wBAAwB,GAC/B,MAAM,CAwBR"}
|