All files / src/crypto/token-signer create-signing-input.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  41x   41x 14x       14x       14x     14x     14x    
import { Json } from './types';
import base64url from './base64url';
 
export function createSigningInput(payload: Json, header: Json) {
  const tokenParts = [];
 
  // add in the header
  const encodedHeader = base64url.encode(JSON.stringify(header));
  tokenParts.push(encodedHeader);
 
  // add in the payload
  const encodedPayload = base64url.encode(JSON.stringify(payload));
  tokenParts.push(encodedPayload);
 
  // prepare the message
  const signingInput = tokenParts.join('.');
 
  // return the signing input
  return signingInput;
}