bkper 4.24.2 → 4.24.3

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 (82) hide show
  1. package/lib/agent/extensions/builtins.d.ts.map +1 -1
  2. package/lib/agent/extensions/builtins.js +2 -2
  3. package/lib/agent/extensions/builtins.js.map +1 -1
  4. package/lib/agent/extensions/handoff.d.ts +2 -13
  5. package/lib/agent/extensions/handoff.d.ts.map +1 -1
  6. package/lib/agent/extensions/handoff.js +37 -17
  7. package/lib/agent/extensions/handoff.js.map +1 -1
  8. package/lib/agent/interactive/interactive-mode.d.ts.map +1 -1
  9. package/lib/agent/interactive/interactive-mode.js +1 -10
  10. package/lib/agent/interactive/interactive-mode.js.map +1 -1
  11. package/lib/commands/apps/deploy.d.ts +3 -1
  12. package/lib/commands/apps/deploy.d.ts.map +1 -1
  13. package/lib/commands/apps/deploy.js +29 -4
  14. package/lib/commands/apps/deploy.js.map +1 -1
  15. package/lib/commands/apps/git/clone.d.ts +23 -0
  16. package/lib/commands/apps/git/clone.d.ts.map +1 -0
  17. package/lib/commands/apps/git/clone.js +161 -0
  18. package/lib/commands/apps/git/clone.js.map +1 -0
  19. package/lib/commands/apps/git/credentials.d.ts +35 -0
  20. package/lib/commands/apps/git/credentials.d.ts.map +1 -0
  21. package/lib/commands/apps/git/credentials.js +196 -0
  22. package/lib/commands/apps/git/credentials.js.map +1 -0
  23. package/lib/commands/apps/git/index.d.ts +12 -0
  24. package/lib/commands/apps/git/index.d.ts.map +1 -0
  25. package/lib/commands/apps/git/index.js +12 -0
  26. package/lib/commands/apps/git/index.js.map +1 -0
  27. package/lib/commands/apps/git/inspect.d.ts +26 -0
  28. package/lib/commands/apps/git/inspect.d.ts.map +1 -0
  29. package/lib/commands/apps/git/inspect.js +207 -0
  30. package/lib/commands/apps/git/inspect.js.map +1 -0
  31. package/lib/commands/apps/git/markers.d.ts +16 -0
  32. package/lib/commands/apps/git/markers.d.ts.map +1 -0
  33. package/lib/commands/apps/git/markers.js +125 -0
  34. package/lib/commands/apps/git/markers.js.map +1 -0
  35. package/lib/commands/apps/git/mode.d.ts +25 -0
  36. package/lib/commands/apps/git/mode.d.ts.map +1 -0
  37. package/lib/commands/apps/git/mode.js +106 -0
  38. package/lib/commands/apps/git/mode.js.map +1 -0
  39. package/lib/commands/apps/git/platform-source.d.ts +18 -0
  40. package/lib/commands/apps/git/platform-source.d.ts.map +1 -0
  41. package/lib/commands/apps/git/platform-source.js +151 -0
  42. package/lib/commands/apps/git/platform-source.js.map +1 -0
  43. package/lib/commands/apps/git/preflight.d.ts +21 -0
  44. package/lib/commands/apps/git/preflight.d.ts.map +1 -0
  45. package/lib/commands/apps/git/preflight.js +130 -0
  46. package/lib/commands/apps/git/preflight.js.map +1 -0
  47. package/lib/commands/apps/git/push.d.ts +22 -0
  48. package/lib/commands/apps/git/push.d.ts.map +1 -0
  49. package/lib/commands/apps/git/push.js +107 -0
  50. package/lib/commands/apps/git/push.js.map +1 -0
  51. package/lib/commands/apps/git/remote.d.ts +7 -0
  52. package/lib/commands/apps/git/remote.d.ts.map +1 -0
  53. package/lib/commands/apps/git/remote.js +48 -0
  54. package/lib/commands/apps/git/remote.js.map +1 -0
  55. package/lib/commands/apps/git/run-git.d.ts +17 -0
  56. package/lib/commands/apps/git/run-git.d.ts.map +1 -0
  57. package/lib/commands/apps/git/run-git.js +61 -0
  58. package/lib/commands/apps/git/run-git.js.map +1 -0
  59. package/lib/commands/apps/git/types.d.ts +95 -0
  60. package/lib/commands/apps/git/types.d.ts.map +1 -0
  61. package/lib/commands/apps/git/types.js +17 -0
  62. package/lib/commands/apps/git/types.js.map +1 -0
  63. package/lib/commands/apps/index.d.ts +2 -0
  64. package/lib/commands/apps/index.d.ts.map +1 -1
  65. package/lib/commands/apps/index.js +3 -0
  66. package/lib/commands/apps/index.js.map +1 -1
  67. package/lib/commands/apps/init.d.ts.map +1 -1
  68. package/lib/commands/apps/init.js +19 -3
  69. package/lib/commands/apps/init.js.map +1 -1
  70. package/lib/commands/apps/register.d.ts.map +1 -1
  71. package/lib/commands/apps/register.js +23 -4
  72. package/lib/commands/apps/register.js.map +1 -1
  73. package/lib/commands/apps/source-workflow.d.ts +32 -0
  74. package/lib/commands/apps/source-workflow.d.ts.map +1 -0
  75. package/lib/commands/apps/source-workflow.js +170 -0
  76. package/lib/commands/apps/source-workflow.js.map +1 -0
  77. package/lib/commands/apps/sync.d.ts.map +1 -1
  78. package/lib/commands/apps/sync.js +13 -8
  79. package/lib/commands/apps/sync.js.map +1 -1
  80. package/lib/docs/cli/app-management.md +94 -6
  81. package/lib/docs/index.md +1 -1
  82. package/package.json +1 -1
@@ -0,0 +1,161 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import fs from 'fs';
11
+ import os from 'os';
12
+ import path from 'path';
13
+ import * as YAML from 'yaml';
14
+ import { runGit } from './run-git.js';
15
+ import { createPlatformSourceApi, stripRepositoryTokenSecret, } from './platform-source.js';
16
+ import { configureManagedOrigin } from './remote.js';
17
+ import { writeManagedSourceMarker } from './markers.js';
18
+ import { ManagedGitError } from './types.js';
19
+ function resolveDestination(appId, destination, cwd) {
20
+ if (destination) {
21
+ return path.resolve(cwd, destination);
22
+ }
23
+ return path.resolve(cwd, appId);
24
+ }
25
+ function readClonedAppId(repoDir) {
26
+ for (const fileName of ['bkper.yaml', 'bkper.json']) {
27
+ const fullPath = path.join(repoDir, fileName);
28
+ if (!fs.existsSync(fullPath)) {
29
+ continue;
30
+ }
31
+ const content = fs.readFileSync(fullPath, 'utf8');
32
+ const config = fileName.endsWith('.json')
33
+ ? JSON.parse(content)
34
+ : YAML.parse(content);
35
+ if (typeof (config === null || config === void 0 ? void 0 : config.id) === 'string') {
36
+ return config.id;
37
+ }
38
+ }
39
+ return undefined;
40
+ }
41
+ function cloneWithReadToken(args) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const password = stripRepositoryTokenSecret(args.token);
44
+ // Use an absolute credential helper so the token never appears in argv or remote URL.
45
+ const helperScript = [
46
+ '#!/bin/sh',
47
+ 'set -eu',
48
+ '[ "${1:-}" = "get" ] || exit 0',
49
+ 'printf "username=x\\npassword=%s\\n" "$BKPER_CLONE_TOKEN"',
50
+ '',
51
+ ].join('\n');
52
+ const helperPath = path.join(os.tmpdir(), `bkper-clone-helper-${process.pid}-${Date.now()}.sh`);
53
+ fs.writeFileSync(helperPath, helperScript, { mode: 0o700 });
54
+ try {
55
+ yield args.runner([
56
+ '-c',
57
+ 'credential.helper=',
58
+ '-c',
59
+ `credential.helper=${helperPath}`,
60
+ 'clone',
61
+ '--branch',
62
+ 'main',
63
+ args.remote,
64
+ args.tempDir,
65
+ ], {
66
+ env: Object.assign(Object.assign({}, process.env), { BKPER_CLONE_TOKEN: password, GIT_TERMINAL_PROMPT: '0' }),
67
+ });
68
+ }
69
+ finally {
70
+ fs.rmSync(helperPath, { force: true });
71
+ }
72
+ });
73
+ }
74
+ /**
75
+ * Atomically clones a managed App source repository.
76
+ * Never installs dependencies or executes repository lifecycle scripts.
77
+ */
78
+ export function cloneManagedApp(options) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ var _a, _b, _c, _d;
81
+ const cwd = (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd();
82
+ const destination = resolveDestination(options.appId, options.destination, cwd);
83
+ const runner = (_b = options.runner) !== null && _b !== void 0 ? _b : runGit;
84
+ const api = (_c = options.api) !== null && _c !== void 0 ? _c : createPlatformSourceApi();
85
+ if (fs.existsSync(destination)) {
86
+ throw new ManagedGitError('CLONE_DESTINATION_EXISTS', [
87
+ `Destination already exists: ${destination}`,
88
+ 'Choose another path or remove the existing directory, then retry:',
89
+ ` bkper app clone ${options.appId} <path>`,
90
+ ].join('\n'));
91
+ }
92
+ const status = yield api.getStatus(options.appId);
93
+ if (status === 'feature_disabled') {
94
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', 'Managed source control is not enabled in this Platform environment.');
95
+ }
96
+ if (status === 'app_not_found' || status.mode !== 'managed') {
97
+ throw new ManagedGitError('EXTERNAL_SOURCE_CLONE', [
98
+ `App '${options.appId}' does not use Bkper-managed source.`,
99
+ 'Clone it from its external Git provider (GitHub, GitLab, etc.).',
100
+ 'If the App publishes a repository URL, use that provider clone command instead of `bkper app clone`.',
101
+ ].join('\n'));
102
+ }
103
+ const credential = yield api.issueCredential(options.appId, 'read');
104
+ const parentDir = path.dirname(destination);
105
+ fs.mkdirSync(parentDir, { recursive: true });
106
+ const tempDir = fs.mkdtempSync(path.join(parentDir, `.${options.appId}-clone-`));
107
+ try {
108
+ const cloneImpl = (_d = options.cloneImpl) !== null && _d !== void 0 ? _d : cloneWithReadToken;
109
+ try {
110
+ yield cloneImpl({
111
+ remote: credential.remote,
112
+ token: credential.token,
113
+ tempDir,
114
+ runner,
115
+ });
116
+ }
117
+ catch (error) {
118
+ const message = error instanceof Error ? error.message : String(error);
119
+ if (/empty|not found|could not find remote|Remote branch main not found/i.test(message)) {
120
+ throw new ManagedGitError('CLONE_EMPTY_REPOSITORY', [
121
+ `Managed repository for '${options.appId}' has no commit on main yet.`,
122
+ 'Ask the App owner to complete the first managed sync/push, then retry clone.',
123
+ ].join('\n'));
124
+ }
125
+ throw error;
126
+ }
127
+ const clonedAppId = readClonedAppId(tempDir);
128
+ if (!clonedAppId) {
129
+ throw new ManagedGitError('APP_ID_MISMATCH', 'Cloned repository is missing bkper.yaml/bkper.json with an id field.');
130
+ }
131
+ if (clonedAppId !== options.appId) {
132
+ throw new ManagedGitError('APP_ID_MISMATCH', [
133
+ 'Cloned bkper.yaml id does not match the requested App ID.',
134
+ `Requested: ${options.appId}`,
135
+ `Found: ${clonedAppId}`,
136
+ ].join('\n'));
137
+ }
138
+ yield configureManagedOrigin(tempDir, credential.remote, options.appId, runner);
139
+ writeManagedSourceMarker(tempDir, options.appId, credential.remote);
140
+ fs.renameSync(tempDir, destination);
141
+ return destination;
142
+ }
143
+ catch (error) {
144
+ fs.rmSync(tempDir, { recursive: true, force: true });
145
+ throw error;
146
+ }
147
+ });
148
+ }
149
+ export function cloneManagedAppCommand(appId, destination) {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ const dest = yield cloneManagedApp({ appId, destination });
152
+ console.log(`Cloned managed App '${appId}' into ${dest}`);
153
+ console.log('');
154
+ console.log('Next steps:');
155
+ console.log(` cd ${path.relative(process.cwd(), dest) || '.'}`);
156
+ console.log(' bun install');
157
+ console.log('');
158
+ console.log('Clone never installs dependencies or runs repository scripts.');
159
+ });
160
+ }
161
+ //# sourceMappingURL=clone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.js","sourceRoot":"","sources":["../../../../src/commands/apps/git/clone.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAC,MAAM,EAAiB,MAAM,cAAc,CAAC;AACpD,OAAO,EACH,uBAAuB,EACvB,0BAA0B,GAE7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,sBAAsB,EAAC,MAAM,aAAa,CAAC;AACnD,OAAO,EAAC,wBAAwB,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAiB3C,SAAS,kBAAkB,CAAC,KAAa,EAAE,WAA+B,EAA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AgB,sBAAsB,CACxC,KAAa,EACb,WAAoB;;QAEpB,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,EAAC,KAAK,EAAE,WAAW,EAAC,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,UAAU,IAAI,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;IACjF,CAAC;CAAA"}
@@ -0,0 +1,35 @@
1
+ import { type GitRunner } from './run-git.js';
2
+ import { type PlatformSourceApi } from './platform-source.js';
3
+ export interface CredentialRequest {
4
+ protocol?: string;
5
+ host?: string;
6
+ path?: string;
7
+ username?: string;
8
+ }
9
+ export interface CredentialHelperOptions {
10
+ appId?: string;
11
+ stdin?: string;
12
+ operation?: string;
13
+ api?: PlatformSourceApi;
14
+ stdout?: (chunk: string) => void;
15
+ stderr?: (chunk: string) => void;
16
+ }
17
+ /**
18
+ * Parses Git's credential helper stdin protocol.
19
+ */
20
+ export declare function parseCredentialInput(input: string): CredentialRequest;
21
+ export declare function buildCredentialHelperCommand(appId: string): string;
22
+ export declare function buildCredentialConfigSection(remote: string, appId: string): string;
23
+ /**
24
+ * Configures exact URL/path-scoped credentials for the managed remote.
25
+ * Clears inherited helpers for that credential context and pins the App ID.
26
+ */
27
+ export declare function configureManagedCredentialHelper(repoRoot: string, remote: string, appId: string, runner?: GitRunner): Promise<void>;
28
+ export declare function formatCredentialGetResponse(password: string): string;
29
+ /**
30
+ * Implements `bkper app git-credential <appId>` for Git's credential helper protocol.
31
+ * - get: issues a short-lived write token and prints protocol fields only
32
+ * - store/erase: no-op (never persists)
33
+ */
34
+ export declare function runGitCredentialHelper(options?: CredentialHelperOptions): Promise<number>;
35
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../src/commands/apps/git/credentials.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EAGH,KAAK,iBAAiB,EACzB,MAAM,sBAAsB,CAAC;AAQ9B,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,iBAAiB,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAkBrE;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGlE;AAMD,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQlF;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,CAClD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,SAAkB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAmBf;AA0BD,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CACxC,OAAO,GAAE,uBAA4B,GACtC,OAAO,CAAC,MAAM,CAAC,CAgFjB"}
@@ -0,0 +1,196 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
11
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
12
+ var m = o[Symbol.asyncIterator], i;
13
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
14
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
15
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
16
+ };
17
+ import { AUTHENTICATION_REQUIRED_MESSAGE } from '../../../auth/auth-errors.js';
18
+ import { runGit } from './run-git.js';
19
+ import { createPlatformSourceApi, stripRepositoryTokenSecret, } from './platform-source.js';
20
+ import { CREDENTIAL_USERNAME, ManagedGitError, } from './types.js';
21
+ import { isArtifactsRemoteUrl, normalizeRemoteUrl } from './inspect.js';
22
+ /**
23
+ * Parses Git's credential helper stdin protocol.
24
+ */
25
+ export function parseCredentialInput(input) {
26
+ const request = {};
27
+ for (const rawLine of input.split(/\r?\n/)) {
28
+ const line = rawLine.trimEnd();
29
+ if (!line) {
30
+ continue;
31
+ }
32
+ const eq = line.indexOf('=');
33
+ if (eq <= 0) {
34
+ continue;
35
+ }
36
+ const key = line.slice(0, eq);
37
+ const value = line.slice(eq + 1);
38
+ if (key === 'protocol' || key === 'host' || key === 'path' || key === 'username') {
39
+ request[key] = value;
40
+ }
41
+ }
42
+ return request;
43
+ }
44
+ export function buildCredentialHelperCommand(appId) {
45
+ // Git appends get|store|erase to this exact shell helper command.
46
+ return `!bkper app git-credential ${shellSingleQuote(appId)}`;
47
+ }
48
+ function shellSingleQuote(value) {
49
+ return `'${value.replace(/'/g, `'\\''`)}'`;
50
+ }
51
+ export function buildCredentialConfigSection(remote, appId) {
52
+ return [
53
+ `[credential ${JSON.stringify(normalizeRemoteUrl(remote))}]`,
54
+ ' useHttpPath = true',
55
+ ' helper =',
56
+ ` helper = ${buildCredentialHelperCommand(appId)}`,
57
+ '',
58
+ ].join('\n');
59
+ }
60
+ /**
61
+ * Configures exact URL/path-scoped credentials for the managed remote.
62
+ * Clears inherited helpers for that credential context and pins the App ID.
63
+ */
64
+ export function configureManagedCredentialHelper(repoRoot_1, remote_1, appId_1) {
65
+ return __awaiter(this, arguments, void 0, function* (repoRoot, remote, appId, runner = runGit) {
66
+ if (!isArtifactsRemoteUrl(remote)) {
67
+ throw new ManagedGitError('INVALID_CREDENTIAL_REQUEST', 'Managed credentials can only be configured for an Artifacts HTTPS remote.');
68
+ }
69
+ const remoteKey = normalizeRemoteUrl(remote);
70
+ yield runner(['config', `credential.${remoteKey}.useHttpPath`, 'true'], { cwd: repoRoot });
71
+ // Replace all local values with the empty helper so retries remain idempotent
72
+ // while clearing inherited persistent helpers for this credential context.
73
+ yield runner(['config', '--replace-all', `credential.${remoteKey}.helper`, ''], {
74
+ cwd: repoRoot,
75
+ });
76
+ yield runner(['config', '--add', `credential.${remoteKey}.helper`, buildCredentialHelperCommand(appId)], { cwd: repoRoot });
77
+ });
78
+ }
79
+ function requestMatchesRemote(request, remote) {
80
+ let parsed;
81
+ try {
82
+ parsed = new URL(remote);
83
+ }
84
+ catch (_a) {
85
+ return false;
86
+ }
87
+ if (request.protocol && request.protocol !== parsed.protocol.replace(/:$/, '')) {
88
+ return false;
89
+ }
90
+ if (request.host && request.host !== parsed.host) {
91
+ return false;
92
+ }
93
+ if (request.path) {
94
+ const expectedPath = parsed.pathname.replace(/^\//, '');
95
+ const actualPath = request.path.replace(/^\//, '');
96
+ if (actualPath !== expectedPath) {
97
+ return false;
98
+ }
99
+ }
100
+ return true;
101
+ }
102
+ export function formatCredentialGetResponse(password) {
103
+ return `username=${CREDENTIAL_USERNAME}\npassword=${password}\n`;
104
+ }
105
+ /**
106
+ * Implements `bkper app git-credential <appId>` for Git's credential helper protocol.
107
+ * - get: issues a short-lived write token and prints protocol fields only
108
+ * - store/erase: no-op (never persists)
109
+ */
110
+ export function runGitCredentialHelper() {
111
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
112
+ var _a, _b, _c, _d, _e, _f;
113
+ const operation = (_b = (_a = options.operation) !== null && _a !== void 0 ? _a : process.argv[2]) !== null && _b !== void 0 ? _b : 'get';
114
+ const writeOut = (_c = options.stdout) !== null && _c !== void 0 ? _c : (chunk => process.stdout.write(chunk));
115
+ // stderr is available for hard failures only; never print tokens.
116
+ const writeErr = (_d = options.stderr) !== null && _d !== void 0 ? _d : (chunk => process.stderr.write(chunk));
117
+ if (operation === 'store' || operation === 'erase') {
118
+ return 0;
119
+ }
120
+ if (operation !== 'get') {
121
+ writeErr(`Unsupported credential operation '${operation}'. Expected get, store, or erase.\n`);
122
+ return 1;
123
+ }
124
+ try {
125
+ const appId = options.appId;
126
+ if (!appId) {
127
+ throw new ManagedGitError('INVALID_CREDENTIAL_REQUEST', 'The managed Git credential helper requires a pinned App ID.');
128
+ }
129
+ const stdin = (_e = options.stdin) !== null && _e !== void 0 ? _e : (yield readStdin());
130
+ const request = parseCredentialInput(stdin);
131
+ if (!request.protocol || !request.host) {
132
+ throw new ManagedGitError('INVALID_CREDENTIAL_REQUEST', 'Git credential request is missing protocol or host.');
133
+ }
134
+ if (request.protocol !== 'https') {
135
+ throw new ManagedGitError('INVALID_CREDENTIAL_REQUEST', 'Managed source credentials only support https.');
136
+ }
137
+ const api = (_f = options.api) !== null && _f !== void 0 ? _f : createPlatformSourceApi();
138
+ let credential;
139
+ try {
140
+ credential = yield api.issueCredential(appId, 'write');
141
+ }
142
+ catch (error) {
143
+ if (error instanceof ManagedGitError) {
144
+ throw error;
145
+ }
146
+ throw new ManagedGitError('MANAGED_SOURCE_UNAVAILABLE', 'Failed to issue managed source credentials. Run: bkper auth login');
147
+ }
148
+ if (!requestMatchesRemote(request, credential.remote)) {
149
+ throw new ManagedGitError('INVALID_CREDENTIAL_REQUEST', [
150
+ 'Git credential request does not match the Platform-registered Artifacts remote.',
151
+ 'Repair managed origin configuration, then retry the Git operation.',
152
+ ].join('\n'));
153
+ }
154
+ const password = stripRepositoryTokenSecret(credential.token);
155
+ // Credential protocol output only — never log this string.
156
+ writeOut(formatCredentialGetResponse(password));
157
+ return 0;
158
+ }
159
+ catch (error) {
160
+ if (error instanceof ManagedGitError) {
161
+ if (error.code === 'AUTHENTICATION_REQUIRED') {
162
+ writeErr(`${AUTHENTICATION_REQUIRED_MESSAGE}\n`);
163
+ }
164
+ else {
165
+ writeErr(`${error.message}\n`);
166
+ }
167
+ return 1;
168
+ }
169
+ writeErr('Managed source credential helper failed.\n');
170
+ return 1;
171
+ }
172
+ });
173
+ }
174
+ function readStdin() {
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ var _a, e_1, _b, _c;
177
+ const chunks = [];
178
+ try {
179
+ for (var _d = true, _e = __asyncValues(process.stdin), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
180
+ _c = _f.value;
181
+ _d = false;
182
+ const chunk = _c;
183
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
184
+ }
185
+ }
186
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
187
+ finally {
188
+ try {
189
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
190
+ }
191
+ finally { if (e_1) throw e_1.error; }
192
+ }
193
+ return Buffer.concat(chunks).toString('utf8');
194
+ });
195
+ }
196
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../../src/commands/apps/git/credentials.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,+BAA+B,EAAC,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAC,MAAM,EAAiB,MAAM,cAAc,CAAC;AACpD,OAAO,EACH,uBAAuB,EACvB,0BAA0B,GAE7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,mBAAmB,EACnB,eAAe,GAElB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAkBtE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAC9C,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,SAAS;QACb,CAAC;QACD,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YACV,SAAS;QACb,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9B,MAAM,KAAK,GAAG,IAAI,C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AO,CAAC,CAAC;YACb,CAAC;YACD,QAAQ,CAAC,4CAA4C,CAAC,CAAC;YACvD,OAAO,CAAC,CAAC;QACb,CAAC;IACL,CAAC;CAAA;AAED,SAAe,SAAS;;;QACpB,MAAM,MAAM,GAAa,EAAE,CAAC;;YAC5B,KAA0B,eAAA,KAAA,cAAA,OAAO,CAAC,KAAK,CAAA,IAAA,sDAAE,CAAC;gBAAhB,cAAa;gBAAb,WAAa;gBAA5B,MAAM,KAAK,KAAA,CAAA;gBAClB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,CAAC;;;;;;;;;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;CAAA"}
@@ -0,0 +1,12 @@
1
+ export { ARTIFACTS_HOST_SUFFIX, CREDENTIAL_USERNAME, DEFAULT_MANAGED_BRANCH, ManagedGitError, SOURCE_MARKER_DIR, SOURCE_MARKER_FILE, type GitPreflightCode, type GitRemote, type GitRepositoryInfo, type ManagedSourceActivationResult, type ManagedSourceCredential, type ManagedSourcePlatformStatus, type SourceMarker, type SourceMode, type SourceModeDecision, type WorkingTreeStatus, } from './types.js';
2
+ export { runGit, type GitCommandResult, type GitRunOptions, type GitRunner } from './run-git.js';
3
+ export { ensureGitInitialized, findBkperYaml, findGitRoot, getCurrentBranch, getHeadSha, getOriginRemote, getWorkingTreeStatus, hasExternalRemote, inspectGitRepository, isArtifactsRemoteUrl, listRemotes, normalizeRemoteUrl, remoteUrlsEqual, requireGitRepository, } from './inspect.js';
4
+ export { createActivationId, ensurePendingSourceMarker, getSourceMarkerPath, isUuidV4, readSourceMarker, writeManagedSourceMarker, } from './markers.js';
5
+ export { requireManagedGitPreflight, requireManagedOrigin, type ManagedGitPreflightOptions, type ManagedGitPreflightResult, } from './preflight.js';
6
+ export { detectSourceMode, type DetectSourceModeInput } from './mode.js';
7
+ export { buildCredentialConfigSection, buildCredentialHelperCommand, configureManagedCredentialHelper, formatCredentialGetResponse, parseCredentialInput, runGitCredentialHelper, type CredentialHelperOptions, type CredentialRequest, } from './credentials.js';
8
+ export { createPlatformSourceApi, getPlatformBaseUrl, stripRepositoryTokenSecret, type PlatformSourceApi, } from './platform-source.js';
9
+ export { configureManagedOrigin } from './remote.js';
10
+ export { assertFastForwardPush, pushCurrentBranchSafe, type SafePushOptions, type SafePushResult, } from './push.js';
11
+ export { cloneManagedApp, cloneManagedAppCommand, type CloneManagedAppOptions, } from './clone.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/apps/git/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACzB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAC,MAAM,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;AAE/F,OAAO,EACH,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,kBAAkB,EAClB,yBAAyB,EACzB,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,EAChB,wBAAwB,GAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,0BAA0B,EAC1B,oBAAoB,EACpB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,GACjC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAC,gBAAgB,EAAE,KAAK,qBAAqB,EAAC,MAAM,WAAW,CAAC;AAEvE,OAAO,EACH,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC3B,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,iBAAiB,GACzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,sBAAsB,EAAC,MAAM,aAAa,CAAC;AAEnD,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACH,eAAe,EACf,sBAAsB,EACtB,KAAK,sBAAsB,GAC9B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,12 @@
1
+ export { ARTIFACTS_HOST_SUFFIX, CREDENTIAL_USERNAME, DEFAULT_MANAGED_BRANCH, ManagedGitError, SOURCE_MARKER_DIR, SOURCE_MARKER_FILE, } from './types.js';
2
+ export { runGit } from './run-git.js';
3
+ export { ensureGitInitialized, findBkperYaml, findGitRoot, getCurrentBranch, getHeadSha, getOriginRemote, getWorkingTreeStatus, hasExternalRemote, inspectGitRepository, isArtifactsRemoteUrl, listRemotes, normalizeRemoteUrl, remoteUrlsEqual, requireGitRepository, } from './inspect.js';
4
+ export { createActivationId, ensurePendingSourceMarker, getSourceMarkerPath, isUuidV4, readSourceMarker, writeManagedSourceMarker, } from './markers.js';
5
+ export { requireManagedGitPreflight, requireManagedOrigin, } from './preflight.js';
6
+ export { detectSourceMode } from './mode.js';
7
+ export { buildCredentialConfigSection, buildCredentialHelperCommand, configureManagedCredentialHelper, formatCredentialGetResponse, parseCredentialInput, runGitCredentialHelper, } from './credentials.js';
8
+ export { createPlatformSourceApi, getPlatformBaseUrl, stripRepositoryTokenSecret, } from './platform-source.js';
9
+ export { configureManagedOrigin } from './remote.js';
10
+ export { assertFastForwardPush, pushCurrentBranchSafe, } from './push.js';
11
+ export { cloneManagedApp, cloneManagedAppCommand, } from './clone.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/apps/git/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GAWrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAC,MAAM,EAA4D,MAAM,cAAc,CAAC;AAE/F,OAAO,EACH,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,kBAAkB,EAClB,yBAAyB,EACzB,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,EAChB,wBAAwB,GAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,0BAA0B,EAC1B,oBAAoB,GAGvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAC,gBAAgB,EAA6B,MAAM,WAAW,CAAC;AAEvE,OAAO,EACH,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC3B,oBAAoB,EACpB,sBAAsB,GAGzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,0BAA0B,GAE7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,sBAAsB,EAAC,MAAM,aAAa,CAAC;AAEnD,OAAO,EACH,qBAAqB,EACrB,qBAAqB,GAGxB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACH,eAAe,EACf,sBAAsB,GAEzB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type GitRunner } from './run-git.js';
2
+ import { type GitRemote, type GitRepositoryInfo, type WorkingTreeStatus } from './types.js';
3
+ export declare function isArtifactsRemoteUrl(url: string): boolean;
4
+ export declare function normalizeRemoteUrl(url: string): string;
5
+ export declare function remoteUrlsEqual(left: string, right: string): boolean;
6
+ /**
7
+ * Resolves the Git repository root for a path, or null when outside a repo.
8
+ */
9
+ export declare function findGitRoot(startDir: string, runner?: GitRunner): Promise<string | null>;
10
+ export declare function findBkperYaml(dir: string): string | null;
11
+ export declare function listRemotes(repoRoot: string, runner?: GitRunner): Promise<GitRemote[]>;
12
+ export declare function hasExternalRemote(remotes: GitRemote[]): boolean;
13
+ export declare function getOriginRemote(remotes: GitRemote[]): GitRemote | undefined;
14
+ export declare function getCurrentBranch(repoRoot: string, runner?: GitRunner): Promise<{
15
+ branch: string | null;
16
+ detached: boolean;
17
+ }>;
18
+ export declare function getHeadSha(repoRoot: string, runner?: GitRunner): Promise<string | null>;
19
+ export declare function getWorkingTreeStatus(repoRoot: string, runner?: GitRunner): Promise<WorkingTreeStatus>;
20
+ /**
21
+ * Inspects the Git repository surrounding an app directory.
22
+ */
23
+ export declare function inspectGitRepository(appDir: string, runner?: GitRunner): Promise<GitRepositoryInfo | null>;
24
+ export declare function ensureGitInitialized(targetDir: string, runner?: GitRunner): Promise<boolean>;
25
+ export declare function requireGitRepository(info: GitRepositoryInfo | null): asserts info is GitRepositoryInfo;
26
+ //# sourceMappingURL=inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.d.ts","source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