Skip to content

Commit

Permalink
base64decode bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ragnika committed Feb 1, 2024
1 parent ef0ad1d commit fa51e35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meeco/sd-jwt",
"version": "0.0.3",
"version": "0.0.4",
"description": "SD-JWT implementation in typescript",
"scripts": {
"build": "tsc",
Expand Down
8 changes: 5 additions & 3 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FORMAT_SEPARATOR, SD_DIGEST, SD_LIST_PREFIX } from './constants.js';
import { CreateDecoyError, DecodeJWTError } from './errors.js';
import * as base64url from './runtime/base64url.js';
import {
CompactSDJWT,
Disclosure,
Expand All @@ -10,7 +11,8 @@ import {
SdDigestHashmap,
UnverifiedJWT,
} from './types.js';
import { encode, decode } from './runtime/base64url.js';

const decoder = new TextDecoder();

export function generateSalt(length: number): string {
let salt = '';
Expand All @@ -22,11 +24,11 @@ export function generateSalt(length: number): string {
}

export function base64encode(input: string | Uint8Array): string {
return encode(input);
return base64url.encode(input);
}

export function base64decode(input: string): string {
return decode(input).toString();
return decoder.decode(base64url.decode(input));
}

export function isObject(input: any): boolean {
Expand Down

0 comments on commit fa51e35

Please sign in to comment.