@sparkvault/sdk-js 13.0.8 → 13.0.10

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.cjs CHANGED
@@ -3929,13 +3929,74 @@ class LoadingView {
3929
3929
  }
3930
3930
  }
3931
3931
 
3932
+ /**
3933
+ * Two consent lines, each in one wording for every surface that shows it: the
3934
+ * SMS and voice consent beside a phone number, and the terms a signup
3935
+ * accepts. Each line is split around the documents it links, and each document
3936
+ * has its one address here: a surface draws the words between the links and
3937
+ * links each document at TERMS_URL or PRIVACY_URL.
3938
+ *
3939
+ * BROWSER-SAFE: data only, no imports. sdk-mobile mirrors it.
3940
+ */
3941
+
3942
+ /** The terms of service, published once, on the marketing site. */
3943
+ const TERMS_URL = 'https://sparkvault.com/terms/';
3944
+
3945
+ /**
3946
+ * Beside every field where a person enters a phone number SparkVault texts or
3947
+ * calls (the sign-in field and the backup phone of Identity's sign-in, in
3948
+ * sdk-js and sdk-mobile, the mobile app's backup phone, and auth.sv's new
3949
+ * phone number), and under the sign-in's method picker wherever it offers a
3950
+ * text or a call: a phone number the sign-in was handed reaches the picker
3951
+ * without passing the field. The terms take the consent from whoever provides
3952
+ * the number, so the words fit a number typed and a number handed over alike.
3953
+ * It agrees with the terms' SMS and voice disclosures (apps/www/terms.md 15.2,
3954
+ * held to them by apps/www/tests/consent-lines.test.mjs): STOP opts the number
3955
+ * out, HELP answers, rates may apply, and where texts and calls go is the
3956
+ * terms' to say. It offers no way to opt back in, since the terms promise none.
3957
+ */
3958
+ const SMS_CONSENT = Object.freeze({
3959
+ beforeTerms: 'By providing a phone number, you agree to receive verification codes and account messages from SparkVault by text or automated call, as its ',
3960
+ terms: 'Terms',
3961
+ afterTerms: ' describe. Message and data rates may apply. Reply STOP to opt out or HELP for help.'
3962
+ });
3963
+
3964
+ /**
3965
+ * SMS and Voice Consent
3966
+ *
3967
+ * The line the sign-in shows wherever a person gives SparkVault a phone number
3968
+ * to text or call, in the platform's one wording
3969
+ * (`@sparkvault/app-sdk/consent-lines`): under every field that takes one, and
3970
+ * under the method picker wherever it offers a text or a call. It describes
3971
+ * the field or the methods above it, so a screen reader reads it with them.
3972
+ */
3973
+ /**
3974
+ * The consent line, its "Terms" opening the terms in a new tab.
3975
+ *
3976
+ * @param id - The line's id, which the field or each method names in its `aria-describedby`
3977
+ */
3978
+ function smsConsent(id) {
3979
+ const line = document.createElement('p');
3980
+ line.className = 'sv-sms-consent';
3981
+ line.id = id;
3982
+ const terms = document.createElement('a');
3983
+ terms.className = 'sv-sms-consent-link';
3984
+ terms.href = TERMS_URL;
3985
+ terms.target = '_blank';
3986
+ terms.rel = 'noopener noreferrer';
3987
+ terms.textContent = SMS_CONSENT.terms;
3988
+ line.append(SMS_CONSENT.beforeTerms, terms, SMS_CONSENT.afterTerms);
3989
+ return line;
3990
+ }
3991
+
3932
3992
  /**
3933
3993
  * Identity Input View
3934
3994
  *
3935
3995
  * Collects and validates the user's email or phone number: reads the input as
3936
3996
  * one or the other by the platform's rules (`@sparkvault/app-sdk/phone` and
3937
3997
  * `@sparkvault/app-sdk/email-address`), and formats a phone-only field as the
3938
- * number is typed.
3998
+ * number is typed. A field that takes a phone number carries the SMS and voice
3999
+ * consent beneath it.
3939
4000
  */
