Skip to content

Commit

Permalink
chore(utils/jwt): add @module docs (#3101)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe authored Jul 6, 2024
1 parent e513fe7 commit a90ff2d
Showing 5 changed files with 27 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/utils/jwt/jwa.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// JSON Web Algorithms (JWA)
// https://datatracker.ietf.org/doc/html/rfc7518
/**
* @module
* JSON Web Algorithms (JWA)
* https://datatracker.ietf.org/doc/html/rfc7518
*/

export enum AlgorithmTypes {
HS256 = 'HS256',
9 changes: 6 additions & 3 deletions src/utils/jwt/jws.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/**
* @module
* JSON Web Signature (JWS)
* https://datatracker.ietf.org/doc/html/rfc7515
*/

import { getRuntimeKey } from '../../helper/adapter'
import { decodeBase64 } from '../encode'
import type { SignatureAlgorithm } from './jwa'
import { CryptoKeyUsage, JwtAlgorithmNotImplemented } from './types'
import { utf8Encoder } from './utf8'

// JSON Web Signature (JWS)
// https://datatracker.ietf.org/doc/html/rfc7515

type KeyImporterAlgorithm = Parameters<typeof crypto.subtle.importKey>[2]
type KeyAlgorithm =
| AlgorithmIdentifier
6 changes: 6 additions & 0 deletions src/utils/jwt/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* @module
* JSON Web Token (JWT)
* https://datatracker.ietf.org/doc/html/rfc7519
*/

import { decodeBase64Url, encodeBase64Url } from '../../utils/encode'
import { AlgorithmTypes } from './jwa'
import type { SignatureAlgorithm } from './jwa'
5 changes: 5 additions & 0 deletions src/utils/jwt/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @module
* Type definitions for JWT utilities.
*/

export class JwtAlgorithmNotImplemented extends Error {
constructor(alg: string) {
super(`${alg} is not an implemented algorithm`)
5 changes: 5 additions & 0 deletions src/utils/jwt/utf8.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/**
* @module
* Functions for encoding/decoding UTF8.
*/

export const utf8Encoder: TextEncoder = new TextEncoder()
export const utf8Decoder: TextDecoder = new TextDecoder()

0 comments on commit a90ff2d

Please sign in to comment.