From eda56fac5163f68704b40e4ed5a602231f43aca9 Mon Sep 17 00:00:00 2001 From: Maximiliano Schultheis Date: Fri, 12 Jul 2024 10:37:20 -0300 Subject: [PATCH] make passkeys server request headers optional --- plugins/modularPermission/signers/toWebAuthnPubKey.ts | 10 +++++----- plugins/modularPermission/signers/toWebAuthnSigner.ts | 6 +++--- plugins/webauthn-key/toWebAuthnKey.ts | 10 +++++----- plugins/weighted-r1-k1/signers/toWebAuthnPubKey.ts | 10 +++++----- plugins/weighted-r1-k1/signers/toWebAuthnSigner.ts | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/plugins/modularPermission/signers/toWebAuthnPubKey.ts b/plugins/modularPermission/signers/toWebAuthnPubKey.ts index f7c36a76..06184cda 100644 --- a/plugins/modularPermission/signers/toWebAuthnPubKey.ts +++ b/plugins/modularPermission/signers/toWebAuthnPubKey.ts @@ -15,7 +15,7 @@ export const toWebAuthnPubKey = async ({ passkeyName: string passkeyServerUrl: string mode: WebAuthnMode - passkeyServerHeaders: Record + passkeyServerHeaders?: Record }): Promise => { let pubKey: string | undefined if (mode === WebAuthnMode.Login) { @@ -26,7 +26,7 @@ export const toWebAuthnPubKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, credentials: "include" } @@ -44,7 +44,7 @@ export const toWebAuthnPubKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ cred: loginCred }), credentials: "include" @@ -74,7 +74,7 @@ export const toWebAuthnPubKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ username: passkeyName }), credentials: "include" @@ -99,7 +99,7 @@ export const toWebAuthnPubKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ userId: registerOptions.userId, diff --git a/plugins/modularPermission/signers/toWebAuthnSigner.ts b/plugins/modularPermission/signers/toWebAuthnSigner.ts index d9676dec..621c0cf0 100644 --- a/plugins/modularPermission/signers/toWebAuthnSigner.ts +++ b/plugins/modularPermission/signers/toWebAuthnSigner.ts @@ -36,7 +36,7 @@ export type WebAuthnModularSignerParams = ModularSignerParams & { passkeyServerUrl: string pubKey?: WebAuthnKey mode?: WebAuthnMode - passkeyServerHeaders: Record + passkeyServerHeaders?: Record } export const toWebAuthnSigner = async < @@ -99,7 +99,7 @@ export const toWebAuthnSigner = async < method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ data: formattedMessage, userId }), credentials: "include" @@ -123,7 +123,7 @@ export const toWebAuthnSigner = async < method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ cred, userId }), credentials: "include" diff --git a/plugins/webauthn-key/toWebAuthnKey.ts b/plugins/webauthn-key/toWebAuthnKey.ts index da7ab2c1..ad2325f4 100644 --- a/plugins/webauthn-key/toWebAuthnKey.ts +++ b/plugins/webauthn-key/toWebAuthnKey.ts @@ -19,7 +19,7 @@ export type WebAuthnAccountParams = { webAuthnKey?: WebAuthnKey mode?: WebAuthnMode credentials?: RequestCredentials - passkeyServerHeaders: Record + passkeyServerHeaders?: Record } export const encodeWebAuthnPubKey = (pubKey: WebAuthnKey) => { @@ -51,7 +51,7 @@ export const toWebAuthnKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, credentials } @@ -71,7 +71,7 @@ export const toWebAuthnKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ cred: loginCred }), credentials @@ -93,7 +93,7 @@ export const toWebAuthnKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ username: passkeyName }), credentials @@ -114,7 +114,7 @@ export const toWebAuthnKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ userId: registerOptions.userId, diff --git a/plugins/weighted-r1-k1/signers/toWebAuthnPubKey.ts b/plugins/weighted-r1-k1/signers/toWebAuthnPubKey.ts index ac85b64a..8ef786fd 100644 --- a/plugins/weighted-r1-k1/signers/toWebAuthnPubKey.ts +++ b/plugins/weighted-r1-k1/signers/toWebAuthnPubKey.ts @@ -17,7 +17,7 @@ export const toWebAuthnPubKey = async ({ passkeyName: string passkeyServerUrl: string mode: WebAuthnMode - passkeyServerHeaders: Record + passkeyServerHeaders?: Record }): Promise => { let pubKey: string | undefined let authenticatorIdHash: Hex @@ -29,7 +29,7 @@ export const toWebAuthnPubKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, credentials: "include" } @@ -52,7 +52,7 @@ export const toWebAuthnPubKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ cred: loginCred }), credentials: "include" @@ -82,7 +82,7 @@ export const toWebAuthnPubKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ username: passkeyName }), credentials: "include" @@ -112,7 +112,7 @@ export const toWebAuthnPubKey = async ({ method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ userId: registerOptions.userId, diff --git a/plugins/weighted-r1-k1/signers/toWebAuthnSigner.ts b/plugins/weighted-r1-k1/signers/toWebAuthnSigner.ts index e2c90f7f..e2a70b2e 100644 --- a/plugins/weighted-r1-k1/signers/toWebAuthnSigner.ts +++ b/plugins/weighted-r1-k1/signers/toWebAuthnSigner.ts @@ -39,7 +39,7 @@ export type WebAuthnModularSignerParams = { passkeyServerUrl: string pubKey?: WebAuthnKey mode?: WebAuthnMode - passkeyServerHeaders: Record + passkeyServerHeaders?: Record } export const toWebAuthnSigner = async < @@ -101,7 +101,7 @@ export const toWebAuthnSigner = async < method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ data: formattedMessage, userId }), credentials: "include" @@ -126,7 +126,7 @@ export const toWebAuthnSigner = async < method: "POST", headers: { "Content-Type": "application/json", - ...passkeyServerHeaders + ...(passkeyServerHeaders ?? {}) }, body: JSON.stringify({ cred, userId }), credentials: "include"