3940
4001
  class IdentityInputView {
3941
4002
  constructor(props) {
@@ -4004,6 +4065,11 @@ class IdentityInputView {
4004
4065
  this.inputElement.addEventListener('keydown', this.boundHandleKeyDown);
4005
4066
  inputWrapper.appendChild(this.labelElement);
4006
4067
  inputWrapper.appendChild(this.inputElement);
4068
+ if (this.allowsPhone) {
4069
+ const consent = smsConsent('sv-identity-sms-consent');
4070
+ this.inputElement.setAttribute('aria-describedby', consent.id);
4071
+ inputWrapper.appendChild(consent);
4072
+ }
4007
4073
  formSection.appendChild(inputWrapper);
4008
4074
  this.submitButton = document.createElement('button');
4009
4075
  this.submitButton.className = 'sv-btn sv-btn-email-primary';
@@ -4469,8 +4535,14 @@ function createUsersIcon() {
4469
4535
  /**
4470
4536
  * Method Select View
4471
4537
  *
4472
- * Displays available authentication methods for the user to choose from.
4473
- */
4538
+ * Displays available authentication methods for the user to choose from. A
4539
+ * list that offers a text or a call carries the SMS and voice consent beneath
4540
+ * it: a phone number the sign-in was handed reaches this list without passing
4541
+ * the identifier field that carries it, so the tap on a text or call method is
4542
+ * what gives it.
4543
+ */
4544
+ /** A method that sends its code to the phone number: a text or a call. */
4545
+ const textsOrCalls = (method) => method.identityType === 'phone';
4474
4546
  class MethodSelectView {
4475
4547
  constructor(props) {
4476
4548
  this.backLink = null;
@@ -4492,9 +4564,13 @@ class MethodSelectView {
4492
4564
  subtitle.className = 'sv-subtitle';
4493
4565
  subtitle.textContent = email;
4494
4566
  }
4567
+ const consent = this.props.methods.some(textsOrCalls) ? smsConsent('sv-method-sms-consent') : null;
4495
4568
  const methodsContainer = div();
4496
4569
  for (const method of this.props.methods) {
4497
4570
  const methodButton = this.createMethodButton(method);
4571
+ if (consent && textsOrCalls(method)) {
4572
+ methodButton.setAttribute('aria-describedby', consent.id);
4573
+ }
4498
4574
  this.methodButtons.push(methodButton);
4499
4575
  methodsContainer.appendChild(methodButton);
4500
4576
  }
@@ -4506,6 +4582,9 @@ class MethodSelectView {
4506
4582
  container.appendChild(subtitle);
4507
4583
  }
4508
4584
  container.appendChild(methodsContainer);
4585
+ if (consent) {
4586
+ container.appendChild(consent);
4587
+ }
4509
4588
  return container;
4510
4589
  }
4511
4590
  createBackLink() {
@@ -5301,9 +5380,10 @@ class PasskeyPromptView {
5301
5380
  * Backup Verification Input View
5302
5381
  *
5303
5382
  * Post-login nudge to add the inverse identifier as a recovery backup:
5304
- * collects a new phone (for an email login) or email (for a phone login),
5305
- * then hands it off to send a one-time code. Includes a "Not now" skip that
5306
- * suppresses this method's prompt for 30 days (handled by the renderer).
5383
+ * collects a new phone (for an email login), under the SMS and voice consent,
5384
+ * or email (for a phone login), then hands it off to send a one-time code.
5385
+ * Includes a "Not now" skip that suppresses this method's prompt for 30 days
5386
+ * (handled by the renderer).
5307
5387
  *
5308
5388
  * Sibling of PasskeyPromptView — same low-friction, skippable shape.
5309
5389
  */
@@ -5365,6 +5445,11 @@ class BackupVerifyView {
5365
5445
  this.inputElement.addEventListener('keydown', this.boundHandleKeyDown);
5366
5446
  inputWrapper.appendChild(label);
5367
5447
  inputWrapper.appendChild(this.inputElement);
5448
+ if (this.isPhone) {
5449
+ const consent = smsConsent('sv-backup-sms-consent');
5450
+ this.inputElement.setAttribute('aria-describedby', consent.id);
5451
+ inputWrapper.appendChild(consent);
5452
+ }
5368
5453
  formSection.appendChild(inputWrapper);
5369
5454
  this.submitButton = document.createElement('button');
5370
5455
  this.submitButton.className = 'sv-btn sv-btn-primary';
@@ -6271,11 +6356,12 @@ const SPARKLINK_CSP_BLOCKED_ERROR = {
6271
6356
  };
6272
6357
  class IdentityRenderer {
6273
6358
  constructor(container, api, options, callbacks) {
6274
- // True only when the identifier was prefilled by the flow (invite / simple
6275
- // redirect), not typed by the person. Gates the "identity is fixed" behavior
6276
- // so a no-hint simple-mode session where the person types their own
6277
- // identifier still gets a change-identity back link and single-method
6278
- // auto-proceed.
6359
+ // True while the identifier is the one the render options supplied (a host's
6360
+ // prefill, a login hint, an invite's identity), false once the person types
6361
+ // their own. Gates the "identity is fixed" behavior, so a no-hint
6362
+ // simple-mode session where the person types their own identifier still
6363
+ // gets a change-identity back link and single-method auto-proceed, and holds
6364
+ // a text or call to a supplied phone number for the person's tap.
6279
6365
  this.identityPrefilled = false;
6280
6366
  // View management
6281
6367
  this.currentView = null;
@@ -6334,7 +6420,7 @@ class IdentityRenderer {
6334
6420
  else {
6335
6421
  this.verificationState.setIdentity(validateEmail(raw) ?? raw, 'email');
6336
6422
  }
6337
- // The flow supplied the identifier — it is fixed, not user-changeable.
6423
+ // The flow supplied the identifier, not the person.
6338
6424
  this.identityPrefilled = true;
6339
6425
  }
6340
6426
  /**
@@ -6918,14 +7004,19 @@ class IdentityRenderer {
6918
7004
  void this.launchPasskeyVerify(true);
6919
7005
  return;
6920
7006
  }
6921
- // A single enabled method normally auto-fires so the recipient skips a
6922
- // redundant one-item picker. But when the identity is fixed by an invite,
6923
- // auto-firing an OTP would silently send a code (another SMS/email) the
6924
- // instant the recipient opens the link, with no consent and re-sent on every
6925
- // reload. In that case render the picker as a one-tap consent gate instead;
6926
- // the recipient taps to request the code. (Passkey auto-route above still
6927
- // applies — a biometric prompt costs nothing and can be dismissed.)
6928
- if (methods.length === 1 && !this.isIdentityFixed()) {
7007
+ // A single enabled method normally auto-fires so the person skips a
7008
+ // redundant one-item picker. The picker stays up instead, as a one-tap
7009
+ // consent gate, for:
7010
+ // - any code to an identity an invite fixes: auto-firing would silently
7011
+ // send a code (another SMS/email) the instant the recipient opens the
7012
+ // link, with no consent, and again on every reload;
7013
+ // - a text or call to a phone number the flow supplied: the person never
7014
+ // typed it under the SMS and voice consent the identifier field carries,
7015
+ // so the picker carries that consent and the tap gives it.
7016
+ // (Passkey auto-route above still applies — a biometric prompt costs
7017
+ // nothing and can be dismissed.)
7018
+ const sendsToSuppliedPhone = this.identityPrefilled && methods[0].identityType === 'phone';
7019
+ if (methods.length === 1 && !this.isIdentityFixed() && !sendsToSuppliedPhone) {
6929
7020
  this.handleMethodSelect(methods[0]);
6930
7021
  return;
6931
7022
  }
@@ -8710,6 +8801,33 @@ function getStyles(options) {
8710
8801
  box-shadow: 0 0 0 3px ${tokens.errorLight};
8711
8802
  }
8712
8803
 
8804
+ /* The SMS and voice consent under a phone number field: fine print in the
8805
+ secondary ink, its link underlined in the same ink so it reads as a link
8806
+ without a second color. */
8807
+ .sv-sms-consent {
8808
+ margin: 8px 0 0;
8809
+ font-size: 12px;
8810
+ line-height: 1.5;
8811
+ color: ${tokens.textSecondary};
8812
+ }
8813
+
8814
+ .sv-sms-consent-link {
8815
+ color: inherit;
8816
+ text-decoration: underline;
8817
+ text-underline-offset: 2px;
8818
+ border-radius: 2px;
8819
+ transition: color var(--sv-dur-fast) var(--sv-ease-standard);
8820
+ }
8821
+
8822
+ .sv-sms-consent-link:hover {
8823
+ color: ${tokens.textPrimary};
8824
+ }
8825
+
8826
+ .sv-sms-consent-link:focus-visible {
8827
+ outline: none;
8828
+ box-shadow: ${tokens.focusRing};
8829
+ }
8830
+
8713
8831
  /* ========================================
8714
8832
  ERROR VIEW
8715
8833
  ======================================== */
@@ -15822,6 +15940,8 @@ class VaultsModule {
15822
15940
  /**
15823
15941
  * Schedule permanent deletion in seven days and immediately lock all vault access.
15824
15942
  * Company admins only; cancelDeletion can abort this schedule before its deadline.
15943
+ * A vault whose irreversible cleanup has already started answers that cleanup
15944
+ * (`status: 'deleting'`) instead, which nothing can cancel.
15825
15945
  *
15826
15946
  * Requires the vault's exact name as confirmation, matched case-sensitively.
15827
15947
  * The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
@@ -15842,14 +15962,18 @@ class VaultsModule {
15842
15962
  'X-Vault-Deletion-Mode': 'schedule',
15843
15963
  },
15844
15964
  });
15845
- const scheduled = response.data;
15965
+ const answer = response.data;
15966
+ if (answer.status === 'deleting') {
15967
+ return { id: answer.vault_id, status: answer.status, startedAt: answer.started_at };
15968
+ }
15846
15969
  return {
15847
- id: scheduled.vault_id,
15848
- status: scheduled.status,
15849
- deletionRequestedAt: scheduled.deletion_requested_at,
15850
- deletionScheduledFor: scheduled.deletion_scheduled_for,
15851
- deletionRequestedBy: scheduled.deletion_requested_by,
15852
- deletionScheduleId: scheduled.deletion_schedule_id,
15970
+ id: answer.vault_id,
15971
+ status: answer.status,
15972
+ deletionRequestedAt: answer.deletion_requested_at,
15973
+ deletionScheduledFor: answer.deletion_scheduled_for,
15974
+ deletionRequestedBy: answer.deletion_requested_by,
15975
+ deletionScheduleId: answer.deletion_schedule_id,
15976
+ deletionNoticeUnreached: answer.deletion_notice_unreached && answer.deletion_notice_unreached.map(mapUnreachedAdmin),
15853
15977
  };
15854
15978
  }
15855
15979
  /** Cancel this exact deletion schedule before its deadline; company admins only. */
@@ -16055,8 +16179,12 @@ function mapVaultDetail(v) {
16055
16179
  createdAt: v.created_at,
16056
16180
  lastUnsealedAt: v.last_unsealed_at ?? null,
16057
16181
  unsealCount: v.unseal_count ?? 0,
16182
+ deletionNoticeUnreached: v.deletion_notice_unreached && v.deletion_notice_unreached.map(mapUnreachedAdmin),
16058
16183
  };
16059
16184
  }
16185
+ function mapUnreachedAdmin(wire) {
16186
+ return { userId: wire.user_id, name: wire.name, email: wire.email, reason: wire.reason };
16187
+ }
16060
16188
  function mapSharingConfig$1(wire) {
16061
16189
  return {
16062
16190
  vaultId: wire.vault_id,
@@ -18320,7 +18448,7 @@ class SparkVault {
18320
18448
  }
18321
18449
  /** Get the SDK version */
18322
18450
  static get version() {
18323
- return '13.0.8';
18451
+ return '13.0.10';
18324
18452
  }
18325
18453
  }
18326
18454
  if (typeof window !== 'undefined') {