deno.land / x / oauth4webapi@v1.2.2 / tap / random.ts

random.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import type QUnit from 'qunit'import * as lib from '../src/index.js'
const b64length = (raw: number) => Math.ceil((raw * 4) / 3)
export default (QUnit: QUnit) => { const { module, test } = QUnit module('random.ts')
test('generateRandomCodeVerifier()', (t) => { const codeVerifier = lib.generateRandomCodeVerifier() t.equal(codeVerifier.length, b64length(32)) })
test('calculatePKCECodeChallenge() - https://www.rfc-editor.org/rfc/rfc7636#appendix-B', async (t) => { const verifier = 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk' t.equal( await lib.calculatePKCECodeChallenge(verifier), 'E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM', ) })
test('generateRandomState()', (t) => { const state = lib.generateRandomState() t.equal(state.length, b64length(32)) })
test('generateRandomNonce()', (t) => { const nonce = lib.generateRandomNonce() t.equal(nonce.length, b64length(32)) })}
oauth4webapi

Version Info

Tagged at
2 years ago