Skip to content

Commit

Permalink
Merge pull request #418 from skooner-k8s/fix-406
Browse files Browse the repository at this point in the history
improve getCrypto function
  • Loading branch information
tianni4104 authored Sep 13, 2023
2 parents 8cc7601 + a8e6bff commit fa2538b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ const k8s = require('@kubernetes/client-node');
const {createProxyMiddleware} = require('http-proxy-middleware');
const toString = require('stream-to-string');
const {Issuer} = require('openid-client');
const crypto = require('crypto').webcrypto;
const getCrypto = () =>
typeof globalThis.crypto?.getRandomValues === 'function'
? globalThis.crypto
: // eslint-disable-next-line @typescript-eslint/no-var-requires
require('crypto').webcrypto;

const crypto = getCrypto();

const NODE_ENV = process.env.NODE_ENV;
const DEBUG_VERBOSE = !!process.env.DEBUG_VERBOSE;
Expand Down Expand Up @@ -67,9 +73,6 @@ async function generateCodeChallengeFromVerifier(v) {

const codeVerifier = generateCodeVerifier()


console.log('OIDC_URL: ', OIDC_URL || 'None');

process.on('uncaughtException', err => console.error('Uncaught exception', err));

const kc = new k8s.KubeConfig();
Expand Down

0 comments on commit fa2538b

Please sign in to comment.