mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-04 00:05:28 -05:00
* chore: compile TS into /dist Having the output co-located with the source meant that the js would be imported by default. Given that we don't recompile on source changes, this means the server got 'stuck' at the point of compilation and would only register changes on build. Also, compiling to a dist directory should make it easier to build when we want to deploy. That said, the motivation is mostly DX. * fix: put schema.prisma in the default location
16 lines
436 B
TypeScript
16 lines
436 B
TypeScript
import { randomBytes, createHash } from 'crypto';
|
|
|
|
export function base64URLEncode(buf: Buffer): string {
|
|
return buf
|
|
.toString('base64')
|
|
.replace(/\+/g, '-')
|
|
.replace(/\//g, '_')
|
|
.replace(/=/g, '');
|
|
}
|
|
export const verifier = base64URLEncode(randomBytes(32));
|
|
|
|
function sha256(buf: Buffer) {
|
|
return createHash('sha256').update(buf).digest();
|
|
}
|
|
export const challenge = base64URLEncode(sha256(Buffer.from(verifier)));
|