David Thomas
commited on
Commit
·
77731d1
1
Parent(s):
da0425a
updated UI
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- app.py +1 -1
- node_modules/.package-lock.json +135 -0
- node_modules/@octokit/auth-token/LICENSE +21 -0
- node_modules/@octokit/auth-token/README.md +285 -0
- node_modules/@octokit/auth-token/dist-node/index.js +79 -0
- node_modules/@octokit/auth-token/dist-node/index.js.map +7 -0
- node_modules/@octokit/auth-token/dist-src/auth.js +17 -0
- node_modules/@octokit/auth-token/dist-src/hook.js +12 -0
- node_modules/@octokit/auth-token/dist-src/index.js +19 -0
- node_modules/@octokit/auth-token/dist-src/with-authorization-prefix.js +9 -0
- node_modules/@octokit/auth-token/dist-types/auth.d.ts +2 -0
- node_modules/@octokit/auth-token/dist-types/hook.d.ts +2 -0
- node_modules/@octokit/auth-token/dist-types/index.d.ts +7 -0
- node_modules/@octokit/auth-token/dist-types/types.d.ts +33 -0
- node_modules/@octokit/auth-token/dist-types/with-authorization-prefix.d.ts +6 -0
- node_modules/@octokit/auth-token/dist-web/index.js +52 -0
- node_modules/@octokit/auth-token/dist-web/index.js.map +7 -0
- node_modules/@octokit/auth-token/package.json +44 -0
- node_modules/@octokit/core/LICENSE +21 -0
- node_modules/@octokit/core/README.md +448 -0
- node_modules/@octokit/core/dist-node/index.js +163 -0
- node_modules/@octokit/core/dist-node/index.js.map +7 -0
- node_modules/@octokit/core/dist-src/index.js +133 -0
- node_modules/@octokit/core/dist-src/version.js +4 -0
- node_modules/@octokit/core/dist-types/index.d.ts +30 -0
- node_modules/@octokit/core/dist-types/types.d.ts +44 -0
- node_modules/@octokit/core/dist-types/version.d.ts +1 -0
- node_modules/@octokit/core/dist-web/index.js +138 -0
- node_modules/@octokit/core/dist-web/index.js.map +7 -0
- node_modules/@octokit/core/package.json +62 -0
- node_modules/@octokit/endpoint/LICENSE +21 -0
- node_modules/@octokit/endpoint/README.md +410 -0
- node_modules/@octokit/endpoint/dist-node/index.js +358 -0
- node_modules/@octokit/endpoint/dist-node/index.js.map +7 -0
- node_modules/@octokit/endpoint/dist-src/defaults.js +17 -0
- node_modules/@octokit/endpoint/dist-src/endpoint-with-defaults.js +9 -0
- node_modules/@octokit/endpoint/dist-src/index.js +6 -0
- node_modules/@octokit/endpoint/dist-src/merge.js +27 -0
- node_modules/@octokit/endpoint/dist-src/parse.js +70 -0
- node_modules/@octokit/endpoint/dist-src/util/add-query-parameters.js +16 -0
- node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js +14 -0
- node_modules/@octokit/endpoint/dist-src/util/lowercase-keys.js +12 -0
- node_modules/@octokit/endpoint/dist-src/util/merge-deep.js +18 -0
- node_modules/@octokit/endpoint/dist-src/util/omit.js +9 -0
- node_modules/@octokit/endpoint/dist-src/util/remove-undefined-properties.js +11 -0
- node_modules/@octokit/endpoint/dist-src/util/url-template.js +128 -0
- node_modules/@octokit/endpoint/dist-src/version.js +4 -0
- node_modules/@octokit/endpoint/dist-src/with-defaults.js +16 -0
- node_modules/@octokit/endpoint/dist-types/defaults.d.ts +2 -0
- node_modules/@octokit/endpoint/dist-types/endpoint-with-defaults.d.ts +3 -0
app.py
CHANGED
@@ -1567,7 +1567,7 @@ with gr.Blocks(title='RVC First Rule v1', theme=theme) as app:
|
|
1567 |
)
|
1568 |
with gr.Tabs():
|
1569 |
with gr.TabItem("Inference"):
|
1570 |
-
gr.HTML("<h1> First Rule --
|
1571 |
gr.HTML("""<h3> A few notes on the flow of the vocal cloning features:
|
1572 |
First, an audio clip needs to be either recorded or uploaded. These should
|
1573 |
be vocals only, preferable under 30 seconds in length. Longer clips
|
|
|
1567 |
)
|
1568 |
with gr.Tabs():
|
1569 |
with gr.TabItem("Inference"):
|
1570 |
+
gr.HTML("<h1> First Rule -- Humanity First </h1>")
|
1571 |
gr.HTML("""<h3> A few notes on the flow of the vocal cloning features:
|
1572 |
First, an audio clip needs to be either recorded or uploaded. These should
|
1573 |
be vocals only, preferable under 30 seconds in length. Longer clips
|
node_modules/.package-lock.json
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "RVC_RULE1",
|
3 |
+
"lockfileVersion": 2,
|
4 |
+
"requires": true,
|
5 |
+
"packages": {
|
6 |
+
"node_modules/@octokit/auth-token": {
|
7 |
+
"version": "4.0.0",
|
8 |
+
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz",
|
9 |
+
"integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==",
|
10 |
+
"engines": {
|
11 |
+
"node": ">= 18"
|
12 |
+
}
|
13 |
+
},
|
14 |
+
"node_modules/@octokit/core": {
|
15 |
+
"version": "5.0.1",
|
16 |
+
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz",
|
17 |
+
"integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==",
|
18 |
+
"dependencies": {
|
19 |
+
"@octokit/auth-token": "^4.0.0",
|
20 |
+
"@octokit/graphql": "^7.0.0",
|
21 |
+
"@octokit/request": "^8.0.2",
|
22 |
+
"@octokit/request-error": "^5.0.0",
|
23 |
+
"@octokit/types": "^12.0.0",
|
24 |
+
"before-after-hook": "^2.2.0",
|
25 |
+
"universal-user-agent": "^6.0.0"
|
26 |
+
},
|
27 |
+
"engines": {
|
28 |
+
"node": ">= 18"
|
29 |
+
}
|
30 |
+
},
|
31 |
+
"node_modules/@octokit/endpoint": {
|
32 |
+
"version": "9.0.1",
|
33 |
+
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.1.tgz",
|
34 |
+
"integrity": "sha512-hRlOKAovtINHQPYHZlfyFwaM8OyetxeoC81lAkBy34uLb8exrZB50SQdeW3EROqiY9G9yxQTpp5OHTV54QD+vA==",
|
35 |
+
"dependencies": {
|
36 |
+
"@octokit/types": "^12.0.0",
|
37 |
+
"is-plain-object": "^5.0.0",
|
38 |
+
"universal-user-agent": "^6.0.0"
|
39 |
+
},
|
40 |
+
"engines": {
|
41 |
+
"node": ">= 18"
|
42 |
+
}
|
43 |
+
},
|
44 |
+
"node_modules/@octokit/graphql": {
|
45 |
+
"version": "7.0.2",
|
46 |
+
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz",
|
47 |
+
"integrity": "sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==",
|
48 |
+
"dependencies": {
|
49 |
+
"@octokit/request": "^8.0.1",
|
50 |
+
"@octokit/types": "^12.0.0",
|
51 |
+
"universal-user-agent": "^6.0.0"
|
52 |
+
},
|
53 |
+
"engines": {
|
54 |
+
"node": ">= 18"
|
55 |
+
}
|
56 |
+
},
|
57 |
+
"node_modules/@octokit/openapi-types": {
|
58 |
+
"version": "19.0.0",
|
59 |
+
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-19.0.0.tgz",
|
60 |
+
"integrity": "sha512-PclQ6JGMTE9iUStpzMkwLCISFn/wDeRjkZFIKALpvJQNBGwDoYYi2fFvuHwssoQ1rXI5mfh6jgTgWuddeUzfWw=="
|
61 |
+
},
|
62 |
+
"node_modules/@octokit/request": {
|
63 |
+
"version": "8.1.4",
|
64 |
+
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.1.4.tgz",
|
65 |
+
"integrity": "sha512-M0aaFfpGPEKrg7XoA/gwgRvc9MSXHRO2Ioki1qrPDbl1e9YhjIwVoHE7HIKmv/m3idzldj//xBujcFNqGX6ENA==",
|
66 |
+
"dependencies": {
|
67 |
+
"@octokit/endpoint": "^9.0.0",
|
68 |
+
"@octokit/request-error": "^5.0.0",
|
69 |
+
"@octokit/types": "^12.0.0",
|
70 |
+
"is-plain-object": "^5.0.0",
|
71 |
+
"universal-user-agent": "^6.0.0"
|
72 |
+
},
|
73 |
+
"engines": {
|
74 |
+
"node": ">= 18"
|
75 |
+
}
|
76 |
+
},
|
77 |
+
"node_modules/@octokit/request-error": {
|
78 |
+
"version": "5.0.1",
|
79 |
+
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz",
|
80 |
+
"integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==",
|
81 |
+
"dependencies": {
|
82 |
+
"@octokit/types": "^12.0.0",
|
83 |
+
"deprecation": "^2.0.0",
|
84 |
+
"once": "^1.4.0"
|
85 |
+
},
|
86 |
+
"engines": {
|
87 |
+
"node": ">= 18"
|
88 |
+
}
|
89 |
+
},
|
90 |
+
"node_modules/@octokit/types": {
|
91 |
+
"version": "12.0.0",
|
92 |
+
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.0.0.tgz",
|
93 |
+
"integrity": "sha512-EzD434aHTFifGudYAygnFlS1Tl6KhbTynEWELQXIbTY8Msvb5nEqTZIm7sbPEt4mQYLZwu3zPKVdeIrw0g7ovg==",
|
94 |
+
"dependencies": {
|
95 |
+
"@octokit/openapi-types": "^19.0.0"
|
96 |
+
}
|
97 |
+
},
|
98 |
+
"node_modules/before-after-hook": {
|
99 |
+
"version": "2.2.3",
|
100 |
+
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz",
|
101 |
+
"integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="
|
102 |
+
},
|
103 |
+
"node_modules/deprecation": {
|
104 |
+
"version": "2.3.1",
|
105 |
+
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
|
106 |
+
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="
|
107 |
+
},
|
108 |
+
"node_modules/is-plain-object": {
|
109 |
+
"version": "5.0.0",
|
110 |
+
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
111 |
+
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
|
112 |
+
"engines": {
|
113 |
+
"node": ">=0.10.0"
|
114 |
+
}
|
115 |
+
},
|
116 |
+
"node_modules/once": {
|
117 |
+
"version": "1.4.0",
|
118 |
+
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
119 |
+
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
120 |
+
"dependencies": {
|
121 |
+
"wrappy": "1"
|
122 |
+
}
|
123 |
+
},
|
124 |
+
"node_modules/universal-user-agent": {
|
125 |
+
"version": "6.0.0",
|
126 |
+
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
127 |
+
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
|
128 |
+
},
|
129 |
+
"node_modules/wrappy": {
|
130 |
+
"version": "1.0.2",
|
131 |
+
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
132 |
+
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
node_modules/@octokit/auth-token/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2019 Octokit contributors
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in
|
13 |
+
all copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
THE SOFTWARE.
|
node_modules/@octokit/auth-token/README.md
ADDED
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# auth-token.js
|
2 |
+
|
3 |
+
> GitHub API token authentication for browsers and Node.js
|
4 |
+
|
5 |
+
[](https://www.npmjs.com/package/@octokit/auth-token)
|
6 |
+
[](https://github.com/octokit/auth-token.js/actions?query=workflow%3ATest)
|
7 |
+
|
8 |
+
`@octokit/auth-token` is the simplest of [GitHub’s authentication strategies](https://github.com/octokit/auth.js).
|
9 |
+
|
10 |
+
It is useful if you want to support multiple authentication strategies, as it’s API is compatible with its sibling packages for [basic](https://github.com/octokit/auth-basic.js), [GitHub App](https://github.com/octokit/auth-app.js) and [OAuth app](https://github.com/octokit/auth.js) authentication.
|
11 |
+
|
12 |
+
<!-- toc -->
|
13 |
+
|
14 |
+
- [Usage](#usage)
|
15 |
+
- [`createTokenAuth(token) options`](#createtokenauthtoken-options)
|
16 |
+
- [`auth()`](#auth)
|
17 |
+
- [Authentication object](#authentication-object)
|
18 |
+
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-options-or-authhookrequest-options)
|
19 |
+
- [Find more information](#find-more-information)
|
20 |
+
- [Find out what scopes are enabled for oauth tokens](#find-out-what-scopes-are-enabled-for-oauth-tokens)
|
21 |
+
- [Find out if token is a personal access token or if it belongs to an OAuth app](#find-out-if-token-is-a-personal-access-token-or-if-it-belongs-to-an-oauth-app)
|
22 |
+
- [Find out what permissions are enabled for a repository](#find-out-what-permissions-are-enabled-for-a-repository)
|
23 |
+
- [Use token for git operations](#use-token-for-git-operations)
|
24 |
+
- [License](#license)
|
25 |
+
|
26 |
+
<!-- tocstop -->
|
27 |
+
|
28 |
+
## Usage
|
29 |
+
|
30 |
+
<table>
|
31 |
+
<tbody valign=top align=left>
|
32 |
+
<tr><th>
|
33 |
+
Browsers
|
34 |
+
</th><td width=100%>
|
35 |
+
|
36 |
+
Load `@octokit/auth-token` directly from [cdn.skypack.dev](https://cdn.skypack.dev)
|
37 |
+
|
38 |
+
```html
|
39 |
+
<script type="module">
|
40 |
+
import { createTokenAuth } from "https://cdn.skypack.dev/@octokit/auth-token";
|
41 |
+
</script>
|
42 |
+
```
|
43 |
+
|
44 |
+
</td></tr>
|
45 |
+
<tr><th>
|
46 |
+
Node
|
47 |
+
</th><td>
|
48 |
+
|
49 |
+
Install with <code>npm install @octokit/auth-token</code>
|
50 |
+
|
51 |
+
```js
|
52 |
+
const { createTokenAuth } = require("@octokit/auth-token");
|
53 |
+
// or: import { createTokenAuth } from "@octokit/auth-token";
|
54 |
+
```
|
55 |
+
|
56 |
+
</td></tr>
|
57 |
+
</tbody>
|
58 |
+
</table>
|
59 |
+
|
60 |
+
```js
|
61 |
+
const auth = createTokenAuth("ghp_PersonalAccessToken01245678900000000");
|
62 |
+
const authentication = await auth();
|
63 |
+
// {
|
64 |
+
// type: 'token',
|
65 |
+
// token: 'ghp_PersonalAccessToken01245678900000000',
|
66 |
+
// tokenType: 'oauth'
|
67 |
+
// }
|
68 |
+
```
|
69 |
+
|
70 |
+
## `createTokenAuth(token) options`
|
71 |
+
|
72 |
+
The `createTokenAuth` method accepts a single argument of type string, which is the token. The passed token can be one of the following:
|
73 |
+
|
74 |
+
- [Personal access token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
|
75 |
+
- [OAuth access token](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)
|
76 |
+
- [GITHUB_TOKEN provided to GitHub Actions](https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#environment-variables)
|
77 |
+
- Installation access token ([server-to-server](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation))
|
78 |
+
- User authentication for installation ([user-to-server](https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps))
|
79 |
+
|
80 |
+
Examples
|
81 |
+
|
82 |
+
```js
|
83 |
+
// Personal access token or OAuth access token
|
84 |
+
createTokenAuth("ghp_PersonalAccessToken01245678900000000");
|
85 |
+
// {
|
86 |
+
// type: 'token',
|
87 |
+
// token: 'ghp_PersonalAccessToken01245678900000000',
|
88 |
+
// tokenType: 'oauth'
|
89 |
+
// }
|
90 |
+
|
91 |
+
// Installation access token or GitHub Action token
|
92 |
+
createTokenAuth("ghs_InstallallationOrActionToken00000000");
|
93 |
+
// {
|
94 |
+
// type: 'token',
|
95 |
+
// token: 'ghs_InstallallationOrActionToken00000000',
|
96 |
+
// tokenType: 'installation'
|
97 |
+
// }
|
98 |
+
|
99 |
+
// Installation access token or GitHub Action token
|
100 |
+
createTokenAuth("ghu_InstallationUserToServer000000000000");
|
101 |
+
// {
|
102 |
+
// type: 'token',
|
103 |
+
// token: 'ghu_InstallationUserToServer000000000000',
|
104 |
+
// tokenType: 'user-to-server'
|
105 |
+
// }
|
106 |
+
```
|
107 |
+
|
108 |
+
## `auth()`
|
109 |
+
|
110 |
+
The `auth()` method has no options. It returns a promise which resolves with the the authentication object.
|
111 |
+
|
112 |
+
## Authentication object
|
113 |
+
|
114 |
+
<table width="100%">
|
115 |
+
<thead align=left>
|
116 |
+
<tr>
|
117 |
+
<th width=150>
|
118 |
+
name
|
119 |
+
</th>
|
120 |
+
<th width=70>
|
121 |
+
type
|
122 |
+
</th>
|
123 |
+
<th>
|
124 |
+
description
|
125 |
+
</th>
|
126 |
+
</tr>
|
127 |
+
</thead>
|
128 |
+
<tbody align=left valign=top>
|
129 |
+
<tr>
|
130 |
+
<th>
|
131 |
+
<code>type</code>
|
132 |
+
</th>
|
133 |
+
<th>
|
134 |
+
<code>string</code>
|
135 |
+
</th>
|
136 |
+
<td>
|
137 |
+
<code>"token"</code>
|
138 |
+
</td>
|
139 |
+
</tr>
|
140 |
+
<tr>
|
141 |
+
<th>
|
142 |
+
<code>token</code>
|
143 |
+
</th>
|
144 |
+
<th>
|
145 |
+
<code>string</code>
|
146 |
+
</th>
|
147 |
+
<td>
|
148 |
+
The provided token.
|
149 |
+
</td>
|
150 |
+
</tr>
|
151 |
+
<tr>
|
152 |
+
<th>
|
153 |
+
<code>tokenType</code>
|
154 |
+
</th>
|
155 |
+
<th>
|
156 |
+
<code>string</code>
|
157 |
+
</th>
|
158 |
+
<td>
|
159 |
+
Can be either <code>"oauth"</code> for personal access tokens and OAuth tokens, <code>"installation"</code> for installation access tokens (includes <code>GITHUB_TOKEN</code> provided to GitHub Actions), <code>"app"</code> for a GitHub App JSON Web Token, or <code>"user-to-server"</code> for a user authentication token through an app installation.
|
160 |
+
</td>
|
161 |
+
</tr>
|
162 |
+
</tbody>
|
163 |
+
</table>
|
164 |
+
|
165 |
+
## `auth.hook(request, route, options)` or `auth.hook(request, options)`
|
166 |
+
|
167 |
+
`auth.hook()` hooks directly into the request life cycle. It authenticates the request using the provided token.
|
168 |
+
|
169 |
+
The `request` option is an instance of [`@octokit/request`](https://github.com/octokit/request.js#readme). The `route`/`options` parameters are the same as for the [`request()` method](https://github.com/octokit/request.js#request).
|
170 |
+
|
171 |
+
`auth.hook()` can be called directly to send an authenticated request
|
172 |
+
|
173 |
+
```js
|
174 |
+
const { data: authorizations } = await auth.hook(
|
175 |
+
request,
|
176 |
+
"GET /authorizations"
|
177 |
+
);
|
178 |
+
```
|
179 |
+
|
180 |
+
Or it can be passed as option to [`request()`](https://github.com/octokit/request.js#request).
|
181 |
+
|
182 |
+
```js
|
183 |
+
const requestWithAuth = request.defaults({
|
184 |
+
request: {
|
185 |
+
hook: auth.hook,
|
186 |
+
},
|
187 |
+
});
|
188 |
+
|
189 |
+
const { data: authorizations } = await requestWithAuth("GET /authorizations");
|
190 |
+
```
|
191 |
+
|
192 |
+
## Find more information
|
193 |
+
|
194 |
+
`auth()` does not send any requests, it only transforms the provided token string into an authentication object.
|
195 |
+
|
196 |
+
Here is a list of things you can do to retrieve further information
|
197 |
+
|
198 |
+
### Find out what scopes are enabled for oauth tokens
|
199 |
+
|
200 |
+
Note that this does not work for installations. There is no way to retrieve permissions based on an installation access tokens.
|
201 |
+
|
202 |
+
```js
|
203 |
+
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
204 |
+
|
205 |
+
const auth = createTokenAuth(TOKEN);
|
206 |
+
const authentication = await auth();
|
207 |
+
|
208 |
+
const response = await request("HEAD /");
|
209 |
+
const scopes = response.headers["x-oauth-scopes"].split(/,\s+/);
|
210 |
+
|
211 |
+
if (scopes.length) {
|
212 |
+
console.log(
|
213 |
+
`"${TOKEN}" has ${scopes.length} scopes enabled: ${scopes.join(", ")}`
|
214 |
+
);
|
215 |
+
} else {
|
216 |
+
console.log(`"${TOKEN}" has no scopes enabled`);
|
217 |
+
}
|
218 |
+
```
|
219 |
+
|
220 |
+
### Find out if token is a personal access token or if it belongs to an OAuth app
|
221 |
+
|
222 |
+
```js
|
223 |
+
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
224 |
+
|
225 |
+
const auth = createTokenAuth(TOKEN);
|
226 |
+
const authentication = await auth();
|
227 |
+
|
228 |
+
const response = await request("HEAD /");
|
229 |
+
const clientId = response.headers["x-oauth-client-id"];
|
230 |
+
|
231 |
+
if (clientId) {
|
232 |
+
console.log(
|
233 |
+
`"${token}" is an OAuth token, its app’s client_id is ${clientId}.`
|
234 |
+
);
|
235 |
+
} else {
|
236 |
+
console.log(`"${token}" is a personal access token`);
|
237 |
+
}
|
238 |
+
```
|
239 |
+
|
240 |
+
### Find out what permissions are enabled for a repository
|
241 |
+
|
242 |
+
Note that the `permissions` key is not set when authenticated using an installation access token.
|
243 |
+
|
244 |
+
```js
|
245 |
+
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
246 |
+
|
247 |
+
const auth = createTokenAuth(TOKEN);
|
248 |
+
const authentication = await auth();
|
249 |
+
|
250 |
+
const response = await request("GET /repos/{owner}/{repo}", {
|
251 |
+
owner: "octocat",
|
252 |
+
repo: "hello-world",
|
253 |
+
});
|
254 |
+
|
255 |
+
console.log(response.data.permissions);
|
256 |
+
// {
|
257 |
+
// admin: true,
|
258 |
+
// push: true,
|
259 |
+
// pull: true
|
260 |
+
// }
|
261 |
+
```
|
262 |
+
|
263 |
+
### Use token for git operations
|
264 |
+
|
265 |
+
Both OAuth and installation access tokens can be used for git operations. However, when using with an installation, [the token must be prefixed with `x-access-token`](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation).
|
266 |
+
|
267 |
+
This example is using the [`execa`](https://github.com/sindresorhus/execa) package to run a `git push` command.
|
268 |
+
|
269 |
+
```js
|
270 |
+
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
271 |
+
|
272 |
+
const auth = createTokenAuth(TOKEN);
|
273 |
+
const { token, tokenType } = await auth();
|
274 |
+
const tokenWithPrefix =
|
275 |
+
tokenType === "installation" ? `x-access-token:${token}` : token;
|
276 |
+
|
277 |
+
const repositoryUrl = `https://${tokenWithPrefix}@github.com/octocat/hello-world.git`;
|
278 |
+
|
279 |
+
const { stdout } = await execa("git", ["push", repositoryUrl]);
|
280 |
+
console.log(stdout);
|
281 |
+
```
|
282 |
+
|
283 |
+
## License
|
284 |
+
|
285 |
+
[MIT](LICENSE)
|
node_modules/@octokit/auth-token/dist-node/index.js
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
var __defProp = Object.defineProperty;
|
3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6 |
+
var __export = (target, all) => {
|
7 |
+
for (var name in all)
|
8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9 |
+
};
|
10 |
+
var __copyProps = (to, from, except, desc) => {
|
11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
12 |
+
for (let key of __getOwnPropNames(from))
|
13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15 |
+
}
|
16 |
+
return to;
|
17 |
+
};
|
18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19 |
+
|
20 |
+
// pkg/dist-src/index.js
|
21 |
+
var dist_src_exports = {};
|
22 |
+
__export(dist_src_exports, {
|
23 |
+
createTokenAuth: () => createTokenAuth
|
24 |
+
});
|
25 |
+
module.exports = __toCommonJS(dist_src_exports);
|
26 |
+
|
27 |
+
// pkg/dist-src/auth.js
|
28 |
+
var REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
|
29 |
+
var REGEX_IS_INSTALLATION = /^ghs_/;
|
30 |
+
var REGEX_IS_USER_TO_SERVER = /^ghu_/;
|
31 |
+
async function auth(token) {
|
32 |
+
const isApp = token.split(/\./).length === 3;
|
33 |
+
const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);
|
34 |
+
const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
|
35 |
+
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
36 |
+
return {
|
37 |
+
type: "token",
|
38 |
+
token,
|
39 |
+
tokenType
|
40 |
+
};
|
41 |
+
}
|
42 |
+
|
43 |
+
// pkg/dist-src/with-authorization-prefix.js
|
44 |
+
function withAuthorizationPrefix(token) {
|
45 |
+
if (token.split(/\./).length === 3) {
|
46 |
+
return `bearer ${token}`;
|
47 |
+
}
|
48 |
+
return `token ${token}`;
|
49 |
+
}
|
50 |
+
|
51 |
+
// pkg/dist-src/hook.js
|
52 |
+
async function hook(token, request, route, parameters) {
|
53 |
+
const endpoint = request.endpoint.merge(
|
54 |
+
route,
|
55 |
+
parameters
|
56 |
+
);
|
57 |
+
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
58 |
+
return request(endpoint);
|
59 |
+
}
|
60 |
+
|
61 |
+
// pkg/dist-src/index.js
|
62 |
+
var createTokenAuth = function createTokenAuth2(token) {
|
63 |
+
if (!token) {
|
64 |
+
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
65 |
+
}
|
66 |
+
if (typeof token !== "string") {
|
67 |
+
throw new Error(
|
68 |
+
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
|
69 |
+
);
|
70 |
+
}
|
71 |
+
token = token.replace(/^(token|bearer) +/i, "");
|
72 |
+
return Object.assign(auth.bind(null, token), {
|
73 |
+
hook: hook.bind(null, token)
|
74 |
+
});
|
75 |
+
};
|
76 |
+
// Annotate the CommonJS export names for ESM import in node:
|
77 |
+
0 && (module.exports = {
|
78 |
+
createTokenAuth
|
79 |
+
});
|
node_modules/@octokit/auth-token/dist-node/index.js.map
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"version": 3,
|
3 |
+
"sources": ["../dist-src/index.js", "../dist-src/auth.js", "../dist-src/with-authorization-prefix.js", "../dist-src/hook.js"],
|
4 |
+
"sourcesContent": ["import { auth } from \"./auth\";\nimport { hook } from \"./hook\";\nconst createTokenAuth = function createTokenAuth2(token) {\n if (!token) {\n throw new Error(\"[@octokit/auth-token] No token passed to createTokenAuth\");\n }\n if (typeof token !== \"string\") {\n throw new Error(\n \"[@octokit/auth-token] Token passed to createTokenAuth is not a string\"\n );\n }\n token = token.replace(/^(token|bearer) +/i, \"\");\n return Object.assign(auth.bind(null, token), {\n hook: hook.bind(null, token)\n });\n};\nexport {\n createTokenAuth\n};\n", "const REGEX_IS_INSTALLATION_LEGACY = /^v1\\./;\nconst REGEX_IS_INSTALLATION = /^ghs_/;\nconst REGEX_IS_USER_TO_SERVER = /^ghu_/;\nasync function auth(token) {\n const isApp = token.split(/\\./).length === 3;\n const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);\n const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);\n const tokenType = isApp ? \"app\" : isInstallation ? \"installation\" : isUserToServer ? \"user-to-server\" : \"oauth\";\n return {\n type: \"token\",\n token,\n tokenType\n };\n}\nexport {\n auth\n};\n", "function withAuthorizationPrefix(token) {\n if (token.split(/\\./).length === 3) {\n return `bearer ${token}`;\n }\n return `token ${token}`;\n}\nexport {\n withAuthorizationPrefix\n};\n", "import { withAuthorizationPrefix } from \"./with-authorization-prefix\";\nasync function hook(token, request, route, parameters) {\n const endpoint = request.endpoint.merge(\n route,\n parameters\n );\n endpoint.headers.authorization = withAuthorizationPrefix(token);\n return request(endpoint);\n}\nexport {\n hook\n};\n"],
|
5 |
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA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|
|
|
|
|
|
|
|
1 |
+
const REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
|
2 |
+
const REGEX_IS_INSTALLATION = /^ghs_/;
|
3 |
+
const REGEX_IS_USER_TO_SERVER = /^ghu_/;
|
4 |
+
async function auth(token) {
|
5 |
+
const isApp = token.split(/\./).length === 3;
|
6 |
+
const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);
|
7 |
+
const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
|
8 |
+
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
9 |
+
return {
|
10 |
+
type: "token",
|
11 |
+
token,
|
12 |
+
tokenType
|
13 |
+
};
|
14 |
+
}
|
15 |
+
export {
|
16 |
+
auth
|
17 |
+
};
|
node_modules/@octokit/auth-token/dist-src/hook.js
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { withAuthorizationPrefix } from "./with-authorization-prefix";
|
2 |
+
async function hook(token, request, route, parameters) {
|
3 |
+
const endpoint = request.endpoint.merge(
|
4 |
+
route,
|
5 |
+
parameters
|
6 |
+
);
|
7 |
+
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
8 |
+
return request(endpoint);
|
9 |
+
}
|
10 |
+
export {
|
11 |
+
hook
|
12 |
+
};
|
node_modules/@octokit/auth-token/dist-src/index.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { auth } from "./auth";
|
2 |
+
import { hook } from "./hook";
|
3 |
+
const createTokenAuth = function createTokenAuth2(token) {
|
4 |
+
if (!token) {
|
5 |
+
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
6 |
+
}
|
7 |
+
if (typeof token !== "string") {
|
8 |
+
throw new Error(
|
9 |
+
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
|
10 |
+
);
|
11 |
+
}
|
12 |
+
token = token.replace(/^(token|bearer) +/i, "");
|
13 |
+
return Object.assign(auth.bind(null, token), {
|
14 |
+
hook: hook.bind(null, token)
|
15 |
+
});
|
16 |
+
};
|
17 |
+
export {
|
18 |
+
createTokenAuth
|
19 |
+
};
|
node_modules/@octokit/auth-token/dist-src/with-authorization-prefix.js
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function withAuthorizationPrefix(token) {
|
2 |
+
if (token.split(/\./).length === 3) {
|
3 |
+
return `bearer ${token}`;
|
4 |
+
}
|
5 |
+
return `token ${token}`;
|
6 |
+
}
|
7 |
+
export {
|
8 |
+
withAuthorizationPrefix
|
9 |
+
};
|
node_modules/@octokit/auth-token/dist-types/auth.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
import type { Token, Authentication } from "./types";
|
2 |
+
export declare function auth(token: Token): Promise<Authentication>;
|
node_modules/@octokit/auth-token/dist-types/hook.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
import type { AnyResponse, EndpointOptions, RequestInterface, RequestParameters, Route, Token } from "./types";
|
2 |
+
export declare function hook(token: Token, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<AnyResponse>;
|
node_modules/@octokit/auth-token/dist-types/index.d.ts
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { StrategyInterface, Token, Authentication } from "./types";
|
2 |
+
export type Types = {
|
3 |
+
StrategyOptions: Token;
|
4 |
+
AuthOptions: never;
|
5 |
+
Authentication: Authentication;
|
6 |
+
};
|
7 |
+
export declare const createTokenAuth: StrategyInterface;
|
node_modules/@octokit/auth-token/dist-types/types.d.ts
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as OctokitTypes from "@octokit/types";
|
2 |
+
export type AnyResponse = OctokitTypes.OctokitResponse<any>;
|
3 |
+
export type StrategyInterface = OctokitTypes.StrategyInterface<[
|
4 |
+
Token
|
5 |
+
], [
|
6 |
+
], Authentication>;
|
7 |
+
export type EndpointDefaults = OctokitTypes.EndpointDefaults;
|
8 |
+
export type EndpointOptions = OctokitTypes.EndpointOptions;
|
9 |
+
export type RequestParameters = OctokitTypes.RequestParameters;
|
10 |
+
export type RequestInterface = OctokitTypes.RequestInterface;
|
11 |
+
export type Route = OctokitTypes.Route;
|
12 |
+
export type Token = string;
|
13 |
+
export type OAuthTokenAuthentication = {
|
14 |
+
type: "token";
|
15 |
+
tokenType: "oauth";
|
16 |
+
token: Token;
|
17 |
+
};
|
18 |
+
export type InstallationTokenAuthentication = {
|
19 |
+
type: "token";
|
20 |
+
tokenType: "installation";
|
21 |
+
token: Token;
|
22 |
+
};
|
23 |
+
export type AppAuthentication = {
|
24 |
+
type: "token";
|
25 |
+
tokenType: "app";
|
26 |
+
token: Token;
|
27 |
+
};
|
28 |
+
export type UserToServerAuthentication = {
|
29 |
+
type: "token";
|
30 |
+
tokenType: "user-to-server";
|
31 |
+
token: Token;
|
32 |
+
};
|
33 |
+
export type Authentication = OAuthTokenAuthentication | InstallationTokenAuthentication | AppAuthentication | UserToServerAuthentication;
|
node_modules/@octokit/auth-token/dist-types/with-authorization-prefix.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Prefix token for usage in the Authorization header
|
3 |
+
*
|
4 |
+
* @param token OAuth token or JSON Web Token
|
5 |
+
*/
|
6 |
+
export declare function withAuthorizationPrefix(token: string): string;
|
node_modules/@octokit/auth-token/dist-web/index.js
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// pkg/dist-src/auth.js
|
2 |
+
var REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
|
3 |
+
var REGEX_IS_INSTALLATION = /^ghs_/;
|
4 |
+
var REGEX_IS_USER_TO_SERVER = /^ghu_/;
|
5 |
+
async function auth(token) {
|
6 |
+
const isApp = token.split(/\./).length === 3;
|
7 |
+
const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);
|
8 |
+
const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
|
9 |
+
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
10 |
+
return {
|
11 |
+
type: "token",
|
12 |
+
token,
|
13 |
+
tokenType
|
14 |
+
};
|
15 |
+
}
|
16 |
+
|
17 |
+
// pkg/dist-src/with-authorization-prefix.js
|
18 |
+
function withAuthorizationPrefix(token) {
|
19 |
+
if (token.split(/\./).length === 3) {
|
20 |
+
return `bearer ${token}`;
|
21 |
+
}
|
22 |
+
return `token ${token}`;
|
23 |
+
}
|
24 |
+
|
25 |
+
// pkg/dist-src/hook.js
|
26 |
+
async function hook(token, request, route, parameters) {
|
27 |
+
const endpoint = request.endpoint.merge(
|
28 |
+
route,
|
29 |
+
parameters
|
30 |
+
);
|
31 |
+
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
32 |
+
return request(endpoint);
|
33 |
+
}
|
34 |
+
|
35 |
+
// pkg/dist-src/index.js
|
36 |
+
var createTokenAuth = function createTokenAuth2(token) {
|
37 |
+
if (!token) {
|
38 |
+
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
39 |
+
}
|
40 |
+
if (typeof token !== "string") {
|
41 |
+
throw new Error(
|
42 |
+
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
|
43 |
+
);
|
44 |
+
}
|
45 |
+
token = token.replace(/^(token|bearer) +/i, "");
|
46 |
+
return Object.assign(auth.bind(null, token), {
|
47 |
+
hook: hook.bind(null, token)
|
48 |
+
});
|
49 |
+
};
|
50 |
+
export {
|
51 |
+
createTokenAuth
|
52 |
+
};
|
node_modules/@octokit/auth-token/dist-web/index.js.map
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"version": 3,
|
3 |
+
"sources": ["../dist-src/auth.js", "../dist-src/with-authorization-prefix.js", "../dist-src/hook.js", "../dist-src/index.js"],
|
4 |
+
"sourcesContent": ["const REGEX_IS_INSTALLATION_LEGACY = /^v1\\./;\nconst REGEX_IS_INSTALLATION = /^ghs_/;\nconst REGEX_IS_USER_TO_SERVER = /^ghu_/;\nasync function auth(token) {\n const isApp = token.split(/\\./).length === 3;\n const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);\n const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);\n const tokenType = isApp ? \"app\" : isInstallation ? \"installation\" : isUserToServer ? \"user-to-server\" : \"oauth\";\n return {\n type: \"token\",\n token,\n tokenType\n };\n}\nexport {\n auth\n};\n", "function withAuthorizationPrefix(token) {\n if (token.split(/\\./).length === 3) {\n return `bearer ${token}`;\n }\n return `token ${token}`;\n}\nexport {\n withAuthorizationPrefix\n};\n", "import { withAuthorizationPrefix } from \"./with-authorization-prefix\";\nasync function hook(token, request, route, parameters) {\n const endpoint = request.endpoint.merge(\n route,\n parameters\n );\n endpoint.headers.authorization = withAuthorizationPrefix(token);\n return request(endpoint);\n}\nexport {\n hook\n};\n", "import { auth } from \"./auth\";\nimport { hook } from \"./hook\";\nconst createTokenAuth = function createTokenAuth2(token) {\n if (!token) {\n throw new Error(\"[@octokit/auth-token] No token passed to createTokenAuth\");\n }\n if (typeof token !== \"string\") {\n throw new Error(\n \"[@octokit/auth-token] Token passed to createTokenAuth is not a string\"\n );\n }\n token = token.replace(/^(token|bearer) +/i, \"\");\n return Object.assign(auth.bind(null, token), {\n hook: hook.bind(null, token)\n });\n};\nexport {\n createTokenAuth\n};\n"],
|
5 |
+
"mappings": ";AAAA,IAAM,+BAA+B;AACrC,IAAM,wBAAwB;AAC9B,IAAM,0BAA0B;AAChC,eAAe,KAAK,OAAO;AACzB,QAAM,QAAQ,MAAM,MAAM,IAAI,EAAE,WAAW;AAC3C,QAAM,iBAAiB,6BAA6B,KAAK,KAAK,KAAK,sBAAsB,KAAK,KAAK;AACnG,QAAM,iBAAiB,wBAAwB,KAAK,KAAK;AACzD,QAAM,YAAY,QAAQ,QAAQ,iBAAiB,iBAAiB,iBAAiB,mBAAmB;AACxG,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;;;ACbA,SAAS,wBAAwB,OAAO;AACtC,MAAI,MAAM,MAAM,IAAI,EAAE,WAAW,GAAG;AAClC,WAAO,UAAU;AAAA,EACnB;AACA,SAAO,SAAS;AAClB;;;ACJA,eAAe,KAAK,OAAO,SAAS,OAAO,YAAY;AACrD,QAAM,WAAW,QAAQ,SAAS;AAAA,IAChC;AAAA,IACA;AAAA,EACF;AACA,WAAS,QAAQ,gBAAgB,wBAAwB,KAAK;AAC9D,SAAO,QAAQ,QAAQ;AACzB;;;ACNA,IAAM,kBAAkB,SAAS,iBAAiB,OAAO;AACvD,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,UAAQ,MAAM,QAAQ,sBAAsB,EAAE;AAC9C,SAAO,OAAO,OAAO,KAAK,KAAK,MAAM,KAAK,GAAG;AAAA,IAC3C,MAAM,KAAK,KAAK,MAAM,KAAK;AAAA,EAC7B,CAAC;AACH;",
|
6 |
+
"names": []
|
7 |
+
}
|
node_modules/@octokit/auth-token/package.json
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@octokit/auth-token",
|
3 |
+
"publishConfig": {
|
4 |
+
"access": "public"
|
5 |
+
},
|
6 |
+
"version": "4.0.0",
|
7 |
+
"description": "GitHub API token authentication for browsers and Node.js",
|
8 |
+
"repository": "github:octokit/auth-token.js",
|
9 |
+
"keywords": [
|
10 |
+
"github",
|
11 |
+
"octokit",
|
12 |
+
"authentication",
|
13 |
+
"api"
|
14 |
+
],
|
15 |
+
"author": "Gregor Martynus (https://github.com/gr2m)",
|
16 |
+
"license": "MIT",
|
17 |
+
"devDependencies": {
|
18 |
+
"@octokit/request": "^6.0.0",
|
19 |
+
"@octokit/tsconfig": "^2.0.0",
|
20 |
+
"@octokit/types": "^9.2.3",
|
21 |
+
"@types/fetch-mock": "^7.3.1",
|
22 |
+
"@types/jest": "^29.0.0",
|
23 |
+
"esbuild": "^0.18.0",
|
24 |
+
"fetch-mock": "^9.0.0",
|
25 |
+
"glob": "^10.2.6",
|
26 |
+
"jest": "^29.0.0",
|
27 |
+
"prettier": "2.8.8",
|
28 |
+
"semantic-release": "^21.0.0",
|
29 |
+
"ts-jest": "^29.0.0",
|
30 |
+
"typescript": "^5.0.0"
|
31 |
+
},
|
32 |
+
"engines": {
|
33 |
+
"node": ">= 18"
|
34 |
+
},
|
35 |
+
"files": [
|
36 |
+
"dist-*/**",
|
37 |
+
"bin/**"
|
38 |
+
],
|
39 |
+
"main": "dist-node/index.js",
|
40 |
+
"browser": "dist-web/index.js",
|
41 |
+
"types": "dist-types/index.d.ts",
|
42 |
+
"module": "dist-src/index.js",
|
43 |
+
"sideEffects": false
|
44 |
+
}
|
node_modules/@octokit/core/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2019 Octokit contributors
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in
|
13 |
+
all copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
THE SOFTWARE.
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# core.js
|
2 |
+
|
3 |
+
> Extendable client for GitHub's REST & GraphQL APIs
|
4 |
+
|
5 |
+
[](https://www.npmjs.com/package/@octokit/core)
|
6 |
+
[](https://github.com/octokit/core.js/actions?query=workflow%3ATest+branch%3Amain)
|
7 |
+
|
8 |
+
<!-- toc -->
|
9 |
+
|
10 |
+
- [Usage](#usage)
|
11 |
+
- [REST API example](#rest-api-example)
|
12 |
+
- [GraphQL example](#graphql-example)
|
13 |
+
- [Options](#options)
|
14 |
+
- [Defaults](#defaults)
|
15 |
+
- [Authentication](#authentication)
|
16 |
+
- [Logging](#logging)
|
17 |
+
- [Hooks](#hooks)
|
18 |
+
- [Plugins](#plugins)
|
19 |
+
- [Build your own Octokit with Plugins and Defaults](#build-your-own-octokit-with-plugins-and-defaults)
|
20 |
+
- [LICENSE](#license)
|
21 |
+
|
22 |
+
<!-- tocstop -->
|
23 |
+
|
24 |
+
If you need a minimalistic library to utilize GitHub's [REST API](https://developer.github.com/v3/) and [GraphQL API](https://developer.github.com/v4/) which you can extend with plugins as needed, then `@octokit/core` is a great starting point.
|
25 |
+
|
26 |
+
If you don't need the Plugin API then using [`@octokit/request`](https://github.com/octokit/request.js/) or [`@octokit/graphql`](https://github.com/octokit/graphql.js/) directly is a good alternative.
|
27 |
+
|
28 |
+
## Usage
|
29 |
+
|
30 |
+
<table>
|
31 |
+
<tbody valign=top align=left>
|
32 |
+
<tr><th>
|
33 |
+
Browsers
|
34 |
+
</th><td width=100%>
|
35 |
+
Load <code>@octokit/core</code> directly from <a href="https://esm.sh">esm.sh</a>
|
36 |
+
|
37 |
+
```html
|
38 |
+
<script type="module">
|
39 |
+
import { Octokit } from "https://esm.sh/@octokit/core";
|
40 |
+
</script>
|
41 |
+
```
|
42 |
+
|
43 |
+
</td></tr>
|
44 |
+
<tr><th>
|
45 |
+
Node
|
46 |
+
</th><td>
|
47 |
+
|
48 |
+
Install with <code>npm install @octokit/core</code>
|
49 |
+
|
50 |
+
```js
|
51 |
+
const { Octokit } = require("@octokit/core");
|
52 |
+
// or: import { Octokit } from "@octokit/core";
|
53 |
+
```
|
54 |
+
|
55 |
+
</td></tr>
|
56 |
+
</tbody>
|
57 |
+
</table>
|
58 |
+
|
59 |
+
### REST API example
|
60 |
+
|
61 |
+
```js
|
62 |
+
// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
|
63 |
+
const octokit = new Octokit({ auth: `personal-access-token123` });
|
64 |
+
|
65 |
+
const response = await octokit.request("GET /orgs/{org}/repos", {
|
66 |
+
org: "octokit",
|
67 |
+
type: "private",
|
68 |
+
});
|
69 |
+
```
|
70 |
+
|
71 |
+
See [`@octokit/request`](https://github.com/octokit/request.js) for full documentation of the `.request` method.
|
72 |
+
|
73 |
+
### GraphQL example
|
74 |
+
|
75 |
+
```js
|
76 |
+
const octokit = new Octokit({ auth: `secret123` });
|
77 |
+
|
78 |
+
const response = await octokit.graphql(
|
79 |
+
`query ($login: String!) {
|
80 |
+
organization(login: $login) {
|
81 |
+
repositories(privacy: PRIVATE) {
|
82 |
+
totalCount
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}`,
|
86 |
+
{ login: "octokit" },
|
87 |
+
);
|
88 |
+
```
|
89 |
+
|
90 |
+
See [`@octokit/graphql`](https://github.com/octokit/graphql.js) for full documentation of the `.graphql` method.
|
91 |
+
|
92 |
+
## Options
|
93 |
+
|
94 |
+
<table>
|
95 |
+
<thead align=left>
|
96 |
+
<tr>
|
97 |
+
<th>
|
98 |
+
name
|
99 |
+
</th>
|
100 |
+
<th>
|
101 |
+
type
|
102 |
+
</th>
|
103 |
+
<th width=100%>
|
104 |
+
description
|
105 |
+
</th>
|
106 |
+
</tr>
|
107 |
+
</thead>
|
108 |
+
<tbody align=left valign=top>
|
109 |
+
<tr>
|
110 |
+
<th>
|
111 |
+
<code>options.authStrategy</code>
|
112 |
+
</th>
|
113 |
+
<td>
|
114 |
+
<code>Function<code>
|
115 |
+
</td>
|
116 |
+
<td>
|
117 |
+
Defaults to <a href="https://github.com/octokit/auth-token.js#readme"><code>@octokit/auth-token</code></a>. See <a href="#authentication">Authentication</a> below for examples.
|
118 |
+
</td>
|
119 |
+
</tr>
|
120 |
+
<tr>
|
121 |
+
<th>
|
122 |
+
<code>options.auth</code>
|
123 |
+
</th>
|
124 |
+
<td>
|
125 |
+
<code>String</code> or <code>Object</code>
|
126 |
+
</td>
|
127 |
+
<td>
|
128 |
+
See <a href="#authentication">Authentication</a> below for examples.
|
129 |
+
</td>
|
130 |
+
</tr>
|
131 |
+
<tr>
|
132 |
+
<th>
|
133 |
+
<code>options.baseUrl</code>
|
134 |
+
</th>
|
135 |
+
<td>
|
136 |
+
<code>String</code>
|
137 |
+
</td>
|
138 |
+
<td>
|
139 |
+
|
140 |
+
When using with GitHub Enterprise Server, set `options.baseUrl` to the root URL of the API. For example, if your GitHub Enterprise Server's hostname is `github.acme-inc.com`, then set `options.baseUrl` to `https://github.acme-inc.com/api/v3`. Example
|
141 |
+
|
142 |
+
```js
|
143 |
+
const octokit = new Octokit({
|
144 |
+
baseUrl: "https://github.acme-inc.com/api/v3",
|
145 |
+
});
|
146 |
+
```
|
147 |
+
|
148 |
+
</td></tr>
|
149 |
+
<tr>
|
150 |
+
<th>
|
151 |
+
<code>options.previews</code>
|
152 |
+
</th>
|
153 |
+
<td>
|
154 |
+
<code>Array of Strings</code>
|
155 |
+
</td>
|
156 |
+
<td>
|
157 |
+
|
158 |
+
Some REST API endpoints require preview headers to be set, or enable
|
159 |
+
additional features. Preview headers can be set on a per-request basis, e.g.
|
160 |
+
|
161 |
+
```js
|
162 |
+
octokit.request("POST /repos/{owner}/{repo}/pulls", {
|
163 |
+
mediaType: {
|
164 |
+
previews: ["shadow-cat"],
|
165 |
+
},
|
166 |
+
owner,
|
167 |
+
repo,
|
168 |
+
title: "My pull request",
|
169 |
+
base: "main",
|
170 |
+
head: "my-feature",
|
171 |
+
draft: true,
|
172 |
+
});
|
173 |
+
```
|
174 |
+
|
175 |
+
You can also set previews globally, by setting the `options.previews` option on the constructor. Example:
|
176 |
+
|
177 |
+
```js
|
178 |
+
const octokit = new Octokit({
|
179 |
+
previews: ["shadow-cat"],
|
180 |
+
});
|
181 |
+
```
|
182 |
+
|
183 |
+
</td></tr>
|
184 |
+
<tr>
|
185 |
+
<th>
|
186 |
+
<code>options.request</code>
|
187 |
+
</th>
|
188 |
+
<td>
|
189 |
+
<code>Object</code>
|
190 |
+
</td>
|
191 |
+
<td>
|
192 |
+
|
193 |
+
Set a default request timeout (`options.request.timeout`) or an [`http(s).Agent`](https://nodejs.org/api/http.html#http_class_http_agent) e.g. for proxy usage (Node only, `options.request.agent`).
|
194 |
+
|
195 |
+
There are more `options.request.*` options, see [`@octokit/request` options](https://github.com/octokit/request.js#request). `options.request` can also be set on a per-request basis.
|
196 |
+
|
197 |
+
</td></tr>
|
198 |
+
<tr>
|
199 |
+
<th>
|
200 |
+
<code>options.timeZone</code>
|
201 |
+
</th>
|
202 |
+
<td>
|
203 |
+
<code>String</code>
|
204 |
+
</td>
|
205 |
+
<td>
|
206 |
+
|
207 |
+
Sets the `Time-Zone` header which defines a timezone according to the [list of names from the Olson database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
208 |
+
|
209 |
+
```js
|
210 |
+
const octokit = new Octokit({
|
211 |
+
timeZone: "America/Los_Angeles",
|
212 |
+
});
|
213 |
+
```
|
214 |
+
|
215 |
+
The time zone header will determine the timezone used for generating the timestamp when creating commits. See [GitHub's Timezones documentation](https://developer.github.com/v3/#timezones).
|
216 |
+
|
217 |
+
</td></tr>
|
218 |
+
<tr>
|
219 |
+
<th>
|
220 |
+
<code>options.userAgent</code>
|
221 |
+
</th>
|
222 |
+
<td>
|
223 |
+
<code>String</code>
|
224 |
+
</td>
|
225 |
+
<td>
|
226 |
+
|
227 |
+
A custom user agent string for your app or library. Example
|
228 |
+
|
229 |
+
```js
|
230 |
+
const octokit = new Octokit({
|
231 |
+
userAgent: "my-app/v1.2.3",
|
232 |
+
});
|
233 |
+
```
|
234 |
+
|
235 |
+
</td></tr>
|
236 |
+
</tbody>
|
237 |
+
</table>
|
238 |
+
|
239 |
+
## Defaults
|
240 |
+
|
241 |
+
You can create a new Octokit class with customized default options.
|
242 |
+
|
243 |
+
```js
|
244 |
+
const MyOctokit = Octokit.defaults({
|
245 |
+
auth: "personal-access-token123",
|
246 |
+
baseUrl: "https://github.acme-inc.com/api/v3",
|
247 |
+
userAgent: "my-app/v1.2.3",
|
248 |
+
});
|
249 |
+
const octokit1 = new MyOctokit();
|
250 |
+
const octokit2 = new MyOctokit();
|
251 |
+
```
|
252 |
+
|
253 |
+
If you pass additional options to your new constructor, the options will be merged shallowly.
|
254 |
+
|
255 |
+
```js
|
256 |
+
const MyOctokit = Octokit.defaults({
|
257 |
+
foo: {
|
258 |
+
opt1: 1,
|
259 |
+
},
|
260 |
+
});
|
261 |
+
const octokit = new MyOctokit({
|
262 |
+
foo: {
|
263 |
+
opt2: 1,
|
264 |
+
},
|
265 |
+
});
|
266 |
+
// options will be { foo: { opt2: 1 }}
|
267 |
+
```
|
268 |
+
|
269 |
+
If you need a deep or conditional merge, you can pass a function instead.
|
270 |
+
|
271 |
+
```js
|
272 |
+
const MyOctokit = Octokit.defaults((options) => {
|
273 |
+
return {
|
274 |
+
foo: Object.assign({}, options.foo, { opt1: 1 }),
|
275 |
+
};
|
276 |
+
});
|
277 |
+
const octokit = new MyOctokit({
|
278 |
+
foo: { opt2: 1 },
|
279 |
+
});
|
280 |
+
// options will be { foo: { opt1: 1, opt2: 1 }}
|
281 |
+
```
|
282 |
+
|
283 |
+
Be careful about mutating the `options` object in the `Octokit.defaults` callback, as it can have unforeseen consequences.
|
284 |
+
|
285 |
+
## Authentication
|
286 |
+
|
287 |
+
Authentication is optional for some REST API endpoints accessing public data, but is required for GraphQL queries. Using authentication also increases your [API rate limit](https://developer.github.com/v3/#rate-limiting).
|
288 |
+
|
289 |
+
By default, Octokit authenticates using the [token authentication strategy](https://github.com/octokit/auth-token.js). Pass in a token using `options.auth`. It can be a personal access token, an OAuth token, an installation access token or a JSON Web Token for GitHub App authentication. The `Authorization` header will be set according to the type of token.
|
290 |
+
|
291 |
+
```js
|
292 |
+
import { Octokit } from "@octokit/core";
|
293 |
+
|
294 |
+
const octokit = new Octokit({
|
295 |
+
auth: "mypersonalaccesstoken123",
|
296 |
+
});
|
297 |
+
|
298 |
+
const { data } = await octokit.request("/user");
|
299 |
+
```
|
300 |
+
|
301 |
+
To use a different authentication strategy, set `options.authStrategy`. A list of authentication strategies is available at [octokit/authentication-strategies.js](https://github.com/octokit/authentication-strategies.js/#readme).
|
302 |
+
|
303 |
+
Example
|
304 |
+
|
305 |
+
```js
|
306 |
+
import { Octokit } from "@octokit/core";
|
307 |
+
import { createAppAuth } from "@octokit/auth-app";
|
308 |
+
|
309 |
+
const appOctokit = new Octokit({
|
310 |
+
authStrategy: createAppAuth,
|
311 |
+
auth: {
|
312 |
+
appId: 123,
|
313 |
+
privateKey: process.env.PRIVATE_KEY,
|
314 |
+
},
|
315 |
+
});
|
316 |
+
|
317 |
+
const { data } = await appOctokit.request("/app");
|
318 |
+
```
|
319 |
+
|
320 |
+
The `.auth()` method returned by the current authentication strategy can be accessed at `octokit.auth()`. Example
|
321 |
+
|
322 |
+
```js
|
323 |
+
const { token } = await appOctokit.auth({
|
324 |
+
type: "installation",
|
325 |
+
installationId: 123,
|
326 |
+
});
|
327 |
+
```
|
328 |
+
|
329 |
+
## Logging
|
330 |
+
|
331 |
+
There are four built-in log methods
|
332 |
+
|
333 |
+
1. `octokit.log.debug(message[, additionalInfo])`
|
334 |
+
1. `octokit.log.info(message[, additionalInfo])`
|
335 |
+
1. `octokit.log.warn(message[, additionalInfo])`
|
336 |
+
1. `octokit.log.error(message[, additionalInfo])`
|
337 |
+
|
338 |
+
They can be configured using the [`log` client option](client-options). By default, `octokit.log.debug()` and `octokit.log.info()` are no-ops, while the other two call `console.warn()` and `console.error()` respectively.
|
339 |
+
|
340 |
+
This is useful if you build reusable [plugins](#plugins).
|
341 |
+
|
342 |
+
If you would like to make the log level configurable using an environment variable or external option, we recommend the [console-log-level](https://github.com/watson/console-log-level) package. Example
|
343 |
+
|
344 |
+
```js
|
345 |
+
const octokit = new Octokit({
|
346 |
+
log: require("console-log-level")({ level: "info" }),
|
347 |
+
});
|
348 |
+
```
|
349 |
+
|
350 |
+
## Hooks
|
351 |
+
|
352 |
+
You can customize Octokit's request lifecycle with hooks.
|
353 |
+
|
354 |
+
```js
|
355 |
+
octokit.hook.before("request", async (options) => {
|
356 |
+
validate(options);
|
357 |
+
});
|
358 |
+
octokit.hook.after("request", async (response, options) => {
|
359 |
+
console.log(`${options.method} ${options.url}: ${response.status}`);
|
360 |
+
});
|
361 |
+
octokit.hook.error("request", async (error, options) => {
|
362 |
+
if (error.status === 304) {
|
363 |
+
return findInCache(error.response.headers.etag);
|
364 |
+
}
|
365 |
+
|
366 |
+
throw error;
|
367 |
+
});
|
368 |
+
octokit.hook.wrap("request", async (request, options) => {
|
369 |
+
// add logic before, after, catch errors or replace the request altogether
|
370 |
+
return request(options);
|
371 |
+
});
|
372 |
+
```
|
373 |
+
|
374 |
+
See [before-after-hook](https://github.com/gr2m/before-after-hook#readme) for more documentation on hooks.
|
375 |
+
|
376 |
+
## Plugins
|
377 |
+
|
378 |
+
Octokit’s functionality can be extended using plugins. The `Octokit.plugin()` method accepts a plugin (or many) and returns a new constructor.
|
379 |
+
|
380 |
+
A plugin is a function which gets two arguments:
|
381 |
+
|
382 |
+
1. the current instance
|
383 |
+
2. the options passed to the constructor.
|
384 |
+
|
385 |
+
In order to extend `octokit`'s API, the plugin must return an object with the new methods. Please refrain from adding methods directly to the `octokit` instance, especialy if you depend on keys that do not exist in `@octokit/core`, such as `octokit.rest`.
|
386 |
+
|
387 |
+
```js
|
388 |
+
// index.js
|
389 |
+
const { Octokit } = require("@octokit/core")
|
390 |
+
const MyOctokit = Octokit.plugin(
|
391 |
+
require("./lib/my-plugin"),
|
392 |
+
require("octokit-plugin-example")
|
393 |
+
);
|
394 |
+
|
395 |
+
const octokit = new MyOctokit({ greeting: "Moin moin" });
|
396 |
+
octokit.helloWorld(); // logs "Moin moin, world!"
|
397 |
+
octokit.request("GET /"); // logs "GET / - 200 in 123ms"
|
398 |
+
|
399 |
+
// lib/my-plugin.js
|
400 |
+
module.exports = (octokit, options = { greeting: "Hello" }) => {
|
401 |
+
// hook into the request lifecycle
|
402 |
+
octokit.hook.wrap("request", async (request, options) => {
|
403 |
+
const time = Date.now();
|
404 |
+
const response = await request(options);
|
405 |
+
console.log(
|
406 |
+
`${options.method} ${options.url} – ${response.status} in ${Date.now() -
|
407 |
+
time}ms`
|
408 |
+
);
|
409 |
+
return response;
|
410 |
+
});
|
411 |
+
|
412 |
+
// add a custom method
|
413 |
+
return {
|
414 |
+
helloWorld: () => console.log(`${options.greeting}, world!`);
|
415 |
+
}
|
416 |
+
};
|
417 |
+
```
|
418 |
+
|
419 |
+
## Build your own Octokit with Plugins and Defaults
|
420 |
+
|
421 |
+
You can build your own Octokit class with preset default options and plugins. In fact, this is mostly how the `@octokit/<context>` modules work, such as [`@octokit/action`](https://github.com/octokit/action.js):
|
422 |
+
|
423 |
+
```js
|
424 |
+
const { Octokit } = require("@octokit/core");
|
425 |
+
const MyActionOctokit = Octokit.plugin(
|
426 |
+
require("@octokit/plugin-paginate-rest").paginateRest,
|
427 |
+
require("@octokit/plugin-throttling").throttling,
|
428 |
+
require("@octokit/plugin-retry").retry,
|
429 |
+
).defaults({
|
430 |
+
throttle: {
|
431 |
+
onAbuseLimit: (retryAfter, options) => {
|
432 |
+
/* ... */
|
433 |
+
},
|
434 |
+
onRateLimit: (retryAfter, options) => {
|
435 |
+
/* ... */
|
436 |
+
},
|
437 |
+
},
|
438 |
+
authStrategy: require("@octokit/auth-action").createActionAuth,
|
439 |
+
userAgent: `my-octokit-action/v1.2.3`,
|
440 |
+
});
|
441 |
+
|
442 |
+
const octokit = new MyActionOctokit();
|
443 |
+
const installations = await octokit.paginate("GET /app/installations");
|
444 |
+
```
|
445 |
+
|
446 |
+
## LICENSE
|
447 |
+
|
448 |
+
[MIT](LICENSE)
|
node_modules/@octokit/core/dist-node/index.js
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
var __defProp = Object.defineProperty;
|
3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6 |
+
var __export = (target, all) => {
|
7 |
+
for (var name in all)
|
8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9 |
+
};
|
10 |
+
var __copyProps = (to, from, except, desc) => {
|
11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
12 |
+
for (let key of __getOwnPropNames(from))
|
13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15 |
+
}
|
16 |
+
return to;
|
17 |
+
};
|
18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19 |
+
|
20 |
+
// pkg/dist-src/index.js
|
21 |
+
var dist_src_exports = {};
|
22 |
+
__export(dist_src_exports, {
|
23 |
+
Octokit: () => Octokit
|
24 |
+
});
|
25 |
+
module.exports = __toCommonJS(dist_src_exports);
|
26 |
+
var import_universal_user_agent = require("universal-user-agent");
|
27 |
+
var import_before_after_hook = require("before-after-hook");
|
28 |
+
var import_request = require("@octokit/request");
|
29 |
+
var import_graphql = require("@octokit/graphql");
|
30 |
+
var import_auth_token = require("@octokit/auth-token");
|
31 |
+
|
32 |
+
// pkg/dist-src/version.js
|
33 |
+
var VERSION = "5.0.1";
|
34 |
+
|
35 |
+
// pkg/dist-src/index.js
|
36 |
+
var Octokit = class {
|
37 |
+
static {
|
38 |
+
this.VERSION = VERSION;
|
39 |
+
}
|
40 |
+
static defaults(defaults) {
|
41 |
+
const OctokitWithDefaults = class extends this {
|
42 |
+
constructor(...args) {
|
43 |
+
const options = args[0] || {};
|
44 |
+
if (typeof defaults === "function") {
|
45 |
+
super(defaults(options));
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
super(
|
49 |
+
Object.assign(
|
50 |
+
{},
|
51 |
+
defaults,
|
52 |
+
options,
|
53 |
+
options.userAgent && defaults.userAgent ? {
|
54 |
+
userAgent: `${options.userAgent} ${defaults.userAgent}`
|
55 |
+
} : null
|
56 |
+
)
|
57 |
+
);
|
58 |
+
}
|
59 |
+
};
|
60 |
+
return OctokitWithDefaults;
|
61 |
+
}
|
62 |
+
static {
|
63 |
+
this.plugins = [];
|
64 |
+
}
|
65 |
+
/**
|
66 |
+
* Attach a plugin (or many) to your Octokit instance.
|
67 |
+
*
|
68 |
+
* @example
|
69 |
+
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
70 |
+
*/
|
71 |
+
static plugin(...newPlugins) {
|
72 |
+
const currentPlugins = this.plugins;
|
73 |
+
const NewOctokit = class extends this {
|
74 |
+
static {
|
75 |
+
this.plugins = currentPlugins.concat(
|
76 |
+
newPlugins.filter((plugin) => !currentPlugins.includes(plugin))
|
77 |
+
);
|
78 |
+
}
|
79 |
+
};
|
80 |
+
return NewOctokit;
|
81 |
+
}
|
82 |
+
constructor(options = {}) {
|
83 |
+
const hook = new import_before_after_hook.Collection();
|
84 |
+
const requestDefaults = {
|
85 |
+
baseUrl: import_request.request.endpoint.DEFAULTS.baseUrl,
|
86 |
+
headers: {},
|
87 |
+
request: Object.assign({}, options.request, {
|
88 |
+
// @ts-ignore internal usage only, no need to type
|
89 |
+
hook: hook.bind(null, "request")
|
90 |
+
}),
|
91 |
+
mediaType: {
|
92 |
+
previews: [],
|
93 |
+
format: ""
|
94 |
+
}
|
95 |
+
};
|
96 |
+
requestDefaults.headers["user-agent"] = [
|
97 |
+
options.userAgent,
|
98 |
+
`octokit-core.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`
|
99 |
+
].filter(Boolean).join(" ");
|
100 |
+
if (options.baseUrl) {
|
101 |
+
requestDefaults.baseUrl = options.baseUrl;
|
102 |
+
}
|
103 |
+
if (options.previews) {
|
104 |
+
requestDefaults.mediaType.previews = options.previews;
|
105 |
+
}
|
106 |
+
if (options.timeZone) {
|
107 |
+
requestDefaults.headers["time-zone"] = options.timeZone;
|
108 |
+
}
|
109 |
+
this.request = import_request.request.defaults(requestDefaults);
|
110 |
+
this.graphql = (0, import_graphql.withCustomRequest)(this.request).defaults(requestDefaults);
|
111 |
+
this.log = Object.assign(
|
112 |
+
{
|
113 |
+
debug: () => {
|
114 |
+
},
|
115 |
+
info: () => {
|
116 |
+
},
|
117 |
+
warn: console.warn.bind(console),
|
118 |
+
error: console.error.bind(console)
|
119 |
+
},
|
120 |
+
options.log
|
121 |
+
);
|
122 |
+
this.hook = hook;
|
123 |
+
if (!options.authStrategy) {
|
124 |
+
if (!options.auth) {
|
125 |
+
this.auth = async () => ({
|
126 |
+
type: "unauthenticated"
|
127 |
+
});
|
128 |
+
} else {
|
129 |
+
const auth = (0, import_auth_token.createTokenAuth)(options.auth);
|
130 |
+
hook.wrap("request", auth.hook);
|
131 |
+
this.auth = auth;
|
132 |
+
}
|
133 |
+
} else {
|
134 |
+
const { authStrategy, ...otherOptions } = options;
|
135 |
+
const auth = authStrategy(
|
136 |
+
Object.assign(
|
137 |
+
{
|
138 |
+
request: this.request,
|
139 |
+
log: this.log,
|
140 |
+
// we pass the current octokit instance as well as its constructor options
|
141 |
+
// to allow for authentication strategies that return a new octokit instance
|
142 |
+
// that shares the same internal state as the current one. The original
|
143 |
+
// requirement for this was the "event-octokit" authentication strategy
|
144 |
+
// of https://github.com/probot/octokit-auth-probot.
|
145 |
+
octokit: this,
|
146 |
+
octokitOptions: otherOptions
|
147 |
+
},
|
148 |
+
options.auth
|
149 |
+
)
|
150 |
+
);
|
151 |
+
hook.wrap("request", auth.hook);
|
152 |
+
this.auth = auth;
|
153 |
+
}
|
154 |
+
const classConstructor = this.constructor;
|
155 |
+
classConstructor.plugins.forEach((plugin) => {
|
156 |
+
Object.assign(this, plugin(this, options));
|
157 |
+
});
|
158 |
+
}
|
159 |
+
};
|
160 |
+
// Annotate the CommonJS export names for ESM import in node:
|
161 |
+
0 && (module.exports = {
|
162 |
+
Octokit
|
163 |
+
});
|
node_modules/@octokit/core/dist-node/index.js.map
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"version": 3,
|
3 |
+
"sources": ["../dist-src/index.js", "../dist-src/version.js"],
|
4 |
+
"sourcesContent": ["import { getUserAgent } from \"universal-user-agent\";\nimport { Collection } from \"before-after-hook\";\nimport { request } from \"@octokit/request\";\nimport { graphql, withCustomRequest } from \"@octokit/graphql\";\nimport { createTokenAuth } from \"@octokit/auth-token\";\nimport { VERSION } from \"./version\";\nclass Octokit {\n static {\n this.VERSION = VERSION;\n }\n static defaults(defaults) {\n const OctokitWithDefaults = class extends this {\n constructor(...args) {\n const options = args[0] || {};\n if (typeof defaults === \"function\") {\n super(defaults(options));\n return;\n }\n super(\n Object.assign(\n {},\n defaults,\n options,\n options.userAgent && defaults.userAgent ? {\n userAgent: `${options.userAgent} ${defaults.userAgent}`\n } : null\n )\n );\n }\n };\n return OctokitWithDefaults;\n }\n static {\n this.plugins = [];\n }\n /**\n * Attach a plugin (or many) to your Octokit instance.\n *\n * @example\n * const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)\n */\n static plugin(...newPlugins) {\n const currentPlugins = this.plugins;\n const NewOctokit = class extends this {\n static {\n this.plugins = currentPlugins.concat(\n newPlugins.filter((plugin) => !currentPlugins.includes(plugin))\n );\n }\n };\n return NewOctokit;\n }\n constructor(options = {}) {\n const hook = new Collection();\n const requestDefaults = {\n baseUrl: request.endpoint.DEFAULTS.baseUrl,\n headers: {},\n request: Object.assign({}, options.request, {\n // @ts-ignore internal usage only, no need to type\n hook: hook.bind(null, \"request\")\n }),\n mediaType: {\n previews: [],\n format: \"\"\n }\n };\n requestDefaults.headers[\"user-agent\"] = [\n options.userAgent,\n `octokit-core.js/${VERSION} ${getUserAgent()}`\n ].filter(Boolean).join(\" \");\n if (options.baseUrl) {\n requestDefaults.baseUrl = options.baseUrl;\n }\n if (options.previews) {\n requestDefaults.mediaType.previews = options.previews;\n }\n if (options.timeZone) {\n requestDefaults.headers[\"time-zone\"] = options.timeZone;\n }\n this.request = request.defaults(requestDefaults);\n this.graphql = withCustomRequest(this.request).defaults(requestDefaults);\n this.log = Object.assign(\n {\n debug: () => {\n },\n info: () => {\n },\n warn: console.warn.bind(console),\n error: console.error.bind(console)\n },\n options.log\n );\n this.hook = hook;\n if (!options.authStrategy) {\n if (!options.auth) {\n this.auth = async () => ({\n type: \"unauthenticated\"\n });\n } else {\n const auth = createTokenAuth(options.auth);\n hook.wrap(\"request\", auth.hook);\n this.auth = auth;\n }\n } else {\n const { authStrategy, ...otherOptions } = options;\n const auth = authStrategy(\n Object.assign(\n {\n request: this.request,\n log: this.log,\n // we pass the current octokit instance as well as its constructor options\n // to allow for authentication strategies that return a new octokit instance\n // that shares the same internal state as the current one. The original\n // requirement for this was the \"event-octokit\" authentication strategy\n // of https://github.com/probot/octokit-auth-probot.\n octokit: this,\n octokitOptions: otherOptions\n },\n options.auth\n )\n );\n hook.wrap(\"request\", auth.hook);\n this.auth = auth;\n }\n const classConstructor = this.constructor;\n classConstructor.plugins.forEach((plugin) => {\n Object.assign(this, plugin(this, options));\n });\n }\n}\nexport {\n Octokit\n};\n", "const VERSION = \"5.0.1\";\nexport {\n VERSION\n};\n"],
|
5 |
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAA6B;AAC7B,+BAA2B;AAC3B,qBAAwB;AACxB,qBAA2C;AAC3C,wBAAgC;;;ACJhC,IAAM,UAAU;;;ADMhB,IAAM,UAAN,MAAc;AAAA,EACZ,OAAO;AACL,SAAK,UAAU;AAAA,EACjB;AAAA,EACA,OAAO,SAAS,UAAU;AACxB,UAAM,sBAAsB,cAAc,KAAK;AAAA,MAC7C,eAAe,MAAM;AACnB,cAAM,UAAU,KAAK,CAAC,KAAK,CAAC;AAC5B,YAAI,OAAO,aAAa,YAAY;AAClC,gBAAM,SAAS,OAAO,CAAC;AACvB;AAAA,QACF;AACA;AAAA,UACE,OAAO;AAAA,YACL,CAAC;AAAA,YACD;AAAA,YACA;AAAA,YACA,QAAQ,aAAa,SAAS,YAAY;AAAA,cACxC,WAAW,GAAG,QAAQ,SAAS,IAAI,SAAS,SAAS;AAAA,YACvD,IAAI;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EACA,OAAO;AACL,SAAK,UAAU,CAAC;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,UAAU,YAAY;AAC3B,UAAM,iBAAiB,KAAK;AAC5B,UAAM,aAAa,cAAc,KAAK;AAAA,MACpC,OAAO;AACL,aAAK,UAAU,eAAe;AAAA,UAC5B,WA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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { getUserAgent } from "universal-user-agent";
|
2 |
+
import { Collection } from "before-after-hook";
|
3 |
+
import { request } from "@octokit/request";
|
4 |
+
import { graphql, withCustomRequest } from "@octokit/graphql";
|
5 |
+
import { createTokenAuth } from "@octokit/auth-token";
|
6 |
+
import { VERSION } from "./version";
|
7 |
+
class Octokit {
|
8 |
+
static {
|
9 |
+
this.VERSION = VERSION;
|
10 |
+
}
|
11 |
+
static defaults(defaults) {
|
12 |
+
const OctokitWithDefaults = class extends this {
|
13 |
+
constructor(...args) {
|
14 |
+
const options = args[0] || {};
|
15 |
+
if (typeof defaults === "function") {
|
16 |
+
super(defaults(options));
|
17 |
+
return;
|
18 |
+
}
|
19 |
+
super(
|
20 |
+
Object.assign(
|
21 |
+
{},
|
22 |
+
defaults,
|
23 |
+
options,
|
24 |
+
options.userAgent && defaults.userAgent ? {
|
25 |
+
userAgent: `${options.userAgent} ${defaults.userAgent}`
|
26 |
+
} : null
|
27 |
+
)
|
28 |
+
);
|
29 |
+
}
|
30 |
+
};
|
31 |
+
return OctokitWithDefaults;
|
32 |
+
}
|
33 |
+
static {
|
34 |
+
this.plugins = [];
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* Attach a plugin (or many) to your Octokit instance.
|
38 |
+
*
|
39 |
+
* @example
|
40 |
+
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
41 |
+
*/
|
42 |
+
static plugin(...newPlugins) {
|
43 |
+
const currentPlugins = this.plugins;
|
44 |
+
const NewOctokit = class extends this {
|
45 |
+
static {
|
46 |
+
this.plugins = currentPlugins.concat(
|
47 |
+
newPlugins.filter((plugin) => !currentPlugins.includes(plugin))
|
48 |
+
);
|
49 |
+
}
|
50 |
+
};
|
51 |
+
return NewOctokit;
|
52 |
+
}
|
53 |
+
constructor(options = {}) {
|
54 |
+
const hook = new Collection();
|
55 |
+
const requestDefaults = {
|
56 |
+
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
57 |
+
headers: {},
|
58 |
+
request: Object.assign({}, options.request, {
|
59 |
+
// @ts-ignore internal usage only, no need to type
|
60 |
+
hook: hook.bind(null, "request")
|
61 |
+
}),
|
62 |
+
mediaType: {
|
63 |
+
previews: [],
|
64 |
+
format: ""
|
65 |
+
}
|
66 |
+
};
|
67 |
+
requestDefaults.headers["user-agent"] = [
|
68 |
+
options.userAgent,
|
69 |
+
`octokit-core.js/${VERSION} ${getUserAgent()}`
|
70 |
+
].filter(Boolean).join(" ");
|
71 |
+
if (options.baseUrl) {
|
72 |
+
requestDefaults.baseUrl = options.baseUrl;
|
73 |
+
}
|
74 |
+
if (options.previews) {
|
75 |
+
requestDefaults.mediaType.previews = options.previews;
|
76 |
+
}
|
77 |
+
if (options.timeZone) {
|
78 |
+
requestDefaults.headers["time-zone"] = options.timeZone;
|
79 |
+
}
|
80 |
+
this.request = request.defaults(requestDefaults);
|
81 |
+
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
82 |
+
this.log = Object.assign(
|
83 |
+
{
|
84 |
+
debug: () => {
|
85 |
+
},
|
86 |
+
info: () => {
|
87 |
+
},
|
88 |
+
warn: console.warn.bind(console),
|
89 |
+
error: console.error.bind(console)
|
90 |
+
},
|
91 |
+
options.log
|
92 |
+
);
|
93 |
+
this.hook = hook;
|
94 |
+
if (!options.authStrategy) {
|
95 |
+
if (!options.auth) {
|
96 |
+
this.auth = async () => ({
|
97 |
+
type: "unauthenticated"
|
98 |
+
});
|
99 |
+
} else {
|
100 |
+
const auth = createTokenAuth(options.auth);
|
101 |
+
hook.wrap("request", auth.hook);
|
102 |
+
this.auth = auth;
|
103 |
+
}
|
104 |
+
} else {
|
105 |
+
const { authStrategy, ...otherOptions } = options;
|
106 |
+
const auth = authStrategy(
|
107 |
+
Object.assign(
|
108 |
+
{
|
109 |
+
request: this.request,
|
110 |
+
log: this.log,
|
111 |
+
// we pass the current octokit instance as well as its constructor options
|
112 |
+
// to allow for authentication strategies that return a new octokit instance
|
113 |
+
// that shares the same internal state as the current one. The original
|
114 |
+
// requirement for this was the "event-octokit" authentication strategy
|
115 |
+
// of https://github.com/probot/octokit-auth-probot.
|
116 |
+
octokit: this,
|
117 |
+
octokitOptions: otherOptions
|
118 |
+
},
|
119 |
+
options.auth
|
120 |
+
)
|
121 |
+
);
|
122 |
+
hook.wrap("request", auth.hook);
|
123 |
+
this.auth = auth;
|
124 |
+
}
|
125 |
+
const classConstructor = this.constructor;
|
126 |
+
classConstructor.plugins.forEach((plugin) => {
|
127 |
+
Object.assign(this, plugin(this, options));
|
128 |
+
});
|
129 |
+
}
|
130 |
+
}
|
131 |
+
export {
|
132 |
+
Octokit
|
133 |
+
};
|
node_modules/@octokit/core/dist-src/version.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const VERSION = "5.0.1";
|
2 |
+
export {
|
3 |
+
VERSION
|
4 |
+
};
|
node_modules/@octokit/core/dist-types/index.d.ts
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { HookCollection } from "before-after-hook";
|
2 |
+
import { request } from "@octokit/request";
|
3 |
+
import { graphql } from "@octokit/graphql";
|
4 |
+
import type { Constructor, Hooks, OctokitOptions, OctokitPlugin, ReturnTypeOf, UnionToIntersection } from "./types";
|
5 |
+
export declare class Octokit {
|
6 |
+
static VERSION: string;
|
7 |
+
static defaults<S extends Constructor<any>>(this: S, defaults: OctokitOptions | Function): S;
|
8 |
+
static plugins: OctokitPlugin[];
|
9 |
+
/**
|
10 |
+
* Attach a plugin (or many) to your Octokit instance.
|
11 |
+
*
|
12 |
+
* @example
|
13 |
+
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
14 |
+
*/
|
15 |
+
static plugin<S extends Constructor<any> & {
|
16 |
+
plugins: any[];
|
17 |
+
}, T extends OctokitPlugin[]>(this: S, ...newPlugins: T): S & Constructor<UnionToIntersection<ReturnTypeOf<T>>>;
|
18 |
+
constructor(options?: OctokitOptions);
|
19 |
+
request: typeof request;
|
20 |
+
graphql: typeof graphql;
|
21 |
+
log: {
|
22 |
+
debug: (message: string, additionalInfo?: object) => any;
|
23 |
+
info: (message: string, additionalInfo?: object) => any;
|
24 |
+
warn: (message: string, additionalInfo?: object) => any;
|
25 |
+
error: (message: string, additionalInfo?: object) => any;
|
26 |
+
[key: string]: any;
|
27 |
+
};
|
28 |
+
hook: HookCollection<Hooks>;
|
29 |
+
auth: (...args: unknown[]) => Promise<unknown>;
|
30 |
+
}
|
node_modules/@octokit/core/dist-types/types.d.ts
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as OctokitTypes from "@octokit/types";
|
2 |
+
import { RequestError } from "@octokit/request-error";
|
3 |
+
import { Octokit } from ".";
|
4 |
+
export type RequestParameters = OctokitTypes.RequestParameters;
|
5 |
+
export interface OctokitOptions {
|
6 |
+
authStrategy?: any;
|
7 |
+
auth?: any;
|
8 |
+
userAgent?: string;
|
9 |
+
previews?: string[];
|
10 |
+
baseUrl?: string;
|
11 |
+
log?: {
|
12 |
+
debug: (message: string) => unknown;
|
13 |
+
info: (message: string) => unknown;
|
14 |
+
warn: (message: string) => unknown;
|
15 |
+
error: (message: string) => unknown;
|
16 |
+
};
|
17 |
+
request?: OctokitTypes.RequestRequestOptions;
|
18 |
+
timeZone?: string;
|
19 |
+
[option: string]: any;
|
20 |
+
}
|
21 |
+
export type Constructor<T> = new (...args: any[]) => T;
|
22 |
+
export type ReturnTypeOf<T extends AnyFunction | AnyFunction[]> = T extends AnyFunction ? ReturnType<T> : T extends AnyFunction[] ? UnionToIntersection<Exclude<ReturnType<T[number]>, void>> : never;
|
23 |
+
/**
|
24 |
+
* @author https://stackoverflow.com/users/2887218/jcalz
|
25 |
+
* @see https://stackoverflow.com/a/50375286/10325032
|
26 |
+
*/
|
27 |
+
export type UnionToIntersection<Union> = (Union extends any ? (argument: Union) => void : never) extends (argument: infer Intersection) => void ? Intersection : never;
|
28 |
+
type AnyFunction = (...args: any) => any;
|
29 |
+
export type OctokitPlugin = (octokit: Octokit, options: OctokitOptions) => {
|
30 |
+
[key: string]: any;
|
31 |
+
} | void;
|
32 |
+
export type Hooks = {
|
33 |
+
request: {
|
34 |
+
Options: Required<OctokitTypes.EndpointDefaults>;
|
35 |
+
Result: OctokitTypes.OctokitResponse<any>;
|
36 |
+
Error: RequestError | Error;
|
37 |
+
};
|
38 |
+
[key: string]: {
|
39 |
+
Options: unknown;
|
40 |
+
Result: unknown;
|
41 |
+
Error: unknown;
|
42 |
+
};
|
43 |
+
};
|
44 |
+
export {};
|
node_modules/@octokit/core/dist-types/version.d.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export declare const VERSION = "5.0.1";
|
node_modules/@octokit/core/dist-web/index.js
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// pkg/dist-src/index.js
|
2 |
+
import { getUserAgent } from "universal-user-agent";
|
3 |
+
import { Collection } from "before-after-hook";
|
4 |
+
import { request } from "@octokit/request";
|
5 |
+
import { graphql, withCustomRequest } from "@octokit/graphql";
|
6 |
+
import { createTokenAuth } from "@octokit/auth-token";
|
7 |
+
|
8 |
+
// pkg/dist-src/version.js
|
9 |
+
var VERSION = "5.0.1";
|
10 |
+
|
11 |
+
// pkg/dist-src/index.js
|
12 |
+
var Octokit = class {
|
13 |
+
static {
|
14 |
+
this.VERSION = VERSION;
|
15 |
+
}
|
16 |
+
static defaults(defaults) {
|
17 |
+
const OctokitWithDefaults = class extends this {
|
18 |
+
constructor(...args) {
|
19 |
+
const options = args[0] || {};
|
20 |
+
if (typeof defaults === "function") {
|
21 |
+
super(defaults(options));
|
22 |
+
return;
|
23 |
+
}
|
24 |
+
super(
|
25 |
+
Object.assign(
|
26 |
+
{},
|
27 |
+
defaults,
|
28 |
+
options,
|
29 |
+
options.userAgent && defaults.userAgent ? {
|
30 |
+
userAgent: `${options.userAgent} ${defaults.userAgent}`
|
31 |
+
} : null
|
32 |
+
)
|
33 |
+
);
|
34 |
+
}
|
35 |
+
};
|
36 |
+
return OctokitWithDefaults;
|
37 |
+
}
|
38 |
+
static {
|
39 |
+
this.plugins = [];
|
40 |
+
}
|
41 |
+
/**
|
42 |
+
* Attach a plugin (or many) to your Octokit instance.
|
43 |
+
*
|
44 |
+
* @example
|
45 |
+
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
46 |
+
*/
|
47 |
+
static plugin(...newPlugins) {
|
48 |
+
const currentPlugins = this.plugins;
|
49 |
+
const NewOctokit = class extends this {
|
50 |
+
static {
|
51 |
+
this.plugins = currentPlugins.concat(
|
52 |
+
newPlugins.filter((plugin) => !currentPlugins.includes(plugin))
|
53 |
+
);
|
54 |
+
}
|
55 |
+
};
|
56 |
+
return NewOctokit;
|
57 |
+
}
|
58 |
+
constructor(options = {}) {
|
59 |
+
const hook = new Collection();
|
60 |
+
const requestDefaults = {
|
61 |
+
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
62 |
+
headers: {},
|
63 |
+
request: Object.assign({}, options.request, {
|
64 |
+
// @ts-ignore internal usage only, no need to type
|
65 |
+
hook: hook.bind(null, "request")
|
66 |
+
}),
|
67 |
+
mediaType: {
|
68 |
+
previews: [],
|
69 |
+
format: ""
|
70 |
+
}
|
71 |
+
};
|
72 |
+
requestDefaults.headers["user-agent"] = [
|
73 |
+
options.userAgent,
|
74 |
+
`octokit-core.js/${VERSION} ${getUserAgent()}`
|
75 |
+
].filter(Boolean).join(" ");
|
76 |
+
if (options.baseUrl) {
|
77 |
+
requestDefaults.baseUrl = options.baseUrl;
|
78 |
+
}
|
79 |
+
if (options.previews) {
|
80 |
+
requestDefaults.mediaType.previews = options.previews;
|
81 |
+
}
|
82 |
+
if (options.timeZone) {
|
83 |
+
requestDefaults.headers["time-zone"] = options.timeZone;
|
84 |
+
}
|
85 |
+
this.request = request.defaults(requestDefaults);
|
86 |
+
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
87 |
+
this.log = Object.assign(
|
88 |
+
{
|
89 |
+
debug: () => {
|
90 |
+
},
|
91 |
+
info: () => {
|
92 |
+
},
|
93 |
+
warn: console.warn.bind(console),
|
94 |
+
error: console.error.bind(console)
|
95 |
+
},
|
96 |
+
options.log
|
97 |
+
);
|
98 |
+
this.hook = hook;
|
99 |
+
if (!options.authStrategy) {
|
100 |
+
if (!options.auth) {
|
101 |
+
this.auth = async () => ({
|
102 |
+
type: "unauthenticated"
|
103 |
+
});
|
104 |
+
} else {
|
105 |
+
const auth = createTokenAuth(options.auth);
|
106 |
+
hook.wrap("request", auth.hook);
|
107 |
+
this.auth = auth;
|
108 |
+
}
|
109 |
+
} else {
|
110 |
+
const { authStrategy, ...otherOptions } = options;
|
111 |
+
const auth = authStrategy(
|
112 |
+
Object.assign(
|
113 |
+
{
|
114 |
+
request: this.request,
|
115 |
+
log: this.log,
|
116 |
+
// we pass the current octokit instance as well as its constructor options
|
117 |
+
// to allow for authentication strategies that return a new octokit instance
|
118 |
+
// that shares the same internal state as the current one. The original
|
119 |
+
// requirement for this was the "event-octokit" authentication strategy
|
120 |
+
// of https://github.com/probot/octokit-auth-probot.
|
121 |
+
octokit: this,
|
122 |
+
octokitOptions: otherOptions
|
123 |
+
},
|
124 |
+
options.auth
|
125 |
+
)
|
126 |
+
);
|
127 |
+
hook.wrap("request", auth.hook);
|
128 |
+
this.auth = auth;
|
129 |
+
}
|
130 |
+
const classConstructor = this.constructor;
|
131 |
+
classConstructor.plugins.forEach((plugin) => {
|
132 |
+
Object.assign(this, plugin(this, options));
|
133 |
+
});
|
134 |
+
}
|
135 |
+
};
|
136 |
+
export {
|
137 |
+
Octokit
|
138 |
+
};
|
node_modules/@octokit/core/dist-web/index.js.map
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"version": 3,
|
3 |
+
"sources": ["../dist-src/index.js", "../dist-src/version.js"],
|
4 |
+
"sourcesContent": ["import { getUserAgent } from \"universal-user-agent\";\nimport { Collection } from \"before-after-hook\";\nimport { request } from \"@octokit/request\";\nimport { graphql, withCustomRequest } from \"@octokit/graphql\";\nimport { createTokenAuth } from \"@octokit/auth-token\";\nimport { VERSION } from \"./version\";\nclass Octokit {\n static {\n this.VERSION = VERSION;\n }\n static defaults(defaults) {\n const OctokitWithDefaults = class extends this {\n constructor(...args) {\n const options = args[0] || {};\n if (typeof defaults === \"function\") {\n super(defaults(options));\n return;\n }\n super(\n Object.assign(\n {},\n defaults,\n options,\n options.userAgent && defaults.userAgent ? {\n userAgent: `${options.userAgent} ${defaults.userAgent}`\n } : null\n )\n );\n }\n };\n return OctokitWithDefaults;\n }\n static {\n this.plugins = [];\n }\n /**\n * Attach a plugin (or many) to your Octokit instance.\n *\n * @example\n * const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)\n */\n static plugin(...newPlugins) {\n const currentPlugins = this.plugins;\n const NewOctokit = class extends this {\n static {\n this.plugins = currentPlugins.concat(\n newPlugins.filter((plugin) => !currentPlugins.includes(plugin))\n );\n }\n };\n return NewOctokit;\n }\n constructor(options = {}) {\n const hook = new Collection();\n const requestDefaults = {\n baseUrl: request.endpoint.DEFAULTS.baseUrl,\n headers: {},\n request: Object.assign({}, options.request, {\n // @ts-ignore internal usage only, no need to type\n hook: hook.bind(null, \"request\")\n }),\n mediaType: {\n previews: [],\n format: \"\"\n }\n };\n requestDefaults.headers[\"user-agent\"] = [\n options.userAgent,\n `octokit-core.js/${VERSION} ${getUserAgent()}`\n ].filter(Boolean).join(\" \");\n if (options.baseUrl) {\n requestDefaults.baseUrl = options.baseUrl;\n }\n if (options.previews) {\n requestDefaults.mediaType.previews = options.previews;\n }\n if (options.timeZone) {\n requestDefaults.headers[\"time-zone\"] = options.timeZone;\n }\n this.request = request.defaults(requestDefaults);\n this.graphql = withCustomRequest(this.request).defaults(requestDefaults);\n this.log = Object.assign(\n {\n debug: () => {\n },\n info: () => {\n },\n warn: console.warn.bind(console),\n error: console.error.bind(console)\n },\n options.log\n );\n this.hook = hook;\n if (!options.authStrategy) {\n if (!options.auth) {\n this.auth = async () => ({\n type: \"unauthenticated\"\n });\n } else {\n const auth = createTokenAuth(options.auth);\n hook.wrap(\"request\", auth.hook);\n this.auth = auth;\n }\n } else {\n const { authStrategy, ...otherOptions } = options;\n const auth = authStrategy(\n Object.assign(\n {\n request: this.request,\n log: this.log,\n // we pass the current octokit instance as well as its constructor options\n // to allow for authentication strategies that return a new octokit instance\n // that shares the same internal state as the current one. The original\n // requirement for this was the \"event-octokit\" authentication strategy\n // of https://github.com/probot/octokit-auth-probot.\n octokit: this,\n octokitOptions: otherOptions\n },\n options.auth\n )\n );\n hook.wrap(\"request\", auth.hook);\n this.auth = auth;\n }\n const classConstructor = this.constructor;\n classConstructor.plugins.forEach((plugin) => {\n Object.assign(this, plugin(this, options));\n });\n }\n}\nexport {\n Octokit\n};\n", "const VERSION = \"5.0.1\";\nexport {\n VERSION\n};\n"],
|
5 |
+
"mappings": ";AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,SAAS,yBAAyB;AAC3C,SAAS,uBAAuB;;;ACJhC,IAAM,UAAU;;;ADMhB,IAAM,UAAN,MAAc;AAAA,EACZ,OAAO;AACL,SAAK,UAAU;AAAA,EACjB;AAAA,EACA,OAAO,SAAS,UAAU;AACxB,UAAM,sBAAsB,cAAc,KAAK;AAAA,MAC7C,eAAe,MAAM;AACnB,cAAM,UAAU,KAAK,CAAC,KAAK,CAAC;AAC5B,YAAI,OAAO,aAAa,YAAY;AAClC,gBAAM,SAAS,OAAO,CAAC;AACvB;AAAA,QACF;AACA;AAAA,UACE,OAAO;AAAA,YACL,CAAC;AAAA,YACD;AAAA,YACA;AAAA,YACA,QAAQ,aAAa,SAAS,YAAY;AAAA,cACxC,WAAW,GAAG,QAAQ,SAAS,IAAI,SAAS,SAAS;AAAA,YACvD,IAAI;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EACA,OAAO;AACL,SAAK,UAAU,CAAC;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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|
+
"publishConfig": {
|
5 |
+
"access": "public"
|
6 |
+
},
|
7 |
+
"description": "Extendable client for GitHub's REST & GraphQL APIs",
|
8 |
+
"repository": "github:octokit/core.js",
|
9 |
+
"keywords": [
|
10 |
+
"octokit",
|
11 |
+
"github",
|
12 |
+
"api",
|
13 |
+
"sdk",
|
14 |
+
"toolkit"
|
15 |
+
],
|
16 |
+
"author": "Gregor Martynus (https://github.com/gr2m)",
|
17 |
+
"license": "MIT",
|
18 |
+
"dependencies": {
|
19 |
+
"@octokit/auth-token": "^4.0.0",
|
20 |
+
"@octokit/graphql": "^7.0.0",
|
21 |
+
"@octokit/request": "^8.0.2",
|
22 |
+
"@octokit/request-error": "^5.0.0",
|
23 |
+
"@octokit/types": "^12.0.0",
|
24 |
+
"before-after-hook": "^2.2.0",
|
25 |
+
"universal-user-agent": "^6.0.0"
|
26 |
+
},
|
27 |
+
"devDependencies": {
|
28 |
+
"@octokit/auth-action": "^4.0.0",
|
29 |
+
"@octokit/auth-app": "^6.0.0",
|
30 |
+
"@octokit/auth-oauth-app": "^7.0.0",
|
31 |
+
"@octokit/tsconfig": "^2.0.0",
|
32 |
+
"@types/fetch-mock": "^7.3.1",
|
33 |
+
"@types/jest": "^29.0.0",
|
34 |
+
"@types/lolex": "^5.1.0",
|
35 |
+
"@types/node": "^18.0.0",
|
36 |
+
"esbuild": "^0.19.0",
|
37 |
+
"fetch-mock": "npm:@gr2m/[email protected]",
|
38 |
+
"glob": "^10.2.5",
|
39 |
+
"http-proxy-agent": "^7.0.0",
|
40 |
+
"jest": "^29.0.0",
|
41 |
+
"lolex": "^6.0.0",
|
42 |
+
"prettier": "3.0.3",
|
43 |
+
"proxy": "^2.0.0",
|
44 |
+
"semantic-release": "^22.0.0",
|
45 |
+
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
46 |
+
"ts-jest": "^29.0.0",
|
47 |
+
"typescript": "^5.0.0",
|
48 |
+
"undici": "5.25.2"
|
49 |
+
},
|
50 |
+
"engines": {
|
51 |
+
"node": ">= 18"
|
52 |
+
},
|
53 |
+
"files": [
|
54 |
+
"dist-*/**",
|
55 |
+
"bin/**"
|
56 |
+
],
|
57 |
+
"main": "dist-node/index.js",
|
58 |
+
"module": "dist-web/index.js",
|
59 |
+
"types": "dist-types/index.d.ts",
|
60 |
+
"source": "dist-src/index.js",
|
61 |
+
"sideEffects": false
|
62 |
+
}
|
node_modules/@octokit/endpoint/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2018 Octokit contributors
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in
|
13 |
+
all copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 |
+
THE SOFTWARE.
|
node_modules/@octokit/endp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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# endpoint.js
|
2 |
+
|
3 |
+
> Turns GitHub REST API endpoints into generic request options
|
4 |
+
|
5 |
+
[](https://www.npmjs.com/package/@octokit/endpoint)
|
6 |
+
[](https://github.com/octokit/endpoint.js/actions/workflows/test.yml?query=branch%3Amain)
|
7 |
+
|
8 |
+
`@octokit/endpoint` combines [GitHub REST API routes](https://developer.github.com/v3/) with your parameters and turns them into generic request options that can be used in any request library.
|
9 |
+
|
10 |
+
<!-- update table of contents by running `npx markdown-toc README.md -i` -->
|
11 |
+
|
12 |
+
<!-- toc -->
|
13 |
+
|
14 |
+
- [Usage](#usage)
|
15 |
+
- [API](#api)
|
16 |
+
- [`endpoint(route, options)` or `endpoint(options)`](#endpointroute-options-or-endpointoptions)
|
17 |
+
- [`endpoint.defaults()`](#endpointdefaults)
|
18 |
+
- [`endpoint.DEFAULTS`](#endpointdefaults)
|
19 |
+
- [`endpoint.merge(route, options)` or `endpoint.merge(options)`](#endpointmergeroute-options-or-endpointmergeoptions)
|
20 |
+
- [`endpoint.parse()`](#endpointparse)
|
21 |
+
- [Special cases](#special-cases)
|
22 |
+
- [The `data` parameter – set request body directly](#the-data-parameter-%E2%80%93-set-request-body-directly)
|
23 |
+
- [Set parameters for both the URL/query and the request body](#set-parameters-for-both-the-urlquery-and-the-request-body)
|
24 |
+
- [LICENSE](#license)
|
25 |
+
|
26 |
+
<!-- tocstop -->
|
27 |
+
|
28 |
+
## Usage
|
29 |
+
|
30 |
+
<table>
|
31 |
+
<tbody valign=top align=left>
|
32 |
+
<tr><th>
|
33 |
+
Browsers
|
34 |
+
</th><td width=100%>
|
35 |
+
Load <code>@octokit/endpoint</code> directly from <a href="https://esm.sh">esm.sh</a>
|
36 |
+
|
37 |
+
```html
|
38 |
+
<script type="module">
|
39 |
+
import { endpoint } from "https://esm.sh/@octokit/endpoint";
|
40 |
+
</script>
|
41 |
+
```
|
42 |
+
|
43 |
+
</td></tr>
|
44 |
+
<tr><th>
|
45 |
+
Node
|
46 |
+
</th><td>
|
47 |
+
|
48 |
+
Install with <code>npm install @octokit/endpoint</code>
|
49 |
+
|
50 |
+
```js
|
51 |
+
const { endpoint } = require("@octokit/endpoint");
|
52 |
+
// or: import { endpoint } from "@octokit/endpoint";
|
53 |
+
```
|
54 |
+
|
55 |
+
</td></tr>
|
56 |
+
</tbody>
|
57 |
+
</table>
|
58 |
+
|
59 |
+
Example for [List organization repositories](https://developer.github.com/v3/repos/#list-organization-repositories)
|
60 |
+
|
61 |
+
```js
|
62 |
+
const requestOptions = endpoint("GET /orgs/{org}/repos", {
|
63 |
+
headers: {
|
64 |
+
authorization: "token 0000000000000000000000000000000000000001",
|
65 |
+
},
|
66 |
+
org: "octokit",
|
67 |
+
type: "private",
|
68 |
+
});
|
69 |
+
```
|
70 |
+
|
71 |
+
The resulting `requestOptions` looks as follows
|
72 |
+
|
73 |
+
```json
|
74 |
+
{
|
75 |
+
"method": "GET",
|
76 |
+
"url": "https://api.github.com/orgs/octokit/repos?type=private",
|
77 |
+
"headers": {
|
78 |
+
"accept": "application/vnd.github.v3+json",
|
79 |
+
"authorization": "token 0000000000000000000000000000000000000001",
|
80 |
+
"user-agent": "octokit/endpoint.js v1.2.3"
|
81 |
+
}
|
82 |
+
}
|
83 |
+
```
|
84 |
+
|
85 |
+
You can pass `requestOptions` to common request libraries
|
86 |
+
|
87 |
+
```js
|
88 |
+
const { url, ...options } = requestOptions;
|
89 |
+
// using with fetch (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
90 |
+
fetch(url, options);
|
91 |
+
// using with request (https://github.com/request/request)
|
92 |
+
request(requestOptions);
|
93 |
+
// using with got (https://github.com/sindresorhus/got)
|
94 |
+
got[options.method](url, options);
|
95 |
+
// using with axios
|
96 |
+
axios(requestOptions);
|
97 |
+
```
|
98 |
+
|
99 |
+
## API
|
100 |
+
|
101 |
+
### `endpoint(route, options)` or `endpoint(options)`
|
102 |
+
|
103 |
+
<table>
|
104 |
+
<thead align=left>
|
105 |
+
<tr>
|
106 |
+
<th>
|
107 |
+
name
|
108 |
+
</th>
|
109 |
+
<th>
|
110 |
+
type
|
111 |
+
</th>
|
112 |
+
<th width=100%>
|
113 |
+
description
|
114 |
+
</th>
|
115 |
+
</tr>
|
116 |
+
</thead>
|
117 |
+
<tbody align=left valign=top>
|
118 |
+
<tr>
|
119 |
+
<th>
|
120 |
+
<code>route</code>
|
121 |
+
</th>
|
122 |
+
<td>
|
123 |
+
String
|
124 |
+
</td>
|
125 |
+
<td>
|
126 |
+
If set, it has to be a string consisting of URL and the request method, e.g., <code>GET /orgs/{org}</code>. If it’s set to a URL, only the method defaults to <code>GET</code>.
|
127 |
+
</td>
|
128 |
+
</tr>
|
129 |
+
<tr>
|
130 |
+
<th>
|
131 |
+
<code>options.method</code>
|
132 |
+
</th>
|
133 |
+
<td>
|
134 |
+
String
|
135 |
+
</td>
|
136 |
+
<td>
|
137 |
+
<strong>Required unless <code>route</code> is set.</strong> Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>. <em>Defaults to <code>GET</code></em>.
|
138 |
+
</td>
|
139 |
+
</tr>
|
140 |
+
<tr>
|
141 |
+
<th>
|
142 |
+
<code>options.url</code>
|
143 |
+
</th>
|
144 |
+
<td>
|
145 |
+
String
|
146 |
+
</td>
|
147 |
+
<td>
|
148 |
+
<strong>Required unless <code>route</code> is set.</strong> A path or full URL which may contain <code>:variable</code> or <code>{variable}</code> placeholders,
|
149 |
+
e.g., <code>/orgs/{org}/repos</code>. The <code>url</code> is parsed using <a href="https://github.com/bramstein/url-template">url-template</a>.
|
150 |
+
</td>
|
151 |
+
</tr>
|
152 |
+
<tr>
|
153 |
+
<th>
|
154 |
+
<code>options.baseUrl</code>
|
155 |
+
</th>
|
156 |
+
<td>
|
157 |
+
String
|
158 |
+
</td>
|
159 |
+
<td>
|
160 |
+
<em>Defaults to <code>https://api.github.com</code></em>.
|
161 |
+
</td>
|
162 |
+
</tr>
|
163 |
+
<tr>
|
164 |
+
<th>
|
165 |
+
<code>options.headers</code>
|
166 |
+
</th>
|
167 |
+
<td>
|
168 |
+
Object
|
169 |
+
</td>
|
170 |
+
<td>
|
171 |
+
Custom headers. Passed headers are merged with defaults:<br>
|
172 |
+
<em><code>headers['user-agent']</code> defaults to <code>octokit-endpoint.js/1.2.3</code> (where <code>1.2.3</code> is the released version)</em>.<br>
|
173 |
+
<em><code>headers['accept']</code> defaults to <code>application/vnd.github.v3+json</code></em>.<br>
|
174 |
+
</td>
|
175 |
+
</tr>
|
176 |
+
<tr>
|
177 |
+
<th>
|
178 |
+
<code>options.mediaType.format</code>
|
179 |
+
</th>
|
180 |
+
<td>
|
181 |
+
String
|
182 |
+
</td>
|
183 |
+
<td>
|
184 |
+
Media type param, such as <code>raw</code>, <code>diff</code>, or <code>text+json</code>. See <a href="https://developer.github.com/v3/media/">Media Types</a>. Setting <code>options.mediaType.format</code> will amend the <code>headers.accept</code> value.
|
185 |
+
</td>
|
186 |
+
</tr>
|
187 |
+
<tr>
|
188 |
+
<th>
|
189 |
+
<code>options.data</code>
|
190 |
+
</th>
|
191 |
+
<td>
|
192 |
+
Any
|
193 |
+
</td>
|
194 |
+
<td>
|
195 |
+
Set request body directly instead of setting it to JSON based on additional parameters. See <a href="#data-parameter">"The <code>data</code> parameter"</a> below.
|
196 |
+
</td>
|
197 |
+
</tr>
|
198 |
+
<tr>
|
199 |
+
<th>
|
200 |
+
<code>options.request</code>
|
201 |
+
</th>
|
202 |
+
<td>
|
203 |
+
Object
|
204 |
+
</td>
|
205 |
+
<td>
|
206 |
+
Pass custom meta information for the request. The <code>request</code> object will be returned as is.
|
207 |
+
</td>
|
208 |
+
</tr>
|
209 |
+
</tbody>
|
210 |
+
</table>
|
211 |
+
|
212 |
+
All other options will be passed depending on the `method` and `url` options.
|
213 |
+
|
214 |
+
1. If the option key has a placeholder in the `url`, it will be used as the replacement. For example, if the passed options are `{url: '/orgs/{org}/repos', org: 'foo'}` the returned `options.url` is `https://api.github.com/orgs/foo/repos`.
|
215 |
+
2. If the `method` is `GET` or `HEAD`, the option is passed as a query parameter.
|
216 |
+
3. Otherwise, the parameter is passed in the request body as a JSON key.
|
217 |
+
|
218 |
+
**Result**
|
219 |
+
|
220 |
+
`endpoint()` is a synchronous method and returns an object with the following keys:
|
221 |
+
|
222 |
+
<table>
|
223 |
+
<thead align=left>
|
224 |
+
<tr>
|
225 |
+
<th>
|
226 |
+
key
|
227 |
+
</th>
|
228 |
+
<th>
|
229 |
+
type
|
230 |
+
</th>
|
231 |
+
<th width=100%>
|
232 |
+
description
|
233 |
+
</th>
|
234 |
+
</tr>
|
235 |
+
</thead>
|
236 |
+
<tbody align=left valign=top>
|
237 |
+
<tr>
|
238 |
+
<th><code>method</code></th>
|
239 |
+
<td>String</td>
|
240 |
+
<td>The http method. Always lowercase.</td>
|
241 |
+
</tr>
|
242 |
+
<tr>
|
243 |
+
<th><code>url</code></th>
|
244 |
+
<td>String</td>
|
245 |
+
<td>The url with placeholders replaced with passed parameters.</td>
|
246 |
+
</tr>
|
247 |
+
<tr>
|
248 |
+
<th><code>headers</code></th>
|
249 |
+
<td>Object</td>
|
250 |
+
<td>All header names are lowercased.</td>
|
251 |
+
</tr>
|
252 |
+
<tr>
|
253 |
+
<th><code>body</code></th>
|
254 |
+
<td>Any</td>
|
255 |
+
<td>The request body if one is present. Only for <code>PATCH</code>, <code>POST</code>, <code>PUT</code>, <code>DELETE</code> requests.</td>
|
256 |
+
</tr>
|
257 |
+
<tr>
|
258 |
+
<th><code>request</code></th>
|
259 |
+
<td>Object</td>
|
260 |
+
<td>Request meta option, it will be returned as it was passed into <code>endpoint()</code></td>
|
261 |
+
</tr>
|
262 |
+
</tbody>
|
263 |
+
</table>
|
264 |
+
|
265 |
+
### `endpoint.defaults()`
|
266 |
+
|
267 |
+
Override or set default options. Example:
|
268 |
+
|
269 |
+
```js
|
270 |
+
const request = require("request");
|
271 |
+
const myEndpoint = require("@octokit/endpoint").defaults({
|
272 |
+
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
273 |
+
headers: {
|
274 |
+
"user-agent": "myApp/1.2.3",
|
275 |
+
authorization: `token 0000000000000000000000000000000000000001`,
|
276 |
+
},
|
277 |
+
org: "my-project",
|
278 |
+
per_page: 100,
|
279 |
+
});
|
280 |
+
|
281 |
+
request(myEndpoint(`GET /orgs/{org}/repos`));
|
282 |
+
```
|
283 |
+
|
284 |
+
You can call `.defaults()` again on the returned method, the defaults will cascade.
|
285 |
+
|
286 |
+
```js
|
287 |
+
const myProjectEndpoint = endpoint.defaults({
|
288 |
+
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
289 |
+
headers: {
|
290 |
+
"user-agent": "myApp/1.2.3",
|
291 |
+
},
|
292 |
+
org: "my-project",
|
293 |
+
});
|
294 |
+
const myProjectEndpointWithAuth = myProjectEndpoint.defaults({
|
295 |
+
headers: {
|
296 |
+
authorization: `token 0000000000000000000000000000000000000001`,
|
297 |
+
},
|
298 |
+
});
|
299 |
+
```
|
300 |
+
|
301 |
+
`myProjectEndpointWithAuth` now defaults the `baseUrl`, `headers['user-agent']`,
|
302 |
+
`org` and `headers['authorization']` on top of `headers['accept']` that is set
|
303 |
+
by the global default.
|
304 |
+
|
305 |
+
### `endpoint.DEFAULTS`
|
306 |
+
|
307 |
+
The current default options.
|
308 |
+
|
309 |
+
```js
|
310 |
+
endpoint.DEFAULTS.baseUrl; // https://api.github.com
|
311 |
+
const myEndpoint = endpoint.defaults({
|
312 |
+
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
313 |
+
});
|
314 |
+
myEndpoint.DEFAULTS.baseUrl; // https://github-enterprise.acme-inc.com/api/v3
|
315 |
+
```
|
316 |
+
|
317 |
+
### `endpoint.merge(route, options)` or `endpoint.merge(options)`
|
318 |
+
|
319 |
+
Get the defaulted endpoint options, but without parsing them into request options:
|
320 |
+
|
321 |
+
```js
|
322 |
+
const myProjectEndpoint = endpoint.defaults({
|
323 |
+
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
324 |
+
headers: {
|
325 |
+
"user-agent": "myApp/1.2.3",
|
326 |
+
},
|
327 |
+
org: "my-project",
|
328 |
+
});
|
329 |
+
myProjectEndpoint.merge("GET /orgs/{org}/repos", {
|
330 |
+
headers: {
|
331 |
+
authorization: `token 0000000000000000000000000000000000000001`,
|
332 |
+
},
|
333 |
+
org: "my-secret-project",
|
334 |
+
type: "private",
|
335 |
+
});
|
336 |
+
|
337 |
+
// {
|
338 |
+
// baseUrl: 'https://github-enterprise.acme-inc.com/api/v3',
|
339 |
+
// method: 'GET',
|
340 |
+
// url: '/orgs/{org}/repos',
|
341 |
+
// headers: {
|
342 |
+
// accept: 'application/vnd.github.v3+json',
|
343 |
+
// authorization: `token 0000000000000000000000000000000000000001`,
|
344 |
+
// 'user-agent': 'myApp/1.2.3'
|
345 |
+
// },
|
346 |
+
// org: 'my-secret-project',
|
347 |
+
// type: 'private'
|
348 |
+
// }
|
349 |
+
```
|
350 |
+
|
351 |
+
### `endpoint.parse()`
|
352 |
+
|
353 |
+
Stateless method to turn endpoint options into request options. Calling
|
354 |
+
`endpoint(options)` is the same as calling `endpoint.parse(endpoint.merge(options))`.
|
355 |
+
|
356 |
+
## Special cases
|
357 |
+
|
358 |
+
<a name="data-parameter"></a>
|
359 |
+
|
360 |
+
### The `data` parameter – set request body directly
|
361 |
+
|
362 |
+
Some endpoints such as [Render a Markdown document in raw mode](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode) don’t have parameters that are sent as request body keys, instead, the request body needs to be set directly. In these cases, set the `data` parameter.
|
363 |
+
|
364 |
+
```js
|
365 |
+
const options = endpoint("POST /markdown/raw", {
|
366 |
+
data: "Hello world github/linguist#1 **cool**, and #1!",
|
367 |
+
headers: {
|
368 |
+
accept: "text/html;charset=utf-8",
|
369 |
+
"content-type": "text/plain",
|
370 |
+
},
|
371 |
+
});
|
372 |
+
|
373 |
+
// options is
|
374 |
+
// {
|
375 |
+
// method: 'post',
|
376 |
+
// url: 'https://api.github.com/markdown/raw',
|
377 |
+
// headers: {
|
378 |
+
// accept: 'text/html;charset=utf-8',
|
379 |
+
// 'content-type': 'text/plain',
|
380 |
+
// 'user-agent': userAgent
|
381 |
+
// },
|
382 |
+
// body: 'Hello world github/linguist#1 **cool**, and #1!'
|
383 |
+
// }
|
384 |
+
```
|
385 |
+
|
386 |
+
### Set parameters for both the URL/query and the request body
|
387 |
+
|
388 |
+
There are API endpoints that accept both query parameters as well as a body. In that case, you need to add the query parameters as templates to `options.url`, as defined in the [RFC 6570 URI Template specification](https://tools.ietf.org/html/rfc6570).
|
389 |
+
|
390 |
+
Example
|
391 |
+
|
392 |
+
```js
|
393 |
+
endpoint(
|
394 |
+
"POST https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}",
|
395 |
+
{
|
396 |
+
name: "example.zip",
|
397 |
+
label: "short description",
|
398 |
+
headers: {
|
399 |
+
"content-type": "text/plain",
|
400 |
+
"content-length": 14,
|
401 |
+
authorization: `token 0000000000000000000000000000000000000001`,
|
402 |
+
},
|
403 |
+
data: "Hello, world!",
|
404 |
+
},
|
405 |
+
);
|
406 |
+
```
|
407 |
+
|
408 |
+
## LICENSE
|
409 |
+
|
410 |
+
[MIT](LICENSE)
|
node_modules/@octokit/endpoint/dist-node/index.js
ADDED
@@ -0,0 +1,358 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
var __defProp = Object.defineProperty;
|
3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6 |
+
var __export = (target, all) => {
|
7 |
+
for (var name in all)
|
8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9 |
+
};
|
10 |
+
var __copyProps = (to, from, except, desc) => {
|
11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
12 |
+
for (let key of __getOwnPropNames(from))
|
13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15 |
+
}
|
16 |
+
return to;
|
17 |
+
};
|
18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19 |
+
|
20 |
+
// pkg/dist-src/index.js
|
21 |
+
var dist_src_exports = {};
|
22 |
+
__export(dist_src_exports, {
|
23 |
+
endpoint: () => endpoint
|
24 |
+
});
|
25 |
+
module.exports = __toCommonJS(dist_src_exports);
|
26 |
+
|
27 |
+
// pkg/dist-src/defaults.js
|
28 |
+
var import_universal_user_agent = require("universal-user-agent");
|
29 |
+
|
30 |
+
// pkg/dist-src/version.js
|
31 |
+
var VERSION = "9.0.1";
|
32 |
+
|
33 |
+
// pkg/dist-src/defaults.js
|
34 |
+
var userAgent = `octokit-endpoint.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`;
|
35 |
+
var DEFAULTS = {
|
36 |
+
method: "GET",
|
37 |
+
baseUrl: "https://api.github.com",
|
38 |
+
headers: {
|
39 |
+
accept: "application/vnd.github.v3+json",
|
40 |
+
"user-agent": userAgent
|
41 |
+
},
|
42 |
+
mediaType: {
|
43 |
+
format: ""
|
44 |
+
}
|
45 |
+
};
|
46 |
+
|
47 |
+
// pkg/dist-src/util/lowercase-keys.js
|
48 |
+
function lowercaseKeys(object) {
|
49 |
+
if (!object) {
|
50 |
+
return {};
|
51 |
+
}
|
52 |
+
return Object.keys(object).reduce((newObj, key) => {
|
53 |
+
newObj[key.toLowerCase()] = object[key];
|
54 |
+
return newObj;
|
55 |
+
}, {});
|
56 |
+
}
|
57 |
+
|
58 |
+
// pkg/dist-src/util/merge-deep.js
|
59 |
+
var import_is_plain_object = require("is-plain-object");
|
60 |
+
function mergeDeep(defaults, options) {
|
61 |
+
const result = Object.assign({}, defaults);
|
62 |
+
Object.keys(options).forEach((key) => {
|
63 |
+
if ((0, import_is_plain_object.isPlainObject)(options[key])) {
|
64 |
+
if (!(key in defaults))
|
65 |
+
Object.assign(result, { [key]: options[key] });
|
66 |
+
else
|
67 |
+
result[key] = mergeDeep(defaults[key], options[key]);
|
68 |
+
} else {
|
69 |
+
Object.assign(result, { [key]: options[key] });
|
70 |
+
}
|
71 |
+
});
|
72 |
+
return result;
|
73 |
+
}
|
74 |
+
|
75 |
+
// pkg/dist-src/util/remove-undefined-properties.js
|
76 |
+
function removeUndefinedProperties(obj) {
|
77 |
+
for (const key in obj) {
|
78 |
+
if (obj[key] === void 0) {
|
79 |
+
delete obj[key];
|
80 |
+
}
|
81 |
+
}
|
82 |
+
return obj;
|
83 |
+
}
|
84 |
+
|
85 |
+
// pkg/dist-src/merge.js
|
86 |
+
function merge(defaults, route, options) {
|
87 |
+
if (typeof route === "string") {
|
88 |
+
let [method, url] = route.split(" ");
|
89 |
+
options = Object.assign(url ? { method, url } : { url: method }, options);
|
90 |
+
} else {
|
91 |
+
options = Object.assign({}, route);
|
92 |
+
}
|
93 |
+
options.headers = lowercaseKeys(options.headers);
|
94 |
+
removeUndefinedProperties(options);
|
95 |
+
removeUndefinedProperties(options.headers);
|
96 |
+
const mergedOptions = mergeDeep(defaults || {}, options);
|
97 |
+
if (options.url === "/graphql") {
|
98 |
+
if (defaults && defaults.mediaType.previews?.length) {
|
99 |
+
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(
|
100 |
+
(preview) => !mergedOptions.mediaType.previews.includes(preview)
|
101 |
+
).concat(mergedOptions.mediaType.previews);
|
102 |
+
}
|
103 |
+
mergedOptions.mediaType.previews = (mergedOptions.mediaType.previews || []).map((preview) => preview.replace(/-preview/, ""));
|
104 |
+
}
|
105 |
+
return mergedOptions;
|
106 |
+
}
|
107 |
+
|
108 |
+
// pkg/dist-src/util/add-query-parameters.js
|
109 |
+
function addQueryParameters(url, parameters) {
|
110 |
+
const separator = /\?/.test(url) ? "&" : "?";
|
111 |
+
const names = Object.keys(parameters);
|
112 |
+
if (names.length === 0) {
|
113 |
+
return url;
|
114 |
+
}
|
115 |
+
return url + separator + names.map((name) => {
|
116 |
+
if (name === "q") {
|
117 |
+
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
|
118 |
+
}
|
119 |
+
return `${name}=${encodeURIComponent(parameters[name])}`;
|
120 |
+
}).join("&");
|
121 |
+
}
|
122 |
+
|
123 |
+
// pkg/dist-src/util/extract-url-variable-names.js
|
124 |
+
var urlVariableRegex = /\{[^}]+\}/g;
|
125 |
+
function removeNonChars(variableName) {
|
126 |
+
return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
|
127 |
+
}
|
128 |
+
function extractUrlVariableNames(url) {
|
129 |
+
const matches = url.match(urlVariableRegex);
|
130 |
+
if (!matches) {
|
131 |
+
return [];
|
132 |
+
}
|
133 |
+
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
|
134 |
+
}
|
135 |
+
|
136 |
+
// pkg/dist-src/util/omit.js
|
137 |
+
function omit(object, keysToOmit) {
|
138 |
+
return Object.keys(object).filter((option) => !keysToOmit.includes(option)).reduce((obj, key) => {
|
139 |
+
obj[key] = object[key];
|
140 |
+
return obj;
|
141 |
+
}, {});
|
142 |
+
}
|
143 |
+
|
144 |
+
// pkg/dist-src/util/url-template.js
|
145 |
+
function encodeReserved(str) {
|
146 |
+
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) {
|
147 |
+
if (!/%[0-9A-Fa-f]/.test(part)) {
|
148 |
+
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
149 |
+
}
|
150 |
+
return part;
|
151 |
+
}).join("");
|
152 |
+
}
|
153 |
+
function encodeUnreserved(str) {
|
154 |
+
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
155 |
+
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
156 |
+
});
|
157 |
+
}
|
158 |
+
function encodeValue(operator, value, key) {
|
159 |
+
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
|
160 |
+
if (key) {
|
161 |
+
return encodeUnreserved(key) + "=" + value;
|
162 |
+
} else {
|
163 |
+
return value;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
function isDefined(value) {
|
167 |
+
return value !== void 0 && value !== null;
|
168 |
+
}
|
169 |
+
function isKeyOperator(operator) {
|
170 |
+
return operator === ";" || operator === "&" || operator === "?";
|
171 |
+
}
|
172 |
+
function getValues(context, operator, key, modifier) {
|
173 |
+
var value = context[key], result = [];
|
174 |
+
if (isDefined(value) && value !== "") {
|
175 |
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
176 |
+
value = value.toString();
|
177 |
+
if (modifier && modifier !== "*") {
|
178 |
+
value = value.substring(0, parseInt(modifier, 10));
|
179 |
+
}
|
180 |
+
result.push(
|
181 |
+
encodeValue(operator, value, isKeyOperator(operator) ? key : "")
|
182 |
+
);
|
183 |
+
} else {
|
184 |
+
if (modifier === "*") {
|
185 |
+
if (Array.isArray(value)) {
|
186 |
+
value.filter(isDefined).forEach(function(value2) {
|
187 |
+
result.push(
|
188 |
+
encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
|
189 |
+
);
|
190 |
+
});
|
191 |
+
} else {
|
192 |
+
Object.keys(value).forEach(function(k) {
|
193 |
+
if (isDefined(value[k])) {
|
194 |
+
result.push(encodeValue(operator, value[k], k));
|
195 |
+
}
|
196 |
+
});
|
197 |
+
}
|
198 |
+
} else {
|
199 |
+
const tmp = [];
|
200 |
+
if (Array.isArray(value)) {
|
201 |
+
value.filter(isDefined).forEach(function(value2) {
|
202 |
+
tmp.push(encodeValue(operator, value2));
|
203 |
+
});
|
204 |
+
} else {
|
205 |
+
Object.keys(value).forEach(function(k) {
|
206 |
+
if (isDefined(value[k])) {
|
207 |
+
tmp.push(encodeUnreserved(k));
|
208 |
+
tmp.push(encodeValue(operator, value[k].toString()));
|
209 |
+
}
|
210 |
+
});
|
211 |
+
}
|
212 |
+
if (isKeyOperator(operator)) {
|
213 |
+
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
214 |
+
} else if (tmp.length !== 0) {
|
215 |
+
result.push(tmp.join(","));
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
} else {
|
220 |
+
if (operator === ";") {
|
221 |
+
if (isDefined(value)) {
|
222 |
+
result.push(encodeUnreserved(key));
|
223 |
+
}
|
224 |
+
} else if (value === "" && (operator === "&" || operator === "?")) {
|
225 |
+
result.push(encodeUnreserved(key) + "=");
|
226 |
+
} else if (value === "") {
|
227 |
+
result.push("");
|
228 |
+
}
|
229 |
+
}
|
230 |
+
return result;
|
231 |
+
}
|
232 |
+
function parseUrl(template) {
|
233 |
+
return {
|
234 |
+
expand: expand.bind(null, template)
|
235 |
+
};
|
236 |
+
}
|
237 |
+
function expand(template, context) {
|
238 |
+
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
239 |
+
return template.replace(
|
240 |
+
/\{([^\{\}]+)\}|([^\{\}]+)/g,
|
241 |
+
function(_, expression, literal) {
|
242 |
+
if (expression) {
|
243 |
+
let operator = "";
|
244 |
+
const values = [];
|
245 |
+
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
246 |
+
operator = expression.charAt(0);
|
247 |
+
expression = expression.substr(1);
|
248 |
+
}
|
249 |
+
expression.split(/,/g).forEach(function(variable) {
|
250 |
+
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
251 |
+
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
252 |
+
});
|
253 |
+
if (operator && operator !== "+") {
|
254 |
+
var separator = ",";
|
255 |
+
if (operator === "?") {
|
256 |
+
separator = "&";
|
257 |
+
} else if (operator !== "#") {
|
258 |
+
separator = operator;
|
259 |
+
}
|
260 |
+
return (values.length !== 0 ? operator : "") + values.join(separator);
|
261 |
+
} else {
|
262 |
+
return values.join(",");
|
263 |
+
}
|
264 |
+
} else {
|
265 |
+
return encodeReserved(literal);
|
266 |
+
}
|
267 |
+
}
|
268 |
+
);
|
269 |
+
}
|
270 |
+
|
271 |
+
// pkg/dist-src/parse.js
|
272 |
+
function parse(options) {
|
273 |
+
let method = options.method.toUpperCase();
|
274 |
+
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
275 |
+
let headers = Object.assign({}, options.headers);
|
276 |
+
let body;
|
277 |
+
let parameters = omit(options, [
|
278 |
+
"method",
|
279 |
+
"baseUrl",
|
280 |
+
"url",
|
281 |
+
"headers",
|
282 |
+
"request",
|
283 |
+
"mediaType"
|
284 |
+
]);
|
285 |
+
const urlVariableNames = extractUrlVariableNames(url);
|
286 |
+
url = parseUrl(url).expand(parameters);
|
287 |
+
if (!/^http/.test(url)) {
|
288 |
+
url = options.baseUrl + url;
|
289 |
+
}
|
290 |
+
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl");
|
291 |
+
const remainingParameters = omit(parameters, omittedParameters);
|
292 |
+
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
293 |
+
if (!isBinaryRequest) {
|
294 |
+
if (options.mediaType.format) {
|
295 |
+
headers.accept = headers.accept.split(/,/).map(
|
296 |
+
(format) => format.replace(
|
297 |
+
/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,
|
298 |
+
`application/vnd$1$2.${options.mediaType.format}`
|
299 |
+
)
|
300 |
+
).join(",");
|
301 |
+
}
|
302 |
+
if (url.endsWith("/graphql")) {
|
303 |
+
if (options.mediaType.previews?.length) {
|
304 |
+
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
|
305 |
+
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {
|
306 |
+
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
|
307 |
+
return `application/vnd.github.${preview}-preview${format}`;
|
308 |
+
}).join(",");
|
309 |
+
}
|
310 |
+
}
|
311 |
+
}
|
312 |
+
if (["GET", "HEAD"].includes(method)) {
|
313 |
+
url = addQueryParameters(url, remainingParameters);
|
314 |
+
} else {
|
315 |
+
if ("data" in remainingParameters) {
|
316 |
+
body = remainingParameters.data;
|
317 |
+
} else {
|
318 |
+
if (Object.keys(remainingParameters).length) {
|
319 |
+
body = remainingParameters;
|
320 |
+
}
|
321 |
+
}
|
322 |
+
}
|
323 |
+
if (!headers["content-type"] && typeof body !== "undefined") {
|
324 |
+
headers["content-type"] = "application/json; charset=utf-8";
|
325 |
+
}
|
326 |
+
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
327 |
+
body = "";
|
328 |
+
}
|
329 |
+
return Object.assign(
|
330 |
+
{ method, url, headers },
|
331 |
+
typeof body !== "undefined" ? { body } : null,
|
332 |
+
options.request ? { request: options.request } : null
|
333 |
+
);
|
334 |
+
}
|
335 |
+
|
336 |
+
// pkg/dist-src/endpoint-with-defaults.js
|
337 |
+
function endpointWithDefaults(defaults, route, options) {
|
338 |
+
return parse(merge(defaults, route, options));
|
339 |
+
}
|
340 |
+
|
341 |
+
// pkg/dist-src/with-defaults.js
|
342 |
+
function withDefaults(oldDefaults, newDefaults) {
|
343 |
+
const DEFAULTS2 = merge(oldDefaults, newDefaults);
|
344 |
+
const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2);
|
345 |
+
return Object.assign(endpoint2, {
|
346 |
+
DEFAULTS: DEFAULTS2,
|
347 |
+
defaults: withDefaults.bind(null, DEFAULTS2),
|
348 |
+
merge: merge.bind(null, DEFAULTS2),
|
349 |
+
parse
|
350 |
+
});
|
351 |
+
}
|
352 |
+
|
353 |
+
// pkg/dist-src/index.js
|
354 |
+
var endpoint = withDefaults(null, DEFAULTS);
|
355 |
+
// Annotate the CommonJS export names for ESM import in node:
|
356 |
+
0 && (module.exports = {
|
357 |
+
endpoint
|
358 |
+
});
|
node_modules/@octokit/endpoint/dist-node/index.js.map
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"version": 3,
|
3 |
+
"sources": ["../dist-src/index.js", "../dist-src/defaults.js", "../dist-src/version.js", "../dist-src/util/lowercase-keys.js", "../dist-src/util/merge-deep.js", "../dist-src/util/remove-undefined-properties.js", "../dist-src/merge.js", "../dist-src/util/add-query-parameters.js", "../dist-src/util/extract-url-variable-names.js", "../dist-src/util/omit.js", "../dist-src/util/url-template.js", "../dist-src/parse.js", "../dist-src/endpoint-with-defaults.js", "../dist-src/with-defaults.js"],
|
4 |
+
"sourcesContent": ["import { withDefaults } from \"./with-defaults\";\nimport { DEFAULTS } from \"./defaults\";\nconst endpoint = withDefaults(null, DEFAULTS);\nexport {\n endpoint\n};\n", "import { getUserAgent } from \"universal-user-agent\";\nimport { VERSION } from \"./version\";\nconst userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;\nconst DEFAULTS = {\n method: \"GET\",\n baseUrl: \"https://api.github.com\",\n headers: {\n accept: \"application/vnd.github.v3+json\",\n \"user-agent\": userAgent\n },\n mediaType: {\n format: \"\"\n }\n};\nexport {\n DEFAULTS\n};\n", "const VERSION = \"9.0.1\";\nexport {\n VERSION\n};\n", "function lowercaseKeys(object) {\n if (!object) {\n return {};\n }\n return Object.keys(object).reduce((newObj, key) => {\n newObj[key.toLowerCase()] = object[key];\n return newObj;\n }, {});\n}\nexport {\n lowercaseKeys\n};\n", "import { isPlainObject } from \"is-plain-object\";\nfunction mergeDeep(defaults, options) {\n const result = Object.assign({}, defaults);\n Object.keys(options).forEach((key) => {\n if (isPlainObject(options[key])) {\n if (!(key in defaults))\n Object.assign(result, { [key]: options[key] });\n else\n result[key] = mergeDeep(defaults[key], options[key]);\n } else {\n Object.assign(result, { [key]: options[key] });\n }\n });\n return result;\n}\nexport {\n mergeDeep\n};\n", "function removeUndefinedProperties(obj) {\n for (const key in obj) {\n if (obj[key] === void 0) {\n delete obj[key];\n }\n }\n return obj;\n}\nexport {\n removeUndefinedProperties\n};\n", "import { lowercaseKeys } from \"./util/lowercase-keys\";\nimport { mergeDeep } from \"./util/merge-deep\";\nimport { removeUndefinedProperties } from \"./util/remove-undefined-properties\";\nfunction merge(defaults, route, options) {\n if (typeof route === \"string\") {\n let [method, url] = route.split(\" \");\n options = Object.assign(url ? { method, url } : { url: method }, options);\n } else {\n options = Object.assign({}, route);\n }\n options.headers = lowercaseKeys(options.headers);\n removeUndefinedProperties(options);\n removeUndefinedProperties(options.headers);\n const mergedOptions = mergeDeep(defaults || {}, options);\n if (options.url === \"/graphql\") {\n if (defaults && defaults.mediaType.previews?.length) {\n mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(\n (preview) => !mergedOptions.mediaType.previews.includes(preview)\n ).concat(mergedOptions.mediaType.previews);\n }\n mergedOptions.mediaType.previews = (mergedOptions.mediaType.previews || []).map((preview) => preview.replace(/-preview/, \"\"));\n }\n return mergedOptions;\n}\nexport {\n merge\n};\n", "function addQueryParameters(url, parameters) {\n const separator = /\\?/.test(url) ? \"&\" : \"?\";\n const names = Object.keys(parameters);\n if (names.length === 0) {\n return url;\n }\n return url + separator + names.map((name) => {\n if (name === \"q\") {\n return \"q=\" + parameters.q.split(\"+\").map(encodeURIComponent).join(\"+\");\n }\n return `${name}=${encodeURIComponent(parameters[name])}`;\n }).join(\"&\");\n}\nexport {\n addQueryParameters\n};\n", "const urlVariableRegex = /\\{[^}]+\\}/g;\nfunction removeNonChars(variableName) {\n return variableName.replace(/^\\W+|\\W+$/g, \"\").split(/,/);\n}\nfunction extractUrlVariableNames(url) {\n const matches = url.match(urlVariableRegex);\n if (!matches) {\n return [];\n }\n return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);\n}\nexport {\n extractUrlVariableNames\n};\n", "function omit(object, keysToOmit) {\n return Object.keys(object).filter((option) => !keysToOmit.includes(option)).reduce((obj, key) => {\n obj[key] = object[key];\n return obj;\n }, {});\n}\nexport {\n omit\n};\n", "function encodeReserved(str) {\n return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) {\n if (!/%[0-9A-Fa-f]/.test(part)) {\n part = encodeURI(part).replace(/%5B/g, \"[\").replace(/%5D/g, \"]\");\n }\n return part;\n }).join(\"\");\n}\nfunction encodeUnreserved(str) {\n return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {\n return \"%\" + c.charCodeAt(0).toString(16).toUpperCase();\n });\n}\nfunction encodeValue(operator, value, key) {\n value = operator === \"+\" || operator === \"#\" ? encodeReserved(value) : encodeUnreserved(value);\n if (key) {\n return encodeUnreserved(key) + \"=\" + value;\n } else {\n return value;\n }\n}\nfunction isDefined(value) {\n return value !== void 0 && value !== null;\n}\nfunction isKeyOperator(operator) {\n return operator === \";\" || operator === \"&\" || operator === \"?\";\n}\nfunction getValues(context, operator, key, modifier) {\n var value = context[key], result = [];\n if (isDefined(value) && value !== \"\") {\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n value = value.toString();\n if (modifier && modifier !== \"*\") {\n value = value.substring(0, parseInt(modifier, 10));\n }\n result.push(\n encodeValue(operator, value, isKeyOperator(operator) ? key : \"\")\n );\n } else {\n if (modifier === \"*\") {\n if (Array.isArray(value)) {\n value.filter(isDefined).forEach(function(value2) {\n result.push(\n encodeValue(operator, value2, isKeyOperator(operator) ? key : \"\")\n );\n });\n } else {\n Object.keys(value).forEach(function(k) {\n if (isDefined(value[k])) {\n result.push(encodeValue(operator, value[k], k));\n }\n });\n }\n } else {\n const tmp = [];\n if (Array.isArray(value)) {\n value.filter(isDefined).forEach(function(value2) {\n tmp.push(encodeValue(operator, value2));\n });\n } else {\n Object.keys(value).forEach(function(k) {\n if (isDefined(value[k])) {\n tmp.push(encodeUnreserved(k));\n tmp.push(encodeValue(operator, value[k].toString()));\n }\n });\n }\n if (isKeyOperator(operator)) {\n result.push(encodeUnreserved(key) + \"=\" + tmp.join(\",\"));\n } else if (tmp.length !== 0) {\n result.push(tmp.join(\",\"));\n }\n }\n }\n } else {\n if (operator === \";\") {\n if (isDefined(value)) {\n result.push(encodeUnreserved(key));\n }\n } else if (value === \"\" && (operator === \"&\" || operator === \"?\")) {\n result.push(encodeUnreserved(key) + \"=\");\n } else if (value === \"\") {\n result.push(\"\");\n }\n }\n return result;\n}\nfunction parseUrl(template) {\n return {\n expand: expand.bind(null, template)\n };\n}\nfunction expand(template, context) {\n var operators = [\"+\", \"#\", \".\", \"/\", \";\", \"?\", \"&\"];\n return template.replace(\n /\\{([^\\{\\}]+)\\}|([^\\{\\}]+)/g,\n function(_, expression, literal) {\n if (expression) {\n let operator = \"\";\n const values = [];\n if (operators.indexOf(expression.charAt(0)) !== -1) {\n operator = expression.charAt(0);\n expression = expression.substr(1);\n }\n expression.split(/,/g).forEach(function(variable) {\n var tmp = /([^:\\*]*)(?::(\\d+)|(\\*))?/.exec(variable);\n values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));\n });\n if (operator && operator !== \"+\") {\n var separator = \",\";\n if (operator === \"?\") {\n separator = \"&\";\n } else if (operator !== \"#\") {\n separator = operator;\n }\n return (values.length !== 0 ? operator : \"\") + values.join(separator);\n } else {\n return values.join(\",\");\n }\n } else {\n return encodeReserved(literal);\n }\n }\n );\n}\nexport {\n parseUrl\n};\n", "import { addQueryParameters } from \"./util/add-query-parameters\";\nimport { extractUrlVariableNames } from \"./util/extract-url-variable-names\";\nimport { omit } from \"./util/omit\";\nimport { parseUrl } from \"./util/url-template\";\nfunction parse(options) {\n let method = options.method.toUpperCase();\n let url = (options.url || \"/\").replace(/:([a-z]\\w+)/g, \"{$1}\");\n let headers = Object.assign({}, options.headers);\n let body;\n let parameters = omit(options, [\n \"method\",\n \"baseUrl\",\n \"url\",\n \"headers\",\n \"request\",\n \"mediaType\"\n ]);\n const urlVariableNames = extractUrlVariableNames(url);\n url = parseUrl(url).expand(parameters);\n if (!/^http/.test(url)) {\n url = options.baseUrl + url;\n }\n const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat(\"baseUrl\");\n const remainingParameters = omit(parameters, omittedParameters);\n const isBinaryRequest = /application\\/octet-stream/i.test(headers.accept);\n if (!isBinaryRequest) {\n if (options.mediaType.format) {\n headers.accept = headers.accept.split(/,/).map(\n (format) => format.replace(\n /application\\/vnd(\\.\\w+)(\\.v3)?(\\.\\w+)?(\\+json)?$/,\n `application/vnd$1$2.${options.mediaType.format}`\n )\n ).join(\",\");\n }\n if (url.endsWith(\"/graphql\")) {\n if (options.mediaType.previews?.length) {\n const previewsFromAcceptHeader = headers.accept.match(/[\\w-]+(?=-preview)/g) || [];\n headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {\n const format = options.mediaType.format ? `.${options.mediaType.format}` : \"+json\";\n return `application/vnd.github.${preview}-preview${format}`;\n }).join(\",\");\n }\n }\n }\n if ([\"GET\", \"HEAD\"].includes(method)) {\n url = addQueryParameters(url, remainingParameters);\n } else {\n if (\"data\" in remainingParameters) {\n body = remainingParameters.data;\n } else {\n if (Object.keys(remainingParameters).length) {\n body = remainingParameters;\n }\n }\n }\n if (!headers[\"content-type\"] && typeof body !== \"undefined\") {\n headers[\"content-type\"] = \"application/json; charset=utf-8\";\n }\n if ([\"PATCH\", \"PUT\"].includes(method) && typeof body === \"undefined\") {\n body = \"\";\n }\n return Object.assign(\n { method, url, headers },\n typeof body !== \"undefined\" ? { body } : null,\n options.request ? { request: options.request } : null\n );\n}\nexport {\n parse\n};\n", "import { DEFAULTS } from \"./defaults\";\nimport { merge } from \"./merge\";\nimport { parse } from \"./parse\";\nfunction endpointWithDefaults(defaults, route, options) {\n return parse(merge(defaults, route, options));\n}\nexport {\n endpointWithDefaults\n};\n", "import { endpointWithDefaults } from \"./endpoint-with-defaults\";\nimport { merge } from \"./merge\";\nimport { parse } from \"./parse\";\nfunction withDefaults(oldDefaults, newDefaults) {\n const DEFAULTS = merge(oldDefaults, newDefaults);\n const endpoint = endpointWithDefaults.bind(null, DEFAULTS);\n return Object.assign(endpoint, {\n DEFAULTS,\n defaults: withDefaults.bind(null, DEFAULTS),\n merge: merge.bind(null, DEFAULTS),\n parse\n });\n}\nexport {\n withDefaults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,UAAU,OAAO,OAAO,CAAC;AAC9C;;;ACFA,SAAS,aAAa,aAAa,aAAa;AAC9C,QAAMA,YAAW,MAAM,aAAa,WAAW;AAC/C,QAAMC,YAAW,qBAAqB,KAAK,MAAMD,SAAQ;AACzD,SAAO,OAAO,OAAOC,WAAU;AAAA,IAC7B,UAAAD;AAAA,IACA,UAAU,aAAa,KAAK,MAAMA,SAAQ;AAAA,IAC1C,OAAO,MAAM,KAAK,MAAMA,SAAQ;AAAA,IAChC;AAAA,EACF,CAAC;AACH;;;AbVA,IAAM,WAAW,aAAa,MAAM,QAAQ;",
|
6 |
+
"names": ["DEFAULTS", "endpoint"]
|
7 |
+
}
|
node_modules/@octokit/endpoint/dist-src/defaults.js
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { getUserAgent } from "universal-user-agent";
|
2 |
+
import { VERSION } from "./version";
|
3 |
+
const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;
|
4 |
+
const DEFAULTS = {
|
5 |
+
method: "GET",
|
6 |
+
baseUrl: "https://api.github.com",
|
7 |
+
headers: {
|
8 |
+
accept: "application/vnd.github.v3+json",
|
9 |
+
"user-agent": userAgent
|
10 |
+
},
|
11 |
+
mediaType: {
|
12 |
+
format: ""
|
13 |
+
}
|
14 |
+
};
|
15 |
+
export {
|
16 |
+
DEFAULTS
|
17 |
+
};
|
node_modules/@octokit/endpoint/dist-src/endpoint-with-defaults.js
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { DEFAULTS } from "./defaults";
|
2 |
+
import { merge } from "./merge";
|
3 |
+
import { parse } from "./parse";
|
4 |
+
function endpointWithDefaults(defaults, route, options) {
|
5 |
+
return parse(merge(defaults, route, options));
|
6 |
+
}
|
7 |
+
export {
|
8 |
+
endpointWithDefaults
|
9 |
+
};
|
node_modules/@octokit/endpoint/dist-src/index.js
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { withDefaults } from "./with-defaults";
|
2 |
+
import { DEFAULTS } from "./defaults";
|
3 |
+
const endpoint = withDefaults(null, DEFAULTS);
|
4 |
+
export {
|
5 |
+
endpoint
|
6 |
+
};
|
node_modules/@octokit/endpoint/dist-src/merge.js
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { lowercaseKeys } from "./util/lowercase-keys";
|
2 |
+
import { mergeDeep } from "./util/merge-deep";
|
3 |
+
import { removeUndefinedProperties } from "./util/remove-undefined-properties";
|
4 |
+
function merge(defaults, route, options) {
|
5 |
+
if (typeof route === "string") {
|
6 |
+
let [method, url] = route.split(" ");
|
7 |
+
options = Object.assign(url ? { method, url } : { url: method }, options);
|
8 |
+
} else {
|
9 |
+
options = Object.assign({}, route);
|
10 |
+
}
|
11 |
+
options.headers = lowercaseKeys(options.headers);
|
12 |
+
removeUndefinedProperties(options);
|
13 |
+
removeUndefinedProperties(options.headers);
|
14 |
+
const mergedOptions = mergeDeep(defaults || {}, options);
|
15 |
+
if (options.url === "/graphql") {
|
16 |
+
if (defaults && defaults.mediaType.previews?.length) {
|
17 |
+
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(
|
18 |
+
(preview) => !mergedOptions.mediaType.previews.includes(preview)
|
19 |
+
).concat(mergedOptions.mediaType.previews);
|
20 |
+
}
|
21 |
+
mergedOptions.mediaType.previews = (mergedOptions.mediaType.previews || []).map((preview) => preview.replace(/-preview/, ""));
|
22 |
+
}
|
23 |
+
return mergedOptions;
|
24 |
+
}
|
25 |
+
export {
|
26 |
+
merge
|
27 |
+
};
|
node_modules/@octokit/endpoint/dist-src/parse.js
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { addQueryParameters } from "./util/add-query-parameters";
|
2 |
+
import { extractUrlVariableNames } from "./util/extract-url-variable-names";
|
3 |
+
import { omit } from "./util/omit";
|
4 |
+
import { parseUrl } from "./util/url-template";
|
5 |
+
function parse(options) {
|
6 |
+
let method = options.method.toUpperCase();
|
7 |
+
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
8 |
+
let headers = Object.assign({}, options.headers);
|
9 |
+
let body;
|
10 |
+
let parameters = omit(options, [
|
11 |
+
"method",
|
12 |
+
"baseUrl",
|
13 |
+
"url",
|
14 |
+
"headers",
|
15 |
+
"request",
|
16 |
+
"mediaType"
|
17 |
+
]);
|
18 |
+
const urlVariableNames = extractUrlVariableNames(url);
|
19 |
+
url = parseUrl(url).expand(parameters);
|
20 |
+
if (!/^http/.test(url)) {
|
21 |
+
url = options.baseUrl + url;
|
22 |
+
}
|
23 |
+
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl");
|
24 |
+
const remainingParameters = omit(parameters, omittedParameters);
|
25 |
+
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
26 |
+
if (!isBinaryRequest) {
|
27 |
+
if (options.mediaType.format) {
|
28 |
+
headers.accept = headers.accept.split(/,/).map(
|
29 |
+
(format) => format.replace(
|
30 |
+
/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,
|
31 |
+
`application/vnd$1$2.${options.mediaType.format}`
|
32 |
+
)
|
33 |
+
).join(",");
|
34 |
+
}
|
35 |
+
if (url.endsWith("/graphql")) {
|
36 |
+
if (options.mediaType.previews?.length) {
|
37 |
+
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
|
38 |
+
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {
|
39 |
+
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
|
40 |
+
return `application/vnd.github.${preview}-preview${format}`;
|
41 |
+
}).join(",");
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
if (["GET", "HEAD"].includes(method)) {
|
46 |
+
url = addQueryParameters(url, remainingParameters);
|
47 |
+
} else {
|
48 |
+
if ("data" in remainingParameters) {
|
49 |
+
body = remainingParameters.data;
|
50 |
+
} else {
|
51 |
+
if (Object.keys(remainingParameters).length) {
|
52 |
+
body = remainingParameters;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
if (!headers["content-type"] && typeof body !== "undefined") {
|
57 |
+
headers["content-type"] = "application/json; charset=utf-8";
|
58 |
+
}
|
59 |
+
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
60 |
+
body = "";
|
61 |
+
}
|
62 |
+
return Object.assign(
|
63 |
+
{ method, url, headers },
|
64 |
+
typeof body !== "undefined" ? { body } : null,
|
65 |
+
options.request ? { request: options.request } : null
|
66 |
+
);
|
67 |
+
}
|
68 |
+
export {
|
69 |
+
parse
|
70 |
+
};
|
node_modules/@octokit/endpoint/dist-src/util/add-query-parameters.js
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function addQueryParameters(url, parameters) {
|
2 |
+
const separator = /\?/.test(url) ? "&" : "?";
|
3 |
+
const names = Object.keys(parameters);
|
4 |
+
if (names.length === 0) {
|
5 |
+
return url;
|
6 |
+
}
|
7 |
+
return url + separator + names.map((name) => {
|
8 |
+
if (name === "q") {
|
9 |
+
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
|
10 |
+
}
|
11 |
+
return `${name}=${encodeURIComponent(parameters[name])}`;
|
12 |
+
}).join("&");
|
13 |
+
}
|
14 |
+
export {
|
15 |
+
addQueryParameters
|
16 |
+
};
|
node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const urlVariableRegex = /\{[^}]+\}/g;
|
2 |
+
function removeNonChars(variableName) {
|
3 |
+
return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
|
4 |
+
}
|
5 |
+
function extractUrlVariableNames(url) {
|
6 |
+
const matches = url.match(urlVariableRegex);
|
7 |
+
if (!matches) {
|
8 |
+
return [];
|
9 |
+
}
|
10 |
+
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
|
11 |
+
}
|
12 |
+
export {
|
13 |
+
extractUrlVariableNames
|
14 |
+
};
|
node_modules/@octokit/endpoint/dist-src/util/lowercase-keys.js
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function lowercaseKeys(object) {
|
2 |
+
if (!object) {
|
3 |
+
return {};
|
4 |
+
}
|
5 |
+
return Object.keys(object).reduce((newObj, key) => {
|
6 |
+
newObj[key.toLowerCase()] = object[key];
|
7 |
+
return newObj;
|
8 |
+
}, {});
|
9 |
+
}
|
10 |
+
export {
|
11 |
+
lowercaseKeys
|
12 |
+
};
|
node_modules/@octokit/endpoint/dist-src/util/merge-deep.js
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { isPlainObject } from "is-plain-object";
|
2 |
+
function mergeDeep(defaults, options) {
|
3 |
+
const result = Object.assign({}, defaults);
|
4 |
+
Object.keys(options).forEach((key) => {
|
5 |
+
if (isPlainObject(options[key])) {
|
6 |
+
if (!(key in defaults))
|
7 |
+
Object.assign(result, { [key]: options[key] });
|
8 |
+
else
|
9 |
+
result[key] = mergeDeep(defaults[key], options[key]);
|
10 |
+
} else {
|
11 |
+
Object.assign(result, { [key]: options[key] });
|
12 |
+
}
|
13 |
+
});
|
14 |
+
return result;
|
15 |
+
}
|
16 |
+
export {
|
17 |
+
mergeDeep
|
18 |
+
};
|
node_modules/@octokit/endpoint/dist-src/util/omit.js
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function omit(object, keysToOmit) {
|
2 |
+
return Object.keys(object).filter((option) => !keysToOmit.includes(option)).reduce((obj, key) => {
|
3 |
+
obj[key] = object[key];
|
4 |
+
return obj;
|
5 |
+
}, {});
|
6 |
+
}
|
7 |
+
export {
|
8 |
+
omit
|
9 |
+
};
|
node_modules/@octokit/endpoint/dist-src/util/remove-undefined-properties.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function removeUndefinedProperties(obj) {
|
2 |
+
for (const key in obj) {
|
3 |
+
if (obj[key] === void 0) {
|
4 |
+
delete obj[key];
|
5 |
+
}
|
6 |
+
}
|
7 |
+
return obj;
|
8 |
+
}
|
9 |
+
export {
|
10 |
+
removeUndefinedProperties
|
11 |
+
};
|
node_modules/@octokit/endpoint/dist-src/util/url-template.js
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function encodeReserved(str) {
|
2 |
+
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) {
|
3 |
+
if (!/%[0-9A-Fa-f]/.test(part)) {
|
4 |
+
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
5 |
+
}
|
6 |
+
return part;
|
7 |
+
}).join("");
|
8 |
+
}
|
9 |
+
function encodeUnreserved(str) {
|
10 |
+
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
11 |
+
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
12 |
+
});
|
13 |
+
}
|
14 |
+
function encodeValue(operator, value, key) {
|
15 |
+
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
|
16 |
+
if (key) {
|
17 |
+
return encodeUnreserved(key) + "=" + value;
|
18 |
+
} else {
|
19 |
+
return value;
|
20 |
+
}
|
21 |
+
}
|
22 |
+
function isDefined(value) {
|
23 |
+
return value !== void 0 && value !== null;
|
24 |
+
}
|
25 |
+
function isKeyOperator(operator) {
|
26 |
+
return operator === ";" || operator === "&" || operator === "?";
|
27 |
+
}
|
28 |
+
function getValues(context, operator, key, modifier) {
|
29 |
+
var value = context[key], result = [];
|
30 |
+
if (isDefined(value) && value !== "") {
|
31 |
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
32 |
+
value = value.toString();
|
33 |
+
if (modifier && modifier !== "*") {
|
34 |
+
value = value.substring(0, parseInt(modifier, 10));
|
35 |
+
}
|
36 |
+
result.push(
|
37 |
+
encodeValue(operator, value, isKeyOperator(operator) ? key : "")
|
38 |
+
);
|
39 |
+
} else {
|
40 |
+
if (modifier === "*") {
|
41 |
+
if (Array.isArray(value)) {
|
42 |
+
value.filter(isDefined).forEach(function(value2) {
|
43 |
+
result.push(
|
44 |
+
encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
|
45 |
+
);
|
46 |
+
});
|
47 |
+
} else {
|
48 |
+
Object.keys(value).forEach(function(k) {
|
49 |
+
if (isDefined(value[k])) {
|
50 |
+
result.push(encodeValue(operator, value[k], k));
|
51 |
+
}
|
52 |
+
});
|
53 |
+
}
|
54 |
+
} else {
|
55 |
+
const tmp = [];
|
56 |
+
if (Array.isArray(value)) {
|
57 |
+
value.filter(isDefined).forEach(function(value2) {
|
58 |
+
tmp.push(encodeValue(operator, value2));
|
59 |
+
});
|
60 |
+
} else {
|
61 |
+
Object.keys(value).forEach(function(k) {
|
62 |
+
if (isDefined(value[k])) {
|
63 |
+
tmp.push(encodeUnreserved(k));
|
64 |
+
tmp.push(encodeValue(operator, value[k].toString()));
|
65 |
+
}
|
66 |
+
});
|
67 |
+
}
|
68 |
+
if (isKeyOperator(operator)) {
|
69 |
+
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
70 |
+
} else if (tmp.length !== 0) {
|
71 |
+
result.push(tmp.join(","));
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
} else {
|
76 |
+
if (operator === ";") {
|
77 |
+
if (isDefined(value)) {
|
78 |
+
result.push(encodeUnreserved(key));
|
79 |
+
}
|
80 |
+
} else if (value === "" && (operator === "&" || operator === "?")) {
|
81 |
+
result.push(encodeUnreserved(key) + "=");
|
82 |
+
} else if (value === "") {
|
83 |
+
result.push("");
|
84 |
+
}
|
85 |
+
}
|
86 |
+
return result;
|
87 |
+
}
|
88 |
+
function parseUrl(template) {
|
89 |
+
return {
|
90 |
+
expand: expand.bind(null, template)
|
91 |
+
};
|
92 |
+
}
|
93 |
+
function expand(template, context) {
|
94 |
+
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
95 |
+
return template.replace(
|
96 |
+
/\{([^\{\}]+)\}|([^\{\}]+)/g,
|
97 |
+
function(_, expression, literal) {
|
98 |
+
if (expression) {
|
99 |
+
let operator = "";
|
100 |
+
const values = [];
|
101 |
+
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
102 |
+
operator = expression.charAt(0);
|
103 |
+
expression = expression.substr(1);
|
104 |
+
}
|
105 |
+
expression.split(/,/g).forEach(function(variable) {
|
106 |
+
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
107 |
+
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
108 |
+
});
|
109 |
+
if (operator && operator !== "+") {
|
110 |
+
var separator = ",";
|
111 |
+
if (operator === "?") {
|
112 |
+
separator = "&";
|
113 |
+
} else if (operator !== "#") {
|
114 |
+
separator = operator;
|
115 |
+
}
|
116 |
+
return (values.length !== 0 ? operator : "") + values.join(separator);
|
117 |
+
} else {
|
118 |
+
return values.join(",");
|
119 |
+
}
|
120 |
+
} else {
|
121 |
+
return encodeReserved(literal);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
);
|
125 |
+
}
|
126 |
+
export {
|
127 |
+
parseUrl
|
128 |
+
};
|
node_modules/@octokit/endpoint/dist-src/version.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const VERSION = "9.0.1";
|
2 |
+
export {
|
3 |
+
VERSION
|
4 |
+
};
|
node_modules/@octokit/endpoint/dist-src/with-defaults.js
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { endpointWithDefaults } from "./endpoint-with-defaults";
|
2 |
+
import { merge } from "./merge";
|
3 |
+
import { parse } from "./parse";
|
4 |
+
function withDefaults(oldDefaults, newDefaults) {
|
5 |
+
const DEFAULTS = merge(oldDefaults, newDefaults);
|
6 |
+
const endpoint = endpointWithDefaults.bind(null, DEFAULTS);
|
7 |
+
return Object.assign(endpoint, {
|
8 |
+
DEFAULTS,
|
9 |
+
defaults: withDefaults.bind(null, DEFAULTS),
|
10 |
+
merge: merge.bind(null, DEFAULTS),
|
11 |
+
parse
|
12 |
+
});
|
13 |
+
}
|
14 |
+
export {
|
15 |
+
withDefaults
|
16 |
+
};
|
node_modules/@octokit/endpoint/dist-types/defaults.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
import type { EndpointDefaults } from "@octokit/types";
|
2 |
+
export declare const DEFAULTS: EndpointDefaults;
|
node_modules/@octokit/endpoint/dist-types/endpoint-with-defaults.d.ts
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import type { EndpointOptions, RequestParameters, Route } from "@octokit/types";
|
2 |
+
import { DEFAULTS } from "./defaults";
|
3 |
+
export declare function endpointWithDefaults(defaults: typeof DEFAULTS, route: Route | EndpointOptions, options?: RequestParameters): import("@octokit/types").RequestOptions;
|