@calimero-network/mero-js 29.7.3 → 29.7.4
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 +18 -2
- package/dist/cloud-v2/passkey.js +2 -2
- package/dist/index.browser.mjs +5 -5
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +27 -6
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +27 -6
- 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);
|
|
@@ -1759,12 +1767,12 @@ function browserPasskey() {
|
|
|
1759
1767
|
clientDataJson: b64url(new Uint8Array(r.clientDataJSON))
|
|
1760
1768
|
};
|
|
1761
1769
|
},
|
|
1762
|
-
async get(challenge, rpId, allowCredentials) {
|
|
1770
|
+
async get(challenge, rpId, allowCredentials, options) {
|
|
1763
1771
|
const cred = await ask("get", {
|
|
1764
1772
|
publicKey: {
|
|
1765
1773
|
challenge: buf(challenge),
|
|
1766
1774
|
rpId,
|
|
1767
|
-
userVerification: "preferred",
|
|
1775
|
+
userVerification: options?.userVerification ?? "preferred",
|
|
1768
1776
|
allowCredentials: (allowCredentials ?? []).map((id) => ({
|
|
1769
1777
|
type: "public-key",
|
|
1770
1778
|
id: buf(fromB64url(id))
|
|
@@ -1988,6 +1996,19 @@ function pageDeployment(href) {
|
|
|
1988
1996
|
return null;
|
|
1989
1997
|
}
|
|
1990
1998
|
}
|
|
1999
|
+
function userVerificationOf(named) {
|
|
2000
|
+
return named === "required" || named === "preferred" || named === "discouraged" ? named : "required";
|
|
2001
|
+
}
|
|
2002
|
+
function promptFailure(error) {
|
|
2003
|
+
const e = error;
|
|
2004
|
+
const name = e?.name;
|
|
2005
|
+
const message = typeof e?.message === "string" ? e.message : "";
|
|
2006
|
+
if (name === "InvalidStateError" || /not focused|already pending/i.test(message)) {
|
|
2007
|
+
return new ConfirmPromptBlocked(error);
|
|
2008
|
+
}
|
|
2009
|
+
if (name === "NotAllowedError" || name === "AbortError") return new ConfirmCancelled(error);
|
|
2010
|
+
return error;
|
|
2011
|
+
}
|
|
1991
2012
|
function seg(value) {
|
|
1992
2013
|
return encodeURIComponent(value);
|
|
1993
2014
|
}
|
|
@@ -2765,11 +2786,11 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2765
2786
|
const d = error.details;
|
|
2766
2787
|
let assertion;
|
|
2767
2788
|
try {
|
|
2768
|
-
assertion = await passkey.get(fromB64url(d.challenge), d.rpId, d.allowCredentials
|
|
2789
|
+
assertion = await passkey.get(fromB64url(d.challenge), d.rpId, d.allowCredentials, {
|
|
2790
|
+
userVerification: userVerificationOf(d.userVerification)
|
|
2791
|
+
});
|
|
2769
2792
|
} catch (declined) {
|
|
2770
|
-
|
|
2771
|
-
if (name === "NotAllowedError" || name === "AbortError") throw new ConfirmCancelled(declined);
|
|
2772
|
-
throw declined;
|
|
2793
|
+
throw promptFailure(declined);
|
|
2773
2794
|
}
|
|
2774
2795
|
return send({ ...body, confirm: { challengeId: d.challengeId, assertion } });
|
|
2775
2796
|
}
|