@cloudflare/workers-oauth-provider 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  This is a TypeScript library that implements the provider side of the OAuth 2.1 protocol with PKCE support. The library is intended to be used on Cloudflare Workers.
4
4
 
5
- ## Beta
6
-
7
- As of March, 2025, this library is very new, prerelease software. The API is still subject to change.
8
-
9
5
  ## Benefits of this library
10
6
 
11
7
  * The library acts as a wrapper around your Worker code, which adds authorization for your API endpoints.
@@ -20,8 +16,7 @@ As of March, 2025, this library is very new, prerelease software. The API is sti
20
16
  A Worker that uses the library might look like this:
21
17
 
22
18
  ```ts
23
- import { OAuthProvider } from "my-oauth";
24
- import type { ExportedHandler } from "@cloudflare/workers-types";
19
+ import { OAuthProvider } from "@cloudflare/workers-oauth-provider";
25
20
  import { WorkerEntrypoint } from "cloudflare:workers";
26
21
 
27
22
  // We export the OAuthProvider instance as the entrypoint to our Worker. This means it
@@ -328,7 +323,7 @@ This library (including the schema documentation) was largely written with the h
328
323
 
329
324
  "haha gpus go brrr"
330
325
 
331
- In all seriousness, two months ago (January 2025), I ([@kentonv](https://github.com/kentonv)) would have agreed. I was an AI skeptic. I thoughts LLMs were glorified Markov chain generators that didn't actually understand code and couldn't produce anything novel. I started this project on a lark, fully expecting the AI to produce terrible code for me to laugh at. And then, uh... the code actually looked pretty good. Not perfect, but I just told the AI to fix things, and it did. I was shocked.
326
+ In all seriousness, two months ago (January 2025), I ([@kentonv](https://github.com/kentonv)) would have agreed. I was an AI skeptic. I thought LLMs were glorified Markov chain generators that didn't actually understand code and couldn't produce anything novel. I started this project on a lark, fully expecting the AI to produce terrible code for me to laugh at. And then, uh... the code actually looked pretty good. Not perfect, but I just told the AI to fix things, and it did. I was shocked.
332
327
 
333
328
  To emphasize, **this is not "vibe coded"**. Every line was thoroughly reviewed and cross-referenced with relevant RFCs, by security experts with previous experience with those RFCs. I was *trying* to validate my skepticism. I ended up proving myself wrong.
334
329
 
@@ -1,4 +1,3 @@
1
- import { ExportedHandler, ExecutionContext } from '@cloudflare/workers-types';
2
1
  import { WorkerEntrypoint } from 'cloudflare:workers';
3
2
 
4
3
  /**
@@ -351,9 +351,9 @@ var OAuthProviderImpl = class {
351
351
  let clientSecret = "";
352
352
  if (authHeader && authHeader.startsWith("Basic ")) {
353
353
  const credentials = atob(authHeader.substring(6));
354
- const [id, secret] = credentials.split(":");
355
- clientId = id;
356
- clientSecret = secret || "";
354
+ const [id, secret] = credentials.split(":", 2);
355
+ clientId = decodeURIComponent(id);
356
+ clientSecret = decodeURIComponent(secret || "");
357
357
  } else {
358
358
  clientId = body.client_id;
359
359
  clientSecret = body.client_secret || "";
@@ -1076,6 +1076,11 @@ var OAuthHelpersImpl = class {
1076
1076
  }
1077
1077
  if (clientId) {
1078
1078
  const clientInfo = await this.lookupClient(clientId);
1079
+ if (!clientInfo) {
1080
+ throw new Error(
1081
+ `Invalid client. The clientId provided does not match to this client.`
1082
+ );
1083
+ }
1079
1084
  if (clientInfo && redirectUri) {
1080
1085
  if (!clientInfo.redirectUris.includes(redirectUri)) {
1081
1086
  throw new Error(
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@cloudflare/workers-oauth-provider",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "OAuth provider for Cloudflare Workers",
5
5
  "main": "dist/oauth-provider.js",
6
6
  "types": "dist/oauth-provider.d.ts",
7
7
  "author": "Kenton Varda <kenton@cloudflare.com>",
8
8
  "license": "MIT",
9
+ "sideEffects": false,
9
10
  "files": [
10
11
  "dist"
11
12
  ],
@@ -13,20 +14,32 @@
13
14
  "publishConfig": {
14
15
  "access": "public"
15
16
  },
16
- "dependencies": {
17
- "@cloudflare/workers-types": "^4.20250311.0"
18
- },
19
- "devDependencies": {
20
- "prettier": "^3.5.3",
21
- "tsup": "^8.4.0",
22
- "typescript": "^5.8.2",
23
- "vitest": "^3.0.8"
24
- },
25
17
  "scripts": {
26
18
  "build": "tsup",
27
19
  "build:watch": "tsup --watch",
20
+ "check": "npm run typecheck && npm run test",
21
+ "typecheck": "tsc",
28
22
  "test": "vitest run",
29
23
  "test:watch": "vitest",
24
+ "prepublishOnly": "npm run build",
30
25
  "prettier": "prettier -w ."
31
- }
32
- }
26
+ },
27
+ "devDependencies": {
28
+ "@changesets/changelog-github": "^0.5.1",
29
+ "@changesets/cli": "^2.29.5",
30
+ "@cloudflare/workers-types": "^4.20250807.0",
31
+ "prettier": "^3.6.2",
32
+ "tsup": "^8.5.0",
33
+ "tsx": "^4.20.3",
34
+ "typescript": "^5.9.2",
35
+ "vitest": "^3.2.4"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/cloudflare/workers-oauth-provider"
40
+ },
41
+ "bugs": {
42
+ "url": "https://github.com/cloudflare/workers-oauth-provider/issues"
43
+ },
44
+ "homepage": "https://github.com/cloudflare/workers-oauth-provider#readme"
45
+ }