-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lukas.J.Han <[email protected]>
- Loading branch information
Showing
10 changed files
with
37 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { createDecoy } from '../decoy'; | ||
import { describe, expect, test } from 'vitest'; | ||
import { Base64urlEncode } from '@sd-jwt/utils'; | ||
import { base64urlEncode } from '@sd-jwt/utils'; | ||
import { digest, generateSalt } from '@sd-jwt/crypto-nodejs'; | ||
|
||
const hash = { | ||
|
@@ -21,7 +21,7 @@ describe('Decoy', () => { | |
// * Contents: ["6Ij7tM-a5iVPGboS5tmvVA", "email", "[email protected]"] | ||
test('apply hasher and saltGenerator', async () => { | ||
const decoyValue = await createDecoy(hash, () => | ||
Base64urlEncode( | ||
base64urlEncode( | ||
'["6Ij7tM-a5iVPGboS5tmvVA", "email", "[email protected]"]', | ||
), | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { Base64 } from 'js-base64'; | ||
|
||
export const Base64urlEncode = Base64.encodeURI; | ||
export const base64urlEncode = Base64.encodeURI; | ||
|
||
export const Base64urlDecode = Base64.decode; | ||
export const base64urlDecode = Base64.decode; | ||
|
||
export const Uint8ArrayToBase64Url = (input: Uint8Array): string => | ||
export const uint8ArrayToBase64Url = (input: Uint8Array): string => | ||
Base64.fromUint8Array(input, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
import { | ||
Base64urlDecode, | ||
Base64urlEncode, | ||
Uint8ArrayToBase64Url, | ||
base64urlDecode, | ||
base64urlEncode, | ||
uint8ArrayToBase64Url, | ||
} from '../base64url'; | ||
|
||
describe('Base64url', () => { | ||
const raw = 'abcdefghijklmnopqrstuvwxyz'; | ||
const encoded = 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo'; | ||
test('Encode', () => { | ||
expect(Base64urlEncode(raw)).toStrictEqual(encoded); | ||
expect(base64urlEncode(raw)).toStrictEqual(encoded); | ||
}); | ||
test('Decode', () => { | ||
expect(Base64urlDecode(encoded)).toStrictEqual(raw); | ||
expect(base64urlDecode(encoded)).toStrictEqual(raw); | ||
}); | ||
test('Encode and decode', () => { | ||
const str = 'hello world'; | ||
expect(Base64urlDecode(Base64urlEncode(str))).toStrictEqual(str); | ||
expect(base64urlDecode(base64urlEncode(str))).toStrictEqual(str); | ||
}); | ||
test('Uint8Array', () => { | ||
const str = 'hello world'; | ||
const uint8 = new TextEncoder().encode(str); | ||
expect(Uint8ArrayToBase64Url(uint8)).toStrictEqual(Base64urlEncode(str)); | ||
expect(uint8ArrayToBase64Url(uint8)).toStrictEqual(base64urlEncode(str)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters