MCPcopy Create free account
hub / github.com/ConsortiumAI/Consortium / decodeBase64

Function decodeBase64

packages/consortium-cli/src/api/encryption.ts:32–41  ·  view source on GitHub ↗
(base64: string, variant: 'base64' | 'base64url' = 'base64')

Source from the content-addressed store, hash-verified

30 * Decode a base64 string to a Uint8Array
31 */
32export function decodeBase64(base64: string, variant: 'base64' | 'base64url' = 'base64'): Uint8Array {
33 if (variant === 'base64url') {
34 const base64Standard = base64
35 .replaceAll('-', '+')
36 .replaceAll('_', '/')
37 + '='.repeat((4 - base64.length % 4) % 4);
38 return new Uint8Array(Buffer.from(base64Standard, 'base64'));
39 }
40 return new Uint8Array(Buffer.from(base64, 'base64'));
41}
42
43/**
44 * Generate secure random bytes

Callers 6

constructorMethod · 0.90
updateMetadataMethod · 0.90
updateAgentStateMethod · 0.90
getOrCreateSessionMethod · 0.90
handleRequestMethod · 0.90
waitForAuthenticationFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected