@sparkvault/sdk-js 15.9.1 → 15.11.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/README.md CHANGED
@@ -214,8 +214,12 @@ mutation automatically. A timeout can occur after publication: it is an
214
214
  uncertain outcome, not proof that nothing changed.
215
215
  `history(vault, ref)` lists retained publications;
216
216
  restore validates historical values against the current Type and creates a new
217
- version. Configure retention with the vault's `structuredIngotVersionLimit`
218
- setting. `delete(vault, ref, { expectedRevision })` deletes only the inspected
217
+ version. Retention is the Vault's `ingotVersionLimit` setting, shared with
218
+ ordinary files and defaulting to zero previous versions. An interactive company
219
+ administrator sets it with `vaults.updateVersionHistory(vaultId, { versionLimit })`
220
+ (0–50). Current content is additional; lowering the limit takes effect on each
221
+ ingot's next successful content change. The old `structuredIngotVersionLimit`
222
+ property and `updateStructuredIngotSettings` method remain compatibility aliases. `delete(vault, ref, { expectedRevision })` deletes only the inspected
219
223
  publication and its retained history. Omitting the option preserves deliberate
220
224
  unconditional deletion. Older server responses may omit `revision`; do not
221
225
  silently drop the guard when a workflow requires conditional writes.
@@ -227,6 +231,14 @@ read-modify-write of file contents, `ingots.downloadWithRevision` returns
227
231
  metadata describes the earlier mint, so it should not be used as proof of the
228
232
  downloaded content's revision.
229
233
 
234
+ `ingots.listVersions(vault, ingotId)` lists previous file publications newest first,
235
+ excluding current content. `ingots.downloadVersion(vault, ingotId, versionId)`
236
+ downloads one retained publication and verifies the content-version header on the
237
+ received bytes. It refuses a pruned version or a response that cannot prove the
238
+ requested publication; it never substitutes current content. Use
239
+ `ingots.createVersionDownloadLink` only when your integration needs the URL itself.
240
+ Structured objects keep their product-specific history and type-aware restore.
241
+
230
242
  Create rejects an existing name; it never overwrites. Names follow the server's
231
243
  Unicode caseless matching rules. An optional stable `idempotencyKey` contains
232
244
  8–128 printable ASCII characters. A successful replay has `replayed: true` and
package/dist/index.cjs CHANGED
@@ -13714,6 +13714,11 @@ async function attemptWith(source, state, options) {
13714
13714
  assertDownloadUrl(link, options.isAllowedHost);
13715
13715
  }
