forked from passwordless-id/webauthn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
71 additions
and
42 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,27 +1,28 @@ | ||
import * as authenticators from './authenticators' | ||
import * as utils from './utils' | ||
import { AuthenticatorInfo, ClientInfo } from './types' | ||
|
||
const utf8Decoder = new TextDecoder('utf-8') | ||
|
||
export function parseClientBuffer(buffer :ArrayBuffer) { | ||
return JSON.parse(utf8Decoder.decode(buffer)) | ||
export function parseClient(data :string|ArrayBuffer) :ClientInfo { | ||
if(typeof data == 'string') | ||
data = utils.parseBase64url(data) | ||
return JSON.parse(utf8Decoder.decode(data)) | ||
} | ||
|
||
|
||
export function parseAuthenticatorBuffer(buffer :ArrayBuffer) { | ||
return authenticators.parseAuthBuffer(buffer) | ||
export function parseAuthenticator(data :string|ArrayBuffer) :AuthenticatorInfo { | ||
if(typeof data == 'string') | ||
data = utils.parseBase64url(data) | ||
return authenticators.parseAuthBuffer(data) | ||
} | ||
|
||
|
||
export function parseAttestationBuffer(buffer :ArrayBuffer) { | ||
export function parseAttestation(data :string|ArrayBuffer) :unknown { | ||
if(typeof data == 'string') | ||
data = utils.parseBase64url(data) | ||
return 'Really complex to parse. Good luck with that one!' | ||
} | ||
|
||
export function parseClientBase64(txt :string) { | ||
return parseClientBuffer( utils.parseBase64url(txt) ) | ||
} | ||
|
||
|
||
export function parseAuthenticatorBase64(txt :string) { | ||
return parseAuthenticatorBuffer( utils.parseBase64url(txt) ) | ||
} |
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