@sphereon/did-auth-siop
Version:
Self Issued OpenID V2 (SIOPv2) and OpenID 4 Verifiable Presentations (OID4VP)
21 lines (15 loc) • 485 B
text/typescript
import { defaultHasher, uuidv4 } from '@sphereon/oid4vc-common'
import { base64urlEncodeBuffer } from './Encodings'
export function getNonce(state: string, nonce?: string) {
return nonce || toNonce(state)
}
export function toNonce(input: string): string {
const buff = defaultHasher(input, 'sha256')
return base64urlEncodeBuffer(buff)
}
export function getState(state?: string) {
return state || createState()
}
export function createState(): string {
return uuidv4()
}