@framers/agentos-ext-github 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -11
- package/dist/__tests__/app.test.js +155 -1
- package/dist/__tests__/app.test.js.map +1 -1
- package/dist/__tests__/documents.test.js +28 -1
- package/dist/__tests__/documents.test.js.map +1 -1
- package/dist/__tests__/events.test.d.ts +8 -0
- package/dist/__tests__/events.test.d.ts.map +1 -0
- package/dist/__tests__/events.test.js +304 -0
- package/dist/__tests__/events.test.js.map +1 -0
- package/dist/app/events.d.ts +142 -0
- package/dist/app/events.d.ts.map +1 -0
- package/dist/app/events.js +182 -0
- package/dist/app/events.js.map +1 -0
- package/dist/app/http.d.ts +82 -13
- package/dist/app/http.d.ts.map +1 -1
- package/dist/app/http.js +151 -23
- package/dist/app/http.js.map +1 -1
- package/dist/app/installations.d.ts +8 -6
- package/dist/app/installations.d.ts.map +1 -1
- package/dist/app/installations.js +21 -15
- package/dist/app/installations.js.map +1 -1
- package/dist/app/reconcile.d.ts +1 -1
- package/dist/app/reconcile.d.ts.map +1 -1
- package/dist/app/reconcile.js +8 -7
- package/dist/app/reconcile.js.map +1 -1
- package/dist/app/userFlow.d.ts +10 -3
- package/dist/app/userFlow.d.ts.map +1 -1
- package/dist/app/userFlow.js +43 -4
- package/dist/app/userFlow.js.map +1 -1
- package/dist/documents/GitHubDocumentsConnector.d.ts +7 -4
- package/dist/documents/GitHubDocumentsConnector.d.ts.map +1 -1
- package/dist/documents/GitHubDocumentsConnector.js +39 -18
- package/dist/documents/GitHubDocumentsConnector.js.map +1 -1
- package/dist/documents/index.d.ts +11 -6
- package/dist/documents/index.d.ts.map +1 -1
- package/dist/documents/index.js +11 -6
- package/dist/documents/index.js.map +1 -1
- package/manifest.json +4 -2
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installations.d.ts","sourceRoot":"","sources":["../../src/app/installations.ts"],"names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AE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,oIAAoI;AACpI,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAMvD;AAUD,mGAAmG;AACnG,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAiB,EAAE,OAAyB,EAAE,SAAS,EAAE,GAAE,gBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,CAGxJ;AAED,sGAAsG;AACtG,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,MAAM,EACb,EAAE,SAAiB,EAAE,OAAyB,EAAE,SAAS,EAAE,GAAE,gBAAqB,GACjF,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAI/B;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,EACtB,EAAE,SAAiB,EAAE,OAAyB,EAAE,SAAS,EAAE,GAAE,gBAAqB,GACjF,OAAO,CAAC,cAAc,EAAE,CAAC,CAW3B;AAED,iGAAiG;AACjG,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,mBAAmB,EAC/B,EAAE,SAAiB,EAAE,OAAyB,EAAE,SAAS,EAAE,GAAE,gBAAqB,GACjF,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAI/B;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,mBAAmB,EAC/B,cAAc,EAAE,MAAM,EACtB,EAAE,SAAiB,EAAE,OAAyB,EAAE,SAAS,EAAE,GAAE,gBAAqB,GACjF,OAAO,CAAC,IAAI,CAAC,CAQf"}
|
|
@@ -1,35 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview What a user token reaches (the person, the app's installations they can access, and the repositories
|
|
3
3
|
* of an installation they can read) and the app's own installations, listed and removed with its JWT. Each function
|
|
4
|
-
* takes `{ fetchImpl, apiBase }` last: `fetch
|
|
4
|
+
* takes `{ fetchImpl, apiBase, timeoutMs }` last: `fetch`, GitHub's API and a 30-second deadline a call when absent.
|
|
5
5
|
* @module agentos-ext-github/app/installations
|
|
6
6
|
*/
|
|
7
7
|
import { arrayOf, discardBody, GITHUB_API_BASE, GitHubApiError, githubFetch, githubSend, numberIn, objectOf, pages, stringIn, } from './http.js';
|
|
8
|
+
/** An installation's account, as GitHub answers it and as a webhook event names it: a login, or an enterprise's slug, and an id. */
|
|
9
|
+
export function accountOf(value) {
|
|
10
|
+
const account = objectOf(value, "an installation's account");
|
|
11
|
+
return {
|
|
12
|
+
login: stringIn(account, typeof account.login === 'string' ? 'login' : 'slug', "an installation's account"),
|
|
13
|
+
id: numberIn(account, 'id', "an installation's account"),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
8
16
|
function installationOf(value) {
|
|
9
17
|
const fields = objectOf(value, 'an installation');
|
|
10
|
-
const account = fields.account === null || fields.account === undefined ? null : objectOf(fields.account, "an installation's account");
|
|
11
18
|
return {
|
|
12
19
|
id: numberIn(fields, 'id', 'an installation'),
|
|
13
|
-
account: account === null
|
|
14
|
-
? null
|
|
15
|
-
: { login: stringIn(account, typeof account.login === 'string' ? 'login' : 'slug', "an installation's account"), id: numberIn(account, 'id', "an installation's account") },
|
|
20
|
+
account: fields.account === null || fields.account === undefined ? null : accountOf(fields.account),
|
|
16
21
|
};
|
|
17
22
|
}
|
|
18
23
|
/** The person a user token belongs to (`GET /user`): the GitHub id and login a link is made by. */
|
|
19
|
-
export async function userOfToken(token, { fetchImpl = fetch, apiBase = GITHUB_API_BASE } = {}) {
|
|
20
|
-
const user = objectOf(await githubFetch(fetchImpl, `${apiBase}/user`, { token }), 'a user');
|
|
24
|
+
export async function userOfToken(token, { fetchImpl = fetch, apiBase = GITHUB_API_BASE, timeoutMs } = {}) {
|
|
25
|
+
const user = objectOf(await githubFetch(fetchImpl, `${apiBase}/user`, { token, timeoutMs }), 'a user');
|
|
21
26
|
return { id: numberIn(user, 'id', 'a user'), login: stringIn(user, 'login', 'a user') };
|
|
22
27
|
}
|
|
23
28
|
/** The app's installations a user token can access (`GET /user/installations`), across every page. */
|
|
24
|
-
export async function installationsOfUser(token, { fetchImpl = fetch, apiBase = GITHUB_API_BASE } = {}) {
|
|
25
|
-
return pages(fetchImpl, `${apiBase}/user/installations?per_page=100`, { token }, (page) => arrayOf(objectOf(page, 'a page of installations').installations, 'a page of installations').map(installationOf));
|
|
29
|
+
export async function installationsOfUser(token, { fetchImpl = fetch, apiBase = GITHUB_API_BASE, timeoutMs } = {}) {
|
|
30
|
+
return pages(fetchImpl, `${apiBase}/user/installations?per_page=100`, { token, timeoutMs }, (page) => arrayOf(objectOf(page, 'a page of installations').installations, 'a page of installations').map(installationOf));
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
28
33
|
* The repositories of an installation a user token can read (`GET /user/installations/{installation_id}/repositories`),
|
|
29
34
|
* across every page: those the person owns, collaborates on or reaches through an organization.
|
|
30
35
|
*/
|
|
31
|
-
export async function repositoriesOfUser(token, installationId, { fetchImpl = fetch, apiBase = GITHUB_API_BASE } = {}) {
|
|
32
|
-
return pages(fetchImpl, `${apiBase}/user/installations/${installationId}/repositories?per_page=100`, { token }, (page) => arrayOf(objectOf(page, 'a page of repositories').repositories, 'a page of repositories').map((value) => {
|
|
36
|
+
export async function repositoriesOfUser(token, installationId, { fetchImpl = fetch, apiBase = GITHUB_API_BASE, timeoutMs } = {}) {
|
|
37
|
+
return pages(fetchImpl, `${apiBase}/user/installations/${installationId}/repositories?per_page=100`, { token, timeoutMs }, (page) => arrayOf(objectOf(page, 'a page of repositories').repositories, 'a page of repositories').map((value) => {
|
|
33
38
|
const repository = objectOf(value, 'a repository');
|
|
34
39
|
return {
|
|
35
40
|
id: numberIn(repository, 'id', 'a repository'),
|
|
@@ -39,8 +44,8 @@ export async function repositoriesOfUser(token, installationId, { fetchImpl = fe
|
|
|
39
44
|
}));
|
|
40
45
|
}
|
|
41
46
|
/** Every installation of the app (`GET /app/installations`, with its JWT), across every page. */
|
|
42
|
-
export async function listInstallations(credential, { fetchImpl = fetch, apiBase = GITHUB_API_BASE } = {}) {
|
|
43
|
-
return pages(fetchImpl, `${apiBase}/app/installations?per_page=100`, { token: credential.jwt() }, (page) => arrayOf(page, 'a page of installations').map(installationOf));
|
|
47
|
+
export async function listInstallations(credential, { fetchImpl = fetch, apiBase = GITHUB_API_BASE, timeoutMs } = {}) {
|
|
48
|
+
return pages(fetchImpl, `${apiBase}/app/installations?per_page=100`, { token: credential.jwt(), timeoutMs }, (page) => arrayOf(page, 'a page of installations').map(installationOf));
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
46
51
|
* Uninstalls the app from an account (`DELETE /app/installations/{installation_id}`, with its JWT). Answers without an
|
|
@@ -48,9 +53,10 @@ export async function listInstallations(credential, { fetchImpl = fetch, apiBase
|
|
|
48
53
|
* answer of earlier versions) and on 404 (the installation is already gone); the answer's body is never read. Any
|
|
49
54
|
* other status throws {@link GitHubApiError}.
|
|
50
55
|
*/
|
|
51
|
-
export async function uninstallInstallation(credential, installationId, { fetchImpl = fetch, apiBase = GITHUB_API_BASE } = {}) {
|
|
56
|
+
export async function uninstallInstallation(credential, installationId, { fetchImpl = fetch, apiBase = GITHUB_API_BASE, timeoutMs } = {}) {
|
|
52
57
|
try {
|
|
53
|
-
|
|
58
|
+
const answer = await githubSend(fetchImpl, `${apiBase}/app/installations/${installationId}`, { token: credential.jwt(), method: 'DELETE', timeoutMs });
|
|
59
|
+
await discardBody(answer.response);
|
|
54
60
|
}
|
|
55
61
|
catch (error) {
|
|
56
62
|
if (error instanceof GitHubApiError && error.status === 404)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installations.js","sourceRoot":"","sources":["../../src/app/installations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,OAAO,EACP,WAAW,EACX,eAAe,EACf,cAAc,EACd,WAAW,EACX,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,QAAQ,GAET,MAA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interface ReconcileOutcome {
|
|
|
81
81
|
* @param links The links to check.
|
|
82
82
|
* @param options The window's start, and where calls go.
|
|
83
83
|
*/
|
|
84
|
-
export declare function reconcileInstallations(credential: GitHubAppCredential, links: readonly ReconcileLink[], { since, fetchImpl, apiBase }: ReconcileOptions): Promise<ReconcileOutcome>;
|
|
84
|
+
export declare function reconcileInstallations(credential: GitHubAppCredential, links: readonly ReconcileLink[], { since, fetchImpl, apiBase, timeoutMs }: ReconcileOptions): Promise<ReconcileOutcome>;
|
|
85
85
|
//# sourceMappingURL=reconcile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../src/app/reconcile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAWL,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;AAGnB,2GAA2G;AAC3G,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAC9C;AAED,+DAA+D;AAC/D,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,iFAAiF;IACjF,KAAK,EAAE,IAAI,CAAC;CACb;AAED,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,8HAA8H;AAC9H,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY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CAAC;CACb;AAED,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,8HAA8H;AAC9H,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,oEAAoE;IACpE,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,6EAA6E;IAC7E,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,kCAAkC;IAClC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,uDAAuD;IACvD,UAAU,EAAE,oBAAoB,EAAE,CAAC;IACnC,kFAAkF;IAClF,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAkFD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,mBAAmB,EAC/B,KAAK,EAAE,SAAS,aAAa,EAAE,EAC/B,EAAE,KAAK,EAAE,SAAiB,EAAE,OAAyB,EAAE,SAAS,EAAE,EAAE,gBAAgB,GACnF,OAAO,CAAC,gBAAgB,CAAC,CA2B3B"}
|
package/dist/app/reconcile.js
CHANGED
|
@@ -32,10 +32,10 @@ function refusedByRoute(attempt) {
|
|
|
32
32
|
* may lie on the pages not read; a redelivery GitHub refuses is answered with its status, and the others are still
|
|
33
33
|
* asked for.
|
|
34
34
|
*/
|
|
35
|
-
async function redeliverFailures(credential, since, fetchImpl, apiBase) {
|
|
35
|
+
async function redeliverFailures(credential, since, fetchImpl, apiBase, timeoutMs) {
|
|
36
36
|
const attemptsByGuid = new Map();
|
|
37
37
|
try {
|
|
38
|
-
for await (const page of githubPages(fetchImpl, `${apiBase}/app/hook/deliveries?per_page=100`, { token: credential.jwt() })) {
|
|
38
|
+
for await (const page of githubPages(fetchImpl, `${apiBase}/app/hook/deliveries?per_page=100`, { token: credential.jwt(), timeoutMs })) {
|
|
39
39
|
const deliveries = arrayOf(page, 'a page of deliveries').map(deliveryOf);
|
|
40
40
|
for (const delivery of deliveries) {
|
|
41
41
|
if (!(delivery.deliveredAt >= since))
|
|
@@ -64,7 +64,8 @@ async function redeliverFailures(credential, since, fetchImpl, apiBase) {
|
|
|
64
64
|
if (refusedByRoute(latest))
|
|
65
65
|
continue;
|
|
66
66
|
try {
|
|
67
|
-
|
|
67
|
+
const answer = await githubSend(fetchImpl, `${apiBase}/app/hook/deliveries/${latest.id}/attempts`, { token: credential.jwt(), method: 'POST', timeoutMs });
|
|
68
|
+
await discardBody(answer.response);
|
|
68
69
|
redelivered.push(latest.id);
|
|
69
70
|
}
|
|
70
71
|
catch (error) {
|
|
@@ -93,8 +94,8 @@ async function redeliverFailures(credential, since, fetchImpl, apiBase) {
|
|
|
93
94
|
* @param links The links to check.
|
|
94
95
|
* @param options The window's start, and where calls go.
|
|
95
96
|
*/
|
|
96
|
-
export async function reconcileInstallations(credential, links, { since, fetchImpl = fetch, apiBase = GITHUB_API_BASE }) {
|
|
97
|
-
const listed = new Set((await listInstallations(credential, { fetchImpl, apiBase })).map((installation) => installation.id));
|
|
97
|
+
export async function reconcileInstallations(credential, links, { since, fetchImpl = fetch, apiBase = GITHUB_API_BASE, timeoutMs }) {
|
|
98
|
+
const listed = new Set((await listInstallations(credential, { fetchImpl, apiBase, timeoutMs })).map((installation) => installation.id));
|
|
98
99
|
const gone = [];
|
|
99
100
|
const moved = [];
|
|
100
101
|
const unreadable = [];
|
|
@@ -107,7 +108,7 @@ export async function reconcileInstallations(credential, links, { since, fetchIm
|
|
|
107
108
|
for (const repository of link.repositories) {
|
|
108
109
|
try {
|
|
109
110
|
const token = await credential.installationToken(link.installationId, [repository.id]);
|
|
110
|
-
const branch = objectOf(await githubFetch(fetchImpl, `${apiBase}/repos/${repository.fullName}/branches/${encodeURIComponent(repository.defaultBranch)}`, { token }), 'a branch');
|
|
111
|
+
const branch = objectOf(await githubFetch(fetchImpl, `${apiBase}/repos/${repository.fullName}/branches/${encodeURIComponent(repository.defaultBranch)}`, { token, timeoutMs }), 'a branch');
|
|
111
112
|
const head = stringIn(objectOf(branch.commit, "a branch's commit"), 'sha', "a branch's commit");
|
|
112
113
|
if (head !== repository.headCommit)
|
|
113
114
|
moved.push({ installationId: link.installationId, repositoryId: repository.id, head });
|
|
@@ -119,7 +120,7 @@ export async function reconcileInstallations(credential, links, { since, fetchIm
|
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
|
-
const { redelivered, deliveries } = await redeliverFailures(credential, since.getTime(), fetchImpl, apiBase);
|
|
123
|
+
const { redelivered, deliveries } = await redeliverFailures(credential, since.getTime(), fetchImpl, apiBase, timeoutMs);
|
|
123
124
|
return { gone, moved, redelivered, unreadable, deliveries };
|
|
124
125
|
}
|
|
125
126
|
//# sourceMappingURL=reconcile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile.js","sourceRoot":"","sources":["../../src/app/reconcile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,OAAO,EACP,WAAW,EACX,eAAe,EACf,cAAc,EACd,WAAW,EACX,WAAW,EACX,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,GAET,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AA4EvD,sFAAsF;AACtF,MAAM,y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AAK,YAAY,cAAc,CAAC;oBAAE,MAAM,KAAK,CAAC;gBACpD,UAAU,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YAC9G,CAAC;QACH,CAAC;IACH,CAAC;IACD,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACxH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AAC9D,CAAC"}
|
package/dist/app/userFlow.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @fileoverview A GitHub App's user authorization on a web server: GitHub's authorize address with `state` and PKCE,
|
|
3
3
|
* and the code exchanged for a user access token, on the auth module's `RedirectOAuthFlow`. The token proves who the
|
|
4
4
|
* person is and which installations and repositories they can reach; it is used once and dropped, so the flow has no
|
|
5
|
-
* store.
|
|
5
|
+
* store. The exchange runs under a deadline, and its answer is read whole under a cap before the auth module reads it.
|
|
6
6
|
* @module agentos-ext-github/app/userFlow
|
|
7
7
|
*/
|
|
8
8
|
import { RedirectOAuthFlow, type RedirectBegin, type RedirectOAuthConfig } from '@framers/agentos/auth';
|
|
@@ -16,13 +16,19 @@ export interface GitHubOAuthEndpoints {
|
|
|
16
16
|
authorize: string;
|
|
17
17
|
token: string;
|
|
18
18
|
}
|
|
19
|
+
/** How the flow reaches GitHub's token address. */
|
|
20
|
+
export interface GitHubAppUserFlowOptions {
|
|
21
|
+
/** How long the code exchange may take, its answer included; {@link GITHUB_TIMEOUT_MS} when absent. */
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}
|
|
19
24
|
/** github.com's own authorize and token addresses. */
|
|
20
25
|
export declare const GITHUB_OAUTH_ENDPOINTS: GitHubOAuthEndpoints;
|
|
21
26
|
/**
|
|
22
27
|
* The user's web flow for a GitHub App: `begin` answers the authorize address with the state and the PKCE verifier
|
|
23
28
|
* for the caller to keep, and `complete` checks the state and exchanges the code (with `code_verifier`, asking for a
|
|
24
29
|
* JSON answer) for the user's token. A GitHub App's permissions are the app's, not the token's, so the address carries
|
|
25
|
-
* no `scope`.
|
|
30
|
+
* no `scope`. The exchange ends at its deadline with `GitHubNoAnswer`, and a redirect from the token address is
|
|
31
|
+
* refused with `OAuthGrantRefused` (reason `exchange`, the redirect's status), never followed.
|
|
26
32
|
*/
|
|
27
33
|
export declare class GitHubAppUserFlow extends RedirectOAuthFlow {
|
|
28
34
|
private readonly client;
|
|
@@ -33,8 +39,9 @@ export declare class GitHubAppUserFlow extends RedirectOAuthFlow {
|
|
|
33
39
|
* @param client The app's client id and client secret.
|
|
34
40
|
* @param fetchImpl The fetch the code is exchanged with.
|
|
35
41
|
* @param endpoints GitHub's authorize and token addresses.
|
|
42
|
+
* @param options The exchange's deadline.
|
|
36
43
|
*/
|
|
37
|
-
constructor(client: GitHubAppClient, fetchImpl?: typeof fetch, endpoints?: GitHubOAuthEndpoints);
|
|
44
|
+
constructor(client: GitHubAppClient, fetchImpl?: typeof fetch, endpoints?: GitHubOAuthEndpoints, options?: GitHubAppUserFlowOptions);
|
|
38
45
|
/** GitHub's addresses and the app's client, with no scopes. */
|
|
39
46
|
protected getConfig(): RedirectOAuthConfig;
|
|
40
47
|
/** The authorize address with the state and the PKCE challenge, leaving out the empty `scope` the base would send. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userFlow.d.ts","sourceRoot":"","sources":["../../src/app/userFlow.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"userFlow.d.ts","sourceRoot":"","sources":["../../src/app/userFlow.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGxG,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,mDAAmD;AACnD,MAAM,WAAW,wBAAwB;IACvC,uGAAuG;IACvG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,sDAAsD;AACtD,eAAO,MAAM,sBAAsB,EAAE,oBAGpC,CAAC;AAoCF;;;;;;GAMG;AACH,qBAAa,iBAAkB,SAAQ,iBAAiB;IAWpD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAZ5B,yBAAyB;IACzB,QAAQ,CAAC,UAAU,YAAY;IAE/B;;;;;OAKG;gBAEgB,MAAM,EAAE,eAAe,EACxC,SAAS,GAAE,OAAO,KAAa,EACd,SAAS,GAAE,oBAA6C,EACzE,OAAO,GAAE,wBAA6B;IAKxC,+DAA+D;IAC/D,SAAS,CAAC,SAAS,IAAI,mBAAmB;IAU1C,sHAAsH;IAC7G,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa;CAMhF"}
|
package/dist/app/userFlow.js
CHANGED
|
@@ -2,20 +2,58 @@
|
|
|
2
2
|
* @fileoverview A GitHub App's user authorization on a web server: GitHub's authorize address with `state` and PKCE,
|
|
3
3
|
* and the code exchanged for a user access token, on the auth module's `RedirectOAuthFlow`. The token proves who the
|
|
4
4
|
* person is and which installations and repositories they can reach; it is used once and dropped, so the flow has no
|
|
5
|
-
* store.
|
|
5
|
+
* store. The exchange runs under a deadline, and its answer is read whole under a cap before the auth module reads it.
|
|
6
6
|
* @module agentos-ext-github/app/userFlow
|
|
7
7
|
*/
|
|
8
|
+
import { readCapped, ReadCapExceeded } from '@framers/agentos-ext-account-sources';
|
|
8
9
|
import { RedirectOAuthFlow } from '@framers/agentos/auth';
|
|
10
|
+
import { callDeadline } from './http.js';
|
|
9
11
|
/** github.com's own authorize and token addresses. */
|
|
10
12
|
export const GITHUB_OAUTH_ENDPOINTS = {
|
|
11
13
|
authorize: 'https://github.com/login/oauth/authorize',
|
|
12
14
|
token: 'https://github.com/login/oauth/access_token',
|
|
13
15
|
};
|
|
16
|
+
/** The largest token answer read: 64 KiB, far above GitHub's few hundred bytes. */
|
|
17
|
+
const TOKEN_ANSWER_BYTES = 65_536;
|
|
18
|
+
/**
|
|
19
|
+
* A fetch that ends each call at its deadline and hands on the answer only once its whole body is read under
|
|
20
|
+
* {@link TOKEN_ANSWER_BYTES}, so the auth module never waits on GitHub past the deadline. A redirect is answered as
|
|
21
|
+
* it came and never followed: a 307 or 308 would send the code and the client secret on to its target, and the auth
|
|
22
|
+
* module refuses the redirect's status. A call that gets no answer, or whose body stops before its end, throws
|
|
23
|
+
* `GitHubNoAnswer`; a body past the cap throws an error that names the cap.
|
|
24
|
+
*/
|
|
25
|
+
function boundedFetch(fetchImpl, timeoutMs) {
|
|
26
|
+
return async (input, init) => {
|
|
27
|
+
const deadline = callDeadline(init?.signal ?? undefined, timeoutMs);
|
|
28
|
+
let response;
|
|
29
|
+
try {
|
|
30
|
+
response = await fetchImpl(input, { ...init, redirect: 'manual', signal: deadline.signal });
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw deadline.noAnswer();
|
|
34
|
+
}
|
|
35
|
+
let bytes;
|
|
36
|
+
try {
|
|
37
|
+
bytes = await readCapped(response, TOKEN_ANSWER_BYTES);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof ReadCapExceeded)
|
|
41
|
+
throw new Error('GitHub answered a body past the size cap');
|
|
42
|
+
throw deadline.noAnswer();
|
|
43
|
+
}
|
|
44
|
+
return new Response(bytes.byteLength === 0 ? null : new TextDecoder().decode(bytes), {
|
|
45
|
+
status: response.status,
|
|
46
|
+
statusText: response.statusText,
|
|
47
|
+
headers: response.headers,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}
|
|
14
51
|
/**
|
|
15
52
|
* The user's web flow for a GitHub App: `begin` answers the authorize address with the state and the PKCE verifier
|
|
16
53
|
* for the caller to keep, and `complete` checks the state and exchanges the code (with `code_verifier`, asking for a
|
|
17
54
|
* JSON answer) for the user's token. A GitHub App's permissions are the app's, not the token's, so the address carries
|
|
18
|
-
* no `scope`.
|
|
55
|
+
* no `scope`. The exchange ends at its deadline with `GitHubNoAnswer`, and a redirect from the token address is
|
|
56
|
+
* refused with `OAuthGrantRefused` (reason `exchange`, the redirect's status), never followed.
|
|
19
57
|
*/
|
|
20
58
|
export class GitHubAppUserFlow extends RedirectOAuthFlow {
|
|
21
59
|
client;
|
|
@@ -26,9 +64,10 @@ export class GitHubAppUserFlow extends RedirectOAuthFlow {
|
|
|
26
64
|
* @param client The app's client id and client secret.
|
|
27
65
|
* @param fetchImpl The fetch the code is exchanged with.
|
|
28
66
|
* @param endpoints GitHub's authorize and token addresses.
|
|
67
|
+
* @param options The exchange's deadline.
|
|
29
68
|
*/
|
|
30
|
-
constructor(client, fetchImpl = fetch, endpoints = GITHUB_OAUTH_ENDPOINTS) {
|
|
31
|
-
super(null, fetchImpl);
|
|
69
|
+
constructor(client, fetchImpl = fetch, endpoints = GITHUB_OAUTH_ENDPOINTS, options = {}) {
|
|
70
|
+
super(null, boundedFetch(fetchImpl, options.timeoutMs));
|
|
32
71
|
this.client = client;
|
|
33
72
|
this.endpoints = endpoints;
|
|
34
73
|
}
|
package/dist/app/userFlow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userFlow.js","sourceRoot":"","sources":["../../src/app/userFlow.ts"],"names":[],"mappings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AI,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE;YAAE,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACnF,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -62,16 +62,19 @@ export declare class GitHubDocumentsConnector implements AccountSourceConnector
|
|
|
62
62
|
gone: SourceGone[];
|
|
63
63
|
}>;
|
|
64
64
|
/**
|
|
65
|
-
* A file's raw bytes at the commit of its version, read as a stream
|
|
66
|
-
* as bytes with their media type, the rest as UTF-8 text, each with a `github`
|
|
67
|
-
* commit. A file GitHub no longer has, or one past the cap, is answered
|
|
65
|
+
* A file's raw bytes at the commit of its version, read as a stream under the call's deadline and cut at
|
|
66
|
+
* `maxFileBytes`: PDF, Word and HTML as bytes with their media type, the rest as UTF-8 text, each with a `github`
|
|
67
|
+
* attribution linking the file at that commit. A file GitHub no longer has (404), or one past the cap, is answered
|
|
68
|
+
* gone with reason `removed`; any other refusal throws `GitHubApiError`, a rate limit with its `retryAt`, so a read
|
|
69
|
+
* GitHub held back is never taken for a file gone.
|
|
68
70
|
*/
|
|
69
71
|
read(item: SourceItem, signal?: AbortSignal): Promise<SourceRead | SourceGone>;
|
|
70
72
|
/**
|
|
71
73
|
* What a push to `after` changed, from the listing at `after` (read here when the caller holds none) against the
|
|
72
74
|
* blobs read before (`cursor`: the JSON of each path's blob). A push's own commit lists are never read, so a force
|
|
73
75
|
* push, or a push of more commits than its event lists, is read like any other. A push to another branch than the
|
|
74
|
-
* default answers no change and the cursor it was given.
|
|
76
|
+
* default answers no change and the cursor it was given. A cursor this connector did not answer throws a
|
|
77
|
+
* `TypeError` before any request.
|
|
75
78
|
*/
|
|
76
79
|
changesSince(cursor: string | null, selection: GitHubChangesSelection, signal?: AbortSignal): Promise<SourceChanges>;
|
|
77
80
|
/** Nothing to end here: an installation is removed by the app's own call (`uninstallInstallation`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubDocumentsConnector.d.ts","sourceRoot":"","sources":["../../src/documents/GitHubDocumentsConnector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"GitHubDocumentsConnector.d.ts","sourceRoot":"","sources":["../../src/documents/GitHubDocumentsConnector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EAEf,KAAK,eAAe,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAA8E,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvI,gCAAgC;AAChC,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC7D,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4GAA4G;IAC5G,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,OAAO,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC/B;AAkCD;;;;GAIG;AACH,qBAAa,wBAAyB,YAAW,sBAAsB;IAYnE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAhB1B,QAAQ,CAAC,IAAI,YAAY;IAEzB;;;;;;;OAOG;gBAEgB,UAAU,EAAE,mBAAmB,EAC/B,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,SAAS,gBAAgB,EAAE,EACzC,MAAM,GAAE,UAAe,EACvB,SAAS,GAAE,OAAO,KAAa,EAC/B,OAAO,SAAkB;IAG5C,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,KAAK;IAIb,wDAAwD;IAClD,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAOvE;;;OAGG;IACG,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAS9F,oGAAoG;IAC9F,IAAI,CAAC,SAAS,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,UAAU,EAAE,CAAC;QAAC,IAAI,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IAWlH;;;;;;OAMG;IACG,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;IAgCpF;;;;;;OAMG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAiB1H,uGAAuG;IACjG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* raw bytes under a cap, and a push compared by the tree at its `after` commit.
|
|
5
5
|
* @module agentos-ext-github/documents/GitHubDocumentsConnector
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { ReadCapExceeded, } from '@framers/agentos-ext-account-sources';
|
|
8
|
+
import { GITHUB_API_BASE, GitHubApiError, githubFetch, githubSend, objectOf, stringIn } from '../app/http.js';
|
|
9
9
|
import { DEFAULT_MAX_FILE_BYTES, extensionOf, pathFilter, readTree, SKIPPED_FOLDERS } from './tree.js';
|
|
10
10
|
/** The files answered as bytes with their media type; every other kept file is answered as text. */
|
|
11
11
|
const MEDIA_TYPES = {
|
|
@@ -18,6 +18,26 @@ const MEDIA_TYPES = {
|
|
|
18
18
|
function encodedPath(path) {
|
|
19
19
|
return path.split('/').map(encodeURIComponent).join('/');
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* The blobs a cursor holds by path. A cursor this connector did not answer (not the JSON of an object of path to
|
|
23
|
+
* blob) throws a `TypeError` that quotes none of it, since a cursor's text is a repository's paths.
|
|
24
|
+
*/
|
|
25
|
+
function blobsOf(cursor) {
|
|
26
|
+
if (cursor === null)
|
|
27
|
+
return new Map();
|
|
28
|
+
let parsed;
|
|
29
|
+
try {
|
|
30
|
+
parsed = JSON.parse(cursor);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// The parser's message would quote the cursor.
|
|
34
|
+
parsed = undefined;
|
|
35
|
+
}
|
|
36
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed) || Object.values(parsed).some((blob) => typeof blob !== 'string')) {
|
|
37
|
+
throw new TypeError('the cursor is not one this connector answered');
|
|
38
|
+
}
|
|
39
|
+
return new Map(Object.entries(parsed));
|
|
40
|
+
}
|
|
21
41
|
/**
|
|
22
42
|
* A repository's documentation as account sources: an item's id is `<repositoryId>:<path>`, its version
|
|
23
43
|
* `<blob>@<commit>`, and the cursor of `changesSince` the JSON of each documentation path's blob at the commit last
|
|
@@ -87,30 +107,30 @@ export class GitHubDocumentsConnector {
|
|
|
87
107
|
return { items, gone: [] };
|
|
88
108
|
}
|
|
89
109
|
/**
|
|
90
|
-
* A file's raw bytes at the commit of its version, read as a stream
|
|
91
|
-
* as bytes with their media type, the rest as UTF-8 text, each with a `github`
|
|
92
|
-
* commit. A file GitHub no longer has, or one past the cap, is answered
|
|
110
|
+
* A file's raw bytes at the commit of its version, read as a stream under the call's deadline and cut at
|
|
111
|
+
* `maxFileBytes`: PDF, Word and HTML as bytes with their media type, the rest as UTF-8 text, each with a `github`
|
|
112
|
+
* attribution linking the file at that commit. A file GitHub no longer has (404), or one past the cap, is answered
|
|
113
|
+
* gone with reason `removed`; any other refusal throws `GitHubApiError`, a rate limit with its `retryAt`, so a read
|
|
114
|
+
* GitHub held back is never taken for a file gone.
|
|
93
115
|
*/
|
|
94
116
|
async read(item, signal) {
|
|
95
117
|
const [repositoryId, ...rest] = item.id.split(':');
|
|
96
118
|
const path = rest.join(':');
|
|
97
119
|
const repository = this.repository(Number(repositoryId));
|
|
98
120
|
const commit = (item.version ?? '').split('@')[1] ?? repository.defaultBranch;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (response.status === 404) {
|
|
104
|
-
await discardBody(response);
|
|
105
|
-
return { id: item.id, reason: 'removed' };
|
|
121
|
+
const url = `${this.apiBase}/repos/${repository.fullName}/contents/${encodedPath(path)}?ref=${encodeURIComponent(commit)}`;
|
|
122
|
+
let answer;
|
|
123
|
+
try {
|
|
124
|
+
answer = await githubSend(this.fetchImpl, url, { token: await this.token(repository.id), accept: 'application/vnd.github.raw+json', signal });
|
|
106
125
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (error instanceof GitHubApiError && error.status === 404)
|
|
128
|
+
return { id: item.id, reason: 'removed' };
|
|
129
|
+
throw error;
|
|
110
130
|
}
|
|
111
131
|
let bytes;
|
|
112
132
|
try {
|
|
113
|
-
bytes = await
|
|
133
|
+
bytes = await answer.bytes(this.filter.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES);
|
|
114
134
|
}
|
|
115
135
|
catch (error) {
|
|
116
136
|
if (error instanceof ReadCapExceeded)
|
|
@@ -132,7 +152,8 @@ export class GitHubDocumentsConnector {
|
|
|
132
152
|
* What a push to `after` changed, from the listing at `after` (read here when the caller holds none) against the
|
|
133
153
|
* blobs read before (`cursor`: the JSON of each path's blob). A push's own commit lists are never read, so a force
|
|
134
154
|
* push, or a push of more commits than its event lists, is read like any other. A push to another branch than the
|
|
135
|
-
* default answers no change and the cursor it was given.
|
|
155
|
+
* default answers no change and the cursor it was given. A cursor this connector did not answer throws a
|
|
156
|
+
* `TypeError` before any request.
|
|
136
157
|
*/
|
|
137
158
|
async changesSince(cursor, selection, signal) {
|
|
138
159
|
const id = Number(selection.ids[0]);
|
|
@@ -140,7 +161,7 @@ export class GitHubDocumentsConnector {
|
|
|
140
161
|
if (selection.ref !== undefined && selection.ref !== `refs/heads/${repository.defaultBranch}`) {
|
|
141
162
|
return { changed: [], gone: [], cursor: cursor ?? '{}' };
|
|
142
163
|
}
|
|
143
|
-
const before =
|
|
164
|
+
const before = blobsOf(cursor);
|
|
144
165
|
const after = selection.after ?? (await this.head(id, signal));
|
|
145
166
|
const blobs = selection.listing ?? (await this.listing(id, after, signal));
|
|
146
167
|
const now = new Map(blobs.map((blob) => [blob.path, blob.sha]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubDocumentsConnector.js","sourceRoot":"","sources":["../../src/documents/GitHubDocumentsConnector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"GitHubDocumentsConnector.js","sourceRoot":"","sources":["../../src/documents/GitHubDocumentsConnector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,eAAe,GAQhB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAqB,MAAM,gBAAgB,CAAC;AACjI,OAAO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EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE,MAAM,EAAE,SAAkB,EAAE,CAAC,CAAC,CAAC;QACtI,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IAC5E,CAAC;IAED,uGAAuG;IACvG,KAAK,CAAC,MAAM;QACV,8FAA8F;IAChG,CAAC;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview The `./documents` entry: a GitHub App's installation mode (its JWT and installation tokens, the user's
|
|
3
|
-
* web flow, what a user token reaches, the webhook signature
|
|
4
|
-
* `GitHubDocumentsConnector`, a repository's documentation as an account source. Every
|
|
5
|
-
* over an injected `fetch
|
|
3
|
+
* web flow, what a user token reaches, the webhook signature and its deliveries read as typed events, the daily
|
|
4
|
+
* reconcile, the uninstall) and `GitHubDocumentsConnector`, a repository's documentation as an account source. Every
|
|
5
|
+
* call goes to GitHub's REST API over an injected `fetch`, under a deadline, its answer read under a cap.
|
|
6
6
|
* @module agentos-ext-github/documents
|
|
7
7
|
*/
|
|
8
8
|
/** The documentation connector and the shape of a push it compares. */
|
|
@@ -12,13 +12,18 @@ export { readTree, pathFilter, extensionOf, TreeTooLarge, DOCUMENT_EXTENSIONS, S
|
|
|
12
12
|
/** The app's JWT and installation tokens. */
|
|
13
13
|
export { appJwt, GitHubAppCredential, type GitHubAppIdentity } from '../app/credential.js';
|
|
14
14
|
/** The user's web flow on the auth module's redirect flow. */
|
|
15
|
-
export { GitHubAppUserFlow, GITHUB_OAUTH_ENDPOINTS, type GitHubAppClient, type GitHubOAuthEndpoints } from '../app/userFlow.js';
|
|
15
|
+
export { GitHubAppUserFlow, GITHUB_OAUTH_ENDPOINTS, type GitHubAppClient, type GitHubAppUserFlowOptions, type GitHubOAuthEndpoints, } from '../app/userFlow.js';
|
|
16
16
|
/** What a user token reaches, and the app's own installations. */
|
|
17
17
|
export { userOfToken, installationsOfUser, repositoriesOfUser, listInstallations, uninstallInstallation, type GitHubAccount, type GitHubInstallation, type GitHubUser, type UserRepository, } from '../app/installations.js';
|
|
18
18
|
/** A webhook delivery's signature. */
|
|
19
19
|
export { verifyWebhookSignature } from '../app/webhook.js';
|
|
20
|
+
/** A webhook delivery read as a typed event once its signature holds. */
|
|
21
|
+
export { readWebhookDelivery, readWebhookRequest, WebhookDeliveryRefused, DEFAULT_MAX_DELIVERY_BYTES, type GitHubDelivery, type GitHubEvent, type GitHubEventRepository, type GitHubInstallationEvent, type GitHubInstallationRepositoriesEvent, type GitHubInstallationTargetEvent, type GitHubOtherEvent, type GitHubPingEvent, type GitHubPushEvent, type ReadWebhookOptions, type WebhookDeliveryInput, type WebhookRefusalReason, type WebhookRequestInput, } from '../app/events.js';
|
|
20
22
|
/** The daily reconcile. */
|
|
21
23
|
export { reconcileInstallations, type DeliveriesOutcome, type MovedRepository, type ReconcileLink, type ReconcileOptions, type ReconcileOutcome, type ReconcileRepository, type RefusedRedelivery, type UnreadableRepository, } from '../app/reconcile.js';
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The API version every call pins, GitHub's address, a call's deadline and an answer's cap, the error of an answer
|
|
26
|
+
* outside 2xx with its rate limit timing, and the error of a call that got no answer.
|
|
27
|
+
*/
|
|
28
|
+
export { GITHUB_API_BASE, GITHUB_API_VERSION, GITHUB_MAX_ANSWER_BYTES, GITHUB_TIMEOUT_MS, GitHubApiError, GitHubNoAnswer, type GitHubApiOptions, type GitHubNoAnswerReason, type GitHubRefusalTiming, } from '../app/http.js';
|
|
24
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uEAAuE;AACvE,OAAO,EAAE,wBAAwB,EAAE,KA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,KAAK,cAAc,GACpB,MAAM,yBAAyB,CAAC;AACjC,sCAAsC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,yEAAyE;AACzE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,mCAAmC,EACxC,KAAK,6BAA6B,EAClC,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,2BAA2B;AAC3B,OAAO,EACL,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B;;;GAGG;AACH,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC"}
|
package/dist/documents/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview The `./documents` entry: a GitHub App's installation mode (its JWT and installation tokens, the user's
|
|
3
|
-
* web flow, what a user token reaches, the webhook signature
|
|
4
|
-
* `GitHubDocumentsConnector`, a repository's documentation as an account source. Every
|
|
5
|
-
* over an injected `fetch
|
|
3
|
+
* web flow, what a user token reaches, the webhook signature and its deliveries read as typed events, the daily
|
|
4
|
+
* reconcile, the uninstall) and `GitHubDocumentsConnector`, a repository's documentation as an account source. Every
|
|
5
|
+
* call goes to GitHub's REST API over an injected `fetch`, under a deadline, its answer read under a cap.
|
|
6
6
|
* @module agentos-ext-github/documents
|
|
7
7
|
*/
|
|
8
8
|
/** The documentation connector and the shape of a push it compares. */
|
|
@@ -12,13 +12,18 @@ export { readTree, pathFilter, extensionOf, TreeTooLarge, DOCUMENT_EXTENSIONS, S
|
|
|
12
12
|
/** The app's JWT and installation tokens. */
|
|
13
13
|
export { appJwt, GitHubAppCredential } from '../app/credential.js';
|
|
14
14
|
/** The user's web flow on the auth module's redirect flow. */
|
|
15
|
-
export { GitHubAppUserFlow, GITHUB_OAUTH_ENDPOINTS } from '../app/userFlow.js';
|
|
15
|
+
export { GitHubAppUserFlow, GITHUB_OAUTH_ENDPOINTS, } from '../app/userFlow.js';
|
|
16
16
|
/** What a user token reaches, and the app's own installations. */
|
|
17
17
|
export { userOfToken, installationsOfUser, repositoriesOfUser, listInstallations, uninstallInstallation, } from '../app/installations.js';
|
|
18
18
|
/** A webhook delivery's signature. */
|
|
19
19
|
export { verifyWebhookSignature } from '../app/webhook.js';
|
|
20
|
+
/** A webhook delivery read as a typed event once its signature holds. */
|
|
21
|
+
export { readWebhookDelivery, readWebhookRequest, WebhookDeliveryRefused, DEFAULT_MAX_DELIVERY_BYTES, } from '../app/events.js';
|
|
20
22
|
/** The daily reconcile. */
|
|
21
23
|
export { reconcileInstallations, } from '../app/reconcile.js';
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The API version every call pins, GitHub's address, a call's deadline and an answer's cap, the error of an answer
|
|
26
|
+
* outside 2xx with its rate limit timing, and the error of a call that got no answer.
|
|
27
|
+
*/
|
|
28
|
+
export { GITHUB_API_BASE, GITHUB_API_VERSION, GITHUB_MAX_ANSWER_BYTES, GITHUB_TIMEOUT_MS, GitHubApiError, GitHubNoAnswer, } from '../app/http.js';
|
|
24
29
|
//# sourceMappingURL=index.js.map
|