@sparkvault/sdk-js 14.2.0 → 14.2.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.cjs +66 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +140 -26
- package/dist/index.mjs +66 -13
- package/dist/index.mjs.map +1 -1
- package/dist/notify/index.d.ts +6 -3
- package/dist/notify/types.d.ts +8 -2
- package/dist/products/index.d.ts +1 -1
- package/dist/products/notify/index.d.ts +31 -4
- package/dist/products/notify/types.d.ts +96 -18
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11348,6 +11348,16 @@ class IdentityModule {
|
|
|
11348
11348
|
const NOTIFY_SEND_ID_PATTERN = /^[A-Za-z0-9_.:-]+$/;
|
|
11349
11349
|
const NOTIFY_SEND_ID_MAX_LENGTH = 128;
|
|
11350
11350
|
|
|
11351
|
+
/**
|
|
11352
|
+
* The kinds of send-level destination an organization's Notify config names,
|
|
11353
|
+
* at most one of each (`destinations.<kind>`), in the one order every reader
|
|
11354
|
+
* lists them in: a send's `destinations`, its status and its history summary.
|
|
11355
|
+
* A destination receives one post per accepted send whose category it routes,
|
|
11356
|
+
* never one per recipient; it never routes `security`, a person's own notices,
|
|
11357
|
+
* and it is never metered.
|
|
11358
|
+
*/
|
|
11359
|
+
const NOTIFY_DESTINATION_KINDS = Object.freeze(['webhook', 'slack', 'teams']);
|
|
11360
|
+
|
|
11351
11361
|
/**
|
|
11352
11362
|
* The Notify category a help desk's alerts to its own staff are classified
|
|
11353
11363
|
* as: a new request in a team's queue, a customer's message, an assignment, a
|
|
@@ -11592,7 +11602,9 @@ class NotifyProductModule {
|
|
|
11592
11602
|
* someone goes out from your organization's own sender (`getEmailSender`) and
|
|
11593
11603
|
* is admitted against your hourly share of sending capacity. Each refusal is
|
|
11594
11604
|
* a thrown `SparkVaultError` whose `serviceCode` names it, made before
|
|
11595
|
-
* anything is sealed, charged or stored
|
|
11605
|
+
* anything is sealed, charged or stored; a send that fails while it seals
|
|
11606
|
+
* gives its admitted recipients back, so its retry is admitted in the same
|
|
11607
|
+
* hour:
|
|
11596
11608
|
*
|
|
11597
11609
|
* | Status | `serviceCode` | `details` | Next |
|
|
11598
11610
|
* | --- | --- | --- | --- |
|
|
@@ -11958,7 +11970,8 @@ class NotifyProductModule {
|
|
|
11958
11970
|
* `events.webhook_url_host` and `events.secret_set`, never the values. A
|
|
11959
11971
|
* `webhook_url` on another host or port needs a new `secret` in the same
|
|
11960
11972
|
* patch (400 `VALIDATION_ERROR` naming `events.secret`), so a secret never
|
|
11961
|
-
* follows its URL to a different host.
|
|
11973
|
+
* follows its URL to a different host. `events: null` removes the webhook,
|
|
11974
|
+
* URL and secret together.
|
|
11962
11975
|
*
|
|
11963
11976
|
* The `email` section selects a domain of your own for your Notify email to go
|
|
11964
11977
|
* out from. `security`, `events` and `email` are an org admin's to change: a
|
|
@@ -11987,6 +12000,36 @@ class NotifyProductModule {
|
|
|
11987
12000
|
const response = await this.http.put(apiPath `/v1/products/notify/config`, patch);
|
|
11988
12001
|
return response.data;
|
|
11989
12002
|
}
|
|
12003
|
+
/**
|
|
12004
|
+
* Post one test message to your destination of `kind` (a webhook, a Slack
|
|
12005
|
+
* channel or a Teams workflow) and learn what became of it, without a send:
|
|
12006
|
+
* nothing reaches a recipient, no send is stored and nothing is metered, and
|
|
12007
|
+
* the test never appears in send history. The post shows the title "Test
|
|
12008
|
+
* post from SparkVault Notify" under your organization's name, through the
|
|
12009
|
+
* sender a send's post takes. A webhook receives a body signed like any
|
|
12010
|
+
* other, typed `notify.destination.test`, naming no send, with a
|
|
12011
|
+
* `delivery_id` of its own. The post is made once and never tried again,
|
|
12012
|
+
* so a fault a send's post would retry reads `failed`.
|
|
12013
|
+
*
|
|
12014
|
+
* An org admin's call, on an account that holds Notify: anyone else is
|
|
12015
|
+
* refused 403 `FORBIDDEN` (`details: { sections: ['destinations'],
|
|
12016
|
+
* required_role: 'admin' }`), an account without Notify 403
|
|
12017
|
+
* `NOTIFY_SUBSCRIPTION_REQUIRED`. A kind with no destination saved is 404
|
|
12018
|
+
* `NOT_FOUND`, an organization name a send would be refused under is 409
|
|
12019
|
+
* (`NOTIFY_SENDER_NAME_REQUIRED` or `NOTIFY_SENDER_NAME_RESERVED`), and each
|
|
12020
|
+
* kind takes 20 tests an hour (429 `RATE_LIMIT_EXCEEDED`).
|
|
12021
|
+
*
|
|
12022
|
+
* @example
|
|
12023
|
+
* const { state, reason } = await sv.products.notify.testDestination('webhook');
|
|
12024
|
+
* if (state !== 'delivered') console.warn(`Test post ${state}: ${reason}`);
|
|
12025
|
+
*/
|
|
12026
|
+
async testDestination(kind) {
|
|
12027
|
+
if (!NOTIFY_DESTINATION_KINDS.includes(kind)) {
|
|
12028
|
+
throw new ValidationError(`kind must be one of ${NOTIFY_DESTINATION_KINDS.join(', ')}`);
|
|
12029
|
+
}
|
|
12030
|
+
const response = await this.http.post(apiPath `/v1/products/notify/destinations/${kind}/test`);
|
|
12031
|
+
return response.data;
|
|
12032
|
+
}
|
|
11990
12033
|
/**
|
|
11991
12034
|
* Who your organization's Notify email is from, as the API answers it
|
|
11992
12035
|
* (verbatim snake_case): `"{organization name}" <from_address>`, with a
|
|
@@ -12052,6 +12095,7 @@ function toSendBody(options) {
|
|
|
12052
12095
|
type: options.type,
|
|
12053
12096
|
instructions: options.instructions,
|
|
12054
12097
|
history_ttl_days: options.historyTtlDays,
|
|
12098
|
+
destinations: options.destinations,
|
|
12055
12099
|
};
|
|
12056
12100
|
}
|
|
12057
12101
|
function requireRecipientId(recipientId) {
|
|
@@ -16496,14 +16540,17 @@ const BRACKET_PAIRS =
|
|
|
16496
16540
|
* right-to-left letter or mark, or an Arabic digit, between Latin words
|
|
16497
16541
|
* reverses their order: "Vault", U+05BE HEBREW PUNCTUATION MAQAF, "Spark" is
|
|
16498
16542
|
* laid out in a right-to-left paragraph as "Spark", the maqaf, "Vault".
|
|
16499
|
-
* An explicit direction control (holdsDirectionControl)
|
|
16500
|
-
* the text after it beyond what this lays out, so a
|
|
16501
|
-
* reader sees refuses it as well, as
|
|
16502
|
-
* organization shows under its name,
|
|
16503
|
-
* also judge a text at every cut of it
|
|
16504
|
-
* since the platform shows a text cut to
|
|
16543
|
+
* An explicit direction control (holdsDirectionControl, ./display-text.js)
|
|
16544
|
+
* sets the direction of the text after it beyond what this lays out, so a
|
|
16545
|
+
* caller that judges what a reader sees refuses it as well, as
|
|
16546
|
+
* isReservedDisplayText, for any text an organization shows under its name,
|
|
16547
|
+
* and isReservedOrganizationName do. Both also judge a text at every cut of it
|
|
16548
|
+
* as stored, each cut read in this way, since the platform shows a text cut to
|
|
16549
|
+
* fit. The implicit marks are no such control: each is a strong character of
|
|
16550
|
+
* its direction, laid out as a letter of that direction is.
|
|
16505
16551
|
*
|
|
16506
|
-
* BROWSER-SAFE: imports only ./
|
|
16552
|
+
* BROWSER-SAFE: imports only ./display-text.js and
|
|
16553
|
+
* ./organization-name-unicode.js, neither of which imports anything, and needs
|
|
16507
16554
|
* String.prototype.isWellFormed and toWellFormed (ES2024: Chrome 111,
|
|
16508
16555
|
* Firefox 119, Safari 16.4).
|
|
16509
16556
|
*/
|
|
@@ -21245,9 +21292,12 @@ class NotifyModule {
|
|
|
21245
21292
|
* End-to-end enable ceremony: feature-detect, fetch the VAPID key, ensure
|
|
21246
21293
|
* Notification permission, subscribe via the caller's service worker, and
|
|
21247
21294
|
* register the subscription with the server. Returns a typed status instead
|
|
21248
|
-
* of throwing on the expected declines
|
|
21249
|
-
*
|
|
21250
|
-
*
|
|
21295
|
+
* of throwing on the expected declines so a host can branch on the outcome:
|
|
21296
|
+
* unsupported, not configured, `permission_denied` (the person blocked
|
|
21297
|
+
* notifications for the site, now or before, so only the browser's site
|
|
21298
|
+
* settings can allow them) and `permission_dismissed` (the person closed the
|
|
21299
|
+
* prompt without answering: the site still asks, so enabling again shows the
|
|
21300
|
+
* prompt again). Call it from a user gesture (permission prompts require one).
|
|
21251
21301
|
*
|
|
21252
21302
|
* A subscription the browser holds for the current key is kept
|
|
21253
21303
|
* (`already_subscribed`); one made for a previous key can never deliver
|
|
@@ -21278,6 +21328,9 @@ class NotifyModule {
|
|
|
21278
21328
|
}
|
|
21279
21329
|
if (Notification.permission === 'default') {
|
|
21280
21330
|
const permission = await Notification.requestPermission();
|
|
21331
|
+
if (permission === 'default') {
|
|
21332
|
+
return { status: 'permission_dismissed' };
|
|
21333
|
+
}
|
|
21281
21334
|
if (permission !== 'granted') {
|
|
21282
21335
|
return { status: 'permission_denied' };
|
|
21283
21336
|
}
|
|
@@ -21468,7 +21521,7 @@ class SparkVault {
|
|
|
21468
21521
|
}
|
|
21469
21522
|
/** Get the SDK version */
|
|
21470
21523
|
static get version() {
|
|
21471
|
-
return '14.2.
|
|
21524
|
+
return '14.2.2';
|
|
21472
21525
|
}
|
|
21473
21526
|
}
|
|
21474
21527
|
if (typeof window !== 'undefined') {
|