Skip to content

Commit

Permalink
fix: cjs being thrown in to provider (#3566)
Browse files Browse the repository at this point in the history
* fix: cjs being thrown in to provider

* Create heavy-colts-reply.md

---------

Co-authored-by: Dax <mail@thdxr.com>
  • Loading branch information
oyed and thdxr committed Dec 12, 2023
1 parent 7d2f92b commit 491ffbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-colts-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sst": patch
---

fix: cjs being thrown in to provider
20 changes: 9 additions & 11 deletions packages/sst/src/node/future/auth/adapter/apple.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@

import querystring from 'node:querystring';
import { generators, Issuer } from 'openid-client';

import {
useBody, useCookie, useDomainName, usePathParam, useQueryParams, useResponse
} from '../../../api/index.js';
import { useBody, useCookie, useDomainName, usePathParam, useResponse } from '../../../api/index.js';
import { Adapter } from './adapter.js';
import { OauthConfig, OauthError } from './oauth.js';

const querystring = require('querystring');
import { OauthConfig } from './oauth.js';

// This adapter support the OAuth flow with the response_mode "form_post" for now.
// This adapter support the OAuth flow with the response_mode "form_post" for now.
// More details about the flow:
// https://developer.apple.com/documentation/devicemanagement/user_enrollment/onboarding_users_with_account_sign-in/implementing_the_oauth2_authentication_user-enrollment_flow
//
Expand Down Expand Up @@ -74,12 +70,14 @@ export const AppleAdapter =
}

if (step === "callback") {
let params
let params = {}
if (config && config.params && config.params.response_mode === "form_post") {
const body = useBody()
params = querystring.parse(body)
if (typeof body === "string") {
params = querystring.parse(body)
}
}

const code_verifier = useCookie("auth_code_verifier");
const state = useCookie("auth_state");
const tokenset = await client["callback"](callback, params, {
Expand Down

0 comments on commit 491ffbf

Please sign in to comment.