@sparkvault/sdk-js 14.2.1 → 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 +56 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +124 -21
- package/dist/index.mjs +56 -6
- 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 +80 -13
- 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) {
|
|
@@ -21248,9 +21292,12 @@ class NotifyModule {
|
|
|
21248
21292
|
* End-to-end enable ceremony: feature-detect, fetch the VAPID key, ensure
|
|
21249
21293
|
* Notification permission, subscribe via the caller's service worker, and
|
|
21250
21294
|
* register the subscription with the server. Returns a typed status instead
|
|
21251
|
-
* of throwing on the expected declines
|
|
21252
|
-
*
|
|
21253
|
-
*
|
|
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).
|
|
21254
21301
|
*
|
|
21255
21302
|
* A subscription the browser holds for the current key is kept
|
|
21256
21303
|
* (`already_subscribed`); one made for a previous key can never deliver
|
|
@@ -21281,6 +21328,9 @@ class NotifyModule {
|
|
|
21281
21328
|
}
|
|
21282
21329
|
if (Notification.permission === 'default') {
|
|
21283
21330
|
const permission = await Notification.requestPermission();
|
|
21331
|
+
if (permission === 'default') {
|
|
21332
|
+
return { status: 'permission_dismissed' };
|
|
21333
|
+
}
|
|
21284
21334
|
if (permission !== 'granted') {
|
|
21285
21335
|
return { status: 'permission_denied' };
|
|
21286
21336
|
}
|
|
@@ -21471,7 +21521,7 @@ class SparkVault {
|
|
|
21471
21521
|
}
|
|
21472
21522
|
/** Get the SDK version */
|
|
21473
21523
|
static get version() {
|
|
21474
|
-
return '14.2.
|
|
21524
|
+
return '14.2.2';
|
|
21475
21525
|
}
|
|
21476
21526
|
}
|
|
21477
21527
|
if (typeof window !== 'undefined') {
|