@calimero-network/mero-js 29.7.3 → 29.7.5
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/README.md +1 -1
- package/dist/cloud-v2/client.d.ts +1 -1
- package/dist/cloud-v2/client.js +36 -9
- package/dist/cloud-v2/errors.d.ts +12 -0
- package/dist/cloud-v2/errors.js +15 -0
- package/dist/cloud-v2/index.d.ts +2 -2
- package/dist/cloud-v2/index.js +1 -1
- package/dist/cloud-v2/passkey.d.ts +35 -2
- package/dist/cloud-v2/passkey.js +19 -16
- package/dist/index.browser.mjs +5 -5
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +34 -19
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +34 -19
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
CalimeroError: () => CalimeroError,
|
|
40
40
|
ClusterNotUpgraded: () => ClusterNotUpgraded,
|
|
41
41
|
ConfirmCancelled: () => ConfirmCancelled,
|
|
42
|
+
ConfirmPromptBlocked: () => ConfirmPromptBlocked,
|
|
42
43
|
ConfirmRequired: () => ConfirmRequired,
|
|
43
44
|
ConsentStale: () => ConsentStale,
|
|
44
45
|
DEFAULT_COLLATERAL_MIRROR: () => DEFAULT_COLLATERAL_MIRROR,
|
|
@@ -1511,6 +1512,13 @@ var ConfirmCancelled = class extends Error {
|
|
|
1511
1512
|
this.name = "ConfirmCancelled";
|
|
1512
1513
|
}
|
|
1513
1514
|
};
|
|
1515
|
+
var ConfirmPromptBlocked = class extends Error {
|
|
1516
|
+
constructor(cause) {
|
|
1517
|
+
super("the passkey prompt was blocked by the browser or a password manager");
|
|
1518
|
+
this.cause = cause;
|
|
1519
|
+
this.name = "ConfirmPromptBlocked";
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1514
1522
|
var ArgsTooLarge = class extends CalimeroError {
|
|
1515
1523
|
constructor(message, details = {}) {
|
|
1516
1524
|
super(413, "ARGS_TOO_LARGE", message, details);
|
|
@@ -1719,19 +1727,13 @@ function cancelled(message) {
|
|
|
1719
1727
|
}
|
|
1720
1728
|
async function ask(method, options) {
|
|
1721
1729
|
const container = navigator.credentials;
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1724
|
-
|
|
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
|
+
const own = globalThis.CredentialsContainer?.prototype?.[method];
|
|
1731
|
+
const call = own ?? container[method];
|
|
1732
|
+
return call.call(container, options);
|
|
1730
1733
|
}
|
|
1731
|
-
function
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
);
|
|
1734
|
+
function es256First(params) {
|
|
1735
|
+
const es256 = params.filter((p) => p.alg === -7);
|
|
1736
|
+
return es256.length ? es256 : params;
|
|
1735
1737
|
}
|
|
1736
1738
|
function browserPasskey() {
|
|
1737
1739
|
return {
|
|
@@ -1742,7 +1744,7 @@ function browserPasskey() {
|
|
|
1742
1744
|
challenge: buf(fromB64url(o.challenge)),
|
|
1743
1745
|
rp: o.rp,
|
|
1744
1746
|
user: { ...o.user, id: buf(fromB64url(o.user.id)) },
|
|
1745
|
-
pubKeyCredParams: o.pubKeyCredParams,
|
|
1747
|
+
pubKeyCredParams: es256First(o.pubKeyCredParams),
|
|
1746
1748
|
excludeCredentials: (o.excludeCredentials ?? []).map((c) => ({
|
|
1747
1749
|
type: c.type,
|
|
1748
1750
|
id: buf(fromB64url(c.id))
|
|
@@ -1759,12 +1761,12 @@ function browserPasskey() {
|
|
|
1759
1761
|
clientDataJson: b64url(new Uint8Array(r.clientDataJSON))
|
|
1760
1762
|
};
|
|
1761
1763
|
},
|
|
1762
|
-
async get(challenge, rpId, allowCredentials) {
|
|
1764
|
+
async get(challenge, rpId, allowCredentials, options) {
|
|
1763
1765
|
const cred = await ask("get", {
|
|
1764
1766
|
publicKey: {
|
|
1765
1767
|
challenge: buf(challenge),
|
|
1766
1768
|
rpId,
|
|
1767
|
-
userVerification: "preferred",
|
|
1769
|
+
userVerification: options?.userVerification ?? "preferred",
|
|
1768
1770
|
allowCredentials: (allowCredentials ?? []).map((id) => ({
|
|
1769
1771
|
type: "public-key",
|
|
1770
1772
|
id: buf(fromB64url(id))
|
|
@@ -1988,6 +1990,19 @@ function pageDeployment(href) {
|
|
|
1988
1990
|
return null;
|
|
1989
1991
|
}
|
|
1990
1992
|
}
|
|
1993
|
+
function userVerificationOf(named) {
|
|
1994
|
+
return named === "required" || named === "preferred" || named === "discouraged" ? named : "required";
|
|
1995
|
+
}
|
|
1996
|
+
function promptFailure(error) {
|
|
1997
|
+
const e = error;
|
|
1998
|
+
const name = e?.name;
|
|
1999
|
+
const message = typeof e?.message === "string" ? e.message : "";
|
|
2000
|
+
if (name === "InvalidStateError" || /not focused|already pending/i.test(message)) {
|
|
2001
|
+
return new ConfirmPromptBlocked(error);
|
|
2002
|
+
}
|
|
2003
|
+
if (name === "NotAllowedError" || name === "AbortError") return new ConfirmCancelled(error);
|
|
2004
|
+
return error;
|
|
2005
|
+
}
|
|
1991
2006
|
function seg(value) {
|
|
1992
2007
|
return encodeURIComponent(value);
|
|
1993
2008
|
}
|
|
@@ -2765,11 +2780,11 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2765
2780
|
const d = error.details;
|
|
2766
2781
|
let assertion;
|
|
2767
2782
|
try {
|
|
2768
|
-
assertion = await passkey.get(fromB64url(d.challenge), d.rpId, d.allowCredentials
|
|
2783
|
+
assertion = await passkey.get(fromB64url(d.challenge), d.rpId, d.allowCredentials, {
|
|
2784
|
+
userVerification: userVerificationOf(d.userVerification)
|
|
2785
|
+
});
|
|
2769
2786
|
} catch (declined) {
|
|
2770
|
-
|
|
2771
|
-
if (name === "NotAllowedError" || name === "AbortError") throw new ConfirmCancelled(declined);
|
|
2772
|
-
throw declined;
|
|
2787
|
+
throw promptFailure(declined);
|
|
2773
2788
|
}
|
|
2774
2789
|
return send({ ...body, confirm: { challengeId: d.challengeId, assertion } });
|
|
2775
2790
|
}
|