@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.mjs
CHANGED
|
@@ -1379,6 +1379,13 @@ var ConfirmCancelled = class extends Error {
|
|
|
1379
1379
|
this.name = "ConfirmCancelled";
|
|
1380
1380
|
}
|
|
1381
1381
|
};
|
|
1382
|
+
var ConfirmPromptBlocked = class extends Error {
|
|
1383
|
+
constructor(cause) {
|
|
1384
|
+
super("the passkey prompt was blocked by the browser or a password manager");
|
|
1385
|
+
this.cause = cause;
|
|
1386
|
+
this.name = "ConfirmPromptBlocked";
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1382
1389
|
var ArgsTooLarge = class extends CalimeroError {
|
|
1383
1390
|
constructor(message, details = {}) {
|
|
1384
1391
|
super(413, "ARGS_TOO_LARGE", message, details);
|
|
@@ -1627,12 +1634,12 @@ function browserPasskey() {
|
|
|
1627
1634
|
clientDataJson: b64url(new Uint8Array(r.clientDataJSON))
|
|
1628
1635
|
};
|
|
1629
1636
|
},
|
|
1630
|
-
async get(challenge, rpId, allowCredentials) {
|
|
1637
|
+
async get(challenge, rpId, allowCredentials, options) {
|
|
1631
1638
|
const cred = await ask("get", {
|
|
1632
1639
|
publicKey: {
|
|
1633
1640
|
challenge: buf(challenge),
|
|
1634
1641
|
rpId,
|
|
1635
|
-
userVerification: "preferred",
|
|
1642
|
+
userVerification: options?.userVerification ?? "preferred",
|
|
1636
1643
|
allowCredentials: (allowCredentials ?? []).map((id) => ({
|
|
1637
1644
|
type: "public-key",
|
|
1638
1645
|
id: buf(fromB64url(id))
|
|
@@ -1856,6 +1863,19 @@ function pageDeployment(href) {
|
|
|
1856
1863
|
return null;
|
|
1857
1864
|
}
|
|
1858
1865
|
}
|
|
1866
|
+
function userVerificationOf(named) {
|
|
1867
|
+
return named === "required" || named === "preferred" || named === "discouraged" ? named : "required";
|
|
1868
|
+
}
|
|
1869
|
+
function promptFailure(error) {
|
|
1870
|
+
const e = error;
|
|
1871
|
+
const name = e?.name;
|
|
1872
|
+
const message = typeof e?.message === "string" ? e.message : "";
|
|
1873
|
+
if (name === "InvalidStateError" || /not focused|already pending/i.test(message)) {
|
|
1874
|
+
return new ConfirmPromptBlocked(error);
|
|
1875
|
+
}
|
|
1876
|
+
if (name === "NotAllowedError" || name === "AbortError") return new ConfirmCancelled(error);
|
|
1877
|
+
return error;
|
|
1878
|
+
}
|
|
1859
1879
|
function seg(value) {
|
|
1860
1880
|
return encodeURIComponent(value);
|
|
1861
1881
|
}
|
|
@@ -2633,11 +2653,11 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2633
2653
|
const d = error.details;
|
|
2634
2654
|
let assertion;
|
|
2635
2655
|
try {
|
|
2636
|
-
assertion = await passkey.get(fromB64url(d.challenge), d.rpId, d.allowCredentials
|
|
2656
|
+
assertion = await passkey.get(fromB64url(d.challenge), d.rpId, d.allowCredentials, {
|
|
2657
|
+
userVerification: userVerificationOf(d.userVerification)
|
|
2658
|
+
});
|
|
2637
2659
|
} catch (declined) {
|
|
2638
|
-
|
|
2639
|
-
if (name === "NotAllowedError" || name === "AbortError") throw new ConfirmCancelled(declined);
|
|
2640
|
-
throw declined;
|
|
2660
|
+
throw promptFailure(declined);
|
|
2641
2661
|
}
|
|
2642
2662
|
return send({ ...body, confirm: { challengeId: d.challengeId, assertion } });
|
|
2643
2663
|
}
|
|
@@ -3629,6 +3649,7 @@ export {
|
|
|
3629
3649
|
CalimeroError,
|
|
3630
3650
|
ClusterNotUpgraded,
|
|
3631
3651
|
ConfirmCancelled,
|
|
3652
|
+
ConfirmPromptBlocked,
|
|
3632
3653
|
ConfirmRequired,
|
|
3633
3654
|
ConsentStale,
|
|
3634
3655
|
DEFAULT_COLLATERAL_MIRROR,
|