13716
13716
  catch (error) {
13717
+ // A successful HTTP response that failed local validation is an answer,
13718
+ // not a lost connection. Retrying cannot make its publication safe to use.
13719
+ if (error instanceof SparkVaultError && error.code === 'invalid_response') {
13720
+ return { ok: false, error, outcome: FINAL };
13721
+ }
13717
13722
  if (!(error instanceof SparkVaultError) || typeof error.statusCode !== 'number') {
13718
13723
  return { ok: false, error, outcome: UNANSWERED };
13719
13724
  }
@@ -13780,6 +13785,12 @@ async function attemptDownload(link, state, options) {
13780
13785
  const outcome = classifyTransferResponse({ status: response.status, headers: (name) => response.headers.get(name) });
13781
13786
  return { ok: false, error: await refusedDownloadError(response, outcome, controller), outcome };
13782
13787
  }
13788
+ // Every response contributes bytes, including a 206 continuation. Never
13789
+ // let a resumed response bypass the caller's publication precondition.
13790
+ const contentVersion = response.headers.get('x-content-version') || null;
13791
+ if (expectedContentVersion && contentVersion && contentVersion !== expectedContentVersion) {
13792
+ return { ok: false, error: new SparkVaultError(CONTENT_CHANGED_MESSAGE, 'content_changed'), outcome: FINAL };
13793
+ }
13783
13794
  if (resume && response.status === 206) {
13784
13795
  const continued = continuation(response, resume);
13785
13796
  if (continued instanceof SparkVaultError)
@@ -13788,10 +13799,6 @@ async function attemptDownload(link, state, options) {
13788
13799
  }
13789
13800
  else {
13790
13801
  received.discard();
13791
- const contentVersion = response.headers.get('x-content-version') || null;
13792
- if (expectedContentVersion && contentVersion && contentVersion !== expectedContentVersion) {
13793
- return { ok: false, error: new SparkVaultError(CONTENT_CHANGED_MESSAGE, 'content_changed'), outcome: FINAL };
13794
- }
13795
13802
  held = {
13796
13803
  contentType: response.headers.get('content-type') ?? '',
13797
13804
  contentVersion,
@@ -13898,7 +13905,9 @@ function resumeValidator(headers) {
13898
13905
  */
13899
13906
  function continuation(response, resume) {
13900
13907
  const etag = response.headers.get('etag');
13901
- if (etag !== null && etag.replace(/^W\//, '') !== resume.validator) {
13908
+ const contentVersion = response.headers.get('x-content-version');
13909
+ if ((etag !== null && etag.replace(/^W\//, '') !== resume.validator) ||
13910
+ (contentVersion && resume.held.contentVersion && contentVersion !== resume.held.contentVersion)) {
13902
13911
  return new SparkVaultError(CONTENT_CHANGED_MESSAGE, 'content_changed');
13903
13912
  }
13904
13913
  const range = CONTENT_RANGE.exec(response.headers.get('content-range') ?? '');
@@ -14059,6 +14068,26 @@ function readRevision(value) {
14059
14068
  }
14060
14069
  }
14061
14070
 
14071
+ /** Core files and Structured Ingots expose the same retained publication metadata. */
14072
+ function mapIngotHistory(data) {
14073
+ return {
14074
+ id: data.ingot_id,
14075
+ versionLimit: data.version_limit,
14076
+ versions: data.versions.map(version => ({
14077
+ versionId: version.version_id,
14078
+ publishedAt: version.published_at,
14079
+ sizeBytes: version.size_bytes,
14080
+ ...(version.content_type === undefined ? {} : { contentType: version.content_type }),
14081
+ })),
14082
+ };
14083
+ }
14084
+ function requireVersionId(value) {
14085
+ if (typeof value !== 'string' || !/^[A-Za-z0-9:_-]{1,128}$/.test(value)) {
14086
+ throw new ValidationError('versionId must name a retained publication');
14087
+ }
14088
+ return value;
14089
+ }
14090
+
14062
14091
  /**
14063
14092
  * Folders Module
14064
14093
  *
@@ -15765,6 +15794,49 @@ class IngotsModule {
15765
15794
  });
15766
15795
  return mapFolderContents(response.data);
15767
15796
  }
15797
+ /** List previous publications of a file, newest first. Structured objects use their product's history method. */
15798
+ async listVersions(vault, ingotId) {
15799
+ const vaultId = requireVaultId(vault);
15800
+ const id = requireResourceId(ingotId, 'ingotId');
15801
+ const { data } = await this.http.get(apiPath `/v1/vaults/${vaultId}/ingots/${id}/versions`, { vat: vault.vatToken });
15802
+ return mapIngotHistory(data);
15803
+ }
15804
+ /** Mint a one-use link to a retained file publication; use downloadVersion to verify the served bytes. */
15805
+ async createVersionDownloadLink(vault, ingotId, versionId) {
15806
+ const vaultId = requireVaultId(vault);
15807
+ const id = requireResourceId(ingotId, 'ingotId');
15808
+ const version = requireVersionId(versionId);
15809
+ const { data } = await this.http.post(apiPath `/v1/vaults/${vaultId}/ingots/${id}/versions/${version}/download`, undefined, { vat: vault.vatToken });
15810
+ if (data.ingot_id !== id || data.content_version !== version) {
15811
+ throw new SparkVaultError('The server returned a different retained publication', 'invalid_response');
15812
+ }
15813
+ assertDownloadUrl(data.download_url, this.allowsTransferHost);
15814
+ return {
15815
+ id: data.ingot_id,
15816
+ downloadUrl: data.download_url,
15817
+ size: data.size_bytes,
15818
+ contentVersion: data.content_version,
15819
+ expiresAt: data.expires_at,
15820
+ ...(data.revision === undefined ? {} : { revision: readRevision(data.revision) }),
15821
+ ...(data.name === undefined ? {} : { name: data.name }),
15822
+ ...(data.content_type === undefined ? {} : { contentType: data.content_type }),
15823
+ };
15824
+ }
15825
+ /** Download a retained file publication; never substitutes the current bytes if history is unavailable. */
15826
+ async downloadVersion(vault, ingotId, versionId) {
15827
+ requireVaultId(vault);
15828
+ requireResourceId(ingotId, 'ingotId');
15829
+ const version = requireVersionId(versionId);
15830
+ const mint = async () => (await this.createVersionDownloadLink(vault, ingotId, version)).downloadUrl;
15831
+ const download = await fetchMintedDownload(mint, {
15832
+ isAllowedHost: this.allowsTransferHost, expectedContentVersion: version,
15833
+ });
15834
+ // Older transfer servers can omit the header; metadata from the mint is not proof of the bytes served.
15835
+ if (download.contentVersion !== version) {
15836
+ throw new SparkVaultError('The download did not identify the requested retained publication', 'invalid_response');
15837
+ }
15838
+ return download.blob;
15839
+ }
15768
15840
  /**
15769
15841
  * Create a signed download link for an ingot (discrete primitive).
15770
15842
  *
@@ -21475,12 +21547,12 @@ function requireRef(ref) {
21475
21547
  return ref;
21476
21548
  throw new ValidationError('ref must be an ingot ID or a :name reference');
21477
21549
  }
21478
- function integer(value, field, minimum, maximum) {
21550
+ function integer$1(value, field, minimum, maximum) {
21479
21551
  if (!Number.isSafeInteger(value) || value < minimum || value > maximum)
21480
21552
  throw new ValidationError(`${field} must be a whole number from ${minimum} to ${maximum}`);
21481
21553
  return value;
21482
21554
  }
21483
- function expectedVersion(value) { return integer(value, 'expectedVersion', 1, 0xFFFFFFFF); }
21555
+ function expectedVersion(value) { return integer$1(value, 'expectedVersion', 1, 0xFFFFFFFF); }
21484
21556
  function mutationPrecondition(options) {
21485
21557
  const revision = expectedRevision(options.expectedRevision);
21486
21558
  const version = options.expectedVersion;
@@ -21501,7 +21573,7 @@ function keysQuery(keys) {
21501
21573
  }
21502
21574
  function pageQuery(options) {
21503
21575
  if (options.limit !== undefined)
21504
- integer(options.limit, 'limit', 1, 200);
21576
+ integer$1(options.limit, 'limit', 1, 200);
21505
21577
  if (options.cursor !== undefined && (typeof options.cursor !== 'string' || !options.cursor.length || options.cursor.length > 8192)) {
21506
21578
  throw new ValidationError('cursor must be a non-empty continuation token');
21507
21579
  }
@@ -21554,7 +21626,7 @@ function idempotencyHeaders(key) {
21554
21626
  }
21555
21627
  /** Empty pages are legitimate; a repeated cursor is never drained forever. */
21556
21628
  async function* iteratePages(read, options = {}) {
21557
- const maxPages = integer(options.maxPages ?? 10000, 'maxPages', 1, 100000);
21629
+ const maxPages = integer$1(options.maxPages ?? 10000, 'maxPages', 1, 100000);
21558
21630
  pageQuery(options);
21559
21631
  const seen = new Set();
21560
21632
  let cursor = options.cursor;
@@ -21607,7 +21679,7 @@ class StructuredIngotTypesModule {
21607
21679
  async publish(vault, typeId, options) {
21608
21680
  const id = requireVault(vault);
21609
21681
  const type = wirePin({ typeId, version: options.expectedVersion }).type_id;
21610
- integer(options.expectedVersion, 'expectedVersion', 1, STRUCTURED_TYPE_LIMITS.maxVersions);
21682
+ integer$1(options.expectedVersion, 'expectedVersion', 1, STRUCTURED_TYPE_LIMITS.maxVersions);
21611
21683
  validateValues(options.schema);
21612
21684
  const { data } = await this.http.post(apiPath `/v1/products/structured-ingots/${id}/types/${type}/versions`, { expected_version: options.expectedVersion, schema: options.schema, transforms: options.transforms ?? [] }, { vat: vault.vatToken });
21613
21685
  return definition(data);
@@ -21714,16 +21786,13 @@ class StructuredIngotsModule {
21714
21786
  const id = requireVault(vault);
21715
21787
  const record = requireRef(ref);
21716
21788
  const { data } = await this.http.get(apiPath `/v1/products/structured-ingots/${id}/${record}/versions`, { vat: vault.vatToken });
21717
- return { id: data.ingot_id, versionLimit: data.version_limit, versions: data.versions.map((version) => ({
21718
- versionId: version.version_id, publishedAt: version.published_at, sizeBytes: version.size_bytes,
21719
- })) };
21789
+ return mapIngotHistory(data);
21720
21790
  }
21721
21791
  async restore(vault, ref, versionId, options) {
21722
21792
  const id = requireVault(vault);
21723
21793
  const record = requireRef(ref);
21724
21794
  const precondition = mutationPrecondition(options);
21725
- if (typeof versionId !== 'string' || !/^[A-Za-z0-9:_-]{1,128}$/.test(versionId))
21726
- throw new ValidationError('versionId must name a retained publication');
21795
+ requireVersionId(versionId);
21727
21796
  const { data } = await this.http.post(apiPath `/v1/products/structured-ingots/${id}/${record}/versions/${versionId}/restore`, precondition, { vat: vault.vatToken });
21728
21797
  return mutation(data);
21729
21798
  }
@@ -21734,7 +21803,7 @@ class StructuredIngotsModule {
21734
21803
  throw new ValidationError('batchGet accepts at most 100 references');
21735
21804
  refs.forEach(requireRef);
21736
21805
  keysQuery(options.keys);
21737
- const concurrency = integer(options.concurrency ?? 4, 'concurrency', 1, 8);
21806
+ const concurrency = integer$1(options.concurrency ?? 4, 'concurrency', 1, 8);
21738
21807
  // Keep the validated work bounded even if the caller reuses its arrays.
21739
21808
  const input = refs.slice();
21740
21809
  const keys = options.keys?.slice();
@@ -21826,12 +21895,156 @@ class StructuredIngotsModule {
21826
21895
  }
21827
21896
  }
21828
21897
 
21898
+ function integer(value, field, minimum = 1) {
21899
+ if (!Number.isSafeInteger(value) || value < minimum) {
21900
+ throw new ValidationError(`${field} must be a ${minimum === 0 ? 'non-negative' : 'positive'} safe integer`, { field });
21901
+ }
21902
+ }
21903
+ function participant(wire) {
21904
+ return { svid: wire.svid, role: wire.role, addedAt: wire.added_at,
21905
+ ...(wire.identity === undefined ? {} : { identity: wire.identity }),
21906
+ ...(wire.opted_out === undefined ? {} : { optedOut: wire.opted_out }) };
21907
+ }
21908
+ function message(wire) {
21909
+ if (wire.recalled)
21910
+ return { messageId: wire.message_id, recalled: true };
21911
+ if (wire.unavailable)
21912
+ return { messageId: wire.message_id, unavailable: true };
21913
+ return { messageId: wire.message_id, schemaVersion: wire.schema_version, senderSvid: wire.sender_svid,
21914
+ senderIdentity: wire.sender_identity, ts: wire.ts, contentType: wire.content_type, content: wire.content,
21915
+ attachments: (wire.attachments ?? []).map((item) => ({ ingotId: item.ingot_id, name: item.name })) };
21916
+ }
21917
+ function receipt(wire) {
21918
+ return { accountId: wire.account_id, conversationId: wire.conversation_id, messageId: wire.message_id,
21919
+ senderSvid: wire.sender_svid, contentHash: wire.content_hash };
21920
+ }
21921
+ /** Stateless, authenticated business API for the pre-launch Messaging product. */
21922
+ class MessagingModule {
21923
+ constructor(http) {
21924
+ this.http = http;
21925
+ }
21926
+ /** Follow cursor even when a page contains fewer than limit conversations. */
21927
+ async getInbox(options = {}) {
21928
+ if (options.limit !== undefined)
21929
+ integer(options.limit, 'limit');
21930
+ // Core decodes the query's cursor once more before JSON.parse. Encode the
21931
+ // serialized key here; the shared transport applies the outer query encoding.
21932
+ const { data } = await this.http.get(apiPath `/v1/products/messaging/inbox`, {
21933
+ query: { limit: options.limit, cursor: options.cursor === undefined ? undefined : encodeURIComponent(JSON.stringify(options.cursor)) },
21934
+ });
21935
+ return { conversations: data.items.map((item) => ({ conversationId: item.conversation_id, accountId: item.account_id,
21936
+ lastActivityTs: item.last_activity_ts, lastMessageId: item.last_message_id, unreadCount: item.unread_count ?? 0,
21937
+ archived: item.archived === true, ...(item.last_read_id === undefined ? {} : { lastReadId: item.last_read_id }),
21938
+ ...(item.other_participants === undefined ? {} : { otherParticipants: item.other_participants }) })),
21939
+ ...(data.cursor == null ? {} : { cursor: data.cursor }) };
21940
+ }
21941
+ /** Create with business members; invite account-less recipients separately. */
21942
+ async createConversation(options = {}) {
21943
+ const { data } = await this.http.post(apiPath `/v1/products/messaging/conversations`, {
21944
+ participants: options.participants,
21945
+ settings: options.settings === undefined ? undefined : { audit_retention_seconds: options.settings.auditRetentionSeconds },
21946
+ });
21947
+ return { conversationId: data.conversation_id, vaultId: data.vault_id,
21948
+ participants: data.participants.map(participant), createdAt: data.created_at };
21949
+ }
21950
+ async getConversation(conversationId) {
21951
+ const { data } = await this.http.get(apiPath `/v1/products/messaging/conversations/${conversationId}`);
21952
+ return { conversationId: data.conversation_id, participants: data.participants.map(participant),
21953
+ committedThrough: data.committed_through, compactedThrough: data.compacted_through, createdAt: data.created_at,
21954
+ settings: data.settings.audit_retention_seconds === undefined ? {} : { auditRetentionSeconds: data.settings.audit_retention_seconds } };
21955
+ }
21956
+ /** Sends are never retried automatically: Core allocates a new id per send. */
21957
+ async send(conversationId, options) {
21958
+ if (typeof options?.content !== 'string' || !options.content.length)
21959
+ throw new ValidationError('content must be a non-empty string');
21960
+ const { data } = await this.http.post(apiPath `/v1/products/messaging/conversations/${conversationId}/messages`, {
21961
+ content: options.content, content_type: options.contentType,
21962
+ attachments: options.attachments?.map((item) => ({ ingot_id: item.ingotId, name: item.name })),
21963
+ });
21964
+ return { messageId: data.message_id, conversationId: data.conversation_id, ts: data.ts, ingotId: data.ingot_id,
21965
+ contentHash: data.content_hash, committedThrough: data.committed_through, status: data.status,
21966
+ receipt: { ...receipt(data.receipt), ts: data.receipt.ts } };
21967
+ }
21968
+ /** Fresh read each time, including recalls and newly resolved gaps at old ids. */
21969
+ async read(conversationId, options = {}) {
21970
+ if ((options.fromId === undefined) !== (options.toId === undefined))
21971
+ throw new ValidationError('fromId and toId must be supplied together');
21972
+ if (options.fromId !== undefined)
21973
+ integer(options.fromId, 'fromId');
21974
+ if (options.toId !== undefined)
21975
+ integer(options.toId, 'toId');
21976
+ if (options.fromId !== undefined && options.toId < options.fromId)
21977
+ throw new ValidationError('toId must be at least fromId');
21978
+ if (options.limit !== undefined)
21979
+ integer(options.limit, 'limit');
21980
+ const { data } = await this.http.get(apiPath `/v1/products/messaging/conversations/${conversationId}/messages`, {
21981
+ query: { from_id: options.fromId, to_id: options.toId, limit: options.limit },
21982
+ });
21983
+ return { messages: data.messages.map(message), committedThrough: data.committed_through, compactedThrough: data.compacted_through };
21984
+ }
21985
+ async markRead(conversationId, lastReadId) {
21986
+ integer(lastReadId, 'lastReadId', 0);
21987
+ await this.http.post(apiPath `/v1/products/messaging/conversations/${conversationId}/read`, { last_read_id: lastReadId });
21988
+ }
21989
+ async archive(conversationId, archived = true) {
21990
+ await this.http.put(apiPath `/v1/products/messaging/conversations/${conversationId}/archive`, { archived });
21991
+ }
21992
+ async invite(conversationId, identity) {
21993
+ if (!identity || !['email', 'phone'].includes(identity.type) || typeof identity.value !== 'string' || !identity.value.trim()) {
21994
+ throw new ValidationError('type (email|phone) and a non-empty value are required');
21995
+ }
21996
+ const { data } = await this.http.post(apiPath `/v1/products/messaging/conversations/${conversationId}/invites`, identity);
21997
+ return { svid: data.svid, accessUrl: data.access_url };
21998
+ }
21999
+ async addParticipant(conversationId, input) {
22000
+ const { data } = await this.http.post(apiPath `/v1/products/messaging/conversations/${conversationId}/participants`, input);
22001
+ return data.participants.map(participant);
22002
+ }
22003
+ async removeParticipant(conversationId, svid) {
22004
+ const { data } = await this.http.delete(apiPath `/v1/products/messaging/conversations/${conversationId}/participants/${svid}`);
22005
+ return data.participants.map(participant);
22006
+ }
22007
+ async recall(conversationId, messageId) {
22008
+ integer(messageId, 'messageId');
22009
+ await this.http.post(apiPath `/v1/products/messaging/conversations/${conversationId}/messages/${String(messageId)}/recall`);
22010
+ }
22011
+ async getReceipt(conversationId, messageId) {
22012
+ integer(messageId, 'messageId');
22013
+ const { data } = await this.http.get(apiPath `/v1/products/messaging/conversations/${conversationId}/messages/${String(messageId)}/receipt`);
22014
+ return { receiptToken: data.receipt_token, expiresAt: data.expires_at,
22015
+ receipt: { ...receipt(data.receipt), messageTs: data.receipt.message_ts } };
22016
+ }
22017
+ /** Owner-only; a closed conversation refuses new sends. */
22018
+ async close(conversationId, closed = true) {
22019
+ await this.http.put(apiPath `/v1/products/messaging/conversations/${conversationId}/close`, { closed });
22020
+ }
22021
+ /** Stores the caller's preference; Core currently does not gate sends on it. */
22022
+ async setOptOut(conversationId, optedOut) {
22023
+ await this.http.put(apiPath `/v1/products/messaging/conversations/${conversationId}/opt-out`, { opted_out: optedOut });
22024
+ }
22025
+ /** Owner-only; legal hold prevents recall, not account deletion. */
22026
+ async setLegalHold(conversationId, held) {
22027
+ await this.http.put(apiPath `/v1/products/messaging/conversations/${conversationId}/legal-hold`, { held });
22028
+ }
22029
+ /** Returns transfer metadata only; no account credential is sent to Forge. */
22030
+ async initiateAttachmentUpload(conversationId, options) {
22031
+ integer(options.sizeBytes, 'sizeBytes');
22032
+ const { data } = await this.http.post(apiPath `/v1/products/messaging/conversations/${conversationId}/attachments`, { size_bytes: options.sizeBytes, content_type: options.contentType });
22033
+ return { ingotId: data.ingot_id, forgeUrl: data.forge_url, expiresAt: data.expires_at, maxBytes: data.max_bytes };
22034
+ }
22035
+ async getAttachmentDownload(conversationId, ingotId) {
22036
+ const { data } = await this.http.get(apiPath `/v1/products/messaging/conversations/${conversationId}/attachments/${ingotId}/download`);
22037
+ return { ingotId: data.ingot_id, forgeUrl: data.forge_url, expiresAt: data.expires_at, sizeBytes: data.size_bytes, contentType: data.content_type };
22038
+ }
22039
+ }
22040
+
21829
22041
  /**
21830
22042
  * Products Module
21831
22043
  *
21832
22044
  * Namespace for SparkVault first-party products. Each product is a
21833
22045
  * self-contained surface (UI + API) the account can enable independently.
21834
- * Identity, Notify, and the customer-facing Help Desk attach here.
22046
+ * Identity, Notify, customer-facing Help Desk, Structured Ingots, and the
22047
+ * pre-launch Messaging business API attach here.
21835
22048
  */
21836
22049
  class ProductsModule {
21837
22050
  /**
@@ -21843,6 +22056,7 @@ class ProductsModule {
21843
22056
  this.notify = new NotifyProductModule(http);
21844
22057
  this.helpDesk = new HelpDeskModule(config);
21845
22058
  this.structuredIngots = new StructuredIngotsModule(http);
22059
+ this.messaging = new MessagingModule(http);
21846
22060
  }
21847
22061
  }
21848
22062
 
@@ -21892,8 +22106,70 @@ function unsealRequestBody(key, ttlSeconds) {
21892
22106
  return ttlSeconds === undefined ? { [field]: trimmed } : { [field]: trimmed, ttl_seconds: ttlSeconds };
21893
22107
  }
21894
22108
 
21895
- /** Maximum previous publications retained for each structured object. */
21896
- const MAX_STRUCTURED_INGOT_VERSIONS = 50;
22109
+ /**
22110
+ * The apps that manage ingots, each by the id its ingots carry as `managed_by`:
22111
+ * the one statement of those ids, of the name each app goes by, of whether an
22112
+ * app manages a row (isManagedIngot), and of whose rows Core seals server-side
22113
+ * (isServerSealedIngot). Each app marks every ingot it creates
22114
+ * with its own (Structured Ingots also calls Core as it, since Core lets only
22115
+ * the internal invoker an ingot's `managed_by` names create or touch one);
22116
+ * Core, the console, the mobile app and the Slack app ask isManagedIngot of a
22117
+ * row, and the mobile app names the app on the row's sheet. An app's ingot is
22118
+ * the app's: Core's file routes act on it only for the app, the vault shares
22119
+ * it with no one, the app included, and no request files it in a folder
22120
+ * (docs/APPS.md → Managed Ingots).
22121
+ *
22122
+ * A value is stored on every ingot its app creates and never changes on the
22123
+ * row (`managed_by` is immutable), so an id here is never renamed: a new
22124
+ * value would leave every existing ingot naming one no app answers to.
22125
+ *
22126
+ * BROWSER-SAFE: data and pure functions, no imports.
22127
+ */
22128
+
22129
+ const MANAGED_BY = Object.freeze({
22130
+ /** A Structured Ingots record, Identity's directory profiles among them. */
22131
+ STRUCTURED_INGOTS: 'structured-ingots',
22132
+ /** An encrypted catalog of a Structured Ingots type's immutable definitions. */
22133
+ STRUCTURED_INGOT_TYPES: 'structured-ingot-types',
22134
+ /** A help desk message body, email original, attachment or requester export part. */
22135
+ HELP_DESK: 'product-help-desk',
22136
+ /** A Messaging message, compacted page or attachment. */
22137
+ MESSAGING: 'product-messaging'
22138
+ });
22139
+
22140
+ /** Each app's name, as UI copy names the product (docs/DESIGN.md → Voice & copy). */
22141
+ new Map([
22142
+ [MANAGED_BY.STRUCTURED_INGOTS, 'Structured Ingots'],
22143
+ [MANAGED_BY.STRUCTURED_INGOT_TYPES, 'Structured Ingots'],
22144
+ [MANAGED_BY.HELP_DESK, 'Secure Help Desk'],
22145
+ [MANAGED_BY.MESSAGING, 'Messaging']
22146
+ ]);
22147
+
22148
+ /**
22149
+ * The apps inside Core whose ingots Core writes server-side, sealing content
22150
+ * it is handed in one call (apps/api UnifiedIngotService.sealIngotContent):
22151
+ * each such ingot lies at the vault root, at an id its app derives from its
22152
+ * own keys, and holds no name claim. Every other ingot, a Structured Ingots
22153
+ * record's included, is created through Core's upload path and holds its name
22154
+ * by a claim.
22155
+ */
22156
+ new Set([MANAGED_BY.HELP_DESK, MANAGED_BY.MESSAGING]);
22157
+
22158
+ /** Maximum previous publications retained for each user file or object. */
22159
+ const MAX_INGOT_VERSIONS = 50;
22160
+
22161
+ /** Existing vaults retain only current content until retention is enabled. */
22162
+ function ingotVersionLimit(vault) {
22163
+ const limit = vault?.ingot_version_limit === undefined
22164
+ ? (vault?.structured_ingot_version_limit === undefined ? 0 : vault.structured_ingot_version_limit)
22165
+ : vault.ingot_version_limit;
22166
+ // Malformed stored settings must never silently disable retention and purge
22167
+ // history. Every writer uses the same bounded integer contract.
22168
+ if (!Number.isSafeInteger(limit) || limit < 0 || limit > MAX_INGOT_VERSIONS) {
22169
+ throw new RangeError('Invalid ingot version limit');
22170
+ }
22171
+ return limit;
22172
+ }
21897
22173
 
21898
22174
  /**
21899
22175
  * Upload Widget Chrome
@@ -24639,7 +24915,7 @@ class VaultsModule {
24639
24915
  createdAt: v.created_at,
24640
24916
  ingotCount: v.ingot_count,
24641
24917
  storageBytes: v.storage_bytes,
24642
- ...(v.structured_ingot_version_limit === undefined ? {} : { structuredIngotVersionLimit: v.structured_ingot_version_limit }),
24918
+ ...mapVersionHistory(v),
24643
24919
  ...(v.structured_ingots_enabled === undefined ? {} : { structuredIngotsEnabled: v.structured_ingots_enabled }),
24644
24920
  ...mapLifecycle(v),
24645
24921
  })),
@@ -24678,19 +24954,23 @@ class VaultsModule {
24678
24954
  };
24679
24955
  }
24680
24956
  /**
24681
- * Retain this many previous versions of each structured object (0–50).
24682
- * Interactive company administrators only. Applies on each object's next
24683
- * successful change; retained versions count toward storage usage.
24957
+ * Retain this many previous versions of each file or structured object (0–50,
24958
+ * default 0). Interactive company administrators only. Applies on each ingot's
24959
+ * next successful content change; retained versions count toward storage usage.
24684
24960
  */
24685
- async updateStructuredIngotSettings(vaultId, settings) {
24961
+ async updateVersionHistory(vaultId, settings) {
24686
24962
  const id = requireResourceId(vaultId, 'vaultId');
24687
24963
  const limit = settings?.versionLimit;
24688
- if (!Number.isSafeInteger(limit) || limit < 0 || limit > MAX_STRUCTURED_INGOT_VERSIONS) {
24689
- throw new ValidationError(`versionLimit must be a whole number from 0 to ${MAX_STRUCTURED_INGOT_VERSIONS}`);
24964
+ if (!Number.isSafeInteger(limit) || limit < 0 || limit > MAX_INGOT_VERSIONS) {
24965
+ throw new ValidationError(`versionLimit must be a whole number from 0 to ${MAX_INGOT_VERSIONS}`);
24690
24966
  }
24691
- const response = await this.http.put(apiPath `/v1/vaults/${id}/structured-ingot-settings`, { version_limit: limit });
24967
+ const response = await this.http.put(apiPath `/v1/vaults/${id}/version-history`, { version_limit: limit });
24692
24968
  return { vaultId: response.data.vault_id, versionLimit: response.data.version_limit };
24693
24969
  }
24970
+ /** @deprecated Use updateVersionHistory; retention applies to files and structured objects. */
24971
+ async updateStructuredIngotSettings(vaultId, settings) {
24972
+ return this.updateVersionHistory(vaultId, settings);
24973
+ }
24694
24974
  /**
24695
24975
  * Rename a vault.
24696
24976
  *
@@ -24954,6 +25234,12 @@ function mapLifecycle(v) {
24954
25234
  deletionScheduleId: v.deletion_schedule_id,
24955
25235
  };
24956
25236
  }
25237
+ function mapVersionHistory(v) {
25238
+ if (v.ingot_version_limit === undefined && v.structured_ingot_version_limit === undefined)
25239
+ return {};
25240
+ const limit = ingotVersionLimit(v);
25241
+ return { ingotVersionLimit: limit, structuredIngotVersionLimit: limit };
25242
+ }
24957
25243
  function mapVaultDetail(v) {
24958
25244
  return {
24959
25245
  id: v.vault_id,
@@ -24962,7 +25248,7 @@ function mapVaultDetail(v) {
24962
25248
  ...mapLifecycle(v),
24963
25249
  ingotCount: v.ingot_count ?? 0,
24964
25250
  storageBytes: v.storage_bytes ?? 0,
24965
- ...(v.structured_ingot_version_limit === undefined ? {} : { structuredIngotVersionLimit: v.structured_ingot_version_limit }),
25251
+ ...mapVersionHistory(v),
24966
25252
  ...(v.structured_ingots_enabled === undefined ? {} : { structuredIngotsEnabled: v.structured_ingots_enabled }),
24967
25253
  createdAt: v.created_at,
24968
25254
  lastUnsealedAt: v.last_unsealed_at ?? null,
@@ -25756,7 +26042,7 @@ class SparkVault {
25756
26042
  }
25757
26043
  /** Get the SDK version */
25758
26044
  static get version() {
25759
- return '15.9.1';
26045
+ return '15.11.0';
25760
26046
  }
25761
26047
  }
25762
26048
  if (typeof window !== 'undefined') {
@@ -25775,6 +26061,7 @@ exports.HelpDeskModule = HelpDeskModule;
25775
26061
  exports.IdentityModule = IdentityModule;
25776
26062
  exports.IdentityProviderError = IdentityProviderError;
25777
26063
  exports.IngotsModule = IngotsModule;
26064
+ exports.MessagingModule = MessagingModule;
25778
26065
  exports.NAME_CONFLICT_POLICIES = NAME_CONFLICT_POLICIES;
25779
26066
  exports.NOTIFY_PRESETS = NOTIFY_PRESETS;
25780
26067
  exports.NetworkError = NetworkError;