@calimero-network/mero-js 29.7.4 → 29.7.6

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/index.mjs CHANGED
@@ -1594,19 +1594,13 @@ function cancelled(message) {
1594
1594
  }
1595
1595
  async function ask(method, options) {
1596
1596
  const container = navigator.credentials;
1597
- const page = container[method];
1598
- try {
1599
- return await page.call(container, options);
1600
- } catch (error) {
1601
- const own = globalThis.CredentialsContainer?.prototype?.[method];
1602
- if (!own || own === page || !stuck(error)) throw error;
1603
- return own.call(container, options);
1604
- }
1597
+ const own = globalThis.CredentialsContainer?.prototype?.[method];
1598
+ const call = own ?? container[method];
1599
+ return call.call(container, options);
1605
1600
  }
1606
- function stuck(error) {
1607
- return /request is already pending/i.test(
1608
- error?.message?.toString() ?? ""
1609
- );
1601
+ function es256First(params) {
1602
+ const es256 = params.filter((p) => p.alg === -7);
1603
+ return es256.length ? es256 : params;
1610
1604
  }
1611
1605
  function browserPasskey() {
1612
1606
  return {
@@ -1617,7 +1611,7 @@ function browserPasskey() {
1617
1611
  challenge: buf(fromB64url(o.challenge)),
1618
1612
  rp: o.rp,
1619
1613
  user: { ...o.user, id: buf(fromB64url(o.user.id)) },
1620
- pubKeyCredParams: o.pubKeyCredParams,
1614
+ pubKeyCredParams: es256First(o.pubKeyCredParams),
1621
1615
  excludeCredentials: (o.excludeCredentials ?? []).map((c) => ({
1622
1616
  type: c.type,
1623
1617
  id: buf(fromB64url(c.id))
@@ -1863,8 +1857,8 @@ function pageDeployment(href) {
1863
1857
  return null;
1864
1858
  }
1865
1859
  }
1866
- function userVerificationOf(named) {
1867
- return named === "required" || named === "preferred" || named === "discouraged" ? named : "required";
1860
+ function userVerificationOf(named, fallback) {
1861
+ return named === "required" || named === "preferred" || named === "discouraged" ? named : fallback;
1868
1862
  }
1869
1863
  function promptFailure(error) {
1870
1864
  const e = error;
@@ -2251,10 +2245,13 @@ var CalimeroClient = class _CalimeroClient {
2251
2245
  origin
2252
2246
  );
2253
2247
  const registration = await passkey.create(begin.options);
2254
- const session = await this.postConfirmed(
2248
+ const session = await this.confirmed(
2249
+ "POST",
2255
2250
  "auth/passkey/register/finish",
2256
2251
  { challengeId: begin.challengeId, registration, ...invite },
2257
- passkey
2252
+ passkey,
2253
+ void 0,
2254
+ "preferred"
2258
2255
  );
2259
2256
  this.useSession(session);
2260
2257
  return session;
@@ -2645,7 +2642,7 @@ var CalimeroClient = class _CalimeroClient {
2645
2642
  deleteConfirmed(path, passkey, body = {}) {
2646
2643
  return this.confirmed("DELETE", path, body, passkey);
2647
2644
  }
2648
- async confirmed(method, path, body, passkey, send = (b) => this.json(method, path, b)) {
2645
+ async confirmed(method, path, body, passkey, send = (b) => this.json(method, path, b), userVerification = "required") {
2649
2646
  try {
2650
2647
  return await send(body);
2651
2648
  } catch (error) {
@@ -2654,7 +2651,7 @@ var CalimeroClient = class _CalimeroClient {
2654
2651
  let assertion;
2655
2652
  try {
2656
2653
  assertion = await passkey.get(fromB64url(d.challenge), d.rpId, d.allowCredentials, {
2657
- userVerification: userVerificationOf(d.userVerification)
2654
+ userVerification: userVerificationOf(d.userVerification, userVerification)
2658
2655
  });
2659
2656
  } catch (declined) {
2660
2657
  throw promptFailure(declined);