@sparkvault/sdk-js 12.0.2 → 12.0.3

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.ts CHANGED
@@ -371,8 +371,12 @@ declare class IdentityModule {
371
371
  * `IdentityModule.isFedcmAvailable()` and fall back to `signIn()` otherwise.
372
372
  *
373
373
  * @returns the verified result, or `null` when the browser has no FedCM
374
- * support (so the caller can fall back). Throws `UserCancelledError` when the
375
- * person dismisses the chooser.
374
+ * support (so the caller can fall back). Throws `UserCancelledError` when
375
+ * the browser ends the request without a credential: the person dismissed
376
+ * the chooser, or the browser had no SparkVault account to offer (the
377
+ * browser reports both alike). Throws `IdentityProviderError`, carrying
378
+ * SparkVault's own error code, when SparkVault answered the sign-in with an
379
+ * error.
376
380
  *
377
381
  * @example
378
382
  * const result = (await sv.products.identity.isFedcmAvailable())
@@ -3611,6 +3615,16 @@ declare class TimeoutError extends SparkVaultError {
3611
3615
  declare class UserCancelledError extends SparkVaultError {
3612
3616
  constructor(message?: string);
3613
3617
  }
3618
+ /**
3619
+ * The identity provider answered a FedCM sign-in with an error of its own
3620
+ * (the browser's `IdentityCredentialError`), after the browser showed the
3621
+ * person its error dialog: the request reached the provider, which refused or
3622
+ * failed it, so it is no cancel. `code` is the provider's answer
3623
+ * (`server_error`, `access_denied`, ...).
3624
+ */
3625
+ declare class IdentityProviderError extends SparkVaultError {
3626
+ constructor(code: string);
3627
+ }
3614
3628
  declare class PopupBlockedError extends SparkVaultError {
3615
3629
  constructor();
3616
3630
  }
@@ -3696,5 +3710,5 @@ declare global {
3696
3710
  }
3697
3711
  }
3698
3712
 
3699
- export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, logger, setDebugMode };
3713
+ export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, logger, setDebugMode };
3700
3714
  export type { AccessLogRetention, AccessLogsOptions, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusRecipient, NotifySendSummary, NotifyVerificationLevel, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, Spark, SparkInviteResend, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushSubscriptionInput };
package/dist/index.mjs CHANGED
@@ -826,6 +826,20 @@ class UserCancelledError extends SparkVaultError {
826
826
  Object.setPrototypeOf(this, UserCancelledError.prototype);
827
827
  }
828
828
  }
829
+ /**
830
+ * The identity provider answered a FedCM sign-in with an error of its own
831
+ * (the browser's `IdentityCredentialError`), after the browser showed the
832
+ * person its error dialog: the request reached the provider, which refused or
833
+ * failed it, so it is no cancel. `code` is the provider's answer
834
+ * (`server_error`, `access_denied`, ...).
835
+ */
836
+ class IdentityProviderError extends SparkVaultError {
837
+ constructor(code) {
838
+ super('The identity provider could not complete the sign-in.', code || 'identity_provider_error');
839
+ this.name = 'IdentityProviderError';
840
+ Object.setPrototypeOf(this, IdentityProviderError.prototype);
841
+ }
842
+ }
829
843
  class PopupBlockedError extends SparkVaultError {
830
844
  constructor() {
831
845
  super('Popup was blocked. Please allow popups for this site.', 'popup_blocked');
@@ -10190,6 +10204,20 @@ function decodeTokenSegment(segment, message) {
10190
10204
  throw new ValidationError(message);
10191
10205
  }
10192
10206
  }
10207
+ /**
10208
+ * The provider's own answer to a FedCM id assertion, as the browser rejects
10209
+ * with it (an `IdentityCredentialError`, a DOMException read by its name, so
10210
+ * neither the class's presence nor the realm it was made in matters), or null
10211
+ * for any other rejection.
10212
+ */
10213
+ function identityProviderErrorOf(error) {
10214
+ if (typeof error !== 'object' || error === null)
10215
+ return null;
10216
+ const { name, error: code } = error;
10217
+ if (name !== 'IdentityCredentialError')
10218
+ return null;
10219
+ return new IdentityProviderError(typeof code === 'string' ? code : '');
10220
+ }
10193
10221
  class IdentityModule {
10194
10222
  constructor(config) {
10195
10223
  this.renderer = null;
@@ -10252,8 +10280,12 @@ class IdentityModule {
10252
10280
  * `IdentityModule.isFedcmAvailable()` and fall back to `signIn()` otherwise.
10253
10281
  *
10254
10282
  * @returns the verified result, or `null` when the browser has no FedCM
10255
- * support (so the caller can fall back). Throws `UserCancelledError` when the
10256
- * person dismisses the chooser.
10283
+ * support (so the caller can fall back). Throws `UserCancelledError` when
10284
+ * the browser ends the request without a credential: the person dismissed
10285
+ * the chooser, or the browser had no SparkVault account to offer (the
10286
+ * browser reports both alike). Throws `IdentityProviderError`, carrying
10287
+ * SparkVault's own error code, when SparkVault answered the sign-in with an
10288
+ * error.
10257
10289
  *
10258
10290
  * @example
10259
10291
  * const result = (await sv.products.identity.isFedcmAvailable())
@@ -10287,9 +10319,12 @@ class IdentityModule {
10287
10319
  credential = await getCredential(request);
10288
10320
  }
10289
10321
  catch (error) {
10290
- // The browser rejects with an AbortError/NotAllowedError when the person
10291
- // dismisses the chooser — normalize that to the SDK's cancel signal.
10292
- throw new UserCancelledError(error instanceof Error ? error.message : undefined);
10322
+ // The provider's own answer to the id assertion is no cancel. Every other
10323
+ // rejection ends the request without a credential: the browser answers a
10324
+ // dismissed chooser and a provider with no account to offer with the same
10325
+ // NetworkError, so that is the SDK's cancel signal.
10326
+ throw identityProviderErrorOf(error)
10327
+ ?? new UserCancelledError(error instanceof Error ? error.message : undefined);
10293
10328
  }
10294
10329
  const token = credential?.token;
10295
10330
  if (!token) {
@@ -17648,7 +17683,7 @@ class SparkVault {
17648
17683
  }
17649
17684
  /** Get the SDK version */
17650
17685
  static get version() {
17651
- return '12.0.2';
17686
+ return '12.0.3';
17652
17687
  }
17653
17688
  }
17654
17689
  if (typeof window !== 'undefined') {
@@ -17658,5 +17693,5 @@ if (typeof window !== 'undefined') {
17658
17693
  window.SparkVault = instance ?? SparkVault;
17659
17694
  }
17660
17695
 
17661
- export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, logger, setDebugMode };
17696
+ export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, logger, setDebugMode };
17662
17697
  //# sourceMappingURL=index.mjs.map