@orangecheck/auth-client 2.2.0 → 2.3.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.d.mts CHANGED
@@ -139,13 +139,26 @@ interface UseWebAuthnRegisterReturn {
139
139
  reset: () => void;
140
140
  }
141
141
  declare function useWebAuthnRegister(opts?: UseHostOptions): UseWebAuthnRegisterReturn;
142
+ type WebAuthnRenameResult = {
143
+ ok: true;
144
+ credential: WebAuthnCredentialPublic;
145
+ } | {
146
+ ok: false;
147
+ reason: string;
148
+ };
149
+ type WebAuthnRemoveResult = {
150
+ ok: true;
151
+ } | {
152
+ ok: false;
153
+ reason: string;
154
+ };
142
155
  interface UseWebAuthnListReturn {
143
156
  status: WebAuthnListStatus;
144
157
  credentials: WebAuthnCredentialPublic[];
145
158
  error: Error | null;
146
159
  refetch: () => Promise<void>;
147
- rename: (id: string, label: string) => Promise<WebAuthnCredentialPublic | null>;
148
- remove: (id: string) => Promise<boolean>;
160
+ rename: (id: string, label: string) => Promise<WebAuthnRenameResult>;
161
+ remove: (id: string) => Promise<WebAuthnRemoveResult>;
149
162
  }
150
163
  declare function useWebAuthnList(opts?: UseHostOptions): UseWebAuthnListReturn;
151
164
  type WebAuthnStepUpResult = {
@@ -177,4 +190,4 @@ declare function handleSudoRequired(body: {
177
190
  returnTo?: string;
178
191
  }): boolean;
179
192
 
180
- export { DEFAULT_CONFIG, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnStepUpResult, buildSignInUrl, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
193
+ export { DEFAULT_CONFIG, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildSignInUrl, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
package/dist/index.d.ts CHANGED
@@ -139,13 +139,26 @@ interface UseWebAuthnRegisterReturn {
139
139
  reset: () => void;
140
140
  }
141
141
  declare function useWebAuthnRegister(opts?: UseHostOptions): UseWebAuthnRegisterReturn;
142
+ type WebAuthnRenameResult = {
143
+ ok: true;
144
+ credential: WebAuthnCredentialPublic;
145
+ } | {
146
+ ok: false;
147
+ reason: string;
148
+ };
149
+ type WebAuthnRemoveResult = {
150
+ ok: true;
151
+ } | {
152
+ ok: false;
153
+ reason: string;
154
+ };
142
155
  interface UseWebAuthnListReturn {
143
156
  status: WebAuthnListStatus;
144
157
  credentials: WebAuthnCredentialPublic[];
145
158
  error: Error | null;
146
159
  refetch: () => Promise<void>;
147
- rename: (id: string, label: string) => Promise<WebAuthnCredentialPublic | null>;
148
- remove: (id: string) => Promise<boolean>;
160
+ rename: (id: string, label: string) => Promise<WebAuthnRenameResult>;
161
+ remove: (id: string) => Promise<WebAuthnRemoveResult>;
149
162
  }
150
163
  declare function useWebAuthnList(opts?: UseHostOptions): UseWebAuthnListReturn;
151
164
  type WebAuthnStepUpResult = {
@@ -177,4 +190,4 @@ declare function handleSudoRequired(body: {
177
190
  returnTo?: string;
178
191
  }): boolean;
179
192
 
180
- export { DEFAULT_CONFIG, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnStepUpResult, buildSignInUrl, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
193
+ export { DEFAULT_CONFIG, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildSignInUrl, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
package/dist/index.js CHANGED
@@ -1395,14 +1395,16 @@ function useWebAuthnList(opts) {
1395
1395
  });
1396
1396
  const j = await r.json();
1397
1397
  if (!j.ok || !j.credential) {
1398
- setError(new Error(j.reason ?? "rename_failed"));
1399
- return null;
1398
+ const reason = j.reason ?? `rename_failed_${r.status}`;
1399
+ setError(new Error(reason));
1400
+ return { ok: false, reason };
1400
1401
  }
1401
1402
  await refetch();
1402
- return j.credential;
1403
+ return { ok: true, credential: j.credential };
1403
1404
  } catch (e) {
1404
- setError(e instanceof Error ? e : new Error(String(e)));
1405
- return null;
1405
+ const reason = e instanceof Error ? e.message : String(e);
1406
+ setError(new Error(reason));
1407
+ return { ok: false, reason };
1406
1408
  }
1407
1409
  },
1408
1410
  [authOrigin, refetch]
@@ -1416,14 +1418,16 @@ function useWebAuthnList(opts) {
1416
1418
  });
1417
1419
  const j = await r.json();
1418
1420
  if (!j.ok) {
1419
- setError(new Error(j.reason ?? "delete_failed"));
1420
- return false;
1421
+ const reason = j.reason ?? `delete_failed_${r.status}`;
1422
+ setError(new Error(reason));
1423
+ return { ok: false, reason };
1421
1424
  }
1422
1425
  await refetch();
1423
- return true;
1426
+ return { ok: true };
1424
1427
  } catch (e) {
1425
- setError(e instanceof Error ? e : new Error(String(e)));
1426
- return false;
1428
+ const reason = e instanceof Error ? e.message : String(e);
1429
+ setError(new Error(reason));
1430
+ return { ok: false, reason };
1427
1431
  }
1428
1432
  },
1429
1433
  [authOrigin, refetch]