@cloudflare/workers-oauth-provider 0.0.0-373bacf → 0.0.0-50a8d92

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.
@@ -1052,7 +1052,7 @@ async function hashSecret(secret) {
1052
1052
  return generateTokenId(secret);
1053
1053
  }
1054
1054
  function generateRandomString(length) {
1055
- const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1055
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1056
1056
  let result = "";
1057
1057
  const values = new Uint8Array(length);
1058
1058
  crypto.getRandomValues(values);
@@ -1221,7 +1221,7 @@ var OAuthHelpersImpl = class {
1221
1221
  const state = url.searchParams.get("state") || "";
1222
1222
  const codeChallenge = url.searchParams.get("code_challenge") || void 0;
1223
1223
  const codeChallengeMethod = url.searchParams.get("code_challenge_method") || "plain";
1224
- if (!redirectUri.startsWith("http://") && !redirectUri.startsWith("https://")) {
1224
+ if (redirectUri.startsWith("javascript:") || redirectUri.startsWith("data:") || redirectUri.startsWith("vbscript:") || redirectUri.startsWith("file:") || redirectUri.startsWith("mailto:") || redirectUri.startsWith("blob:")) {
1225
1225
  throw new Error("Invalid redirect URI");
1226
1226
  }
1227
1227
  if (responseType === "token" && !this.provider.options.allowImplicitFlow) {
@@ -1266,6 +1266,16 @@ var OAuthHelpersImpl = class {
1266
1266
  * @returns A Promise resolving to an object containing the redirect URL
1267
1267
  */
1268
1268
  async completeAuthorization(options) {
1269
+ const { clientId, redirectUri } = options.request;
1270
+ if (!clientId || !redirectUri) {
1271
+ throw new Error("Client ID and Redirect URI are required in the authorization request.");
1272
+ }
1273
+ const clientInfo = await this.lookupClient(clientId);
1274
+ if (!clientInfo || !clientInfo.redirectUris.includes(redirectUri)) {
1275
+ throw new Error(
1276
+ "Invalid redirect URI. The redirect URI provided does not match any registered URI for this client."
1277
+ );
1278
+ }
1269
1279
  const grantId = generateRandomString(16);
1270
1280
  const { encryptedData, key: encryptionKey } = await encryptProps(options.props);
1271
1281
  const now = Math.floor(Date.now() / 1e3);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/workers-oauth-provider",
3
- "version": "0.0.0-373bacf",
3
+ "version": "0.0.0-50a8d92",
4
4
  "description": "OAuth provider for Cloudflare Workers",
5
5
  "main": "dist/oauth-provider.js",
6
6
  "types": "dist/oauth-provider.d.ts",