gcb-host 0.0.0 → 0.0.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/CHANGELOG.md +9 -0
- package/bin/gcb.js +5 -0
- package/lib/audit.d.ts +25 -0
- package/lib/audit.d.ts.map +1 -0
- package/lib/audit.js +73 -0
- package/lib/audit.js.map +1 -0
- package/lib/broker.d.ts +61 -0
- package/lib/broker.d.ts.map +1 -0
- package/lib/broker.js +512 -0
- package/lib/broker.js.map +1 -0
- package/lib/commands/authorize.d.ts +38 -0
- package/lib/commands/authorize.d.ts.map +1 -0
- package/lib/commands/authorize.js +134 -0
- package/lib/commands/authorize.js.map +1 -0
- package/lib/commands/compose.d.ts +42 -0
- package/lib/commands/compose.d.ts.map +1 -0
- package/lib/commands/compose.js +208 -0
- package/lib/commands/compose.js.map +1 -0
- package/lib/commands/deployment.d.ts +49 -0
- package/lib/commands/deployment.d.ts.map +1 -0
- package/lib/commands/deployment.js +72 -0
- package/lib/commands/deployment.js.map +1 -0
- package/lib/commands/diagnose.d.ts +4 -0
- package/lib/commands/diagnose.d.ts.map +1 -0
- package/lib/commands/diagnose.js +213 -0
- package/lib/commands/diagnose.js.map +1 -0
- package/lib/commands/host-opener.d.ts +23 -0
- package/lib/commands/host-opener.d.ts.map +1 -0
- package/lib/commands/host-opener.js +244 -0
- package/lib/commands/host-opener.js.map +1 -0
- package/lib/commands/init.d.ts +153 -0
- package/lib/commands/init.d.ts.map +1 -0
- package/lib/commands/init.js +510 -0
- package/lib/commands/init.js.map +1 -0
- package/lib/commands/stage.d.ts +44 -0
- package/lib/commands/stage.d.ts.map +1 -0
- package/lib/commands/stage.js +165 -0
- package/lib/commands/stage.js.map +1 -0
- package/lib/config.d.ts +110 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +408 -0
- package/lib/config.js.map +1 -0
- package/lib/daemon.d.ts +45 -0
- package/lib/daemon.d.ts.map +1 -0
- package/lib/daemon.js +123 -0
- package/lib/daemon.js.map +1 -0
- package/lib/device-flow.d.ts +80 -0
- package/lib/device-flow.d.ts.map +1 -0
- package/lib/device-flow.js +148 -0
- package/lib/device-flow.js.map +1 -0
- package/lib/gh.d.ts +37 -0
- package/lib/gh.d.ts.map +1 -0
- package/lib/gh.js +181 -0
- package/lib/gh.js.map +1 -0
- package/lib/http.d.ts +20 -0
- package/lib/http.d.ts.map +1 -0
- package/lib/http.js +133 -0
- package/lib/http.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +52 -0
- package/lib/index.js.map +1 -0
- package/lib/policy.d.ts +60 -0
- package/lib/policy.d.ts.map +1 -0
- package/lib/policy.js +118 -0
- package/lib/policy.js.map +1 -0
- package/lib/providers/github-app.d.ts +56 -0
- package/lib/providers/github-app.d.ts.map +1 -0
- package/lib/providers/github-app.js +901 -0
- package/lib/providers/github-app.js.map +1 -0
- package/lib/providers/index.d.ts +29 -0
- package/lib/providers/index.d.ts.map +1 -0
- package/lib/providers/index.js +32 -0
- package/lib/providers/index.js.map +1 -0
- package/lib/providers/static.d.ts +18 -0
- package/lib/providers/static.d.ts.map +1 -0
- package/lib/providers/static.js +41 -0
- package/lib/providers/static.js.map +1 -0
- package/lib/proxy.d.ts +23 -0
- package/lib/proxy.d.ts.map +1 -0
- package/lib/proxy.js +57 -0
- package/lib/proxy.js.map +1 -0
- package/package.json +36 -2
- package/README.md +0 -1
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-side entry point: the broker daemon and administration commands.
|
|
3
|
+
*
|
|
4
|
+
* This is the only side that imports `yaml` (through config.ts) and holds the App key.
|
|
5
|
+
*/
|
|
6
|
+
import type { CommandBackend } from 'gcb-core';
|
|
7
|
+
export * from './gh.ts';
|
|
8
|
+
export declare const HOST_HELP = "gcb-host \u2014 host-side gcb broker and administration commands.\n\nUsage: gcb <command> [options]\n\nCommands\n app Run the app broker (alias for daemon)\n host Run the host operations opener (alias for host-opener)\n daemon Run the broker (normally started by the service manager)\n init Create or update the broker config, and install the key\n stage Export a reviewed commit to where the broker will run\n compose Print a Docker sidecar definition for the broker\n diagnose Ask GitHub what the App can actually see\n authorize Authorize this app once for person-authored pull requests\n host-opener Watch for the container's pull-request requests and create them\n\nClient commands such as setup/probe/logs/pr are in gcb-client.";
|
|
9
|
+
export declare const hostBackend: CommandBackend;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,SAAS,8xBAeyC,CAAC;AA8BhE,eAAO,MAAM,WAAW,EAAE,cAKzB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { assertProxyEnabled } from './proxy.js';
|
|
2
|
+
export * from './gh.js';
|
|
3
|
+
export const HOST_HELP = `gcb-host — host-side gcb broker and administration commands.
|
|
4
|
+
|
|
5
|
+
Usage: gcb <command> [options]
|
|
6
|
+
|
|
7
|
+
Commands
|
|
8
|
+
app Run the app broker (alias for daemon)
|
|
9
|
+
host Run the host operations opener (alias for host-opener)
|
|
10
|
+
daemon Run the broker (normally started by the service manager)
|
|
11
|
+
init Create or update the broker config, and install the key
|
|
12
|
+
stage Export a reviewed commit to where the broker will run
|
|
13
|
+
compose Print a Docker sidecar definition for the broker
|
|
14
|
+
diagnose Ask GitHub what the App can actually see
|
|
15
|
+
authorize Authorize this app once for person-authored pull requests
|
|
16
|
+
host-opener Watch for the container's pull-request requests and create them
|
|
17
|
+
|
|
18
|
+
Client commands such as setup/probe/logs/pr are in gcb-client.`;
|
|
19
|
+
async function run(argv) {
|
|
20
|
+
const [command, ...rest] = argv;
|
|
21
|
+
switch (command) {
|
|
22
|
+
case 'app':
|
|
23
|
+
case 'daemon': {
|
|
24
|
+
assertProxyEnabled();
|
|
25
|
+
const { runDaemon } = await import('./daemon.js');
|
|
26
|
+
return runDaemon(rest);
|
|
27
|
+
}
|
|
28
|
+
case 'init':
|
|
29
|
+
return (await import('./commands/init.js')).runInit(rest);
|
|
30
|
+
case 'stage':
|
|
31
|
+
return (await import('./commands/stage.js')).runStage(rest);
|
|
32
|
+
case 'compose':
|
|
33
|
+
return (await import('./commands/compose.js')).runCompose(rest);
|
|
34
|
+
case 'diagnose':
|
|
35
|
+
return (await import('./commands/diagnose.js')).runDiagnose(rest);
|
|
36
|
+
case 'authorize':
|
|
37
|
+
return (await import('./commands/authorize.js')).runAuthorize(rest);
|
|
38
|
+
case 'host':
|
|
39
|
+
case 'host-opener':
|
|
40
|
+
return (await import('./commands/host-opener.js')).runHostOpener(rest);
|
|
41
|
+
default:
|
|
42
|
+
process.stderr.write(`gcb: unknown host command \`${command ?? ''}\`.\n`);
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export const hostBackend = {
|
|
47
|
+
role: 'host',
|
|
48
|
+
commands: ['app', 'host', 'daemon', 'init', 'stage', 'compose', 'diagnose', 'authorize', 'host-opener'],
|
|
49
|
+
help: HOST_HELP,
|
|
50
|
+
run,
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,cAAc,SAAS,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;+DAesC,CAAC;AAEhE,KAAK,UAAU,GAAG,CAAC,IAAuB;IACxC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,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UAAU,EAAE,WAAW,EAAE,aAAa,CAAC;IACvG,IAAI,EAAE,SAAS;IACf,GAAG;CACJ,CAAC"}
|
package/lib/policy.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authorization policy: the only place that decides whether a host + repository pair may
|
|
3
|
+
* receive a credential.
|
|
4
|
+
*
|
|
5
|
+
* Design rules (see the design review, findings P0-1 and P2-3):
|
|
6
|
+
* - default deny: an unknown host or an unlisted repository never yields a credential;
|
|
7
|
+
* - repository paths are normalized (drop leading/trailing slashes, drop a trailing
|
|
8
|
+
* `.git`, lowercase) before matching, because GitHub owner/repo names are
|
|
9
|
+
* case-insensitive;
|
|
10
|
+
* - matching is exact per path segment, never a prefix match, so an allowlist entry for
|
|
11
|
+
* `acme/widget` can never authorize `acme/widget-evil`;
|
|
12
|
+
* - a wildcard is allowed only as a whole segment, never inside one, so a malformed entry
|
|
13
|
+
* matches nothing and therefore fails closed.
|
|
14
|
+
*/
|
|
15
|
+
import type { BrokerConfig, HostConfig, RepoRef } from 'gcb-core';
|
|
16
|
+
/** One parsed allowlist entry. */
|
|
17
|
+
export interface AllowEntry {
|
|
18
|
+
readonly owner: string;
|
|
19
|
+
readonly repo: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Normalize the `path=` value git hands to a credential helper into an `owner/repo` pair.
|
|
23
|
+
*
|
|
24
|
+
* @param rawPath - the raw `path` field, e.g. `acme/widget.git`.
|
|
25
|
+
* @returns the normalized reference, or null when the value is missing, has more than two
|
|
26
|
+
* segments, is made of dots, or contains characters we refuse to guess about.
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeRepoPath(rawPath: unknown): RepoRef | null;
|
|
29
|
+
/**
|
|
30
|
+
* Parse one allowlist entry: exactly two segments, each either an identifier or a
|
|
31
|
+
* whole-segment wildcard.
|
|
32
|
+
*
|
|
33
|
+
* @param entry - the raw entry from configuration.
|
|
34
|
+
* @returns the parsed entry, or null when it is malformed (which matches nothing).
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseAllowEntry(entry: unknown): AllowEntry | null;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a normalized repository is covered by an allowlist.
|
|
39
|
+
*
|
|
40
|
+
* @param allowList - configured allow entries.
|
|
41
|
+
* @param full - a normalized `owner/repo` string.
|
|
42
|
+
* @returns true only for an exact segment-wise match.
|
|
43
|
+
*/
|
|
44
|
+
export declare function repoAllowed(allowList: unknown, full: string): boolean;
|
|
45
|
+
/** A host block together with the key it was configured under. */
|
|
46
|
+
export type ResolvedHostConfig = HostConfig & {
|
|
47
|
+
readonly host: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Look up the configuration block for a host as git reports it.
|
|
51
|
+
*
|
|
52
|
+
* git sends `host=github.com` for the default port and `host=127.0.0.1:8080` otherwise, so
|
|
53
|
+
* the comparison is on the literal string, case-insensitively.
|
|
54
|
+
*
|
|
55
|
+
* @param config - a validated broker config.
|
|
56
|
+
* @param host - the `host` field from the credential request.
|
|
57
|
+
* @returns the matching block, or null (default deny).
|
|
58
|
+
*/
|
|
59
|
+
export declare function hostConfig(config: BrokerConfig, host: unknown): ResolvedHostConfig | null;
|
|
60
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAclE,kCAAkC;AAClC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CA2BlE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAUjE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAerE;AAED,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAOzF"}
|
package/lib/policy.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** One `owner` or `repo` segment: starts alphanumeric, then letters/digits/._- */
|
|
2
|
+
const SEGMENT_RE = /^[a-z0-9][a-z0-9._-]*$/;
|
|
3
|
+
/** A whole repository path as git would report it, before normalization. */
|
|
4
|
+
const REPO_PATH_RE = /^([A-Za-z0-9][A-Za-z0-9._-]*)\/([A-Za-z0-9._-]+)$/;
|
|
5
|
+
/** A segment that is nothing but dots — `.`, `..`, `...` — never a real repository name. */
|
|
6
|
+
const ALL_DOTS_RE = /^\.+$/;
|
|
7
|
+
/** The wildcard that may stand in for one whole segment. */
|
|
8
|
+
const WILDCARD = '*';
|
|
9
|
+
/**
|
|
10
|
+
* Normalize the `path=` value git hands to a credential helper into an `owner/repo` pair.
|
|
11
|
+
*
|
|
12
|
+
* @param rawPath - the raw `path` field, e.g. `acme/widget.git`.
|
|
13
|
+
* @returns the normalized reference, or null when the value is missing, has more than two
|
|
14
|
+
* segments, is made of dots, or contains characters we refuse to guess about.
|
|
15
|
+
*/
|
|
16
|
+
export function normalizeRepoPath(rawPath) {
|
|
17
|
+
if (typeof rawPath !== 'string')
|
|
18
|
+
return null;
|
|
19
|
+
let candidate = rawPath.trim();
|
|
20
|
+
if (!candidate)
|
|
21
|
+
return null;
|
|
22
|
+
const hash = candidate.indexOf('#');
|
|
23
|
+
if (hash >= 0)
|
|
24
|
+
candidate = candidate.slice(0, hash);
|
|
25
|
+
const query = candidate.indexOf('?');
|
|
26
|
+
if (query >= 0)
|
|
27
|
+
candidate = candidate.slice(0, query);
|
|
28
|
+
while (candidate.startsWith('/'))
|
|
29
|
+
candidate = candidate.slice(1);
|
|
30
|
+
while (candidate.endsWith('/'))
|
|
31
|
+
candidate = candidate.slice(0, -1);
|
|
32
|
+
if (candidate.toLowerCase().endsWith('.git'))
|
|
33
|
+
candidate = candidate.slice(0, -4);
|
|
34
|
+
if (!candidate)
|
|
35
|
+
return null;
|
|
36
|
+
const match = REPO_PATH_RE.exec(candidate);
|
|
37
|
+
if (!match)
|
|
38
|
+
return null;
|
|
39
|
+
const rawOwner = match[1];
|
|
40
|
+
const rawRepo = match[2];
|
|
41
|
+
if (rawOwner === undefined || rawRepo === undefined)
|
|
42
|
+
return null;
|
|
43
|
+
// `acme/..` satisfies the segment pattern above but is a traversal attempt, not a name.
|
|
44
|
+
if (ALL_DOTS_RE.test(rawOwner) || ALL_DOTS_RE.test(rawRepo))
|
|
45
|
+
return null;
|
|
46
|
+
const owner = rawOwner.toLowerCase();
|
|
47
|
+
const repo = rawRepo.toLowerCase();
|
|
48
|
+
return { owner, repo, full: `${owner}/${repo}` };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse one allowlist entry: exactly two segments, each either an identifier or a
|
|
52
|
+
* whole-segment wildcard.
|
|
53
|
+
*
|
|
54
|
+
* @param entry - the raw entry from configuration.
|
|
55
|
+
* @returns the parsed entry, or null when it is malformed (which matches nothing).
|
|
56
|
+
*/
|
|
57
|
+
export function parseAllowEntry(entry) {
|
|
58
|
+
if (typeof entry !== 'string')
|
|
59
|
+
return null;
|
|
60
|
+
const parts = entry.trim().toLowerCase().split('/');
|
|
61
|
+
if (parts.length !== 2)
|
|
62
|
+
return null;
|
|
63
|
+
const owner = parts[0];
|
|
64
|
+
const repo = parts[1];
|
|
65
|
+
if (owner === undefined || repo === undefined)
|
|
66
|
+
return null;
|
|
67
|
+
const valid = (segment) => segment === WILDCARD || SEGMENT_RE.test(segment);
|
|
68
|
+
if (!valid(owner) || !valid(repo))
|
|
69
|
+
return null;
|
|
70
|
+
return { owner, repo };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether a normalized repository is covered by an allowlist.
|
|
74
|
+
*
|
|
75
|
+
* @param allowList - configured allow entries.
|
|
76
|
+
* @param full - a normalized `owner/repo` string.
|
|
77
|
+
* @returns true only for an exact segment-wise match.
|
|
78
|
+
*/
|
|
79
|
+
export function repoAllowed(allowList, full) {
|
|
80
|
+
if (typeof full !== 'string' || !Array.isArray(allowList))
|
|
81
|
+
return false;
|
|
82
|
+
const slash = full.indexOf('/');
|
|
83
|
+
if (slash <= 0)
|
|
84
|
+
return false;
|
|
85
|
+
const owner = full.slice(0, slash);
|
|
86
|
+
const repo = full.slice(slash + 1);
|
|
87
|
+
for (const raw of allowList) {
|
|
88
|
+
const entry = parseAllowEntry(raw);
|
|
89
|
+
if (!entry)
|
|
90
|
+
continue;
|
|
91
|
+
const ownerMatches = entry.owner === WILDCARD || entry.owner === owner;
|
|
92
|
+
const repoMatches = entry.repo === WILDCARD || entry.repo === repo;
|
|
93
|
+
if (ownerMatches && repoMatches)
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Look up the configuration block for a host as git reports it.
|
|
100
|
+
*
|
|
101
|
+
* git sends `host=github.com` for the default port and `host=127.0.0.1:8080` otherwise, so
|
|
102
|
+
* the comparison is on the literal string, case-insensitively.
|
|
103
|
+
*
|
|
104
|
+
* @param config - a validated broker config.
|
|
105
|
+
* @param host - the `host` field from the credential request.
|
|
106
|
+
* @returns the matching block, or null (default deny).
|
|
107
|
+
*/
|
|
108
|
+
export function hostConfig(config, host) {
|
|
109
|
+
if (typeof host !== 'string' || !host)
|
|
110
|
+
return null;
|
|
111
|
+
const wanted = host.toLowerCase();
|
|
112
|
+
for (const [configuredHost, block] of Object.entries(config.hosts)) {
|
|
113
|
+
if (configuredHost.toLowerCase() === wanted)
|
|
114
|
+
return { host: configuredHost, ...block };
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAgBA,kFAAkF;AAClF,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAE5C,4EAA4E;AAC5E,MAAM,YAAY,GAAG,mDAAmD,CAAC;AAEzE,4FAA4F;AAC5F,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,4DAA4D;AAC5D,MAAM,QAAQ,GAAG,GAAG,CAAC;AAQrB;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC7C,IAAI,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAE5B,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,IAAI,IAAI,CAAC;QAAE,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,KAAK,IAAI,CAAC;QAAE,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAEtD,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjE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,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QACnE,IAAI,YAAY,IAAI,WAAW;YAAE,OAAO,IAAI,CAAC;IAC/C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAKD;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,MAAoB,EAAE,IAAa;IAC5D,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACnD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAClC,KAAK,MAAM,CAAC,cAAc,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACnE,IAAI,cAAc,CAAC,WAAW,EAAE,KAAK,MAAM;YAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,KAAK,EAAE,CAAC;IACzF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { FetchLike, GithubAppHostConfig, Provider } from 'gcb-core';
|
|
2
|
+
/** Options for {@link createGithubAppProvider}. */
|
|
3
|
+
export interface GithubAppProviderOptions {
|
|
4
|
+
/** The host this provider serves. */
|
|
5
|
+
readonly host: string;
|
|
6
|
+
readonly cfg: GithubAppHostConfig;
|
|
7
|
+
/** Re-mint a cached token this many seconds before it expires. */
|
|
8
|
+
readonly skewSeconds?: number;
|
|
9
|
+
/** Transport, injectable for tests. */
|
|
10
|
+
readonly fetchImpl?: FetchLike;
|
|
11
|
+
/** Clock, injectable for tests. */
|
|
12
|
+
readonly now?: () => number;
|
|
13
|
+
/** gh executable, injectable for tests. */
|
|
14
|
+
readonly ghPath?: string;
|
|
15
|
+
/** Host-side diagnostics. */
|
|
16
|
+
readonly log?: (message: string) => void;
|
|
17
|
+
}
|
|
18
|
+
/** Options for {@link signAppJwt}. */
|
|
19
|
+
export interface SignAppJwtOptions {
|
|
20
|
+
readonly privateKeyPem: string;
|
|
21
|
+
readonly iss: string | number;
|
|
22
|
+
readonly nowMs: number;
|
|
23
|
+
readonly lifetimeSeconds?: number;
|
|
24
|
+
readonly skewSeconds?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Base64url-encode a string or buffer, without padding, as JWS requires.
|
|
28
|
+
*
|
|
29
|
+
* @param input - the value to encode.
|
|
30
|
+
* @returns the base64url encoding.
|
|
31
|
+
*/
|
|
32
|
+
export declare function base64url(input: string | Buffer): string;
|
|
33
|
+
/**
|
|
34
|
+
* Sign a GitHub App JWT.
|
|
35
|
+
*
|
|
36
|
+
* @param options - signing options.
|
|
37
|
+
* @returns the compact JWS.
|
|
38
|
+
* @throws {Error} when required inputs are missing or the lifetime exceeds GitHub's limit.
|
|
39
|
+
*/
|
|
40
|
+
export declare function signAppJwt(options: SignAppJwtOptions): string;
|
|
41
|
+
/**
|
|
42
|
+
* Extract the `rel="next"` URL from a `Link` header.
|
|
43
|
+
*
|
|
44
|
+
* @param linkHeader - the raw header value.
|
|
45
|
+
* @returns the next page URL, or null when there is none.
|
|
46
|
+
*/
|
|
47
|
+
export declare function nextLink(linkHeader: string | null): string | null;
|
|
48
|
+
/**
|
|
49
|
+
* Build a GitHub App provider for one host.
|
|
50
|
+
*
|
|
51
|
+
* @param options - provider options.
|
|
52
|
+
* @returns the provider.
|
|
53
|
+
* @throws {Error} when the private key or app identity is missing (fail fast).
|
|
54
|
+
*/
|
|
55
|
+
export declare function createGithubAppProvider(options: GithubAppProviderOptions): Provider;
|
|
56
|
+
//# sourceMappingURL=github-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-app.d.ts","sourceRoot":"","sources":["../../src/providers/github-app.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAc,SAAS,EAAqB,mBAAmB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAmBxG,mDAA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