Skip to content

Commit

Permalink
make passkeys server request headers optional
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisch committed Jul 12, 2024
1 parent a34af01 commit eda56fa
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions plugins/modularPermission/signers/toWebAuthnPubKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const toWebAuthnPubKey = async ({
passkeyName: string
passkeyServerUrl: string
mode: WebAuthnMode
passkeyServerHeaders: Record<string, string>
passkeyServerHeaders?: Record<string, string>
}): Promise<WebAuthnKey> => {
let pubKey: string | undefined
if (mode === WebAuthnMode.Login) {
Expand All @@ -26,7 +26,7 @@ export const toWebAuthnPubKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
credentials: "include"
}
Expand All @@ -44,7 +44,7 @@ export const toWebAuthnPubKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({ cred: loginCred }),
credentials: "include"
Expand Down Expand Up @@ -74,7 +74,7 @@ export const toWebAuthnPubKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({ username: passkeyName }),
credentials: "include"
Expand All @@ -99,7 +99,7 @@ export const toWebAuthnPubKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({
userId: registerOptions.userId,
Expand Down
6 changes: 3 additions & 3 deletions plugins/modularPermission/signers/toWebAuthnSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type WebAuthnModularSignerParams = ModularSignerParams & {
passkeyServerUrl: string
pubKey?: WebAuthnKey
mode?: WebAuthnMode
passkeyServerHeaders: Record<string, string>
passkeyServerHeaders?: Record<string, string>
}

export const toWebAuthnSigner = async <
Expand Down Expand Up @@ -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"
Expand All @@ -123,7 +123,7 @@ export const toWebAuthnSigner = async <
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({ cred, userId }),
credentials: "include"
Expand Down
10 changes: 5 additions & 5 deletions plugins/webauthn-key/toWebAuthnKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type WebAuthnAccountParams = {
webAuthnKey?: WebAuthnKey
mode?: WebAuthnMode
credentials?: RequestCredentials
passkeyServerHeaders: Record<string, string>
passkeyServerHeaders?: Record<string, string>
}

export const encodeWebAuthnPubKey = (pubKey: WebAuthnKey) => {
Expand Down Expand Up @@ -51,7 +51,7 @@ export const toWebAuthnKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
credentials
}
Expand All @@ -71,7 +71,7 @@ export const toWebAuthnKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({ cred: loginCred }),
credentials
Expand All @@ -93,7 +93,7 @@ export const toWebAuthnKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({ username: passkeyName }),
credentials
Expand All @@ -114,7 +114,7 @@ export const toWebAuthnKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({
userId: registerOptions.userId,
Expand Down
10 changes: 5 additions & 5 deletions plugins/weighted-r1-k1/signers/toWebAuthnPubKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const toWebAuthnPubKey = async ({
passkeyName: string
passkeyServerUrl: string
mode: WebAuthnMode
passkeyServerHeaders: Record<string, string>
passkeyServerHeaders?: Record<string, string>
}): Promise<WebAuthnKey> => {
let pubKey: string | undefined
let authenticatorIdHash: Hex
Expand All @@ -29,7 +29,7 @@ export const toWebAuthnPubKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
credentials: "include"
}
Expand All @@ -52,7 +52,7 @@ export const toWebAuthnPubKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({ cred: loginCred }),
credentials: "include"
Expand Down Expand Up @@ -82,7 +82,7 @@ export const toWebAuthnPubKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({ username: passkeyName }),
credentials: "include"
Expand Down Expand Up @@ -112,7 +112,7 @@ export const toWebAuthnPubKey = async ({
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({
userId: registerOptions.userId,
Expand Down
6 changes: 3 additions & 3 deletions plugins/weighted-r1-k1/signers/toWebAuthnSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type WebAuthnModularSignerParams = {
passkeyServerUrl: string
pubKey?: WebAuthnKey
mode?: WebAuthnMode
passkeyServerHeaders: Record<string, string>
passkeyServerHeaders?: Record<string, string>
}

export const toWebAuthnSigner = async <
Expand Down Expand Up @@ -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"
Expand All @@ -126,7 +126,7 @@ export const toWebAuthnSigner = async <
method: "POST",
headers: {
"Content-Type": "application/json",
...passkeyServerHeaders
...(passkeyServerHeaders ?? {})
},
body: JSON.stringify({ cred, userId }),
credentials: "include"
Expand Down

0 comments on commit eda56fa

Please sign in to comment.