@orangecheck/auth-client 2.2.0 → 2.4.0

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
@@ -35,7 +35,8 @@ function normalizeAccount(raw) {
35
35
  displayName: raw.display_name ?? raw.displayName ?? null,
36
36
  nostrNpub: raw.nostr_npub ?? raw.nostrNpub ?? null,
37
37
  homeFederation: raw.home_federation_slug ?? raw.homeFederation ?? null,
38
- signingMethod: raw.signing_method ?? raw.signingMethod ?? null
38
+ signingMethod: raw.signing_method ?? raw.signingMethod ?? null,
39
+ isOwner: Boolean(raw.is_owner ?? raw.isOwner ?? false)
39
40
  };
40
41
  }
41
42
  function OcSessionProvider({
@@ -1373,14 +1374,16 @@ function useWebAuthnList(opts) {
1373
1374
  });
1374
1375
  const j = await r.json();
1375
1376
  if (!j.ok || !j.credential) {
1376
- setError(new Error(j.reason ?? "rename_failed"));
1377
- return null;
1377
+ const reason = j.reason ?? `rename_failed_${r.status}`;
1378
+ setError(new Error(reason));
1379
+ return { ok: false, reason };
1378
1380
  }
1379
1381
  await refetch();
1380
- return j.credential;
1382
+ return { ok: true, credential: j.credential };
1381
1383
  } catch (e) {
1382
- setError(e instanceof Error ? e : new Error(String(e)));
1383
- return null;
1384
+ const reason = e instanceof Error ? e.message : String(e);
1385
+ setError(new Error(reason));
1386
+ return { ok: false, reason };
1384
1387
  }
1385
1388
  },
1386
1389
  [authOrigin, refetch]
@@ -1394,14 +1397,16 @@ function useWebAuthnList(opts) {
1394
1397
  });
1395
1398
  const j = await r.json();
1396
1399
  if (!j.ok) {
1397
- setError(new Error(j.reason ?? "delete_failed"));
1398
- return false;
1400
+ const reason = j.reason ?? `delete_failed_${r.status}`;
1401
+ setError(new Error(reason));
1402
+ return { ok: false, reason };
1399
1403
  }
1400
1404
  await refetch();
1401
- return true;
1405
+ return { ok: true };
1402
1406
  } catch (e) {
1403
- setError(e instanceof Error ? e : new Error(String(e)));
1404
- return false;
1407
+ const reason = e instanceof Error ? e.message : String(e);
1408
+ setError(new Error(reason));
1409
+ return { ok: false, reason };
1405
1410
  }
1406
1411
  },
1407
1412
  [authOrigin, refetch]