@bevel-software/platform-core-backend 0.12.0 → 0.13.1
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/THIRD-PARTY-NOTICES.md +9 -7
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +8 -1
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +58 -2
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +174 -33
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/access/admin-locked-commit.d.ts.map +1 -1
- package/dist/modules/access/admin-locked-commit.js +1 -0
- package/dist/modules/access/admin-locked-commit.js.map +1 -1
- package/dist/modules/access/synced-groups-committer.js +1 -1
- package/dist/modules/access/synced-groups-committer.js.map +1 -1
- package/dist/modules/access-model/access-errors.d.ts +11 -0
- package/dist/modules/access-model/access-errors.d.ts.map +1 -1
- package/dist/modules/access-model/access-errors.js +14 -0
- package/dist/modules/access-model/access-errors.js.map +1 -1
- package/dist/modules/access-model/access-grammar.d.ts +24 -8
- package/dist/modules/access-model/access-grammar.d.ts.map +1 -1
- package/dist/modules/access-model/access-grammar.js +64 -3
- package/dist/modules/access-model/access-grammar.js.map +1 -1
- package/dist/modules/declared-variables/declared-variables.routes.d.ts +42 -0
- package/dist/modules/declared-variables/declared-variables.routes.d.ts.map +1 -0
- package/dist/modules/declared-variables/declared-variables.routes.js +135 -0
- package/dist/modules/declared-variables/declared-variables.routes.js.map +1 -0
- package/dist/modules/declared-variables/index.d.ts +2 -0
- package/dist/modules/declared-variables/index.d.ts.map +1 -0
- package/dist/modules/declared-variables/index.js +2 -0
- package/dist/modules/declared-variables/index.js.map +1 -0
- package/dist/modules/diff/diff.routes.d.ts +1 -1
- package/dist/modules/diff/diff.routes.d.ts.map +1 -1
- package/dist/modules/diff/diff.routes.js +3 -3
- package/dist/modules/diff/diff.routes.js.map +1 -1
- package/dist/modules/kb-fs/clone-config.d.ts +40 -2
- package/dist/modules/kb-fs/clone-config.d.ts.map +1 -1
- package/dist/modules/kb-fs/clone-config.js +94 -2
- package/dist/modules/kb-fs/clone-config.js.map +1 -1
- package/dist/modules/kb-fs/locking-filesystem.d.ts +16 -0
- package/dist/modules/kb-fs/locking-filesystem.d.ts.map +1 -1
- package/dist/modules/kb-fs/locking-filesystem.js +20 -0
- package/dist/modules/kb-fs/locking-filesystem.js.map +1 -1
- package/dist/modules/kb-fs/repo-path.d.ts +32 -0
- package/dist/modules/kb-fs/repo-path.d.ts.map +1 -0
- package/dist/modules/kb-fs/repo-path.js +54 -0
- package/dist/modules/kb-fs/repo-path.js.map +1 -0
- package/dist/modules/secrets-vault/db-secrets-vault.service.d.ts.map +1 -1
- package/dist/modules/secrets-vault/db-secrets-vault.service.js +60 -18
- package/dist/modules/secrets-vault/db-secrets-vault.service.js.map +1 -1
- package/dist/modules/secrets-vault/mcp-oauth-discovery.service.d.ts +20 -0
- package/dist/modules/secrets-vault/mcp-oauth-discovery.service.d.ts.map +1 -1
- package/dist/modules/secrets-vault/mcp-oauth-discovery.service.js +121 -47
- package/dist/modules/secrets-vault/mcp-oauth-discovery.service.js.map +1 -1
- package/dist/modules/secrets-vault/secrets-vault.routes.d.ts.map +1 -1
- package/dist/modules/secrets-vault/secrets-vault.routes.js +20 -2
- package/dist/modules/secrets-vault/secrets-vault.routes.js.map +1 -1
- package/dist/modules/tool-helpers/tool-context.d.ts.map +1 -1
- package/dist/modules/tool-helpers/tool-context.js +1 -0
- package/dist/modules/tool-helpers/tool-context.js.map +1 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.d.ts.map +1 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.js +45 -12
- package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -1
- package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/mcp-server-edit.service.js +2 -1
- package/dist/modules/tool-manuals/mcp-server-edit.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts +40 -8
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts +38 -14
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.js +164 -55
- package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.js +10 -5
- package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
- package/dist/modules/tool-manuals/utcp-cli-parse-only.d.ts +55 -0
- package/dist/modules/tool-manuals/utcp-cli-parse-only.d.ts.map +1 -0
- package/dist/modules/tool-manuals/utcp-cli-parse-only.js +76 -0
- package/dist/modules/tool-manuals/utcp-cli-parse-only.js.map +1 -0
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts +3 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.js +19 -2
- package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
- package/dist/modules/workflow/git/git.service.d.ts +32 -1
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +70 -5
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/git/pull-request.service.d.ts +3 -3
- package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/pull-request.service.js +20 -2
- package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
- package/dist/modules/workflow/pending-commits.worker.d.ts +8 -0
- package/dist/modules/workflow/pending-commits.worker.d.ts.map +1 -1
- package/dist/modules/workflow/pending-commits.worker.js +74 -16
- package/dist/modules/workflow/pending-commits.worker.js.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.js +7 -0
- package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
- package/dist/modules/workflow/workflow.routes.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.routes.js +12 -0
- package/dist/modules/workflow/workflow.routes.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +39 -0
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +116 -6
- package/dist/modules/workflow/workflow.service.js.map +1 -1
- package/dist/modules/workspace/startup/kb-git.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-git.js +21 -4
- package/dist/modules/workspace/startup/kb-git.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +52 -8
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +121 -23
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.tools.js +31 -15
- package/dist/modules/workspace/workspace.tools.js.map +1 -1
- package/kb-template/AGENTS.md +52 -8
- package/package.json +6 -5
- package/src/core/create-core-server.ts +13 -1
- package/src/core/create-core-services.ts +1 -0
- package/src/modules/access/__tests__/access-control.atref-cache.test.ts +260 -0
- package/src/modules/access/__tests__/access-groups.test.ts +28 -0
- package/src/modules/access/access-control.service.ts +198 -37
- package/src/modules/access/admin-locked-commit.ts +1 -0
- package/src/modules/access/synced-groups-committer.ts +1 -1
- package/src/modules/access-model/__tests__/access-grammar.test.ts +101 -1
- package/src/modules/access-model/access-errors.ts +19 -0
- package/src/modules/access-model/access-grammar.ts +67 -3
- package/src/modules/declared-variables/__tests__/declared-variables.route.test.ts +166 -0
- package/src/modules/declared-variables/declared-variables.routes.ts +151 -0
- package/src/modules/declared-variables/index.ts +1 -0
- package/src/modules/diff/__tests__/diff.routes.rejectPathsLocked.test.ts +4 -4
- package/src/modules/diff/diff.routes.ts +3 -2
- package/src/modules/kb-fs/__tests__/clone-config.test.ts +63 -2
- package/src/modules/kb-fs/__tests__/locking-filesystem.test.ts +306 -131
- package/src/modules/kb-fs/__tests__/repo-path.test.ts +106 -0
- package/src/modules/kb-fs/clone-config.ts +97 -2
- package/src/modules/kb-fs/locking-filesystem.ts +30 -0
- package/src/modules/kb-fs/repo-path.ts +56 -0
- package/src/modules/secrets-vault/__tests__/db-secrets-vault.oauth.test.ts +104 -0
- package/src/modules/secrets-vault/__tests__/mcp-oauth-discovery.service.test.ts +52 -0
- package/src/modules/secrets-vault/__tests__/tool-owner-gate.route.test.ts +48 -1
- package/src/modules/secrets-vault/db-secrets-vault.service.ts +73 -22
- package/src/modules/secrets-vault/mcp-oauth-discovery.service.ts +141 -50
- package/src/modules/secrets-vault/secrets-vault.routes.ts +20 -2
- package/src/modules/tool-helpers/tool-context.ts +1 -0
- package/src/modules/tool-manuals/__tests__/mcp-json-discovery.test.ts +38 -0
- package/src/modules/tool-manuals/__tests__/mcp-server-edit.service.test.ts +2 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.cli.test.ts +243 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +95 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +17 -1
- package/src/modules/tool-manuals/mcp-json-discovery.ts +39 -15
- package/src/modules/tool-manuals/mcp-server-edit.service.ts +2 -1
- package/src/modules/tool-manuals/tool-manuals.contract.ts +40 -9
- package/src/modules/tool-manuals/tool-manuals.service.ts +156 -28
- package/src/modules/tool-manuals/tool-manuals.tools.ts +10 -5
- package/src/modules/tool-manuals/utcp-cli-parse-only.ts +76 -0
- package/src/modules/workflow/__tests__/pending-commits.worker.test.ts +46 -0
- package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +11 -5
- package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +172 -7
- package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +60 -1
- package/src/modules/workflow/agent-tools/workflow.tools.ts +18 -1
- package/src/modules/workflow/git/__tests__/git.service.changedFilesForPr.test.ts +56 -0
- package/src/modules/workflow/git/__tests__/git.service.commitFile.strayPath.test.ts +162 -0
- package/src/modules/workflow/git/__tests__/pull-request.service.getPrDetail.test.ts +114 -0
- package/src/modules/workflow/git/git.service.ts +73 -6
- package/src/modules/workflow/git/pull-request.service.ts +22 -4
- package/src/modules/workflow/pending-commits.worker.ts +80 -18
- package/src/modules/workflow/review-workflow/__tests__/approval-states.test.ts +60 -0
- package/src/modules/workflow/review-workflow/review-workflow.service.ts +5 -0
- package/src/modules/workflow/workflow.routes.ts +12 -0
- package/src/modules/workflow/workflow.service.ts +123 -7
- package/src/modules/workspace/__tests__/workspace.service.test.ts +1 -1
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +45 -0
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +141 -0
- package/src/modules/workspace/startup/kb-git.ts +20 -7
- package/src/modules/workspace/workspace.service.ts +132 -25
- package/src/modules/workspace/workspace.tools.ts +35 -15
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The git configuration a per-branch workspace clone must
|
|
3
|
-
* to
|
|
2
|
+
* The git configuration a per-branch workspace clone must carry: the tracking
|
|
3
|
+
* config that pins its branch to exactly ONE upstream ref, and the credential
|
|
4
|
+
* helper its remote operations authenticate with.
|
|
5
|
+
*
|
|
6
|
+
* Both are stamped at clone time AND re-stamped when an existing clone is
|
|
7
|
+
* adopted from disk, so a clone created by an older build — or by a path that
|
|
8
|
+
* only authenticated its own invocation — is repaired rather than left broken.
|
|
9
|
+
*
|
|
10
|
+
* On the tracking half:
|
|
4
11
|
*
|
|
5
12
|
* Why this exists: a clone's config is append-only from git's point of view,
|
|
6
13
|
* and several things write to it:
|
|
@@ -66,4 +73,89 @@ export function cloneTrackingConfigArgs(branch) {
|
|
|
66
73
|
['config', '--replace-all', `branch.${branch}.merge`, `refs/heads/${branch}`],
|
|
67
74
|
];
|
|
68
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The inline credential helper a workspace clone authenticates its remote
|
|
78
|
+
* operations with, or null when the deployment has no git token configured.
|
|
79
|
+
*
|
|
80
|
+
* The snippet reads `$GITHUB_TOKEN` at CALL time, so the secret itself never
|
|
81
|
+
* enters argv, the clone's `.git/config`, or any error message quoting either.
|
|
82
|
+
* `GITHUB_TOKEN` is the normalised name — `CoreConfig` collapses `GIT_TOKEN` /
|
|
83
|
+
* `GH_TOKEN` onto it at boot, and `DeploymentSettingsService.syncGitTokenEnv`
|
|
84
|
+
* publishes a token supplied through the setup screen to the same place — so
|
|
85
|
+
* this one name covers every way a token can arrive.
|
|
86
|
+
*
|
|
87
|
+
* The username is provider-specific (GitHub `x-access-token`, GitLab `oauth2`,
|
|
88
|
+
* Bitbucket `x-token-auth`); the token is always the Basic-auth password,
|
|
89
|
+
* which every major host accepts.
|
|
90
|
+
*/
|
|
91
|
+
export function credentialHelperValue(gitUsername) {
|
|
92
|
+
if (!process.env.GITHUB_TOKEN)
|
|
93
|
+
return null;
|
|
94
|
+
// Interpolated into a shell snippet that git will execute. `CoreConfig` and
|
|
95
|
+
// `DeploymentSettingsService` both reject a username outside this charset
|
|
96
|
+
// before it can get this far, so reaching the throw means an unvalidated
|
|
97
|
+
// fourth path appeared — fail closed rather than emit an injectable helper.
|
|
98
|
+
if (!/^[A-Za-z0-9._-]+$/.test(gitUsername)) {
|
|
99
|
+
throw new Error(`git username must match [A-Za-z0-9._-]+; got "${gitUsername}"`);
|
|
100
|
+
}
|
|
101
|
+
// printf '%s' rather than echo: POSIX leaves echo's handling of backslash
|
|
102
|
+
// escapes implementation-defined (dash interprets \c as "stop output"), so
|
|
103
|
+
// a token containing a backslash sequence could be silently truncated on
|
|
104
|
+
// the way to git. printf %s passes the bytes through verbatim. The literal
|
|
105
|
+
// `password=$GITHUB_TOKEN` stays in the snippet, which is what
|
|
106
|
+
// APP_HELPER_VALUE_PATTERN keys on — echo-era helpers stamped by earlier
|
|
107
|
+
// builds still match it and get replaced on the next stamp.
|
|
108
|
+
return `!f() { printf '%s\\n' "username=${gitUsername}" "password=$GITHUB_TOKEN"; }; f`;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* `git clone` arguments that PERSIST the credential helper into the repository
|
|
112
|
+
* being created. Position is load-bearing: these belong AFTER the `clone`
|
|
113
|
+
* subcommand, where `--config` means "write this into the new repo's config".
|
|
114
|
+
* The same pair placed BEFORE it is git's per-invocation `-c`, which
|
|
115
|
+
* authenticates that one clone and leaves the resulting repo with no helper at
|
|
116
|
+
* all — so every later `git push` from that clone prompts for a username,
|
|
117
|
+
* finds no tty, and dies. That was a real outage: a self-hosted deployment
|
|
118
|
+
* cloned fine, committed fine, and silently pushed nothing for two days.
|
|
119
|
+
*
|
|
120
|
+
* Empty when no token is configured, matching the un-authenticated clone the
|
|
121
|
+
* rest of the layer already supports.
|
|
122
|
+
*/
|
|
123
|
+
export function cloneCredentialArgs(gitUsername) {
|
|
124
|
+
const helper = credentialHelperValue(gitUsername);
|
|
125
|
+
return helper ? ['--config', `credential.helper=${helper}`] : [];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* `git` argument lists that bring a clone's credential helper into line with
|
|
129
|
+
* the deployment's current config — the repair path for clones on disk (see
|
|
130
|
+
* `cloneCredentialArgs`), applied wherever `cloneTrackingConfigArgs` is:
|
|
131
|
+
* `--replace-all` when a token is configured (idempotent re-stamp, stale
|
|
132
|
+
* values collapse), `--unset-all` when the deployment lost its token (a
|
|
133
|
+
* leftover helper answering with an empty password must not shadow whatever
|
|
134
|
+
* auth the operator fell back to; unset of a missing value exits non-zero
|
|
135
|
+
* and callers tolerate it — see `stampCredentialHelper`). Both operations
|
|
136
|
+
* are scoped by the value pattern below so only app-owned helpers are
|
|
137
|
+
* touched. Returns the arguments rather than running them, for the same
|
|
138
|
+
* reason `cloneTrackingConfigArgs` does.
|
|
139
|
+
*/
|
|
140
|
+
/**
|
|
141
|
+
* Value pattern (a POSIX ERE, as `git config`'s optional value-pattern
|
|
142
|
+
* argument expects) that matches ONLY helpers this application stamped —
|
|
143
|
+
* every one of ours reads `password=$GITHUB_TOKEN`, and no operator-authored
|
|
144
|
+
* helper has a reason to contain that literal. Scoping both the replace and
|
|
145
|
+
* the unset to it means an operator's own clone-local helper (`store`,
|
|
146
|
+
* `cache`, something custom) is never collapsed away or deleted by our
|
|
147
|
+
* stamping: git chains all configured helpers in order, so ours and theirs
|
|
148
|
+
* coexist.
|
|
149
|
+
*/
|
|
150
|
+
const APP_HELPER_VALUE_PATTERN = 'password=\\$GITHUB_TOKEN';
|
|
151
|
+
export function cloneCredentialConfigArgs(gitUsername) {
|
|
152
|
+
const helper = credentialHelperValue(gitUsername);
|
|
153
|
+
// `--replace-all key value pattern` replaces every line MATCHING the
|
|
154
|
+
// pattern with the one value (adding it when none match) and leaves
|
|
155
|
+
// non-matching values — operator helpers — untouched. Same scoping on the
|
|
156
|
+
// unset: only app-stamped values are removed when the token goes away.
|
|
157
|
+
return helper
|
|
158
|
+
? [['config', '--replace-all', 'credential.helper', helper, APP_HELPER_VALUE_PATTERN]]
|
|
159
|
+
: [['config', '--unset-all', 'credential.helper', APP_HELPER_VALUE_PATTERN]];
|
|
160
|
+
}
|
|
69
161
|
//# sourceMappingURL=clone-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone-config.js","sourceRoot":"","sources":["../../../src/modules/kb-fs/clone-config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"clone-config.js","sourceRoot":"","sources":["../../../src/modules/kb-fs/clone-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,qCAAqC,CAAC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GASG;AACH,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAE5D,MAAM,UAAU,yBAAyB,CAAC,WAAmB;IAC3D,MAAM,MAAM,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAClD,qEAAqE;IACrE,oEAAoE;IACpE,0EAA0E;IAC1E,uEAAuE;IACvE,OAAO,MAAM;QACX,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC;QACtF,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,mBAAmB,EAAE,wBAAwB,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -46,6 +46,16 @@ export interface LockingFilesystemContext {
|
|
|
46
46
|
workspaceId: string;
|
|
47
47
|
branch: string;
|
|
48
48
|
user: AuthUser;
|
|
49
|
+
/**
|
|
50
|
+
* The clone folder at the workspace root (`knowledge-base`). The filesystem
|
|
51
|
+
* is rooted one level ABOVE the repository, so containment alone lets a
|
|
52
|
+
* repo-relative path (`KnowledgeBase/…`) land beside the clone, where git
|
|
53
|
+
* never sees it and the release commit quietly no-ops. Every op that
|
|
54
|
+
* creates or modifies bytes is refused unless its path starts with this
|
|
55
|
+
* folder; removals stay open so a stray the old behaviour left there can
|
|
56
|
+
* still be cleaned up.
|
|
57
|
+
*/
|
|
58
|
+
kbDirName: string;
|
|
49
59
|
/**
|
|
50
60
|
* Optional pre-disk write validator. Invoked with the (workspace-relative
|
|
51
61
|
* path, full content) of every WHOLE-FILE write BEFORE the bytes land. Throw
|
|
@@ -108,6 +118,12 @@ export declare class LockingFilesystem extends LocalFilesystem {
|
|
|
108
118
|
recursive?: boolean;
|
|
109
119
|
}): Promise<void>;
|
|
110
120
|
rmdir(_inputPath: string, _options?: RemoveOptions): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Refuse a path that would put bytes beside the repository instead of in
|
|
123
|
+
* it. Runs before any side effect (plan, validator, lock, disk) so a refusal
|
|
124
|
+
* leaves nothing behind. See `LockingFilesystemContext.kbDirName`.
|
|
125
|
+
*/
|
|
126
|
+
private assertInsideRepo;
|
|
111
127
|
/**
|
|
112
128
|
* Land a `seed-access-md` creation-grant plan: under the access.md's own
|
|
113
129
|
* lock (single acquire+release cycle → one commit), re-read the CURRENT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locking-filesystem.d.ts","sourceRoot":"","sources":["../../../src/modules/kb-fs/locking-filesystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAE1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"locking-filesystem.d.ts","sourceRoot":"","sources":["../../../src/modules/kb-fs/locking-filesystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAE1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAOpF;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,gBA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AAO,GAAE,MAAM,EAAO,GACrB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA4SV,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC1E,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjF;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;;;;;;OAQG;YACW,YAAY;IA0B1B;;;;;OAKG;YACW,UAAU;IAiBxB;;;;;;OAMG;YACW,QAAQ;CAoDvB"}
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import fs from 'node:fs/promises';
|
|
35
35
|
import { LocalFilesystem, } from '@mastra/core/workspace';
|
|
36
36
|
import { PushNeedsAgentResolutionError } from '../../shared/domain-errors.js';
|
|
37
|
+
import { assertInsideRepo } from './repo-path.js';
|
|
37
38
|
/** How many times to retry a contended acquire before giving up. */
|
|
38
39
|
const ACQUIRE_RETRY_ATTEMPTS = 3;
|
|
39
40
|
/** Backoff between retries (ms). 3 attempts × 2s ≈ 6s ceiling. */
|
|
@@ -45,6 +46,7 @@ export class LockingFilesystem extends LocalFilesystem {
|
|
|
45
46
|
this.lockContext = lockContext;
|
|
46
47
|
}
|
|
47
48
|
async writeFile(inputPath, content, options) {
|
|
49
|
+
this.assertInsideRepo(inputPath);
|
|
48
50
|
// Pre-disk gate (e.g. reject a roles.yaml edit that would lock out admins).
|
|
49
51
|
// Runs OUTSIDE the lock so a refusal never acquires/holds one.
|
|
50
52
|
this.lockContext.validateWrite?.(inputPath, content);
|
|
@@ -61,17 +63,22 @@ export class LockingFilesystem extends LocalFilesystem {
|
|
|
61
63
|
return this.withLock(inputPath, () => super.writeFile(inputPath, toWrite, options));
|
|
62
64
|
}
|
|
63
65
|
async appendFile(inputPath, content) {
|
|
66
|
+
this.assertInsideRepo(inputPath);
|
|
64
67
|
return this.withLock(inputPath, () => super.appendFile(inputPath, content));
|
|
65
68
|
}
|
|
66
69
|
async deleteFile(inputPath, options) {
|
|
67
70
|
return this.withLock(inputPath, () => super.deleteFile(inputPath, options));
|
|
68
71
|
}
|
|
69
72
|
async copyFile(src, dest, options) {
|
|
73
|
+
this.assertInsideRepo(dest);
|
|
70
74
|
// Lock on `dest`. `src` is read-only from this op's perspective — copy
|
|
71
75
|
// creates a new file at dest without disturbing src on disk.
|
|
72
76
|
return this.withLock(dest, () => super.copyFile(src, dest, options));
|
|
73
77
|
}
|
|
74
78
|
async moveFile(src, dest, options) {
|
|
79
|
+
// Only the destination is gated: moving a stray INTO the repository is how
|
|
80
|
+
// a file the old behaviour left beside the clone gets rescued.
|
|
81
|
+
this.assertInsideRepo(dest);
|
|
75
82
|
// A move mutates two paths: the source is deleted and the destination
|
|
76
83
|
// is created. Only locking `dest` would let a concurrent writer hold
|
|
77
84
|
// the source's lock and mutate it under us, and would also leave the
|
|
@@ -113,6 +120,10 @@ export class LockingFilesystem extends LocalFilesystem {
|
|
|
113
120
|
*/
|
|
114
121
|
async writeFiles(writes, summary, deletes = []) {
|
|
115
122
|
const { workflow, workspaceId, branch, user } = this.lockContext;
|
|
123
|
+
// Fail the whole batch before any plan, validator or lock: one stray path
|
|
124
|
+
// must not let its siblings land while it silently misses git.
|
|
125
|
+
for (const w of writes)
|
|
126
|
+
this.assertInsideRepo(w.path);
|
|
116
127
|
// Creator read grants for the batch: transform new markdown files'
|
|
117
128
|
// content in place, and fold any subtree access.md seeds into the SAME
|
|
118
129
|
// atomic batch (deduped — several files landing in one new folder share
|
|
@@ -396,6 +407,7 @@ export class LockingFilesystem extends LocalFilesystem {
|
|
|
396
407
|
return change;
|
|
397
408
|
}
|
|
398
409
|
async mkdir(inputPath, options) {
|
|
410
|
+
this.assertInsideRepo(inputPath);
|
|
399
411
|
// Creator read grant: planned BEFORE the dir exists (the plan's
|
|
400
412
|
// new-directory detection needs the pre-creation tree), seeded right
|
|
401
413
|
// after — so the new folder's access.md names the acting user under
|
|
@@ -443,6 +455,14 @@ export class LockingFilesystem extends LocalFilesystem {
|
|
|
443
455
|
throw new Error('Recursive directory removal is not supported through the lock-aware filesystem. ' +
|
|
444
456
|
'Delete files individually so each removal lands as its own change.');
|
|
445
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Refuse a path that would put bytes beside the repository instead of in
|
|
460
|
+
* it. Runs before any side effect (plan, validator, lock, disk) so a refusal
|
|
461
|
+
* leaves nothing behind. See `LockingFilesystemContext.kbDirName`.
|
|
462
|
+
*/
|
|
463
|
+
assertInsideRepo(inputPath) {
|
|
464
|
+
assertInsideRepo(inputPath, this.lockContext.kbDirName);
|
|
465
|
+
}
|
|
446
466
|
/**
|
|
447
467
|
* Land a `seed-access-md` creation-grant plan: under the access.md's own
|
|
448
468
|
* lock (single acquire+release cycle → one commit), re-read the CURRENT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locking-filesystem.js","sourceRoot":"","sources":["../../../src/modules/kb-fs/locking-filesystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EACL,eAAe,GAMhB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAI9E,oEAAoE;AACpE,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,kEAAkE;AAClE,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAuCrC,MAAM,OAAO,iBAAkB,SAAQ,eAAe;IACnC,WAAW,CAA2B;IAEvD,YACE,OAA+B,EAC/B,WAAqC;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEQ,KAAK,CAAC,SAAS,CACtB,SAAiB,EACj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space-relative paths and the repository folder.
|
|
3
|
+
*
|
|
4
|
+
* A workspace directory holds the git clone as `<kbDirName>/` (plus transient
|
|
5
|
+
* scratch such as `tmp/`). The agent filesystem, the lock keys and the human
|
|
6
|
+
* editor all speak WORKSPACE-relative paths, so a path reaches git only when
|
|
7
|
+
* it starts with that folder. `KnowledgeBase/Foo.md` on its own is not a
|
|
8
|
+
* shorthand for `knowledge-base/KnowledgeBase/Foo.md`: it is a different
|
|
9
|
+
* location, beside the clone, that nothing commits and nothing pushes.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* True when `wsPath` is the repository folder or lies under it.
|
|
13
|
+
*
|
|
14
|
+
* Judged segment by segment, not by string prefix: `knowledge-base/../x.md`
|
|
15
|
+
* starts with the folder yet resolves beside it, and the filesystem's own
|
|
16
|
+
* containment is against the WORKSPACE dir, so it would accept that path.
|
|
17
|
+
* `.` and `..` segments (and empty ones from `//`) are therefore refused
|
|
18
|
+
* outright, and so is any backslash: on Windows it separates segments too,
|
|
19
|
+
* so `foo\..\..` would climb the same way. Both match what the commit layer
|
|
20
|
+
* accepts. A single trailing slash on a directory path is tolerated.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isInsideRepo(wsPath: string, kbDirName: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Refuse a workspace-relative path that would land outside the repository.
|
|
25
|
+
* The message carries the corrected path so an agent can retry without
|
|
26
|
+
* guessing; the payload carries a typed discriminator for callers that
|
|
27
|
+
* switch on it, plus the same corrected path on its own, for a consumer
|
|
28
|
+
* that cannot rely on the message surviving intact (the pending-commits
|
|
29
|
+
* worker stores a sanitized, truncated copy).
|
|
30
|
+
*/
|
|
31
|
+
export declare function assertInsideRepo(wsPath: string, kbDirName: string): void;
|
|
32
|
+
//# sourceMappingURL=repo-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-path.d.ts","sourceRoot":"","sources":["../../../src/modules/kb-fs/repo-path.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAKvE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAexE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { WorkflowValidationError } from '../../shared/domain-errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Workspace-relative paths and the repository folder.
|
|
5
|
+
*
|
|
6
|
+
* A workspace directory holds the git clone as `<kbDirName>/` (plus transient
|
|
7
|
+
* scratch such as `tmp/`). The agent filesystem, the lock keys and the human
|
|
8
|
+
* editor all speak WORKSPACE-relative paths, so a path reaches git only when
|
|
9
|
+
* it starts with that folder. `KnowledgeBase/Foo.md` on its own is not a
|
|
10
|
+
* shorthand for `knowledge-base/KnowledgeBase/Foo.md`: it is a different
|
|
11
|
+
* location, beside the clone, that nothing commits and nothing pushes.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* True when `wsPath` is the repository folder or lies under it.
|
|
15
|
+
*
|
|
16
|
+
* Judged segment by segment, not by string prefix: `knowledge-base/../x.md`
|
|
17
|
+
* starts with the folder yet resolves beside it, and the filesystem's own
|
|
18
|
+
* containment is against the WORKSPACE dir, so it would accept that path.
|
|
19
|
+
* `.` and `..` segments (and empty ones from `//`) are therefore refused
|
|
20
|
+
* outright, and so is any backslash: on Windows it separates segments too,
|
|
21
|
+
* so `foo\..\..` would climb the same way. Both match what the commit layer
|
|
22
|
+
* accepts. A single trailing slash on a directory path is tolerated.
|
|
23
|
+
*/
|
|
24
|
+
export function isInsideRepo(wsPath, kbDirName) {
|
|
25
|
+
if (typeof wsPath !== 'string' || wsPath.includes('\\'))
|
|
26
|
+
return false;
|
|
27
|
+
const segments = wsPath.replace(/\/$/, '').split('/');
|
|
28
|
+
if (segments[0] !== kbDirName)
|
|
29
|
+
return false;
|
|
30
|
+
return segments.every((segment) => segment !== '' && segment !== '.' && segment !== '..');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Refuse a workspace-relative path that would land outside the repository.
|
|
34
|
+
* The message carries the corrected path so an agent can retry without
|
|
35
|
+
* guessing; the payload carries a typed discriminator for callers that
|
|
36
|
+
* switch on it, plus the same corrected path on its own, for a consumer
|
|
37
|
+
* that cannot rely on the message surviving intact (the pending-commits
|
|
38
|
+
* worker stores a sanitized, truncated copy).
|
|
39
|
+
*/
|
|
40
|
+
export function assertInsideRepo(wsPath, kbDirName) {
|
|
41
|
+
if (isInsideRepo(wsPath, kbDirName))
|
|
42
|
+
return;
|
|
43
|
+
// The suggestion collapses what made the path wrong: backslashes, leading
|
|
44
|
+
// `./` or `/`, and any `..` climbing back out (a bare `..` included, so the
|
|
45
|
+
// suggestion is never itself a climb). The agent gets a path it can use.
|
|
46
|
+
const normalized = path.posix
|
|
47
|
+
.normalize(String(wsPath).replace(/\\/g, '/').replace(/^(\.\/|\/)+/, ''))
|
|
48
|
+
.replace(/^(\.\.(\/|$))+/, '')
|
|
49
|
+
.replace(/^\.$/, '');
|
|
50
|
+
const corrected = isInsideRepo(normalized, kbDirName) ? normalized : `${kbDirName}/${normalized}`;
|
|
51
|
+
throw new WorkflowValidationError(`"${wsPath}" is outside the knowledge base repository: paths are workspace-relative, must start with "${kbDirName}/" and may not contain "." or ".." segments or backslashes. ` +
|
|
52
|
+
`Use "${corrected}" instead. A file written without that prefix lands beside the repository, where it is never committed or pushed.`, { kind: 'path-outside-repo', path: wsPath, kbDirName, corrected });
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=repo-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-path.js","sourceRoot":"","sources":["../../../src/modules/kb-fs/repo-path.ts"],"names":[],"mappings":"AAAA,OAAO,IAA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IAAI,MAAM,8FAA8F,SAAS,8DAA8D;QAC7K,QAAQ,SAAS,mHAAmH,EACtI,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAClE,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-secrets-vault.service.d.ts","sourceRoot":"","sources":["../../../src/modules/secrets-vault/db-secrets-vault.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAI1D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAI3B,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"db-secrets-vault.service.d.ts","sourceRoot":"","sources":["../../../src/modules/secrets-vault/db-secrets-vault.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAI1D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAI3B,MAAM,6BAA6B,CAAC;AA+CrC;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAsB,YAAW,oBAAoB;IAI9D,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,yFAAyF;IACzF,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAb3B,OAAO,CAAC,cAAc,CAA4B;gBAG/B,EAAE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AalB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,SAAS;CAelB"}
|
|
@@ -229,16 +229,39 @@ export class DbSecretsVaultService {
|
|
|
229
229
|
// PKCE (S256): same as the tool path — mint the verifier, stash it on the
|
|
230
230
|
// row (so `completeOAuth` echoes it at the token exchange), and put only
|
|
231
231
|
// the derived challenge in the consent URL. A provider registered pkce
|
|
232
|
-
// would otherwise fail the exchange from this standalone flow.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
232
|
+
// would otherwise fail the exchange from this standalone flow. The
|
|
233
|
+
// requested scopes ride along for the same exchange (see `pendingScopes`).
|
|
234
|
+
const pendingVerifier = meta.pkce ? randomBytes(32).toString('base64url') : undefined;
|
|
235
|
+
const pendingScopes = meta.scopes && meta.scopes.length ? meta.scopes.join(' ') : undefined;
|
|
236
|
+
if (pendingVerifier || pendingScopes) {
|
|
237
|
+
// Read-modify-write on the blob, guarded on the ciphertext we read: a
|
|
238
|
+
// refresh running concurrently (the row is a live credential) may have
|
|
239
|
+
// persisted ROTATED tokens in between, and writing our copy over them
|
|
240
|
+
// would leave the row holding a dead refresh token if this consent is
|
|
241
|
+
// then abandoned. On a miss (0 rows), re-read and merge onto the fresh
|
|
242
|
+
// blob; bounded so a row that keeps changing fails loudly, not forever.
|
|
243
|
+
let current = row;
|
|
244
|
+
for (let attempt = 0;; attempt++) {
|
|
245
|
+
const blob = this.readBlob(current.valueEncrypted);
|
|
246
|
+
const next = { ...blob, pendingVerifier, pendingScopes };
|
|
247
|
+
const written = await this.db
|
|
248
|
+
.update(secrets)
|
|
249
|
+
.set({ valueEncrypted: this.crypto().encrypt(JSON.stringify(next)), updatedAt: new Date() })
|
|
250
|
+
.where(and(eq(secrets.id, id), eq(secrets.userId, userId), eq(secrets.valueEncrypted, current.valueEncrypted)))
|
|
251
|
+
.returning({ id: secrets.id });
|
|
252
|
+
if (!Array.isArray(written) || written.length > 0)
|
|
253
|
+
break;
|
|
254
|
+
if (attempt >= 2)
|
|
255
|
+
throw new SecretOAuthError('The sign-in changed while starting — try again');
|
|
256
|
+
current = await this.requireRow(userId, id);
|
|
257
|
+
// Only a token rotation is merge-able. A row that is no longer this
|
|
258
|
+
// OAuth secret — re-registered against another provider, or replaced by
|
|
259
|
+
// a static value — would have the consent URL built above pointing at
|
|
260
|
+
// one provider and the pending fields stashed for another.
|
|
261
|
+
if (current.kind !== 'oauth' || JSON.stringify(current.oauthMeta) !== JSON.stringify(row.oauthMeta)) {
|
|
262
|
+
throw new SecretOAuthError('The sign-in changed while starting — try again');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
242
265
|
}
|
|
243
266
|
const url = new URL(meta.authorizationUrl);
|
|
244
267
|
url.searchParams.set('response_type', 'code');
|
|
@@ -291,7 +314,15 @@ export class DbSecretsVaultService {
|
|
|
291
314
|
if (meta.resource)
|
|
292
315
|
body.set('resource', meta.resource);
|
|
293
316
|
const tokens = await this.tokenRequest(meta.tokenUrl, body);
|
|
294
|
-
//
|
|
317
|
+
// A silent token response granted what was asked (RFC 6749 §5.1) — record
|
|
318
|
+
// the request as the grant, or every declared scope would read as missing
|
|
319
|
+
// and the sign-in would be flagged "again" forever. An echoed `scope` is
|
|
320
|
+
// the provider's own word and wins — narrower grants included, and so does
|
|
321
|
+
// an explicit empty one: only an ABSENT field means "as requested".
|
|
322
|
+
if (tokens.scope === undefined && blob.pendingScopes)
|
|
323
|
+
tokens.scope = blob.pendingScopes;
|
|
324
|
+
// The verifier and the requested scopes are one-time — never carried past
|
|
325
|
+
// the exchange they were minted for.
|
|
295
326
|
const next = { clientSecret: blob.clientSecret, tokens };
|
|
296
327
|
await this.db
|
|
297
328
|
.update(secrets)
|
|
@@ -369,10 +400,21 @@ export class DbSecretsVaultService {
|
|
|
369
400
|
// only the derived challenge in the consent URL. `completeOAuth` echoes the
|
|
370
401
|
// verifier at the token exchange and drops it.
|
|
371
402
|
const pendingVerifier = meta.pkce ? randomBytes(32).toString('base64url') : undefined;
|
|
403
|
+
// The scopes this consent asks for: the caller may override from the live
|
|
404
|
+
// tool file (`input.scopes`) so an owner adding a permission takes effect
|
|
405
|
+
// without re-setting the secret. Remembered on the row so a token response
|
|
406
|
+
// that echoes no `scope` is read as granting exactly this (RFC 6749 §5.1).
|
|
407
|
+
const requestedScopes = input.scopes && input.scopes.length ? input.scopes : meta.scopes;
|
|
408
|
+
const pendingScopes = requestedScopes && requestedScopes.length ? requestedScopes.join(' ') : undefined;
|
|
372
409
|
// Provision (or reset) the caller's own oauth row for this key from the shared
|
|
373
410
|
// provider meta + secret, preserving any existing tokens. Keyed `<manual>_<VAR>`
|
|
374
411
|
// so `resolve` (scope 'user') returns the token once sign-in completes.
|
|
375
|
-
const blob = {
|
|
412
|
+
const blob = {
|
|
413
|
+
clientSecret: sharedBlob.clientSecret,
|
|
414
|
+
tokens: existingTokens,
|
|
415
|
+
pendingVerifier,
|
|
416
|
+
pendingScopes,
|
|
417
|
+
};
|
|
376
418
|
const valueEncrypted = this.crypto().encrypt(JSON.stringify(blob));
|
|
377
419
|
const [row] = await this.db
|
|
378
420
|
.insert(secrets)
|
|
@@ -383,10 +425,8 @@ export class DbSecretsVaultService {
|
|
|
383
425
|
})
|
|
384
426
|
.returning();
|
|
385
427
|
// Build the consent URL exactly as beginOAuth does, from the stored meta —
|
|
386
|
-
// EXCEPT the requested scopes
|
|
387
|
-
//
|
|
388
|
-
// re-setting the secret. Client id, addresses, and secret stay owner-pinned.
|
|
389
|
-
const requestedScopes = input.scopes && input.scopes.length ? input.scopes : meta.scopes;
|
|
428
|
+
// EXCEPT the requested scopes (above). Client id, addresses, and secret
|
|
429
|
+
// stay owner-pinned.
|
|
390
430
|
const url = new URL(meta.authorizationUrl);
|
|
391
431
|
url.searchParams.set('response_type', 'code');
|
|
392
432
|
url.searchParams.set('client_id', meta.clientId);
|
|
@@ -512,8 +552,10 @@ export class DbSecretsVaultService {
|
|
|
512
552
|
if (!refreshed.refresh_token)
|
|
513
553
|
refreshed.refresh_token = tokens.refresh_token;
|
|
514
554
|
// Likewise, a refresh response often omits `scope` — keep the granted scopes
|
|
515
|
-
// recorded at sign-in so coverage checks don't regress to "unknown".
|
|
516
|
-
|
|
555
|
+
// recorded at sign-in so coverage checks don't regress to "unknown". Same
|
|
556
|
+
// rule as the exchange: only an ABSENT field means "unchanged"; an echoed
|
|
557
|
+
// value, empty included, is the provider's word.
|
|
558
|
+
if (refreshed.scope === undefined)
|
|
517
559
|
refreshed.scope = tokens.scope;
|
|
518
560
|
const next = { clientSecret: blob.clientSecret, tokens: refreshed };
|
|
519
561
|
// Optimistic concurrency: only persist if the stored ciphertext is unchanged,
|