From 67e94d391e82a87a382c15ce805af6e40b7a23b0 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Wed, 23 Oct 2024 13:30:17 +1100 Subject: [PATCH] refactor: update for Deno 2 (#329) --- .github/codecov.yml | 2 +- .github/dependabot.yml | 3 +-- .github/workflows/ci.yml | 2 +- .github/workflows/publish.yml | 4 ++-- README.md | 8 ++++---- demo.ts | 2 +- lib/create_auth0_oauth_config.ts | 2 +- lib/create_aws_cognito_oauth_config.ts | 4 ++-- lib/create_azure_ad_oauth_config.ts | 2 +- lib/create_azure_adb2c_oauth_config.ts | 2 +- lib/create_clerk_oauth_config.ts | 2 +- lib/create_discord_oauth_config.ts | 2 +- lib/create_dropbox_oauth_config.ts | 2 +- lib/create_facebook_oauth_config.ts | 2 +- lib/create_github_oauth_config.ts | 2 +- lib/create_gitlab_oauth_config.ts | 2 +- lib/create_google_oauth_config.ts | 2 +- lib/create_helpers.ts | 20 ++++++++++---------- lib/create_helpers_test.ts | 4 ++-- lib/create_logto_oauth_config.ts | 2 +- lib/create_notion_oauth_config.ts | 2 +- lib/create_okta_oauth_config.ts | 2 +- lib/create_patreon_oauth_config.ts | 2 +- lib/create_slack_oauth_config.ts | 2 +- lib/create_spotify_oauth_config.ts | 2 +- lib/create_twitter_oauth_config.ts | 2 +- lib/get_required_env.ts | 4 ++-- 27 files changed, 43 insertions(+), 44 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index d5b3829..fde1c61 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -8,4 +8,4 @@ coverage: informational: true ignore: - - "vendor" \ No newline at end of file + - "vendor" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 73f11c1..d202a33 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,8 +1,7 @@ version: 2 updates: - - package-ecosystem: "github-actions" directory: "/" schedule: # Check for updates to GitHub Actions every week - interval: "weekly" \ No newline at end of file + interval: "weekly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a1fb70..d62411e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: uses: denoland/setup-deno@v1 with: deno-version: ${{ matrix.deno }} - + - name: Check typos if: matrix.os == 'ubuntu-latest' uses: crate-ci/typos@master diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e094d33..2c604f2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - id-token: write # The OIDC ID token is used for authentication with JSR. + id-token: write # The OIDC ID token is used for authentication with JSR. steps: - uses: actions/checkout@v4 - - run: npx jsr publish \ No newline at end of file + - run: npx jsr publish diff --git a/README.md b/README.md index 5a19165..0cd8c84 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ configurations. 1. Create your web server using Deno KV OAuth's request handlers, helpers and pre-defined OAuth configuration. - ```ts + ```ts ignore // server.ts import { createGitHubOAuthConfig, createHelpers } from "jsr:@deno/kv-oauth"; @@ -95,7 +95,7 @@ configurations. 1. Create your web server using Deno KV OAuth's request handlers and helpers, and custom OAuth configuration. - ```ts + ```ts ignore // server.ts import { createHelpers, @@ -155,7 +155,7 @@ This is required for OAuth solutions that span more than one sub-domain. 1. Create your web server using Deno KV OAuth's helpers factory function with cookie options defined. - ```ts + ```ts ignore // server.ts import { createGitHubOAuthConfig, createHelpers } from "jsr:@deno/kv-oauth"; @@ -206,7 +206,7 @@ This is required for OAuth solutions that span more than one sub-domain. 1. Create your OAuth configuration and Fresh plugin. - ```ts, ignore + ```ts ignore // plugins/kv_oauth.ts import { createGitHubOAuthConfig, createHelpers } from "jsr:@deno/kv-oauth"; import type { Plugin } from "$fresh/server.ts"; diff --git a/demo.ts b/demo.ts index 91d8537..04e7b5d 100644 --- a/demo.ts +++ b/demo.ts @@ -5,7 +5,7 @@ import { createGitHubOAuthConfig, createHelpers } from "./mod.ts"; /** * Modify the OAuth configuration creation function when testing for providers. * - * @example + * @example Usage * ```ts * import { createNotionOAuthConfig } from "./mod.ts"; * diff --git a/lib/create_auth0_oauth_config.ts b/lib/create_auth0_oauth_config.ts index 38c165f..b63203d 100644 --- a/lib/create_auth0_oauth_config.ts +++ b/lib/create_auth0_oauth_config.ts @@ -11,7 +11,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 2. `AUTH0_CLIENT_SECRET` * 3. `AUTH0_DOMAIN` * - * @example + * @example Usage * ```ts * import { createAuth0OAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_aws_cognito_oauth_config.ts b/lib/create_aws_cognito_oauth_config.ts index b1e29a7..f2a445c 100644 --- a/lib/create_aws_cognito_oauth_config.ts +++ b/lib/create_aws_cognito_oauth_config.ts @@ -11,8 +11,8 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 2. `AWS_COGNITO_CLIENT_SECRET` * 3. `AWS_COGNITO_DOMAIN` * - * @example - * ```ts + * @example Usage + * ```ts ignore * import { createAwsCognitoOAuthConfig } from "jsr:@deno/kv-oauth"; * * const oauthConfig = createAwsCognitoOAuthConfig({ diff --git a/lib/create_azure_ad_oauth_config.ts b/lib/create_azure_ad_oauth_config.ts index 9bf8dfc..3f6a3bf 100644 --- a/lib/create_azure_ad_oauth_config.ts +++ b/lib/create_azure_ad_oauth_config.ts @@ -11,7 +11,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 2. `AZURE_AD_CLIENT_SECRET` * 4. `AZURE_AD_TENANT_ID` * - * @example + * @example Usage * ```ts * import { createAzureAdOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_azure_adb2c_oauth_config.ts b/lib/create_azure_adb2c_oauth_config.ts index 3f953df..487250f 100644 --- a/lib/create_azure_adb2c_oauth_config.ts +++ b/lib/create_azure_adb2c_oauth_config.ts @@ -13,7 +13,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 4. `AZURE_ADB2C_POLICY` * 5. `AZURE_ADB2C_TENANT_ID` * - * @example + * @example Usage * ```ts * import { createAzureAdb2cOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_clerk_oauth_config.ts b/lib/create_clerk_oauth_config.ts index 5558c7c..236045c 100644 --- a/lib/create_clerk_oauth_config.ts +++ b/lib/create_clerk_oauth_config.ts @@ -11,7 +11,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 2. `CLERK_CLIENT_SECRET` * 3. `CLERK_DOMAIN` * - * @example + * @example Usage * ```ts * import { createClerkOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_discord_oauth_config.ts b/lib/create_discord_oauth_config.ts index 0d81b79..e80a733 100644 --- a/lib/create_discord_oauth_config.ts +++ b/lib/create_discord_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `DISCORD_CLIENT_ID` * 2. `DISCORD_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createDiscordOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_dropbox_oauth_config.ts b/lib/create_dropbox_oauth_config.ts index 904345c..a8d1abd 100644 --- a/lib/create_dropbox_oauth_config.ts +++ b/lib/create_dropbox_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `DROPBOX_CLIENT_ID` * 2. `DROPBOX_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createDropboxOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_facebook_oauth_config.ts b/lib/create_facebook_oauth_config.ts index 0a42b2e..f05f87c 100644 --- a/lib/create_facebook_oauth_config.ts +++ b/lib/create_facebook_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `FACEBOOK_CLIENT_ID` * 2. `FACEBOOK_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createFacebookOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_github_oauth_config.ts b/lib/create_github_oauth_config.ts index b4d39ea..01e1e6b 100644 --- a/lib/create_github_oauth_config.ts +++ b/lib/create_github_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `GITHUB_CLIENT_ID` * 2. `GITHUB_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createGitHubOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_gitlab_oauth_config.ts b/lib/create_gitlab_oauth_config.ts index 71b7550..f2877c3 100644 --- a/lib/create_gitlab_oauth_config.ts +++ b/lib/create_gitlab_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `GITLAB_CLIENT_ID` * 2. `GITLAB_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createGitLabOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_google_oauth_config.ts b/lib/create_google_oauth_config.ts index 1465182..58aab26 100644 --- a/lib/create_google_oauth_config.ts +++ b/lib/create_google_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `GOOGLE_CLIENT_ID` * 2. `GOOGLE_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createGoogleOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_helpers.ts b/lib/create_helpers.ts index 8d412da..6bfe417 100644 --- a/lib/create_helpers.ts +++ b/lib/create_helpers.ts @@ -38,8 +38,8 @@ export interface Helpers { * * @see {@link https://github.com/denoland/deno_kv_oauth/tree/main#redirects-after-sign-in-and-sign-out} * - * @example - * ```ts + * @example Usage + * ```ts ignore * import { createGitHubOAuthConfig, createHelpers } from "jsr:@deno/kv-oauth"; * * const oauthConfig = createGitHubOAuthConfig(); @@ -55,8 +55,8 @@ export interface Helpers { * {@linkcode Handlers.signIn}. The request URL must match the redirect URL * of the OAuth application. * - * @example - * ```ts + * @example Usage + * ```ts ignore * import { createGitHubOAuthConfig, createHelpers } from "jsr:@deno/kv-oauth"; * * const oauthConfig = createGitHubOAuthConfig(); @@ -79,8 +79,8 @@ export interface Helpers { * * @see {@link https://github.com/denoland/deno_kv_oauth/tree/main#redirects-after-sign-in-and-sign-out} * - * @example - * ```ts + * @example Usage + * ```ts ignore * import { createGitHubOAuthConfig, createHelpers } from "jsr:@deno/kv-oauth"; * * const oauthConfig = createGitHubOAuthConfig(); @@ -95,8 +95,8 @@ export interface Helpers { * check whether the client is signed-in and whether the session ID was created * on the server by checking if the return value is defined. * - * @example - * ```ts + * @example Usage + * ```ts ignore * import { createGitHubOAuthConfig, createHelpers } from "jsr:@deno/kv-oauth"; * * const oauthConfig = createGitHubOAuthConfig(); @@ -124,8 +124,8 @@ export interface CreateHelpersOptions { * Creates the full set of helpers with the given OAuth configuration and * options. * - * @example - * ```ts + * @example Usage + * ```ts ignore * // server.ts * import { * createGitHubOAuthConfig, diff --git a/lib/create_helpers_test.ts b/lib/create_helpers_test.ts index d6d0d76..fb911fe 100644 --- a/lib/create_helpers_test.ts +++ b/lib/create_helpers_test.ts @@ -96,7 +96,7 @@ Deno.test("handleCallback() correctly handles the callback response", async () = const { handleCallback } = createHelpers(randomOAuthConfig()); const tokensBody = randomTokensBody(); const fetchStub = stub( - window, + globalThis, "fetch", returnsNext([Promise.resolve(Response.json(tokensBody))]), ); @@ -133,7 +133,7 @@ Deno.test("handleCallback() correctly handles the callback response", async () = Deno.test("handleCallback() correctly handles the callback response with options", async () => { const tokensBody = randomTokensBody(); const fetchStub = stub( - window, + globalThis, "fetch", returnsNext([Promise.resolve(Response.json(tokensBody))]), ); diff --git a/lib/create_logto_oauth_config.ts b/lib/create_logto_oauth_config.ts index eb89380..5673b24 100644 --- a/lib/create_logto_oauth_config.ts +++ b/lib/create_logto_oauth_config.ts @@ -11,7 +11,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 2. `LOGTO_CLIENT_SECRET` * 3. `LOGTO_DOMAIN` * - * @example + * @example Usage * ```ts * import { createLogtoOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_notion_oauth_config.ts b/lib/create_notion_oauth_config.ts index 1784724..e6867db 100644 --- a/lib/create_notion_oauth_config.ts +++ b/lib/create_notion_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `NOTION_CLIENT_ID` * 2. `NOTION_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createNotionOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_okta_oauth_config.ts b/lib/create_okta_oauth_config.ts index f37461b..f7a1794 100644 --- a/lib/create_okta_oauth_config.ts +++ b/lib/create_okta_oauth_config.ts @@ -11,7 +11,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 2. `OKTA_CLIENT_SECRET` * 3. `OKTA_DOMAIN` * - * @example + * @example Usage * ```ts * import { createOktaOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_patreon_oauth_config.ts b/lib/create_patreon_oauth_config.ts index 9292a79..64d0f72 100644 --- a/lib/create_patreon_oauth_config.ts +++ b/lib/create_patreon_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `PATREON_CLIENT_ID` * 2. `PATREON_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createPatreonOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_slack_oauth_config.ts b/lib/create_slack_oauth_config.ts index 83e9e52..fc246f0 100644 --- a/lib/create_slack_oauth_config.ts +++ b/lib/create_slack_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `SLACK_CLIENT_ID` * 2. `SLACK_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createSlackOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_spotify_oauth_config.ts b/lib/create_spotify_oauth_config.ts index f08f76d..7c33da0 100644 --- a/lib/create_spotify_oauth_config.ts +++ b/lib/create_spotify_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `SPOTIFY_CLIENT_ID` * 2. `SPOTIFY_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createSpotifyOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/create_twitter_oauth_config.ts b/lib/create_twitter_oauth_config.ts index ec510ad..6883909 100644 --- a/lib/create_twitter_oauth_config.ts +++ b/lib/create_twitter_oauth_config.ts @@ -10,7 +10,7 @@ import { getRequiredEnv } from "./get_required_env.ts"; * 1. `TWITTER_CLIENT_ID` * 2. `TWITTER_CLIENT_SECRET` * - * @example + * @example Usage * ```ts * import { createTwitterOAuthConfig } from "jsr:@deno/kv-oauth"; * diff --git a/lib/get_required_env.ts b/lib/get_required_env.ts index 6d9f44e..5b4b250 100644 --- a/lib/get_required_env.ts +++ b/lib/get_required_env.ts @@ -4,8 +4,8 @@ * been set in the current process. This can be used when defining a custom * OAuth configuration. * - * @example - * ```ts + * @example Usage + * ```ts ignore * import { getRequiredEnv } from "jsr:@deno/kv-oauth"; * * getRequiredEnv("HOME"); // Returns "/home/alice"