@kosha-ai/integration-github 0.0.6 → 0.2.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-github.d.ts","sourceRoot":"","sources":["../../src/lib/integration-github.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAQlE,MAAM,WAAW,wBAAwB;IACvC,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"integration-github.d.ts","sourceRoot":"","sources":["../../src/lib/integration-github.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAQlE,MAAM,WAAW,wBAAwB;IACvC,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAiBD,wBAAgB,MAAM,CACpB,OAAO,GAAE,wBAA6B,GACrC,gBAAgB,CA4DlB;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -3,6 +3,15 @@ import path from 'node:path';
|
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
5
5
|
const docsDirectory = path.join(currentDir, '../../docs');
|
|
6
|
+
/**
|
|
7
|
+
* The hosts a `git clone` talks to. github.com redirects pack fetches to
|
|
8
|
+
* codeload.github.com, which needs the same credential; a GitHub Enterprise
|
|
9
|
+
* Server instance serves both from its own host.
|
|
10
|
+
*/
|
|
11
|
+
function gitHosts(webBaseUrl) {
|
|
12
|
+
const host = new URL(webBaseUrl).hostname;
|
|
13
|
+
return host === 'github.com' ? [host, 'codeload.github.com'] : [host];
|
|
14
|
+
}
|
|
6
15
|
export function github(options = {}) {
|
|
7
16
|
const apiBaseUrl = options.baseUrl ?? 'https://api.github.com';
|
|
8
17
|
const webBaseUrl = options.webBaseUrl ?? 'https://github.com';
|
|
@@ -35,6 +44,20 @@ export function github(options = {}) {
|
|
|
35
44
|
Accept: 'application/vnd.github+json',
|
|
36
45
|
'X-GitHub-Api-Version': '2022-11-28',
|
|
37
46
|
}),
|
|
47
|
+
egress: [
|
|
48
|
+
{
|
|
49
|
+
hosts: gitHosts(webBaseUrl),
|
|
50
|
+
// Git's smart-HTTP transport wants Basic, not Bearer. GitHub ignores
|
|
51
|
+
// the username for a token credential but requires one, and
|
|
52
|
+
// `x-access-token` is the documented placeholder.
|
|
53
|
+
headers: ({ accessToken }) => ({
|
|
54
|
+
authorization: `Basic ${Buffer.from(`x-access-token:${accessToken}`).toString('base64')}`,
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
// No `headers`, so the REST API gets what `authHeaders` builds and a
|
|
58
|
+
// call from a sandbox looks identical to one through the proxy.
|
|
59
|
+
{ hosts: [new URL(apiBaseUrl).hostname] },
|
|
60
|
+
],
|
|
38
61
|
},
|
|
39
62
|
identity: {
|
|
40
63
|
async fetchAccount({ accessToken, http }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosha-ai/integration-github",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "GitHub integration for Kosha",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kosha",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"key": "github"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@kosha-ai/integration-sdk": "0.0
|
|
50
|
+
"@kosha-ai/integration-sdk": "0.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@kosha-ai/integration-sdk": "0.0
|
|
53
|
+
"@kosha-ai/integration-sdk": "0.2.0"
|
|
54
54
|
}
|
|
55
55
|
}
|