@calimero-network/mero-js 29.7.1 → 29.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloud-v2/passkey.js +35 -12
- package/dist/index.browser.mjs +5 -5
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +26 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +26 -4
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1717,17 +1717,36 @@ function cancelled(message) {
|
|
|
1717
1717
|
error.name = "NotAllowedError";
|
|
1718
1718
|
return error;
|
|
1719
1719
|
}
|
|
1720
|
+
async function ask(method, options) {
|
|
1721
|
+
const container = navigator.credentials;
|
|
1722
|
+
const page = container[method];
|
|
1723
|
+
try {
|
|
1724
|
+
return await page.call(container, options);
|
|
1725
|
+
} catch (error) {
|
|
1726
|
+
const own = globalThis.CredentialsContainer?.prototype?.[method];
|
|
1727
|
+
if (!own || own === page || !stuck(error)) throw error;
|
|
1728
|
+
return own.call(container, options);
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
function stuck(error) {
|
|
1732
|
+
return /request is already pending/i.test(
|
|
1733
|
+
error?.message?.toString() ?? ""
|
|
1734
|
+
);
|
|
1735
|
+
}
|
|
1720
1736
|
function browserPasskey() {
|
|
1721
1737
|
return {
|
|
1722
1738
|
async create(options) {
|
|
1723
1739
|
const o = options;
|
|
1724
|
-
const cred = await
|
|
1740
|
+
const cred = await ask("create", {
|
|
1725
1741
|
publicKey: {
|
|
1726
1742
|
challenge: buf(fromB64url(o.challenge)),
|
|
1727
1743
|
rp: o.rp,
|
|
1728
1744
|
user: { ...o.user, id: buf(fromB64url(o.user.id)) },
|
|
1729
1745
|
pubKeyCredParams: o.pubKeyCredParams,
|
|
1730
|
-
excludeCredentials: (o.excludeCredentials ?? []).map((c) => ({
|
|
1746
|
+
excludeCredentials: (o.excludeCredentials ?? []).map((c) => ({
|
|
1747
|
+
type: c.type,
|
|
1748
|
+
id: buf(fromB64url(c.id))
|
|
1749
|
+
})),
|
|
1731
1750
|
authenticatorSelection: o.authenticatorSelection,
|
|
1732
1751
|
attestation: "none",
|
|
1733
1752
|
timeout: o.timeout
|
|
@@ -1741,12 +1760,15 @@ function browserPasskey() {
|
|
|
1741
1760
|
};
|
|
1742
1761
|
},
|
|
1743
1762
|
async get(challenge, rpId, allowCredentials) {
|
|
1744
|
-
const cred = await
|
|
1763
|
+
const cred = await ask("get", {
|
|
1745
1764
|
publicKey: {
|
|
1746
1765
|
challenge: buf(challenge),
|
|
1747
1766
|
rpId,
|
|
1748
1767
|
userVerification: "preferred",
|
|
1749
|
-
allowCredentials: (allowCredentials ?? []).map((id) => ({
|
|
1768
|
+
allowCredentials: (allowCredentials ?? []).map((id) => ({
|
|
1769
|
+
type: "public-key",
|
|
1770
|
+
id: buf(fromB64url(id))
|
|
1771
|
+
}))
|
|
1750
1772
|
}
|
|
1751
1773
|
});
|
|
1752
1774
|
if (!cred) throw cancelled("passkey sign-in was cancelled");
|