firefox-passkey-background.js

897 B · raw

1const CREATE_CREDENTIAL_ID = "AQIDBA";2const GET_CREDENTIAL_ID = "BQYHCA";34browser.runtime.onMessage.addListener((message) => {5  if (message?.type === "PASSKEY_HAS_CREDENTIALS") {6    return Promise.resolve({ ok: true, hasCredentials: true });7  }8  if (message?.type === "PASSKEY_CREATE") {9    return Promise.resolve({10      ok: true,11      credential: {12        type: "create",13        id: CREATE_CREDENTIAL_ID,14        clientDataJSON: [1],15        attestationObject: "AQ",16        authenticatorData: "Ag",17        publicKey: "Aw",18        algorithm: -7,19      },20    });21  }22  if (message?.type === "PASSKEY_GET") {23    return Promise.resolve({24      ok: true,25      credential: {26        type: "get",27        id: GET_CREDENTIAL_ID,28        clientDataJSON: [1],29        authenticatorData: "Ag",30        signature: "Aw",31        userHandle: "BA",32      },33    });34  }35  return undefined;36});