oidc-client-ts/src/JsonService.ts at mai...

GitHub
oidc-client-ts/src/JsonService.ts at main · authts/oidc-client-ts
OpenID Connect (OIDC) and OAuth2 protocol support for browser-based JavaScript applications - authts/oidc-client-ts
1 Reply
valkyrie_pilot
valkyrie_pilotOP17mo ago
the issue is setting Credentials, not a header
[mf:err] Error: The 'credentials' field on 'RequestInitializerDict' is not implemented.
at checkedFetch (/private/private/var/folders/kr/x026klkx43s4nscrbnb8m0g00000gn/T/tmp-30922-RVNE6PV99gns/checked-fetch.js:9:9)
at JsonService.fetchWithTimeout (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/JsonService.ts:53:26)
at JsonService.postForm (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/JsonService.ts:149:35)
at TokenClient.exchangeCode (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/TokenClient.ts:125:50)
at async ResponseValidator._processCode (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/ResponseValidator.ts:175:35)
at async ResponseValidator.validateSigninResponse (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/ResponseValidator.ts:39:9)
at async OidcClient.processSigninResponse (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/OidcClient.ts:164:9)
at async onRequest (/private/Users/redacted/Code/redacted/functions/login/callback.ts:12:23)
at async next (/private/opt/homebrew/lib/node_modules/wrangler/templates/pages-template-worker.ts:152:22)
at async onRequest3 (/private/Users/redacted/Code/redacted/functions/_middleware.ts:11:10)
[mf:err] Error: The 'credentials' field on 'RequestInitializerDict' is not implemented.
at checkedFetch (/private/private/var/folders/kr/x026klkx43s4nscrbnb8m0g00000gn/T/tmp-30922-RVNE6PV99gns/checked-fetch.js:9:9)
at JsonService.fetchWithTimeout (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/JsonService.ts:53:26)
at JsonService.postForm (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/JsonService.ts:149:35)
at TokenClient.exchangeCode (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/TokenClient.ts:125:50)
at async ResponseValidator._processCode (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/ResponseValidator.ts:175:35)
at async ResponseValidator.validateSigninResponse (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/ResponseValidator.ts:39:9)
at async OidcClient.processSigninResponse (/private/Users/redacted/Code/redacted/node_modules/oidc-client-ts/src/OidcClient.ts:164:9)
at async onRequest (/private/Users/redacted/Code/redacted/functions/login/callback.ts:12:23)
at async next (/private/opt/homebrew/lib/node_modules/wrangler/templates/pages-template-worker.ts:152:22)
at async onRequest3 (/private/Users/redacted/Code/redacted/functions/_middleware.ts:11:10)
hmm well.. i'm not particularly married to this library, if there is an OAuth/OpenID Connect client that actually supports workers, i would much rather use that i just wasn't able to find one is that the only thing that cloudflare doesn't support from browser apis? sigh i do not enjoy forking libraries I'll see if I can convince them to add support somehow if i can't, i may fork Oh absolutely not it worked hmmm is this a sarcastic suggestion because npm is currently dead on my machine hmmm would i need to throw this in the start of every http client instantiation well, anywhere in pages functions? or just "in every handler" i wonder if it'll work in a middleware i think so because it's await next i'll test well that's throwing errors, but i have a more immediate problem UNABLE_TO_GET_ISSUER_CERT_LOCALLY and i have no idea how to troubleshoot it npm, pnpm, wrangler anything that tries to acess the internet from node i think no why would i use a http registry like i see a lot of solutions online that are just "ignore security" hmmm i wonder if that happened i'm scared that i screwed something up with my dns no, macOS well, my issue is that google has been no help at all no Turns out homebrew node is just broken, using nvm node works fine anyway, i now get the error
Property 'credentials' does not exist on type 'RequestInit<RequestInitCfProperties>'.ts(2339)
Property 'credentials' does not exist on type 'RequestInit<RequestInitCfProperties>'.ts(2339)
using a very slightly tweaked version of this dang the ts compiler is so smart lol (no, i don't have any types yet but still)
const boundFetch = fetch.bind(globalThis);
globalThis.fetch = (
resource,
options: RequestInit<RequestInitCfProperties> & { credentials?: any }
) => {
if (options) delete options.credentials;
return boundFetch(resource, options);
};
const boundFetch = fetch.bind(globalThis);
globalThis.fetch = (
resource,
options: RequestInit<RequestInitCfProperties> & { credentials?: any }
) => {
if (options) delete options.credentials;
return boundFetch(resource, options);
};
hmm despite the stacktrace starting at the middleware, i still get The 'credentials' field on 'RequestInitializerDict' is not implemented. something like this:
import { Env, OpenIdClient } from "../env";

const boundFetch = fetch.bind(globalThis);
globalThis.fetch = (
resource,
options: RequestInit<RequestInitCfProperties> & { credentials?: any }
) => {
if (options) delete options.credentials;
return boundFetch(resource, options);
};

export async function onRequest(context: { request: Request; env: Env }) {
const { request, env } = context;
let client = OpenIdClient(
env.OAUTH_CLIENT_ID,
env.OAUTH_CLIENT_SECRET,
env.KV,
env.ROOT_URL
);
const signin_resp = await client.processSigninResponse(request.url);
let headers = new Headers();
headers.append("Set-Cookie", JSON.stringify(signin_resp));
return new Response("", { headers: headers });
}
import { Env, OpenIdClient } from "../env";

const boundFetch = fetch.bind(globalThis);
globalThis.fetch = (
resource,
options: RequestInit<RequestInitCfProperties> & { credentials?: any }
) => {
if (options) delete options.credentials;
return boundFetch(resource, options);
};

export async function onRequest(context: { request: Request; env: Env }) {
const { request, env } = context;
let client = OpenIdClient(
env.OAUTH_CLIENT_ID,
env.OAUTH_CLIENT_SECRET,
env.KV,
env.ROOT_URL
);
const signin_resp = await client.processSigninResponse(request.url);
let headers = new Headers();
headers.append("Set-Cookie", JSON.stringify(signin_resp));
return new Response("", { headers: headers });
}
hmm that seems to have the exact same problem? what? why on earth would this like happen even removing the ifsuffering THEN THOUGH that it is
Want results from more Discord servers?
Add your server