@sparkvault/sdk-js 8.9.0 → 8.9.2
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 +110 -2
- package/dist/notify/index.d.ts +41 -0
- package/dist/notify/types.d.ts +65 -0
- package/dist/products/identity/renderer.d.ts +1 -0
- package/dist/sparkvault.cjs.js +88 -1
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +88 -2
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/sparkvault.esm.js
CHANGED
|
@@ -6250,6 +6250,12 @@ const SPARKLINK_CSP_BLOCKED_ERROR = {
|
|
|
6250
6250
|
};
|
|
6251
6251
|
class IdentityRenderer {
|
|
6252
6252
|
constructor(container, api, options, callbacks) {
|
|
6253
|
+
// True only when the identifier was prefilled by the flow (invite / simple
|
|
6254
|
+
// redirect), not typed by the person. Gates the "identity is fixed" behavior
|
|
6255
|
+
// so a no-hint simple-mode session where the person types their own
|
|
6256
|
+
// identifier still gets a change-identity back link and single-method
|
|
6257
|
+
// auto-proceed.
|
|
6258
|
+
this.identityPrefilled = false;
|
|
6253
6259
|
// View management
|
|
6254
6260
|
this.currentView = null;
|
|
6255
6261
|
this.focusTimeoutId = null;
|
|
@@ -6307,6 +6313,8 @@ class IdentityRenderer {
|
|
|
6307
6313
|
else {
|
|
6308
6314
|
this.verificationState.setIdentity(validateEmail(raw) ?? raw, 'email');
|
|
6309
6315
|
}
|
|
6316
|
+
// The flow supplied the identifier — it is fixed, not user-changeable.
|
|
6317
|
+
this.identityPrefilled = true;
|
|
6310
6318
|
}
|
|
6311
6319
|
/**
|
|
6312
6320
|
* True when the identifier is fixed by the flow and the person must prove
|
|
@@ -6316,7 +6324,8 @@ class IdentityRenderer {
|
|
|
6316
6324
|
* identifier than the one they were invited as.
|
|
6317
6325
|
*/
|
|
6318
6326
|
isIdentityFixed() {
|
|
6319
|
-
return this.
|
|
6327
|
+
return this.identityPrefilled
|
|
6328
|
+
&& this.verificationState.authContext?.simpleMode !== undefined;
|
|
6320
6329
|
}
|
|
6321
6330
|
/**
|
|
6322
6331
|
* Fire the host's onSuccess callback, swallowing any exception so a
|
|
@@ -6919,6 +6928,9 @@ class IdentityRenderer {
|
|
|
6919
6928
|
}
|
|
6920
6929
|
handleIdentitySubmit(result) {
|
|
6921
6930
|
this.verificationState.setIdentity(result.value, result.type);
|
|
6931
|
+
// The person typed this identifier, so it is theirs to change — a no-hint
|
|
6932
|
+
// simple-mode session must keep the back link + single-method auto-proceed.
|
|
6933
|
+
this.identityPrefilled = false;
|
|
6922
6934
|
this.showMethodSelect();
|
|
6923
6935
|
}
|
|
6924
6936
|
getAllowedIdentityTypes() {
|
|
@@ -13508,6 +13520,79 @@ class EntropyModule {
|
|
|
13508
13520
|
}
|
|
13509
13521
|
}
|
|
13510
13522
|
|
|
13523
|
+
/**
|
|
13524
|
+
* Notify Module
|
|
13525
|
+
*
|
|
13526
|
+
* The signed-in user's first-party Notify surface: their own metadata-only
|
|
13527
|
+
* inbox. The recipient is ALWAYS derived from the session on the server — no
|
|
13528
|
+
* method takes a `recipient_id`, and any account/recipient a caller might try
|
|
13529
|
+
* to supply is ignored. This mirrors `@sparkvault/sdk-mobile`'s notify client;
|
|
13530
|
+
* device push registration is intentionally omitted (Expo-only on mobile).
|
|
13531
|
+
*/
|
|
13532
|
+
const MARK_STATES = ['seen', 'read', 'archived'];
|
|
13533
|
+
class NotifyModule {
|
|
13534
|
+
constructor(http) {
|
|
13535
|
+
this.http = http;
|
|
13536
|
+
}
|
|
13537
|
+
/**
|
|
13538
|
+
* The caller's own inbox feed (newest first). Follow `cursor` to page — a
|
|
13539
|
+
* page can come back short of `limit` yet still carry a non-null cursor.
|
|
13540
|
+
*
|
|
13541
|
+
* @example
|
|
13542
|
+
* const { notifications, cursor } = await sv.notify.getInbox({ state: 'unread' });
|
|
13543
|
+
*/
|
|
13544
|
+
async getInbox(options = {}) {
|
|
13545
|
+
const params = new URLSearchParams();
|
|
13546
|
+
if (options.state)
|
|
13547
|
+
params.set('state', options.state);
|
|
13548
|
+
if (options.limit)
|
|
13549
|
+
params.set('limit', String(options.limit));
|
|
13550
|
+
if (options.cursor)
|
|
13551
|
+
params.set('cursor', options.cursor);
|
|
13552
|
+
const query = params.toString();
|
|
13553
|
+
const response = await this.http.get(query ? `/v1/me/notifications?${query}` : '/v1/me/notifications');
|
|
13554
|
+
return response.data;
|
|
13555
|
+
}
|
|
13556
|
+
/**
|
|
13557
|
+
* Bounded unseen badge count for the caller's own inbox. `capped` true means
|
|
13558
|
+
* the true count is at/beyond the ceiling — render "N+".
|
|
13559
|
+
*
|
|
13560
|
+
* @example
|
|
13561
|
+
* const { unread_count, capped } = await sv.notify.getUnreadCount();
|
|
13562
|
+
*/
|
|
13563
|
+
async getUnreadCount() {
|
|
13564
|
+
const response = await this.http.get('/v1/me/notifications/unread-count');
|
|
13565
|
+
return response.data;
|
|
13566
|
+
}
|
|
13567
|
+
/**
|
|
13568
|
+
* Apply a terminal display state to one of the caller's own rows (idempotent).
|
|
13569
|
+
* `createdAt` MUST be the row's own `created_at` (round-tripped from the list
|
|
13570
|
+
* row) — the id alone cannot address the row.
|
|
13571
|
+
*
|
|
13572
|
+
* @example
|
|
13573
|
+
* await sv.notify.markState('ntf_abc', { createdAt: row.created_at, state: 'read' });
|
|
13574
|
+
*/
|
|
13575
|
+
async markState(notificationId, options) {
|
|
13576
|
+
if (!notificationId || typeof notificationId !== 'string') {
|
|
13577
|
+
throw new ValidationError('notificationId is required', { field: 'notificationId' });
|
|
13578
|
+
}
|
|
13579
|
+
if (!Number.isFinite(options?.createdAt)) {
|
|
13580
|
+
throw new ValidationError('createdAt (the row\'s created_at) is required', {
|
|
13581
|
+
field: 'createdAt',
|
|
13582
|
+
received: options?.createdAt,
|
|
13583
|
+
});
|
|
13584
|
+
}
|
|
13585
|
+
if (!MARK_STATES.includes(options.state)) {
|
|
13586
|
+
throw new ValidationError(`state must be one of ${MARK_STATES.join(', ')}`, {
|
|
13587
|
+
field: 'state',
|
|
13588
|
+
received: options.state,
|
|
13589
|
+
});
|
|
13590
|
+
}
|
|
13591
|
+
const response = await this.http.post(`/v1/me/notifications/${encodeURIComponent(notificationId)}/state`, { created_at: options.createdAt, state: options.state });
|
|
13592
|
+
return response.data;
|
|
13593
|
+
}
|
|
13594
|
+
}
|
|
13595
|
+
|
|
13511
13596
|
/**
|
|
13512
13597
|
* SparkVault Debug Logger
|
|
13513
13598
|
*
|
|
@@ -13696,6 +13781,7 @@ class SparkVault {
|
|
|
13696
13781
|
this.folders = new FoldersModule(http);
|
|
13697
13782
|
this.sparks = new SparksModule(http);
|
|
13698
13783
|
this.entropy = new EntropyModule(http);
|
|
13784
|
+
this.notify = new NotifyModule(http);
|
|
13699
13785
|
this.health = new HealthModule(this.config);
|
|
13700
13786
|
}
|
|
13701
13787
|
/**
|
|
@@ -13735,5 +13821,5 @@ if (typeof window !== 'undefined') {
|
|
|
13735
13821
|
window.SparkVault = instance ?? SparkVault;
|
|
13736
13822
|
}
|
|
13737
13823
|
|
|
13738
|
-
export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NetworkError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, SparkVault as default, logger, setDebugMode };
|
|
13824
|
+
export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NetworkError, NotifyModule, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, SparkVault as default, logger, setDebugMode };
|
|
13739
13825
|
//# sourceMappingURL=sparkvault.esm.js.map
|