summaryrefslogtreecommitdiffhomepage
path: root/packages/typescript-types/src
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-05-20 22:58:00 -0700
committerMatthew Miller <matthew@millerti.me>2020-05-20 22:58:00 -0700
commitec4993382244b1153df3d92dd14280a252db4bde (patch)
tree2e6331995bafcdc49e1f1ff8427400a6bb3e587c /packages/typescript-types/src
parentdcb6c682066970ce569c145220f10686b08f71cf (diff)
Add new types for credentials as JSON
Diffstat (limited to 'packages/typescript-types/src')
-rw-r--r--packages/typescript-types/src/index.ts56
1 files changed, 56 insertions, 0 deletions
diff --git a/packages/typescript-types/src/index.ts b/packages/typescript-types/src/index.ts
index 58cc90c..2d9f8d2 100644
--- a/packages/typescript-types/src/index.ts
+++ b/packages/typescript-types/src/index.ts
@@ -6,6 +6,36 @@ export type AttestationCredentials = {
};
/**
+ * A variant of AttestationCredentials suitable for JSON transmission to the browser
+ *
+ * Noteworthy values:
+ * @param challenge A random string of characters. Will be converted to a Uint8Array in the browser
+ * @param user.id Your unique, internal ID for the user. Will be converted to a Uint8Array in the
+ * browser
+ */
+export type AttestationCredentialsJSON = {
+ publicKey: {
+ challenge: string,
+ // The organization registering and authenticating the user
+ rp: {
+ name: string,
+ id: string,
+ },
+ user: {
+ id: string,
+ name: string,
+ displayName: string,
+ },
+ pubKeyCredParams: [{
+ alg: -7,
+ type: 'public-key',
+ }],
+ timeout?: number,
+ attestation: 'direct' | 'indirect',
+ },
+};
+
+/**
* An object that can be passed into navigator.credentials.get(...) in the browser
*/
export type AssertionCredentials = {
@@ -13,6 +43,31 @@ export type AssertionCredentials = {
};
/**
+ * A variant of AssertionCredentials suitable for JSON transmission to the browser
+ *
+ * Noteworthy values:
+ * @param challenge A random string of characters. Will be converted to a Uint8Array in the browser
+ * @param allowCredentials.id Base64-encoded credentialId. Will be converted to a Uint8Array in the
+ * browser
+ */
+export type AssertionCredentialsJSON = {
+ publicKey: {
+ //
+ challenge: string,
+ allowCredentials: {
+ // Will be converted to a Uint8Array in the browser
+ id: string,
+ type: 'public-key',
+ transports?: AuthenticatorTransport[],
+ }[],
+ // extensions?: AuthenticationExtensionsClientInputs,
+ rpId?: string,
+ timeout?: number,
+ userVerification?: UserVerificationRequirement,
+ },
+};
+
+/**
* A slightly-modified AuthenticatorAttestationResponse to simplify working with ArrayBuffers that
* are base64-encoded in the browser so that they can be sent as JSON to the server.
*/
@@ -33,6 +88,7 @@ AuthenticatorAssertionResponse, 'clientDataJSON' | 'authenticatorData' | 'signat
base64AuthenticatorData: string;
base64ClientDataJSON: string;
base64Signature: string;
+ base64UserHandle: string;
}
export enum ATTESTATION_FORMATS {