@sparkvault/sdk-js 13.0.7 → 13.0.9
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 +142 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.mjs +142 -22
- package/dist/index.mjs.map +1 -1
- package/dist/products/identity/types.d.ts +6 -2
- package/dist/products/identity/views/backup-verify.d.ts +4 -3
- package/dist/products/identity/views/identity-input.d.ts +2 -1
- package/dist/products/identity/views/method-select.d.ts +5 -1
- package/dist/products/identity/views/sms-consent.d.ts +15 -0
- package/dist/products/notify/index.d.ts +3 -1
- package/dist/products/notify/types.d.ts +3 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -187,7 +187,11 @@ interface AuthContext {
|
|
|
187
187
|
interface VerifyOptions {
|
|
188
188
|
/** Pre-fill email address (mutually exclusive with phone) */
|
|
189
189
|
email?: string;
|
|
190
|
-
/**
|
|
190
|
+
/**
|
|
191
|
+
* Pre-fill phone number in E.164 format, e.g. "+14155551234" (mutually
|
|
192
|
+
* exclusive with email). The sign-in texts or calls it only once the person
|
|
193
|
+
* picks a text or call method, under the SMS and voice consent.
|
|
194
|
+
*/
|
|
191
195
|
phone?: string;
|
|
192
196
|
/**
|
|
193
197
|
* Target element for inline rendering. Can be:
|
|
@@ -239,7 +243,7 @@ interface VerifyOptions {
|
|
|
239
243
|
interface AttachOptions {
|
|
240
244
|
/** Pre-fill email address */
|
|
241
245
|
email?: string;
|
|
242
|
-
/** Pre-fill phone number in E.164 format */
|
|
246
|
+
/** Pre-fill phone number in E.164 format (see `VerifyOptions.phone`) */
|
|
243
247
|
phone?: string;
|
|
244
248
|
/** Auth context for OIDC/simple mode flows */
|
|
245
249
|
authContext?: AuthContext;
|
|
@@ -1873,7 +1877,9 @@ interface NotifyConfig {
|
|
|
1873
1877
|
* `marketing`) is stored as a tombstone, which keeps the default from
|
|
1874
1878
|
* re-appearing on the next merge; any other delete leaves no entry. Storing a
|
|
1875
1879
|
* normal object under the same key later re-creates it. The reserved `security`
|
|
1876
|
-
* category can neither be removed nor made optional
|
|
1880
|
+
* category can neither be removed nor made optional, and the promotional
|
|
1881
|
+
* categories `marketing` and `product` can never be made required: their email
|
|
1882
|
+
* always carries an unsubscribe link.
|
|
1877
1883
|
*/
|
|
1878
1884
|
interface NotifyConfigPatch {
|
|
1879
1885
|
delivery?: NotifyConfigDeliveryPatch;
|
|
@@ -2222,7 +2228,9 @@ declare class NotifyProductModule {
|
|
|
2222
2228
|
*
|
|
2223
2229
|
* Delete a category by storing an explicit `null` TOMBSTONE — that is what keeps
|
|
2224
2230
|
* a seeded default from re-appearing on the next merge. The reserved `security`
|
|
2225
|
-
* category can neither be removed nor made optional
|
|
2231
|
+
* category can neither be removed nor made optional, and the promotional
|
|
2232
|
+
* categories `marketing` and `product` can never be made required: their email
|
|
2233
|
+
* always carries an unsubscribe link.
|
|
2226
2234
|
*
|
|
2227
2235
|
* The `events` section configures the outbound event webhook: `webhook_url`
|
|
2228
2236
|
* must be https on a public host, and `secret` (16-256 chars) signs every event
|
package/dist/index.mjs
CHANGED
|
@@ -3925,13 +3925,74 @@ class LoadingView {
|
|
|
3925
3925
|
}
|
|
3926
3926
|
}
|
|
3927
3927
|
|
|
3928
|
+
/**
|
|
3929
|
+
* Two consent lines, each in one wording for every surface that shows it: the
|
|
3930
|
+
* SMS and voice consent beside a phone number, and the terms a signup
|
|
3931
|
+
* accepts. Each line is split around the documents it links, and each document
|
|
3932
|
+
* has its one address here: a surface draws the words between the links and
|
|
3933
|
+
* links each document at TERMS_URL or PRIVACY_URL.
|
|
3934
|
+
*
|
|
3935
|
+
* BROWSER-SAFE: data only, no imports. sdk-mobile mirrors it.
|
|
3936
|
+
*/
|
|
3937
|
+
|
|
3938
|
+
/** The terms of service, published once, on the marketing site. */
|
|
3939
|
+
const TERMS_URL = 'https://sparkvault.com/terms/';
|
|
3940
|
+
|
|
3941
|
+
/**
|
|
3942
|
+
* Beside every field where a person enters a phone number SparkVault texts or
|
|
3943
|
+
* calls (the sign-in field and the backup phone of Identity's sign-in, in
|
|
3944
|
+
* sdk-js and sdk-mobile, the mobile app's backup phone, and auth.sv's new
|
|
3945
|
+
* phone number), and under the sign-in's method picker wherever it offers a
|
|
3946
|
+
* text or a call: a phone number the sign-in was handed reaches the picker
|
|
3947
|
+
* without passing the field. The terms take the consent from whoever provides
|
|
3948
|
+
* the number, so the words fit a number typed and a number handed over alike.
|
|
3949
|
+
* It agrees with the terms' SMS and voice disclosures (apps/www/terms.md 15.2,
|
|
3950
|
+
* held to them by apps/www/tests/consent-lines.test.mjs): STOP opts the number
|
|
3951
|
+
* out, HELP answers, rates may apply, and where texts and calls go is the
|
|
3952
|
+
* terms' to say. It offers no way to opt back in, since the terms promise none.
|
|
3953
|
+
*/
|
|
3954
|
+
const SMS_CONSENT = Object.freeze({
|
|
3955
|
+
beforeTerms: 'By providing a phone number, you agree to receive verification codes and account messages from SparkVault by text or automated call, as its ',
|
|
3956
|
+
terms: 'Terms',
|
|
3957
|
+
afterTerms: ' describe. Message and data rates may apply. Reply STOP to opt out or HELP for help.'
|
|
3958
|
+
});
|
|
3959
|
+
|
|
3960
|
+
/**
|
|
3961
|
+
* SMS and Voice Consent
|
|
3962
|
+
*
|
|
3963
|
+
* The line the sign-in shows wherever a person gives SparkVault a phone number
|
|
3964
|
+
* to text or call, in the platform's one wording
|
|
3965
|
+
* (`@sparkvault/app-sdk/consent-lines`): under every field that takes one, and
|
|
3966
|
+
* under the method picker wherever it offers a text or a call. It describes
|
|
3967
|
+
* the field or the methods above it, so a screen reader reads it with them.
|
|
3968
|
+
*/
|
|
3969
|
+
/**
|
|
3970
|
+
* The consent line, its "Terms" opening the terms in a new tab.
|
|
3971
|
+
*
|
|
3972
|
+
* @param id - The line's id, which the field or each method names in its `aria-describedby`
|
|
3973
|
+
*/
|
|
3974
|
+
function smsConsent(id) {
|
|
3975
|
+
const line = document.createElement('p');
|
|
3976
|
+
line.className = 'sv-sms-consent';
|
|
3977
|
+
line.id = id;
|
|
3978
|
+
const terms = document.createElement('a');
|
|
3979
|
+
terms.className = 'sv-sms-consent-link';
|
|
3980
|
+
terms.href = TERMS_URL;
|
|
3981
|
+
terms.target = '_blank';
|
|
3982
|
+
terms.rel = 'noopener noreferrer';
|
|
3983
|
+
terms.textContent = SMS_CONSENT.terms;
|
|
3984
|
+
line.append(SMS_CONSENT.beforeTerms, terms, SMS_CONSENT.afterTerms);
|
|
3985
|
+
return line;
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3928
3988
|
/**
|
|
3929
3989
|
* Identity Input View
|
|
3930
3990
|
*
|
|
3931
3991
|
* Collects and validates the user's email or phone number: reads the input as
|
|
3932
3992
|
* one or the other by the platform's rules (`@sparkvault/app-sdk/phone` and
|
|
3933
3993
|
* `@sparkvault/app-sdk/email-address`), and formats a phone-only field as the
|
|
3934
|
-
* number is typed.
|
|
3994
|
+
* number is typed. A field that takes a phone number carries the SMS and voice
|
|
3995
|
+
* consent beneath it.
|
|
3935
3996
|
*/
|
|
3936
3997
|
class IdentityInputView {
|
|
3937
3998
|
constructor(props) {
|
|
@@ -4000,6 +4061,11 @@ class IdentityInputView {
|
|
|
4000
4061
|
this.inputElement.addEventListener('keydown', this.boundHandleKeyDown);
|
|
4001
4062
|
inputWrapper.appendChild(this.labelElement);
|
|
4002
4063
|
inputWrapper.appendChild(this.inputElement);
|
|
4064
|
+
if (this.allowsPhone) {
|
|
4065
|
+
const consent = smsConsent('sv-identity-sms-consent');
|
|
4066
|
+
this.inputElement.setAttribute('aria-describedby', consent.id);
|
|
4067
|
+
inputWrapper.appendChild(consent);
|
|
4068
|
+
}
|
|
4003
4069
|
formSection.appendChild(inputWrapper);
|
|
4004
4070
|
this.submitButton = document.createElement('button');
|
|
4005
4071
|
this.submitButton.className = 'sv-btn sv-btn-email-primary';
|
|
@@ -4465,8 +4531,14 @@ function createUsersIcon() {
|
|
|
4465
4531
|
/**
|
|
4466
4532
|
* Method Select View
|
|
4467
4533
|
*
|
|
4468
|
-
* Displays available authentication methods for the user to choose from.
|
|
4469
|
-
|
|
4534
|
+
* Displays available authentication methods for the user to choose from. A
|
|
4535
|
+
* list that offers a text or a call carries the SMS and voice consent beneath
|
|
4536
|
+
* it: a phone number the sign-in was handed reaches this list without passing
|
|
4537
|
+
* the identifier field that carries it, so the tap on a text or call method is
|
|
4538
|
+
* what gives it.
|
|
4539
|
+
*/
|
|
4540
|
+
/** A method that sends its code to the phone number: a text or a call. */
|
|
4541
|
+
const textsOrCalls = (method) => method.identityType === 'phone';
|
|
4470
4542
|
class MethodSelectView {
|
|
4471
4543
|
constructor(props) {
|
|
4472
4544
|
this.backLink = null;
|
|
@@ -4488,9 +4560,13 @@ class MethodSelectView {
|
|
|
4488
4560
|
subtitle.className = 'sv-subtitle';
|
|
4489
4561
|
subtitle.textContent = email;
|
|
4490
4562
|
}
|
|
4563
|
+
const consent = this.props.methods.some(textsOrCalls) ? smsConsent('sv-method-sms-consent') : null;
|
|
4491
4564
|
const methodsContainer = div();
|
|
4492
4565
|
for (const method of this.props.methods) {
|
|
4493
4566
|
const methodButton = this.createMethodButton(method);
|
|
4567
|
+
if (consent && textsOrCalls(method)) {
|
|
4568
|
+
methodButton.setAttribute('aria-describedby', consent.id);
|
|
4569
|
+
}
|
|
4494
4570
|
this.methodButtons.push(methodButton);
|
|
4495
4571
|
methodsContainer.appendChild(methodButton);
|
|
4496
4572
|
}
|
|
@@ -4502,6 +4578,9 @@ class MethodSelectView {
|
|
|
4502
4578
|
container.appendChild(subtitle);
|
|
4503
4579
|
}
|
|
4504
4580
|
container.appendChild(methodsContainer);
|
|
4581
|
+
if (consent) {
|
|
4582
|
+
container.appendChild(consent);
|
|
4583
|
+
}
|
|
4505
4584
|
return container;
|
|
4506
4585
|
}
|
|
4507
4586
|
createBackLink() {
|
|
@@ -5297,9 +5376,10 @@ class PasskeyPromptView {
|
|
|
5297
5376
|
* Backup Verification Input View
|
|
5298
5377
|
*
|
|
5299
5378
|
* Post-login nudge to add the inverse identifier as a recovery backup:
|
|
5300
|
-
* collects a new phone (for an email login)
|
|
5301
|
-
* then hands it off to send a one-time code.
|
|
5302
|
-
* suppresses this method's prompt for 30 days
|
|
5379
|
+
* collects a new phone (for an email login), under the SMS and voice consent,
|
|
5380
|
+
* or email (for a phone login), then hands it off to send a one-time code.
|
|
5381
|
+
* Includes a "Not now" skip that suppresses this method's prompt for 30 days
|
|
5382
|
+
* (handled by the renderer).
|
|
5303
5383
|
*
|
|
5304
5384
|
* Sibling of PasskeyPromptView — same low-friction, skippable shape.
|
|
5305
5385
|
*/
|
|
@@ -5361,6 +5441,11 @@ class BackupVerifyView {
|
|
|
5361
5441
|
this.inputElement.addEventListener('keydown', this.boundHandleKeyDown);
|
|
5362
5442
|
inputWrapper.appendChild(label);
|
|
5363
5443
|
inputWrapper.appendChild(this.inputElement);
|
|
5444
|
+
if (this.isPhone) {
|
|
5445
|
+
const consent = smsConsent('sv-backup-sms-consent');
|
|
5446
|
+
this.inputElement.setAttribute('aria-describedby', consent.id);
|
|
5447
|
+
inputWrapper.appendChild(consent);
|
|
5448
|
+
}
|
|
5364
5449
|
formSection.appendChild(inputWrapper);
|
|
5365
5450
|
this.submitButton = document.createElement('button');
|
|
5366
5451
|
this.submitButton.className = 'sv-btn sv-btn-primary';
|
|
@@ -6267,11 +6352,12 @@ const SPARKLINK_CSP_BLOCKED_ERROR = {
|
|
|
6267
6352
|
};
|
|
6268
6353
|
class IdentityRenderer {
|
|
6269
6354
|
constructor(container, api, options, callbacks) {
|
|
6270
|
-
// True
|
|
6271
|
-
//
|
|
6272
|
-
//
|
|
6273
|
-
//
|
|
6274
|
-
// auto-proceed
|
|
6355
|
+
// True while the identifier is the one the render options supplied (a host's
|
|
6356
|
+
// prefill, a login hint, an invite's identity), false once the person types
|
|
6357
|
+
// their own. Gates the "identity is fixed" behavior, so a no-hint
|
|
6358
|
+
// simple-mode session where the person types their own identifier still
|
|
6359
|
+
// gets a change-identity back link and single-method auto-proceed, and holds
|
|
6360
|
+
// a text or call to a supplied phone number for the person's tap.
|
|
6275
6361
|
this.identityPrefilled = false;
|
|
6276
6362
|
// View management
|
|
6277
6363
|
this.currentView = null;
|
|
@@ -6330,7 +6416,7 @@ class IdentityRenderer {
|
|
|
6330
6416
|
else {
|
|
6331
6417
|
this.verificationState.setIdentity(validateEmail(raw) ?? raw, 'email');
|
|
6332
6418
|
}
|
|
6333
|
-
// The flow supplied the identifier
|
|
6419
|
+
// The flow supplied the identifier, not the person.
|
|
6334
6420
|
this.identityPrefilled = true;
|
|
6335
6421
|
}
|
|
6336
6422
|
/**
|
|
@@ -6914,14 +7000,19 @@ class IdentityRenderer {
|
|
|
6914
7000
|
void this.launchPasskeyVerify(true);
|
|
6915
7001
|
return;
|
|
6916
7002
|
}
|
|
6917
|
-
// A single enabled method normally auto-fires so the
|
|
6918
|
-
// redundant one-item picker.
|
|
6919
|
-
//
|
|
6920
|
-
//
|
|
6921
|
-
//
|
|
6922
|
-
//
|
|
6923
|
-
//
|
|
6924
|
-
|
|
7003
|
+
// A single enabled method normally auto-fires so the person skips a
|
|
7004
|
+
// redundant one-item picker. The picker stays up instead, as a one-tap
|
|
7005
|
+
// consent gate, for:
|
|
7006
|
+
// - any code to an identity an invite fixes: auto-firing would silently
|
|
7007
|
+
// send a code (another SMS/email) the instant the recipient opens the
|
|
7008
|
+
// link, with no consent, and again on every reload;
|
|
7009
|
+
// - a text or call to a phone number the flow supplied: the person never
|
|
7010
|
+
// typed it under the SMS and voice consent the identifier field carries,
|
|
7011
|
+
// so the picker carries that consent and the tap gives it.
|
|
7012
|
+
// (Passkey auto-route above still applies — a biometric prompt costs
|
|
7013
|
+
// nothing and can be dismissed.)
|
|
7014
|
+
const sendsToSuppliedPhone = this.identityPrefilled && methods[0].identityType === 'phone';
|
|
7015
|
+
if (methods.length === 1 && !this.isIdentityFixed() && !sendsToSuppliedPhone) {
|
|
6925
7016
|
this.handleMethodSelect(methods[0]);
|
|
6926
7017
|
return;
|
|
6927
7018
|
}
|
|
@@ -8706,6 +8797,33 @@ function getStyles(options) {
|
|
|
8706
8797
|
box-shadow: 0 0 0 3px ${tokens.errorLight};
|
|
8707
8798
|
}
|
|
8708
8799
|
|
|
8800
|
+
/* The SMS and voice consent under a phone number field: fine print in the
|
|
8801
|
+
secondary ink, its link underlined in the same ink so it reads as a link
|
|
8802
|
+
without a second color. */
|
|
8803
|
+
.sv-sms-consent {
|
|
8804
|
+
margin: 8px 0 0;
|
|
8805
|
+
font-size: 12px;
|
|
8806
|
+
line-height: 1.5;
|
|
8807
|
+
color: ${tokens.textSecondary};
|
|
8808
|
+
}
|
|
8809
|
+
|
|
8810
|
+
.sv-sms-consent-link {
|
|
8811
|
+
color: inherit;
|
|
8812
|
+
text-decoration: underline;
|
|
8813
|
+
text-underline-offset: 2px;
|
|
8814
|
+
border-radius: 2px;
|
|
8815
|
+
transition: color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
8816
|
+
}
|
|
8817
|
+
|
|
8818
|
+
.sv-sms-consent-link:hover {
|
|
8819
|
+
color: ${tokens.textPrimary};
|
|
8820
|
+
}
|
|
8821
|
+
|
|
8822
|
+
.sv-sms-consent-link:focus-visible {
|
|
8823
|
+
outline: none;
|
|
8824
|
+
box-shadow: ${tokens.focusRing};
|
|
8825
|
+
}
|
|
8826
|
+
|
|
8709
8827
|
/* ========================================
|
|
8710
8828
|
ERROR VIEW
|
|
8711
8829
|
======================================== */
|
|
@@ -11706,7 +11824,9 @@ class NotifyProductModule {
|
|
|
11706
11824
|
*
|
|
11707
11825
|
* Delete a category by storing an explicit `null` TOMBSTONE — that is what keeps
|
|
11708
11826
|
* a seeded default from re-appearing on the next merge. The reserved `security`
|
|
11709
|
-
* category can neither be removed nor made optional
|
|
11827
|
+
* category can neither be removed nor made optional, and the promotional
|
|
11828
|
+
* categories `marketing` and `product` can never be made required: their email
|
|
11829
|
+
* always carries an unsubscribe link.
|
|
11710
11830
|
*
|
|
11711
11831
|
* The `events` section configures the outbound event webhook: `webhook_url`
|
|
11712
11832
|
* must be https on a public host, and `secret` (16-256 chars) signs every event
|
|
@@ -18314,7 +18434,7 @@ class SparkVault {
|
|
|
18314
18434
|
}
|
|
18315
18435
|
/** Get the SDK version */
|
|
18316
18436
|
static get version() {
|
|
18317
|
-
return '13.0.
|
|
18437
|
+
return '13.0.9';
|
|
18318
18438
|
}
|
|
18319
18439
|
}
|
|
18320
18440
|
if (typeof window !== 'undefined') {
|