|
69 | 69 | Install with <code>npm install @octokit/auth-app</code>
|
70 | 70 |
|
71 | 71 | ```js
|
72 |
| -const { createAppAuth } = require("@octokit/auth-app"); |
73 |
| -// or: import { createAppAuth } from "@octokit/auth-app"; |
| 72 | +import { createAppAuth } from "@octokit/auth-app"; |
74 | 73 | ```
|
75 | 74 |
|
76 | 75 | </td></tr>
|
77 | 76 | </tbody>
|
78 | 77 | </table>
|
79 | 78 |
|
| 79 | +> [!IMPORTANT] |
| 80 | +> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`. |
| 81 | +> |
| 82 | +> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br> |
| 83 | +> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus) |
| 84 | +
|
80 | 85 | ### Authenticate as GitHub App (JSON Web Token)
|
81 | 86 |
|
82 | 87 | ```js
|
|
225 | 230 | Install with `npm install @octokit/core @octokit/auth-app`. Optionally replace `@octokit/core` with a compatible module
|
226 | 231 |
|
227 | 232 | ```js
|
228 |
| -const { Octokit } = require("@octokit/core"); |
229 |
| -const { createAppAuth, createOAuthUserAuth } = require("@octokit/auth-app"); |
| 233 | +import { Octokit } from "@octokit/core"; |
| 234 | +import { createAppAuth, createOAuthUserAuth } from "@octokit/auth-app"; |
230 | 235 | ```
|
231 | 236 |
|
232 | 237 | </td></tr>
|
@@ -332,7 +337,7 @@ await installationOctokit.request("POST /repos/{owner}/{repo}/issues", {
|
332 | 337 | <code>string</code>
|
333 | 338 | </th>
|
334 | 339 | <td>
|
335 |
| - <strong>Required</strong>. Content of the <code>*.pem</code> file you downloaded from the app’s about page. You can generate a new private key if needed. |
| 340 | + <strong>Required</strong>. Content of the <code>*.pem</code> file you downloaded from the app’s about page. You can generate a new private key if needed. If your private key contains escaped newlines (`\\n`), they will be automatically replaced with actual newlines. |
336 | 341 | </td>
|
337 | 342 | </tr>
|
338 | 343 | <tr>
|
@@ -382,7 +387,7 @@ Automatically set to `octokit.request` when using with an `Octokit` constructor.
|
382 | 387 | For standalone usage, you can pass in your own [`@octokit/request`](https://github.com/octokit/request.js) instance. For usage with enterprise, set `baseUrl` to the hostname + `/api/v3`. Example:
|
383 | 388 |
|
384 | 389 | ```js
|
385 |
| -const { request } = require("@octokit/request"); |
| 390 | +import { request } from "@octokit/request"; |
386 | 391 | createAppAuth({
|
387 | 392 | appId: 1,
|
388 | 393 | privateKey: "-----BEGIN PRIVATE KEY-----\n...",
|
@@ -431,10 +436,11 @@ createAppAuth({
|
431 | 436 | You can pass in your preferred logging tool by passing <code>option.log</code> to the constructor. If you would like to make the log level configurable using an environment variable or external option, we recommend the console-log-level package. For example:
|
432 | 437 |
|
433 | 438 | ```js
|
| 439 | +import consoleLogLevel from "console-log-level"; |
434 | 440 | createAppAuth({
|
435 | 441 | appId: 1,
|
436 | 442 | privateKey: "-----BEGIN PRIVATE KEY-----\n...",
|
437 |
| - log: require("console-log-level")({ level: "info" }), |
| 443 | + log: consoleLogLevel({ level: "info" }), |
438 | 444 | });
|
439 | 445 | ```
|
440 | 446 |
|
@@ -674,10 +680,7 @@ The `auth({type: "oauth-user", factory })` call with resolve with whatever the f
|
674 | 680 | For example, you can create a new `auth` instance for an installation which shares the internal state (especially the access token cache) with the calling `auth` instance:
|
675 | 681 |
|
676 | 682 | ```js
|
677 |
| -const { |
678 |
| - createAppAuth, |
679 |
| - createOAuthUserAuth, |
680 |
| -} = require("@octokit/auth-oauth-app"); |
| 683 | +import { createAppAuth, createOAuthUserAuth } from "@octokit/auth-oauth-app"; |
681 | 684 |
|
682 | 685 | const appAuth = createAppAuth({
|
683 | 686 | appId: 1,
|
@@ -807,10 +810,7 @@ The `auth({type: "oauth-user", factory })` call with resolve with whatever the f
|
807 | 810 | For example, you can create a new `auth` instance for an installation which shares the internal state (especially the access token cache) with the calling `auth` instance:
|
808 | 811 |
|
809 | 812 | ```js
|
810 |
| -const { |
811 |
| - createAppAuth, |
812 |
| - createOAuthUserAuth, |
813 |
| -} = require("@octokit/auth-oauth-app"); |
| 813 | +import { createAppAuth, createOAuthUserAuth } from "@octokit/auth-oauth-app"; |
814 | 814 |
|
815 | 815 | const appAuth = createAppAuth({
|
816 | 816 | appId: 1,
|
|
0 commit comments