@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.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);
|
|
@@ -1587,19 +1594,13 @@ function cancelled(message) {
|
|
|
1587
1594
|
}
|
|
1588
1595
|
async function ask(method, options) {
|
|
1589
1596
|
const container = navigator.credentials;
|
|
1590
|
-
const
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
} catch (error) {
|
|
1594
|
-
const own = globalThis.CredentialsContainer?.prototype?.[method];
|
|
1595
|
-
if (!own || own === page || !stuck(error)) throw error;
|
|
1596
|
-
return own.call(container, options);
|
|
1597
|
-
}
|
|
1597
|
+
const own = globalThis.CredentialsContainer?.prototype?.[method];
|
|
1598
|
+
const call = own ?? container[method];
|
|
1599
|
+
return call.call(container, options);
|
|
1598
1600
|
}
|
|
1599
|
-
function
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
);
|
|
1601
|
+
function es256First(params) {
|
|
1602
|
+
const es256 = params.filter((p) => p.alg === -7);
|
|
1603
|
+
return es256.length ? es256 : params;
|
|
1603
1604
|
}
|
|
1604
1605
|
function browserPasskey() {
|
|
1605
1606
|
return {
|
|
@@ -1610,7 +1611,7 @@ function browserPasskey() {
|
|
|
1610
1611
|
challenge: buf(fromB64url(o.challenge)),
|
|
1611
1612
|
rp: o.rp,
|
|
1612
1613
|
user: { ...o.user, id: buf(fromB64url(o.user.id)) },
|
|
1613
|
-
pubKeyCredParams: o.pubKeyCredParams,
|
|
1614
|
+
pubKeyCredParams: es256First(o.pubKeyCredParams),
|
|
1614
1615
|
excludeCredentials: (o.excludeCredentials ?? []).map((c) => ({
|
|
1615
1616
|
type: c.type,
|
|
1616
1617
|
id: buf(fromB64url(c.id))
|
|
@@ -1627,12 +1628,12 @@ function browserPasskey() {
|
|
|
1627
1628
|
clientDataJson: b64url(new Uint8Array(r.clientDataJSON))
|
|
1628
1629
|
};
|
|
1629
1630
|
},
|
|
1630
|
-
async get(challenge, rpId, allowCredentials) {
|
|
1631
|
+
async get(challenge, rpId, allowCredentials, options) {
|
|
1631
1632
|
const cred = await ask("get", {
|
|
1632
1633
|
publicKey: {
|
|
1633
1634
|
challenge: buf(challenge),
|
|
1634
1635
|
rpId,
|
|
1635
|
-
userVerification: "preferred",
|
|
1636
|
+
userVerification: options?.userVerification ?? "preferred",
|
|
1636
1637
|
allowCredentials: (allowCredentials ?? []).map((id) => ({
|
|
1637
1638
|
type: "public-key",
|
|
1638
1639
|
id: buf(fromB64url(id))
|
|
@@ -1856,6 +1857,19 @@ function pageDeployment(href) {
|
|
|
1856
1857
|
return null;
|
|
1857
1858
|
}
|
|
1858
1859
|
}
|
|
1860
|
+
function userVerificationOf(named) {
|
|
1861
|
+
return named === "required" || named === "preferred" || named === "discouraged" ? named : "required";
|
|
1862
|
+
}
|
|
1863
|
+
function promptFailure(error) {
|
|
1864
|
+
const e = error;
|
|
1865
|
+
const name = e?.name;
|
|
1866
|
+
const message = typeof e?.message === "string" ? e.message : "";
|
|
1867
|
+
if (name === "InvalidStateError" || /not focused|already pending/i.test(message)) {
|
|
1868
|
+
return new ConfirmPromptBlocked(error);
|
|
1869
|
+
}
|
|
1870
|
+
if (name === "NotAllowedError" || name === "AbortError") return new ConfirmCancelled(error);
|
|
1871
|
+
return error;
|
|
1872
|
+
}
|
|
1859
1873
|
function seg(value) {
|
|
1860
1874
|
return encodeURIComponent(value);
|
|
1861
1875
|
}
|
|
@@ -2633,11 +2647,11 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2633
2647
|
const d = error.details;
|
|
2634
2648
|
let assertion;
|
|
2635
2649
|
try {
|
|
2636
|
-
assertion = await passkey.get(fromB64url(d.challenge), d.rpId, d.allowCredentials
|
|
2650
|
+
assertion = await passkey.get(fromB64url(d.challenge), d.rpId, d.allowCredentials, {
|
|
2651
|
+
userVerification: userVerificationOf(d.userVerification)
|
|
2652
|
+
});
|
|
2637
2653
|
} catch (declined) {
|
|
2638
|
-
|
|
2639
|
-
if (name === "NotAllowedError" || name === "AbortError") throw new ConfirmCancelled(declined);
|
|
2640
|
-
throw declined;
|
|
2654
|
+
throw promptFailure(declined);
|
|
2641
2655
|
}
|
|
2642
2656
|
return send({ ...body, confirm: { challengeId: d.challengeId, assertion } });
|
|
2643
2657
|
}
|
|
@@ -3629,6 +3643,7 @@ export {
|
|
|
3629
3643
|
CalimeroError,
|
|
3630
3644
|
ClusterNotUpgraded,
|
|
3631
3645
|
ConfirmCancelled,
|
|
3646
|
+
ConfirmPromptBlocked,
|
|
3632
3647
|
ConfirmRequired,
|
|
3633
3648
|
ConsentStale,
|
|
3634
3649
|
DEFAULT_COLLATERAL_MIRROR,
|