diff --git a/README.md b/README.md index acaac06..7be8269 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Node Install with `npm install @octokit/core @octokit/oauth-methods` ```js -const { +import { exchangeWebFlowCode, createDeviceCode, exchangeDeviceCode, @@ -67,7 +67,7 @@ const { resetToken, deleteToken, deleteAuthorization, -} = require("@octokit/oauth-methods"); +} from "@octokit/oauth-methods"; ``` @@ -248,7 +248,7 @@ Defaults to `[]`. You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { url } = getWebFlowAuthorizationUrl({ clientType: "oauth-app", clientId: "1234567890abcdef1234", @@ -470,7 +470,7 @@ Options You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { data, authentication } = await exchangeWebFlowCode({ clientType: "oauth-app", clientId: "1234567890abcdef1234", @@ -564,7 +564,7 @@ Array of [scope names](https://docs.github.com/en/developers/apps/scopes-for-oau You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { data } = await createDeviceCode({ clientType: "oauth-app", clientId: "1234567890abcdef1234", @@ -651,7 +651,7 @@ const { data, authentication } = await exchangeDeviceCode({ You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { data, authentication } = await exchangeDeviceCode({ clientType: "oauth-app", clientId: "1234567890abcdef1234", @@ -750,7 +750,7 @@ Options You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { data, authentication } = await checkToken({ clientType: "oauth-app", clientId: "1234567890abcdef1234", @@ -856,7 +856,7 @@ Options You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { data, authentication } = await refreshToken({ clientType: "github-app", clientId: "lv1.1234567890abcdef", @@ -1007,7 +1007,7 @@ Options You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { data, authentication } = await scopeToken({ clientType: "github-app", clientId: "lv1.1234567890abcdef", @@ -1113,7 +1113,7 @@ Options You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { data, authentication } = await resetToken({ clientId: "1234567890abcdef1234", clientSecret: "secret", @@ -1214,7 +1214,7 @@ Options You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { data, authentication } = await deleteToken({ clientId: "1234567890abcdef1234", clientSecret: "secret", @@ -1315,7 +1315,7 @@ Options You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the REST API root endpoint. Example: ```js -const { request } = require("@octokit/request"); +import { request } from "@octokit/request"; const { data, authentication } = await deleteAuthorization({ clientId: "1234567890abcdef1234", clientSecret: "secret", diff --git a/package-lock.json b/package-lock.json index ac97f9d..e96f8fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,13 @@ "version": "0.0.0-development", "license": "MIT", "dependencies": { - "@octokit/oauth-authorization-url": "^6.0.2", - "@octokit/request": "^8.0.2", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0", - "btoa-lite": "^1.0.0" + "@octokit/oauth-authorization-url": "^7.0.0", + "@octokit/request": "^9.0.0", + "@octokit/request-error": "^6.0.0", + "@octokit/types": "^12.0.0" }, "devDependencies": { "@octokit/tsconfig": "^3.0.0", - "@types/btoa-lite": "^1.0.0", "@types/jest": "^29.0.0", "@types/node": "^20.0.0", "esbuild": "^0.20.0", @@ -1781,11 +1779,27 @@ "node": ">= 18" } }, - "node_modules/@octokit/endpoint": { + "node_modules/@octokit/core/node_modules/@octokit/endpoint": { "version": "9.0.4", "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.4.tgz", "integrity": "sha512-DWPLtr1Kz3tv8L0UvXTDP1fNwM0S+z6EJpRcvH66orY6Eld4XBMCSYsaWp4xIm61jTWxK68BrR7ibO+vSDnZqw==", + "dev": true, + "dependencies": { + "@octokit/types": "^12.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/core/node_modules/@octokit/request": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.2.0.tgz", + "integrity": "sha512-exPif6x5uwLqv1N1irkLG1zZNJkOtj8bZxuVHd71U5Ftuxf2wGNvAJyNBcPbPC+EBzwYEbBDdSFb8EPcjpYxPQ==", + "dev": true, "dependencies": { + "@octokit/endpoint": "^9.0.0", + "@octokit/request-error": "^5.0.0", "@octokit/types": "^12.0.0", "universal-user-agent": "^6.0.0" }, @@ -1793,6 +1807,37 @@ "node": ">= 18" } }, + "node_modules/@octokit/core/node_modules/@octokit/request-error": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz", + "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==", + "dev": true, + "dependencies": { + "@octokit/types": "^12.0.0", + "deprecation": "^2.0.0", + "once": "^1.4.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/endpoint": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.0.0.tgz", + "integrity": "sha512-emBcNDxBdC1y3+knJonS5zhUB/CG6TihubxM2U1/pG/Z1y3a4oV0Gzz3lmkCvWWQI6h3tqBAX9MgCBFp+M68Jw==", + "dependencies": { + "@octokit/types": "^12.0.0", + "universal-user-agent": "^7.0.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/endpoint/node_modules/universal-user-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz", + "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q==" + }, "node_modules/@octokit/graphql": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz", @@ -1807,10 +1852,52 @@ "node": ">= 18" } }, + "node_modules/@octokit/graphql/node_modules/@octokit/endpoint": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.4.tgz", + "integrity": "sha512-DWPLtr1Kz3tv8L0UvXTDP1fNwM0S+z6EJpRcvH66orY6Eld4XBMCSYsaWp4xIm61jTWxK68BrR7ibO+vSDnZqw==", + "dev": true, + "dependencies": { + "@octokit/types": "^12.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/graphql/node_modules/@octokit/request": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.2.0.tgz", + "integrity": "sha512-exPif6x5uwLqv1N1irkLG1zZNJkOtj8bZxuVHd71U5Ftuxf2wGNvAJyNBcPbPC+EBzwYEbBDdSFb8EPcjpYxPQ==", + "dev": true, + "dependencies": { + "@octokit/endpoint": "^9.0.0", + "@octokit/request-error": "^5.0.0", + "@octokit/types": "^12.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/graphql/node_modules/@octokit/request-error": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz", + "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==", + "dev": true, + "dependencies": { + "@octokit/types": "^12.0.0", + "deprecation": "^2.0.0", + "once": "^1.4.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/@octokit/oauth-authorization-url": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-6.0.2.tgz", - "integrity": "sha512-CdoJukjXXxqLNK4y/VOiVzQVjibqoj/xHgInekviUJV73y/BSIcwvJ/4aNHPBPKcPWFnd4/lO9uqRV65jXhcLA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-7.0.0.tgz", + "integrity": "sha512-/x3GvKiAD0ntPvVlbuObuF+sP36CKDvXzwwyQG4VIf6TjqXFXFQ/BsmbZF+mD+rTSImmRPwH+Vr6HndyR+5qIQ==", "engines": { "node": ">= 18" } @@ -1852,6 +1939,20 @@ "@octokit/core": ">=5" } }, + "node_modules/@octokit/plugin-retry/node_modules/@octokit/request-error": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz", + "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==", + "dev": true, + "dependencies": { + "@octokit/types": "^12.0.0", + "deprecation": "^2.0.0", + "once": "^1.4.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/@octokit/plugin-throttling": { "version": "8.1.3", "resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-8.1.3.tgz", @@ -1869,32 +1970,35 @@ } }, "node_modules/@octokit/request": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.2.0.tgz", - "integrity": "sha512-exPif6x5uwLqv1N1irkLG1zZNJkOtj8bZxuVHd71U5Ftuxf2wGNvAJyNBcPbPC+EBzwYEbBDdSFb8EPcjpYxPQ==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.0.0.tgz", + "integrity": "sha512-hShsrZ40W8dz3TkyD5ifHNcrYfYpYF7Sh2x+ZKafA+eO0zNeKDTsbF1E0xrUf0mVYGeKL+NLMO5SnfAP22l05Q==", "dependencies": { - "@octokit/endpoint": "^9.0.0", - "@octokit/request-error": "^5.0.0", + "@octokit/endpoint": "^10.0.0", + "@octokit/request-error": "^6.0.1", "@octokit/types": "^12.0.0", - "universal-user-agent": "^6.0.0" + "universal-user-agent": "^7.0.2" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/request-error": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz", - "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.0.1.tgz", + "integrity": "sha512-EPeILOAEGqwmEG6g7dYlbvqkjJ5nWNcZvQpgeLEn1MieIcJ0xK0CJtvVcIMXqzIM8DOWzvI6zL5FQAwjTvk/Tg==", "dependencies": { - "@octokit/types": "^12.0.0", - "deprecation": "^2.0.0", - "once": "^1.4.0" + "@octokit/types": "^12.0.0" }, "engines": { "node": ">= 18" } }, + "node_modules/@octokit/request/node_modules/universal-user-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz", + "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q==" + }, "node_modules/@octokit/tsconfig": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-3.0.0.tgz", @@ -1940,12 +2044,6 @@ "node": ">=12.22.0" } }, - "node_modules/@pnpm/network.ca-file/node_modules/graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", - "dev": true - }, "node_modules/@pnpm/npm-conf": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/@pnpm/npm-conf/-/npm-conf-2.2.2.tgz", @@ -2128,9 +2226,9 @@ } }, "node_modules/@semantic-release/npm/node_modules/npm-run-path": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.2.0.tgz", - "integrity": "sha512-W4/tgAXFqFA0iL7fk0+uQ3g7wkL8xJmx3XdK0VGb4cHW//eZTtKGvFBBoRKVTpY7n6ze4NL9ly7rgXcHufqXKg==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", + "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", "dev": true, "dependencies": { "path-key": "^4.0.0" @@ -2327,12 +2425,6 @@ "@babel/types": "^7.20.7" } }, - "node_modules/@types/btoa-lite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@types/btoa-lite/-/btoa-lite-1.0.2.tgz", - "integrity": "sha512-ZYbcE2x7yrvNFJiU7xJGrpF/ihpkM7zKgw8bha3LNJSesvTtUNxbpzaT7WXBIryf6jovisrxTBvymxMeLLj1Mg==", - "dev": true - }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", @@ -2788,11 +2880,6 @@ "node-int64": "^0.4.0" } }, - "node_modules/btoa-lite": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", - "integrity": "sha512-gvW7InbIyF8AicrqWoptdW08pUxuhq8BEgowNajy9RhiE86fmGAGl+bLKo6oB8QP0CkqHLowfN0oJdKC/J6LbA==" - }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -3656,7 +3743,8 @@ "node_modules/deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", - "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", + "dev": true }, "node_modules/detect-newline": { "version": "3.1.0", @@ -3827,9 +3915,9 @@ } }, "node_modules/env-ci/node_modules/npm-run-path": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.2.0.tgz", - "integrity": "sha512-W4/tgAXFqFA0iL7fk0+uQ3g7wkL8xJmx3XdK0VGb4cHW//eZTtKGvFBBoRKVTpY7n6ze4NL9ly7rgXcHufqXKg==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", + "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", "dev": true, "dependencies": { "path-key": "^4.0.0" @@ -4387,9 +4475,9 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, "node_modules/handlebars": { @@ -4819,14 +4907,14 @@ } }, "node_modules/istanbul-lib-instrument": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.1.tgz", - "integrity": "sha512-EAMEJBsYuyyztxMxW3g7ugGPkrZsV57v0Hmv3mm1uQsmB+QnZuepg731CRaIgeUVSdmsTngOkSnauNF8p7FIhA==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.2.tgz", + "integrity": "sha512-1WUsZ9R1lA0HtBSohTkm39WTPlNKSJ5iFk7UwqXkBLoHQT+hfqPsfsTDVuZdKGaBwn7din9bS7SsnoAr943hvw==", "dev": true, "dependencies": { - "@babel/core": "^7.12.3", - "@babel/parser": "^7.14.7", - "@istanbuljs/schema": "^0.1.2", + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", "istanbul-lib-coverage": "^3.2.0", "semver": "^7.5.4" }, @@ -9991,6 +10079,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "dependencies": { "wrappy": "1" } @@ -10562,9 +10651,9 @@ } }, "node_modules/read-pkg-up/node_modules/type-fest": { - "version": "4.10.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.10.2.tgz", - "integrity": "sha512-anpAG63wSpdEbLwOqH8L84urkL6PiVIov3EMmgIhhThevh9aiMQov+6Btx0wldNcvm4wV+e2/Rt1QdDwKHFbHw==", + "version": "4.10.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.10.3.tgz", + "integrity": "sha512-JLXyjizi072smKGGcZiAJDCNweT8J+AuRxmPZ1aG7TERg4ijx9REl8CNhbr36RV4qXqL1gO1FF9HL8OkVmmrsA==", "dev": true, "engines": { "node": ">=16" @@ -10591,9 +10680,9 @@ } }, "node_modules/read-pkg/node_modules/type-fest": { - "version": "4.10.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.10.2.tgz", - "integrity": "sha512-anpAG63wSpdEbLwOqH8L84urkL6PiVIov3EMmgIhhThevh9aiMQov+6Btx0wldNcvm4wV+e2/Rt1QdDwKHFbHw==", + "version": "4.10.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.10.3.tgz", + "integrity": "sha512-JLXyjizi072smKGGcZiAJDCNweT8J+AuRxmPZ1aG7TERg4ijx9REl8CNhbr36RV4qXqL1gO1FF9HL8OkVmmrsA==", "dev": true, "engines": { "node": ">=16" @@ -10906,9 +10995,9 @@ } }, "node_modules/semantic-release/node_modules/npm-run-path": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.2.0.tgz", - "integrity": "sha512-W4/tgAXFqFA0iL7fk0+uQ3g7wkL8xJmx3XdK0VGb4cHW//eZTtKGvFBBoRKVTpY7n6ze4NL9ly7rgXcHufqXKg==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", + "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", "dev": true, "dependencies": { "path-key": "^4.0.0" @@ -11837,7 +11926,8 @@ "node_modules/universal-user-agent": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", - "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==" + "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==", + "dev": true }, "node_modules/universalify": { "version": "2.0.1", @@ -12088,7 +12178,8 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true }, "node_modules/write-file-atomic": { "version": "4.0.2", diff --git a/package.json b/package.json index c953c78..7055650 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "@octokit/oauth-methods", + "type": "module", "version": "0.0.0-development", "description": "Set of stateless request methods to create, check, reset, refresh, and delete user access tokens for OAuth and GitHub Apps", "scripts": { @@ -7,7 +8,7 @@ "lint": "prettier --check '{src,test,scripts}/**/*' README.md package.json", "lint:fix": "prettier --write '{src,test,scripts}/**/*' README.md package.json", "pretest": "npm run -s lint", - "test": "jest --coverage" + "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage" }, "repository": "https://github.com/octokit/oauth-methods.js", "keywords": [ @@ -20,15 +21,13 @@ "author": "Gregor Martynus (https://dev.to/gr2m)", "license": "MIT", "dependencies": { - "@octokit/oauth-authorization-url": "^6.0.2", - "@octokit/request": "^8.0.2", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0", - "btoa-lite": "^1.0.0" + "@octokit/oauth-authorization-url": "^7.0.0", + "@octokit/request": "^9.0.0", + "@octokit/request-error": "^6.0.0", + "@octokit/types": "^12.0.0" }, "devDependencies": { "@octokit/tsconfig": "^3.0.0", - "@types/btoa-lite": "^1.0.0", "@types/jest": "^29.0.0", "@types/node": "^20.0.0", "esbuild": "^0.20.0", @@ -42,11 +41,15 @@ "typescript": "^5.0.0" }, "jest": { + "extensionsToTreatAsEsm": [ + ".ts" + ], "transform": { "^.+\\.(ts|tsx)$": [ "ts-jest", { - "tsconfig": "test/tsconfig.test.json" + "tsconfig": "test/tsconfig.test.json", + "useESM": true } ] }, @@ -57,6 +60,9 @@ "functions": 100, "lines": 100 } + }, + "moduleNameMapper": { + "^(.+)\\.jsx?$": "$1" } }, "release": { diff --git a/scripts/build.mjs b/scripts/build.mjs index 65c96ca..82d0c8a 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -35,14 +35,13 @@ async function main() { const entryPoints = ["./pkg/dist-src/index.js"]; - // Build a CJS Node.js bundle + // Build a bundle await esbuild.build({ entryPoints, - outdir: "pkg/dist-node", + outdir: "pkg/dist-bundle", bundle: true, - platform: "node", - target: "node14", - format: "cjs", + platform: "neutral", + format: "esm", ...sharedOptions, }); @@ -63,9 +62,12 @@ async function main() { { ...pkg, files: ["dist-*/**", "bin/**"], - main: "dist-node/index.js", - types: "dist-types/index.d.ts", - module: "dist-src/index.js", + exports: { + ".": { + types: "./dist-types/index.d.ts", + import: "./dist-bundle/index.js", + }, + }, sideEffects: false, }, null, diff --git a/src/check-token.ts b/src/check-token.ts index 21f21e4..29bc809 100644 --- a/src/check-token.ts +++ b/src/check-token.ts @@ -1,12 +1,11 @@ import { request as defaultRequest } from "@octokit/request"; import type { RequestInterface, Endpoints } from "@octokit/types"; -import btoa from "btoa-lite"; import type { OAuthAppAuthentication, GitHubAppAuthenticationWithExpirationEnabled, GitHubAppAuthenticationWithExpirationDisabled, -} from "./types"; +} from "./types.js"; export type CheckTokenOAuthAppOptions = { clientType: "oauth-app"; diff --git a/src/create-device-code.ts b/src/create-device-code.ts index de5701c..9aad45c 100644 --- a/src/create-device-code.ts +++ b/src/create-device-code.ts @@ -1,7 +1,7 @@ import { request as defaultRequest } from "@octokit/request"; import type { OctokitResponse, RequestInterface } from "@octokit/types"; -import { oauthRequest } from "./utils"; +import { oauthRequest } from "./utils.js"; export type CreateDeviceCodeOAuthAppOptions = { clientType: "oauth-app"; diff --git a/src/delete-authorization.ts b/src/delete-authorization.ts index d6b44fb..a7830e5 100644 --- a/src/delete-authorization.ts +++ b/src/delete-authorization.ts @@ -1,6 +1,5 @@ import { request as defaultRequest } from "@octokit/request"; import type { RequestInterface, Endpoints } from "@octokit/types"; -import btoa from "btoa-lite"; export type DeleteAuthorizationOAuthAppOptions = { clientType: "oauth-app"; diff --git a/src/delete-token.ts b/src/delete-token.ts index 2098957..84688ae 100644 --- a/src/delete-token.ts +++ b/src/delete-token.ts @@ -1,6 +1,5 @@ import { request as defaultRequest } from "@octokit/request"; import type { RequestInterface, Endpoints } from "@octokit/types"; -import btoa from "btoa-lite"; export type DeleteTokenOAuthAppOptions = { clientType: "oauth-app"; diff --git a/src/exchange-device-code.ts b/src/exchange-device-code.ts index b6de60c..32ae1fd 100644 --- a/src/exchange-device-code.ts +++ b/src/exchange-device-code.ts @@ -9,8 +9,8 @@ import type { OAuthAppCreateTokenResponseData, GitHubAppCreateTokenResponseData, GitHubAppCreateTokenWithExpirationResponseData, -} from "./types"; -import { oauthRequest } from "./utils"; +} from "./types.js"; +import { oauthRequest } from "./utils.js"; export type ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret = { clientType: "oauth-app"; diff --git a/src/exchange-web-flow-code.ts b/src/exchange-web-flow-code.ts index e7a94db..8afe84f 100644 --- a/src/exchange-web-flow-code.ts +++ b/src/exchange-web-flow-code.ts @@ -9,8 +9,8 @@ import type { OAuthAppCreateTokenResponseData, GitHubAppCreateTokenResponseData, GitHubAppCreateTokenWithExpirationResponseData, -} from "./types"; -import { oauthRequest } from "./utils"; +} from "./types.js"; +import { oauthRequest } from "./utils.js"; export type ExchangeWebFlowCodeOAuthAppOptions = { clientType: "oauth-app"; diff --git a/src/get-web-flow-authorization-url.ts b/src/get-web-flow-authorization-url.ts index c5fe840..50b3ef4 100644 --- a/src/get-web-flow-authorization-url.ts +++ b/src/get-web-flow-authorization-url.ts @@ -6,7 +6,7 @@ import type { import { request as defaultRequest } from "@octokit/request"; import type { RequestInterface } from "@octokit/types"; -import { requestToOAuthBaseUrl } from "./utils"; +import { requestToOAuthBaseUrl } from "./utils.js"; export type GetWebFlowAuthorizationUrlOAuthAppOptions = { clientType: "oauth-app"; diff --git a/src/index.ts b/src/index.ts index b0c4021..94b6086 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,14 @@ -export { VERSION } from "./version"; -export * from "./get-web-flow-authorization-url"; -export * from "./exchange-web-flow-code"; -export * from "./create-device-code"; -export * from "./exchange-device-code"; -export * from "./check-token"; -export * from "./refresh-token"; -export * from "./scope-token"; -export * from "./reset-token"; -export * from "./delete-token"; -export * from "./delete-authorization"; +export { VERSION } from "./version.js"; +export * from "./get-web-flow-authorization-url.js"; +export * from "./exchange-web-flow-code.js"; +export * from "./create-device-code.js"; +export * from "./exchange-device-code.js"; +export * from "./check-token.js"; +export * from "./refresh-token.js"; +export * from "./scope-token.js"; +export * from "./reset-token.js"; +export * from "./delete-token.js"; +export * from "./delete-authorization.js"; export type { OAuthAppAuthentication, GitHubAppAuthenticationWithExpirationDisabled, @@ -16,4 +16,4 @@ export type { GitHubAppAuthenticationWithRefreshToken, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, -} from "./types"; +} from "./types.js"; diff --git a/src/refresh-token.ts b/src/refresh-token.ts index 16696b5..721fdb5 100644 --- a/src/refresh-token.ts +++ b/src/refresh-token.ts @@ -4,8 +4,8 @@ import type { OctokitResponse, RequestInterface } from "@octokit/types"; import type { GitHubAppAuthenticationWithRefreshToken, GitHubAppCreateTokenWithExpirationResponseData, -} from "./types"; -import { oauthRequest } from "./utils"; +} from "./types.js"; +import { oauthRequest } from "./utils.js"; export type RefreshTokenOptions = { clientType: "github-app"; diff --git a/src/reset-token.ts b/src/reset-token.ts index 9542436..1cc3f61 100644 --- a/src/reset-token.ts +++ b/src/reset-token.ts @@ -1,12 +1,11 @@ import { request as defaultRequest } from "@octokit/request"; -import btoa from "btoa-lite"; import type { Endpoints, RequestInterface } from "@octokit/types"; import type { OAuthAppAuthentication, GitHubAppAuthenticationWithExpirationEnabled, GitHubAppAuthenticationWithExpirationDisabled, -} from "./types"; +} from "./types.js"; export type ResetTokenOAuthAppOptions = { clientType: "oauth-app"; diff --git a/src/scope-token.ts b/src/scope-token.ts index e092bc7..3068118 100644 --- a/src/scope-token.ts +++ b/src/scope-token.ts @@ -1,11 +1,10 @@ import { request as defaultRequest } from "@octokit/request"; import type { RequestInterface, Endpoints } from "@octokit/types"; -import btoa from "btoa-lite"; import type { GitHubAppAuthenticationWithExpirationEnabled, GitHubAppAuthenticationWithExpirationDisabled, -} from "./types"; +} from "./types.js"; type CommonOptions = { clientType: "github-app"; diff --git a/src/utils.ts b/src/utils.ts index 880cf33..01f413f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -31,7 +31,6 @@ export async function oauthRequest( route, withOAuthParameters, ) as RequestOptions, - headers: response.headers, }, ); diff --git a/test/check-token.test.ts b/test/check-token.test.ts index 5e45767..c60f41e 100644 --- a/test/check-token.test.ts +++ b/test/check-token.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; import { request } from "@octokit/request"; -import { checkToken } from "../src"; +import { checkToken } from "../src/index.js"; describe("checkToken()", () => { it("README example", async () => { diff --git a/test/create-device-code.test.ts b/test/create-device-code.test.ts index c3306af..7ab3f0d 100644 --- a/test/create-device-code.test.ts +++ b/test/create-device-code.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; import { request } from "@octokit/request"; -import { createDeviceCode } from "../src"; +import { createDeviceCode } from "../src/index.js"; describe("createDeviceCode()", () => { it("README example", async () => { diff --git a/test/delete-authorization.test.ts b/test/delete-authorization.test.ts index 305964e..465f822 100644 --- a/test/delete-authorization.test.ts +++ b/test/delete-authorization.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; import { request } from "@octokit/request"; -import { deleteAuthorization } from "../src"; +import { deleteAuthorization } from "../src/index.js"; describe("deleteAuthorization()", () => { it("README example", async () => { diff --git a/test/delete-token.test.ts b/test/delete-token.test.ts index 00e39ad..ccfcd3a 100644 --- a/test/delete-token.test.ts +++ b/test/delete-token.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; import { request } from "@octokit/request"; -import { deleteToken } from "../src"; +import { deleteToken } from "../src/index.js"; describe("deleteToken()", () => { it("README example", async () => { diff --git a/test/exchange-device-code.test.ts b/test/exchange-device-code.test.ts index a8fb61b..9c4f425 100644 --- a/test/exchange-device-code.test.ts +++ b/test/exchange-device-code.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; import { request } from "@octokit/request"; -import { exchangeDeviceCode } from "../src"; +import { exchangeDeviceCode } from "../src/index.js"; describe("exchangeDeviceCode()", () => { it("README example", async () => { diff --git a/test/exchange-web-flow-code.test.ts b/test/exchange-web-flow-code.test.ts index 4429179..7c48c36 100644 --- a/test/exchange-web-flow-code.test.ts +++ b/test/exchange-web-flow-code.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; import { request } from "@octokit/request"; -import { exchangeWebFlowCode } from "../src"; +import { exchangeWebFlowCode } from "../src/index.js"; describe("exchangeWebFlowCode()", () => { it("README example", async () => { diff --git a/test/get-web-flow-authorization-url.test.ts b/test/get-web-flow-authorization-url.test.ts index e6bc6f7..0b354d0 100644 --- a/test/get-web-flow-authorization-url.test.ts +++ b/test/get-web-flow-authorization-url.test.ts @@ -1,5 +1,5 @@ import { request } from "@octokit/request"; -import { getWebFlowAuthorizationUrl } from "../src"; +import { getWebFlowAuthorizationUrl } from "../src/index.js"; describe("getWebFlowAuthorizationUrl()", () => { it("README example", () => { diff --git a/test/refresh-token.test.ts b/test/refresh-token.test.ts index 0a4b8e5..6ab75d4 100644 --- a/test/refresh-token.test.ts +++ b/test/refresh-token.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; import { request } from "@octokit/request"; -import { refreshToken } from "../src"; +import { refreshToken } from "../src/index.js"; describe("refreshToken()", () => { it("README example", async () => { diff --git a/test/reset-token.test.ts b/test/reset-token.test.ts index 77f0787..4e6f07e 100644 --- a/test/reset-token.test.ts +++ b/test/reset-token.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; import { request } from "@octokit/request"; -import { resetToken } from "../src"; +import { resetToken } from "../src/index.js"; describe("resetToken()", () => { it("README example", async () => { diff --git a/test/scope-token.test.ts b/test/scope-token.test.ts index a03bba0..63ab0bc 100644 --- a/test/scope-token.test.ts +++ b/test/scope-token.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; import { request } from "@octokit/request"; -import { scopeToken } from "../src"; +import { scopeToken } from "../src/index.js"; describe("scopeToken()", () => { it("README example", async () => { diff --git a/test/smoke.test.ts b/test/smoke.test.ts index ce3b177..91e8b79 100644 --- a/test/smoke.test.ts +++ b/test/smoke.test.ts @@ -10,7 +10,7 @@ import { deleteToken, deleteAuthorization, VERSION, -} from "../src"; +} from "../src/index.js"; describe("Smoke test", () => { it("exports getWebFlowAuthorizationUrl", () => { diff --git a/test/tsconfig.test.json b/test/tsconfig.test.json index b0961e1..fe99a4e 100644 --- a/test/tsconfig.test.json +++ b/test/tsconfig.test.json @@ -2,8 +2,7 @@ "extends": "../tsconfig.json", "compilerOptions": { "emitDeclarationOnly": false, - "noEmit": true, - "verbatimModuleSyntax": false + "noEmit": true }, "include": ["src/**/*"] }