diff options
author | Matthew Miller <matthew@millerti.me> | 2024-02-24 16:45:51 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-24 16:45:51 -0800 |
commit | 6eb5ac62e778c6c39c936cfce3309b9aa852021d (patch) | |
tree | 1d33f0a5ea58d74d0b41e6cc407ef604d76c399e /packages/server/src/helpers/iso/isoBase64URL.ts | |
parent | fe2245b9c1b7ada2099a6411c8ce2e6e6f18bbf9 (diff) | |
parent | b835ce41e1936765a49d7f7114116d78ddb67a1c (diff) |
Merge pull request #529 from MasterKale/fix/528-simplify-use-of-credential-id
fix/528-simplify-use-of-credential-id
Diffstat (limited to 'packages/server/src/helpers/iso/isoBase64URL.ts')
-rw-r--r-- | packages/server/src/helpers/iso/isoBase64URL.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/server/src/helpers/iso/isoBase64URL.ts b/packages/server/src/helpers/iso/isoBase64URL.ts index 5098b0c..99bf82a 100644 --- a/packages/server/src/helpers/iso/isoBase64URL.ts +++ b/packages/server/src/helpers/iso/isoBase64URL.ts @@ -1,4 +1,5 @@ import { base64 } from '../../deps.ts'; +import type { Base64URLString } from '../../deps.ts'; /** * Decode from a Base64URL-encoded string to an ArrayBuffer. Best used when converting a @@ -63,8 +64,15 @@ export function isBase64(input: string): boolean { /** * Confirm that the string is encoded into base64url, with support for optional padding */ -export function isBase64url(input: string): boolean { +export function isBase64URL(input: string): boolean { // Trim padding characters from the string if present - input = input.replace(/=/g, ''); + input = trimPadding(input); return base64.validate(input, true); } + +/** + * Remove optional padding from a base64url-encoded string + */ +export function trimPadding(input: Base64URLString): Base64URLString { + return input.replace(/=/g, ''); +} |