@vantageos/backend-doctor 0.1.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/README.md +88 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +94 -0
- package/dist/contract.d.ts +18 -0
- package/dist/contract.js +29 -0
- package/dist/coverage-cli.d.ts +2 -0
- package/dist/coverage-cli.js +17 -0
- package/dist/coverage.d.ts +32 -0
- package/dist/coverage.js +77 -0
- package/dist/detectors/oracle-axis1.d.ts +86 -0
- package/dist/detectors/oracle-axis1.js +221 -0
- package/dist/detectors/oracle-axis2.d.ts +22 -0
- package/dist/detectors/oracle-axis2.js +149 -0
- package/dist/detectors/predicates.d.ts +19 -0
- package/dist/detectors/predicates.js +334 -0
- package/dist/detectors/shared.d.ts +56 -0
- package/dist/detectors/shared.js +103 -0
- package/dist/detectors/source/_scan.d.ts +43 -0
- package/dist/detectors/source/_scan.js +82 -0
- package/dist/detectors/source/backfill.d.ts +27 -0
- package/dist/detectors/source/backfill.js +211 -0
- package/dist/detectors/source/contract.d.ts +33 -0
- package/dist/detectors/source/contract.js +385 -0
- package/dist/detectors/source/identity.d.ts +47 -0
- package/dist/detectors/source/identity.js +410 -0
- package/dist/detectors/source/jobs.d.ts +10 -0
- package/dist/detectors/source/jobs.js +209 -0
- package/dist/detectors/source/lifecycle.d.ts +6 -0
- package/dist/detectors/source/lifecycle.js +147 -0
- package/dist/detectors/source/readbudget.d.ts +6 -0
- package/dist/detectors/source/readbudget.js +133 -0
- package/dist/detectors/source/refusal.d.ts +6 -0
- package/dist/detectors/source/refusal.js +125 -0
- package/dist/detectors/source/security.d.ts +37 -0
- package/dist/detectors/source/security.js +392 -0
- package/dist/detectors/source/writesafety.d.ts +14 -0
- package/dist/detectors/source/writesafety.js +345 -0
- package/dist/detectors/standard/_doc.d.ts +66 -0
- package/dist/detectors/standard/_doc.js +152 -0
- package/dist/detectors/standard/r41-frontier.d.ts +58 -0
- package/dist/detectors/standard/r41-frontier.js +176 -0
- package/dist/detectors/standard/r46-returns-validator.d.ts +61 -0
- package/dist/detectors/standard/r46-returns-validator.js +474 -0
- package/dist/detectors/standard/standard-doc.d.ts +12 -0
- package/dist/detectors/standard/standard-doc.js +271 -0
- package/dist/detectors/structural.d.ts +14 -0
- package/dist/detectors/structural.js +83 -0
- package/dist/engine-types.d.ts +10 -0
- package/dist/engine-types.js +1 -0
- package/dist/not-checkable.d.ts +22 -0
- package/dist/not-checkable.js +37 -0
- package/dist/oracle.d.ts +33 -0
- package/dist/oracle.js +133 -0
- package/dist/registry.d.ts +11 -0
- package/dist/registry.js +140 -0
- package/dist/report.d.ts +35 -0
- package/dist/report.js +138 -0
- package/dist/severity.d.ts +30 -0
- package/dist/severity.js +121 -0
- package/dist/tally.d.ts +57 -0
- package/dist/tally.js +152 -0
- package/dist/trigger.d.ts +47 -0
- package/dist/trigger.js +143 -0
- package/fixtures/backend-standard-51ec7af1.md +648 -0
- package/fixtures/backend-standard-a9d7877b.md +629 -0
- package/fixtures/mcp-app-standard-a74a042b.md +279 -0
- package/fixtures/mcp-extension-standard-a74a042b.md +259 -0
- package/fixtures/mcp-server-standard-a74a042b.md +434 -0
- package/fixtures/mcp-standard-a74a042b.md +354 -0
- package/fixtures/vp-1200-green/.pin +1 -0
- package/fixtures/vp-1200-green/convex/migrations.ts +350 -0
- package/fixtures/vp-1200-green/convex/schema.ts +1243 -0
- package/fixtures/vp-1200-red/.pin +1 -0
- package/fixtures/vp-1200-red/convex/migrations.ts +239 -0
- package/fixtures/vp-1200-red/convex/schema.ts +1243 -0
- package/fixtures/vp-by-tool-day158.csv +190 -0
- package/fixtures/vp-convex/.github/workflows/npm-publish.yml +163 -0
- package/fixtures/vp-convex/.pin +1 -0
- package/fixtures/vp-convex/bun.lock +783 -0
- package/fixtures/vp-convex/convex/auth.config.ts +8 -0
- package/fixtures/vp-convex/convex/briefingNotes.ts +321 -0
- package/fixtures/vp-convex/convex/convex.config.ts +14 -0
- package/fixtures/vp-convex/convex/credentials.ts +591 -0
- package/fixtures/vp-convex/convex/crons.ts +72 -0
- package/fixtures/vp-convex/convex/dashboard.ts +199 -0
- package/fixtures/vp-convex/convex/gumroadWebhook.ts +815 -0
- package/fixtures/vp-convex/convex/issues.ts +544 -0
- package/fixtures/vp-convex/convex/kb.ts +305 -0
- package/fixtures/vp-convex/convex/kbMutations.ts +192 -0
- package/fixtures/vp-convex/convex/kbShared.ts +56 -0
- package/fixtures/vp-convex/convex/licenses.ts +443 -0
- package/fixtures/vp-convex/convex/memories.ts +406 -0
- package/fixtures/vp-convex/convex/memoriesScoped.ts +220 -0
- package/fixtures/vp-convex/convex/messages.ts +971 -0
- package/fixtures/vp-convex/convex/migrations.ts +239 -0
- package/fixtures/vp-convex/convex/missionTemplates.ts +369 -0
- package/fixtures/vp-convex/convex/oauth.ts +1608 -0
- package/fixtures/vp-convex/convex/oauthMigrations.ts +96 -0
- package/fixtures/vp-convex/convex/okfBundleNode.ts +1031 -0
- package/fixtures/vp-convex/convex/recurringTasks.ts +386 -0
- package/fixtures/vp-convex/convex/schema.ts +1229 -0
- package/fixtures/vp-convex/convex/tasks.ts +2782 -0
- package/fixtures/vp-r31-green/.pin +1 -0
- package/fixtures/vp-r31-green/convex/migrations.ts +350 -0
- package/fixtures/vp-r31-red/.pin +1 -0
- package/fixtures/vp-r31-red/convex/migrations.ts +286 -0
- package/fixtures/vr-by-tool-day159.csv +89 -0
- package/package.json +39 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* convex/oauthMigrations.ts
|
|
3
|
+
*
|
|
4
|
+
* One-off migration mutations for OAuth schema changes.
|
|
5
|
+
* All migrations are gated by BEARER_SECRET_MASTER and MUST NOT be auto-run.
|
|
6
|
+
* Pi triggers each via master curl. Document required curl in PR body.
|
|
7
|
+
*
|
|
8
|
+
* Migrations:
|
|
9
|
+
* backfillTokenEndpointAuthMethod — D-CROSS-1 (Day 91)
|
|
10
|
+
* Sets tokenEndpointAuthMethod="client_secret_basic" on all oauth_clients
|
|
11
|
+
* rows where the field is absent (null/undefined). RFC 7591 §2 default.
|
|
12
|
+
*
|
|
13
|
+
* Required curl (Pi runs after deploy):
|
|
14
|
+
* curl -X POST https://<CONVEX_URL>/api/mutation \
|
|
15
|
+
* -H "Content-Type: application/json" \
|
|
16
|
+
* -d '{"path":"oauthMigrations:backfillTokenEndpointAuthMethod","args":{"callerToken":"<BEARER_SECRET_MASTER>"}}'
|
|
17
|
+
*
|
|
18
|
+
* Mirror: Theta VCRM convex/oauthMigrations.ts (backfillTokenEndpointAuthMethod)
|
|
19
|
+
* Directive: D-CROSS-1 msg jn75b55wpq16fmkbph4n7j7v3n87z8km
|
|
20
|
+
* Mission: k57c7s478gw1a3e5gmhdeptg5n87z78n
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { v } from "convex/values";
|
|
24
|
+
import { mutation } from "./_generated/server";
|
|
25
|
+
|
|
26
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
27
|
+
// Master-token gate (inline constant-time compare — mirrors convex/oauth.ts:23-45)
|
|
28
|
+
// Keeping inline in migrations file for isolation (no cross-file import).
|
|
29
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
async function requireMasterAuth(callerToken: string): Promise<void> {
|
|
32
|
+
const masterToken = process.env.BEARER_SECRET_MASTER;
|
|
33
|
+
if (!masterToken) {
|
|
34
|
+
throw new Error("BEARER_SECRET_MASTER env var is not configured");
|
|
35
|
+
}
|
|
36
|
+
const encoder = new TextEncoder();
|
|
37
|
+
const aBytes = encoder.encode(callerToken);
|
|
38
|
+
const bBytes = encoder.encode(masterToken);
|
|
39
|
+
// Constant-time comparison: length mismatch guarded by dummy HMAC to avoid
|
|
40
|
+
// branch-timing leak (pattern from convex/oauth.ts timingSafeEqual).
|
|
41
|
+
if (aBytes.length !== bBytes.length) {
|
|
42
|
+
const dummy = new Uint8Array(aBytes.length);
|
|
43
|
+
const aKey = await crypto.subtle.importKey(
|
|
44
|
+
"raw",
|
|
45
|
+
aBytes,
|
|
46
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
47
|
+
false,
|
|
48
|
+
["sign"],
|
|
49
|
+
);
|
|
50
|
+
await crypto.subtle.sign("HMAC", aKey, dummy);
|
|
51
|
+
throw new Error("Unauthorized: invalid master token");
|
|
52
|
+
}
|
|
53
|
+
let diff = 0;
|
|
54
|
+
for (let i = 0; i < aBytes.length; i++) {
|
|
55
|
+
diff |= aBytes[i] ^ bBytes[i];
|
|
56
|
+
}
|
|
57
|
+
if (diff !== 0) {
|
|
58
|
+
throw new Error("Unauthorized: invalid master token");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
63
|
+
// backfillTokenEndpointAuthMethod
|
|
64
|
+
//
|
|
65
|
+
// Sets tokenEndpointAuthMethod="client_secret_basic" on all oauth_clients rows
|
|
66
|
+
// where the field is absent (undefined/null). Safe to re-run (idempotent).
|
|
67
|
+
// Rows with any existing value (e.g. "none") are NOT touched.
|
|
68
|
+
//
|
|
69
|
+
// RFC 7591 §2: "If omitted, the default is 'client_secret_basic'."
|
|
70
|
+
// Mirror: Theta VCRM convex/oauthMigrations.ts backfillTokenEndpointAuthMethod
|
|
71
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
72
|
+
|
|
73
|
+
export const backfillTokenEndpointAuthMethod = mutation({
|
|
74
|
+
args: { callerToken: v.string() },
|
|
75
|
+
returns: v.object({ scanned: v.number(), backfilled: v.number() }),
|
|
76
|
+
handler: async (ctx, args) => {
|
|
77
|
+
await requireMasterAuth(args.callerToken);
|
|
78
|
+
|
|
79
|
+
const clients = await ctx.db.query("oauth_clients").collect();
|
|
80
|
+
let backfilled = 0;
|
|
81
|
+
|
|
82
|
+
for (const c of clients) {
|
|
83
|
+
if (
|
|
84
|
+
c.tokenEndpointAuthMethod === undefined ||
|
|
85
|
+
c.tokenEndpointAuthMethod === null
|
|
86
|
+
) {
|
|
87
|
+
await ctx.db.patch(c._id, {
|
|
88
|
+
tokenEndpointAuthMethod: "client_secret_basic",
|
|
89
|
+
});
|
|
90
|
+
backfilled++;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return { scanned: clients.length, backfilled };
|
|
95
|
+
},
|
|
96
|
+
});
|