Skip to content

Commit

Permalink
build: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
npenin committed Mar 22, 2024
1 parent bb8b7ca commit 54d0c09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/authentication/src/client/oidc-client/get-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ export default async function authorize(this: OIDCClientState, provider: string,

const result: X = { endpoint, state, query: { state, client_id: this.providers[provider].clientId, scope: scope.join('+'), redirect_uri, response_type } };

//PKCE
if (oidc.code_challenge_methods_supported && oidc.code_challenge_methods_supported.length)
{
if (oidc.code_challenge_methods_supported.indexOf('S256') > -1)
{
result.verifier = crypto.randomUUID();
const encoder = new TextEncoder();
const data = encoder.encode(result.verifier);
result.query.code_challenge = base64.base64EncArr(await crypto.subtle.digest('SHA-256', data)).replace(/-/g, '+').replace(/_/g, '/');
result.query.code_challenge = base64.base64EncArr(new Uint8Array(await crypto.subtle.digest('SHA-256', data))).replace(/-/g, '+').replace(/_/g, '/');
result.query.code_challenge_method = 'S256';
}
else if (oidc.code_challenge_methods_supported.indexOf('plain') > -1)
Expand Down
4 changes: 2 additions & 2 deletions packages/authentication/src/client/oidc-client/get-token.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OIDCClientState, OIDCResponseType, providers, OICDAuthMethods } from "../oidc-state.js";

import { base64 } from '@akala/core'

type X = {
endpoint: URL;
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function (this: OIDCClientState, provider: string, code: string,
switch (x)
{
case OICDAuthMethods.ClientSecretBasic:
result.headers.authorization = Buffer.from(providerConfig.clientId + ':' + providerConfig.clientSecret).toString('base64');
result.headers.authorization = base64.base64EncArr(base64.strToUTF8Arr(providerConfig.clientId + ':' + providerConfig.clientSecret));
return result;
case OICDAuthMethods.ClientSecretPost:
result.body = result.query;
Expand Down

0 comments on commit 54d0c09

Please sign in to comment.