@asyncify-hq/node 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shubam Patil
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @asyncify-hq/node
2
+
3
+ Server-side SDK for [Asyncify](https://asyncify.org) — multi-channel
4
+ notification infrastructure. One trigger call fans out to email, SMS, push
5
+ and in-app, with priority queues, retries, digests and delivery tracking
6
+ handled for you.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @asyncify-hq/node
12
+ ```
13
+
14
+ ## Quickstart
15
+
16
+ ```ts
17
+ import { AsyncifyClient } from '@asyncify-hq/node';
18
+
19
+ const asyncify = new AsyncifyClient({
20
+ apiKey: process.env.ASYNCIFY_API_KEY!,
21
+ baseUrl: 'https://api.your-deployment.com',
22
+ });
23
+
24
+ // Fire a workflow for a user
25
+ await asyncify.trigger('order-shipped', {
26
+ to: [{ subscriberId: 'user-42', email: 'user42@example.com' }],
27
+ payload: { orderId: 'ORD-1', eta: 'Tuesday' },
28
+ });
29
+
30
+ // Idempotent retries: same transactionId can never double-send
31
+ await asyncify.trigger('otp', {
32
+ to: [{ subscriberId: 'user-42', phone: '+15550001111' }],
33
+ payload: { code: '123456' },
34
+ priority: 'p0',
35
+ transactionId: `otp-${loginAttemptId}`,
36
+ });
37
+
38
+ // Send to a topic (named segment) or to everyone
39
+ await asyncify.trigger('changelog', { to: [{ topic: 'beta-users' }] });
40
+ await asyncify.broadcast('maintenance-notice');
41
+ ```
42
+
43
+ ## The inbox widget token
44
+
45
+ Mint a short-lived, single-subscriber token in your backend and hand it to
46
+ [`@asyncify-hq/react`](https://www.npmjs.com/package/@asyncify-hq/react) in
47
+ your frontend — API keys never reach the browser:
48
+
49
+ ```ts
50
+ const { token } = await asyncify.subscriberToken('user-42');
51
+ ```
52
+
53
+ ## API surface
54
+
55
+ | Method | Purpose |
56
+ |---|---|
57
+ | `trigger(workflowKey, { to, payload, priority?, transactionId? })` | Fire a workflow (recipients and/or `{ topic }` refs) |
58
+ | `broadcast(workflowKey, { payload? })` | Send to every subscriber (bulk tier) |
59
+ | `events.get(transactionId)` | Per-channel delivery status |
60
+ | `subscribers.upsert({ subscriberId, email?, phone?, pushToken? })` | Create/update a subscriber |
61
+ | `topics.upsert / addSubscribers / removeSubscribers / list / delete` | Manage segments |
62
+ | `workflows.upsert / list` · `templates.upsert / get / list / delete` | Manage workflows & MJML templates |
63
+ | `subscriberToken(subscriberId, ttlSeconds?)` | Browser-safe inbox token |
64
+
65
+ Errors throw `AsyncifyError` with `status` and the API's message.
66
+
67
+ MIT © Shubam Patil
package/dist/index.cjs ADDED
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AsyncifyClient: () => AsyncifyClient,
24
+ AsyncifyError: () => AsyncifyError
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var AsyncifyError = class extends Error {
28
+ constructor(status, message) {
29
+ super(message);
30
+ this.status = status;
31
+ this.name = "AsyncifyError";
32
+ }
33
+ status;
34
+ };
35
+ var AsyncifyClient = class {
36
+ apiKey;
37
+ baseUrl;
38
+ constructor(options) {
39
+ if (!options.apiKey) throw new Error("apiKey is required");
40
+ this.apiKey = options.apiKey;
41
+ this.baseUrl = (options.baseUrl ?? "http://localhost:3000").replace(/\/$/, "");
42
+ }
43
+ async request(method, path, body) {
44
+ const res = await fetch(`${this.baseUrl}${path}`, {
45
+ method,
46
+ headers: { "content-type": "application/json", "x-api-key": this.apiKey },
47
+ body: body === void 0 ? void 0 : JSON.stringify(body)
48
+ });
49
+ const data = await res.json().catch(() => ({}));
50
+ if (!res.ok) {
51
+ throw new AsyncifyError(res.status, data.error ?? `request failed (${res.status})`);
52
+ }
53
+ return data;
54
+ }
55
+ /** Fire a workflow for specific recipients. */
56
+ trigger(workflowKey, options) {
57
+ return this.request("POST", "/v1/events/trigger", { workflowKey, ...options });
58
+ }
59
+ /** Send a workflow to EVERY subscriber in the environment (bulk tier by default). */
60
+ broadcast(workflowKey, options = {}) {
61
+ return this.request("POST", "/v1/events/broadcast", { workflowKey, ...options });
62
+ }
63
+ workflows = {
64
+ upsert: (workflow) => this.request("PUT", "/v1/workflows", workflow),
65
+ list: () => this.request("GET", "/v1/workflows")
66
+ };
67
+ subscribers = {
68
+ upsert: (subscriber) => this.request("PUT", "/v1/subscribers", subscriber)
69
+ };
70
+ templates = {
71
+ upsert: (template) => this.request("PUT", "/v1/templates", template),
72
+ list: () => this.request("GET", "/v1/templates"),
73
+ get: (key) => this.request("GET", `/v1/templates/${encodeURIComponent(key)}`),
74
+ delete: (key) => this.request("DELETE", `/v1/templates/${encodeURIComponent(key)}`)
75
+ };
76
+ topics = {
77
+ upsert: (key, name) => this.request("PUT", "/v1/topics", { key, name }),
78
+ list: () => this.request("GET", "/v1/topics"),
79
+ addSubscribers: (key, subscriberIds) => this.request(
80
+ "POST",
81
+ `/v1/topics/${encodeURIComponent(key)}/subscribers`,
82
+ { subscriberIds }
83
+ ),
84
+ removeSubscribers: (key, subscriberIds) => this.request(
85
+ "DELETE",
86
+ `/v1/topics/${encodeURIComponent(key)}/subscribers`,
87
+ { subscriberIds }
88
+ ),
89
+ delete: (key) => this.request("DELETE", `/v1/topics/${encodeURIComponent(key)}`)
90
+ };
91
+ events = {
92
+ /** Delivery status of one trigger. */
93
+ get: (transactionId) => this.request(
94
+ "GET",
95
+ `/v1/events/${encodeURIComponent(transactionId)}`
96
+ )
97
+ };
98
+ /**
99
+ * Mint a short-lived token scoped to one subscriber — pass it to the
100
+ * <NotificationInbox /> widget in your frontend. Never ship the api key.
101
+ */
102
+ subscriberToken(subscriberId, ttlSeconds = 3600) {
103
+ return this.request("POST", "/v1/subscriber-tokens", { subscriberId, ttlSeconds });
104
+ }
105
+ };
106
+ // Annotate the CommonJS export names for ESM import in node:
107
+ 0 && (module.exports = {
108
+ AsyncifyClient,
109
+ AsyncifyError
110
+ });
@@ -0,0 +1,157 @@
1
+ /**
2
+ * @asyncify-hq/node — server-side client for Asyncify.
3
+ *
4
+ * const asyncify = new AsyncifyClient({ apiKey: process.env.ASYNCIFY_API_KEY! });
5
+ * await asyncify.trigger('order-shipped', {
6
+ * to: [{ subscriberId: 'user-42', email: 'u42@example.com' }],
7
+ * payload: { orderId: 'ORD-1' },
8
+ * });
9
+ *
10
+ * Zero dependencies — plain fetch over the REST API.
11
+ */
12
+ interface Recipient {
13
+ subscriberId: string;
14
+ email?: string;
15
+ phone?: string;
16
+ pushToken?: string;
17
+ }
18
+ type Priority = 'p0' | 'p1' | 'p2';
19
+ /** Direct recipient, or a topic reference ({ topic: "beta-users" }). */
20
+ type TriggerRecipient = Recipient | {
21
+ topic: string;
22
+ };
23
+ interface TriggerOptions {
24
+ to: TriggerRecipient[];
25
+ payload?: Record<string, unknown>;
26
+ priority?: Priority;
27
+ /** Provide your own id to make the trigger idempotent across retries. */
28
+ transactionId?: string;
29
+ }
30
+ interface TriggerResult {
31
+ transactionId: string;
32
+ eventId?: string;
33
+ duplicate?: boolean;
34
+ priority?: Priority;
35
+ }
36
+ interface WorkflowStep {
37
+ channel: 'email' | 'sms' | 'push' | 'inapp';
38
+ subject?: string;
39
+ body?: string;
40
+ /** Email steps: render this MJML template instead of an inline body. */
41
+ templateKey?: string;
42
+ delaySeconds?: number;
43
+ digest?: {
44
+ windowSeconds: number;
45
+ itemTemplate?: string;
46
+ };
47
+ /** All must pass; evaluated over payload + subscriber at fan-out. */
48
+ conditions?: Array<{
49
+ field: string;
50
+ op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'exists' | 'not_exists';
51
+ value?: unknown;
52
+ }>;
53
+ /** Skip at delivery time if an earlier step reached one of these states. */
54
+ skipIfStep?: {
55
+ stepIndex: number;
56
+ statusIn: string[];
57
+ };
58
+ }
59
+ declare class AsyncifyError extends Error {
60
+ readonly status: number;
61
+ constructor(status: number, message: string);
62
+ }
63
+ interface AsyncifyClientOptions {
64
+ apiKey: string;
65
+ /** Defaults to http://localhost:3000 — point at your deployment. */
66
+ baseUrl?: string;
67
+ }
68
+ declare class AsyncifyClient {
69
+ private readonly apiKey;
70
+ private readonly baseUrl;
71
+ constructor(options: AsyncifyClientOptions);
72
+ private request;
73
+ /** Fire a workflow for specific recipients. */
74
+ trigger(workflowKey: string, options: TriggerOptions): Promise<TriggerResult>;
75
+ /** Send a workflow to EVERY subscriber in the environment (bulk tier by default). */
76
+ broadcast(workflowKey: string, options?: {
77
+ payload?: Record<string, unknown>;
78
+ priority?: Priority;
79
+ transactionId?: string;
80
+ }): Promise<TriggerResult & {
81
+ broadcast: boolean;
82
+ }>;
83
+ readonly workflows: {
84
+ upsert: (workflow: {
85
+ key: string;
86
+ name: string;
87
+ steps: WorkflowStep[];
88
+ }) => Promise<{
89
+ id: string;
90
+ key: string;
91
+ }>;
92
+ list: () => Promise<{
93
+ workflows: unknown[];
94
+ }>;
95
+ };
96
+ readonly subscribers: {
97
+ upsert: (subscriber: Recipient) => Promise<{
98
+ id: string;
99
+ subscriberId: string;
100
+ }>;
101
+ };
102
+ readonly templates: {
103
+ upsert: (template: {
104
+ key: string;
105
+ name: string;
106
+ subject: string;
107
+ mjml: string;
108
+ }) => Promise<{
109
+ key: string;
110
+ version: number;
111
+ }>;
112
+ list: () => Promise<{
113
+ templates: unknown[];
114
+ }>;
115
+ get: (key: string) => Promise<{
116
+ template: unknown;
117
+ }>;
118
+ delete: (key: string) => Promise<{
119
+ deleted: boolean;
120
+ }>;
121
+ };
122
+ readonly topics: {
123
+ upsert: (key: string, name: string) => Promise<{
124
+ id: string;
125
+ key: string;
126
+ }>;
127
+ list: () => Promise<{
128
+ topics: unknown[];
129
+ }>;
130
+ addSubscribers: (key: string, subscriberIds: string[]) => Promise<{
131
+ added: number;
132
+ }>;
133
+ removeSubscribers: (key: string, subscriberIds: string[]) => Promise<{
134
+ removed: number;
135
+ }>;
136
+ delete: (key: string) => Promise<{
137
+ deleted: boolean;
138
+ }>;
139
+ };
140
+ readonly events: {
141
+ /** Delivery status of one trigger. */
142
+ get: (transactionId: string) => Promise<{
143
+ status: string;
144
+ messages: unknown[];
145
+ }>;
146
+ };
147
+ /**
148
+ * Mint a short-lived token scoped to one subscriber — pass it to the
149
+ * <NotificationInbox /> widget in your frontend. Never ship the api key.
150
+ */
151
+ subscriberToken(subscriberId: string, ttlSeconds?: number): Promise<{
152
+ token: string;
153
+ expiresAt: number;
154
+ }>;
155
+ }
156
+
157
+ export { AsyncifyClient, type AsyncifyClientOptions, AsyncifyError, type Priority, type Recipient, type TriggerOptions, type TriggerRecipient, type TriggerResult, type WorkflowStep };
@@ -0,0 +1,157 @@
1
+ /**
2
+ * @asyncify-hq/node — server-side client for Asyncify.
3
+ *
4
+ * const asyncify = new AsyncifyClient({ apiKey: process.env.ASYNCIFY_API_KEY! });
5
+ * await asyncify.trigger('order-shipped', {
6
+ * to: [{ subscriberId: 'user-42', email: 'u42@example.com' }],
7
+ * payload: { orderId: 'ORD-1' },
8
+ * });
9
+ *
10
+ * Zero dependencies — plain fetch over the REST API.
11
+ */
12
+ interface Recipient {
13
+ subscriberId: string;
14
+ email?: string;
15
+ phone?: string;
16
+ pushToken?: string;
17
+ }
18
+ type Priority = 'p0' | 'p1' | 'p2';
19
+ /** Direct recipient, or a topic reference ({ topic: "beta-users" }). */
20
+ type TriggerRecipient = Recipient | {
21
+ topic: string;
22
+ };
23
+ interface TriggerOptions {
24
+ to: TriggerRecipient[];
25
+ payload?: Record<string, unknown>;
26
+ priority?: Priority;
27
+ /** Provide your own id to make the trigger idempotent across retries. */
28
+ transactionId?: string;
29
+ }
30
+ interface TriggerResult {
31
+ transactionId: string;
32
+ eventId?: string;
33
+ duplicate?: boolean;
34
+ priority?: Priority;
35
+ }
36
+ interface WorkflowStep {
37
+ channel: 'email' | 'sms' | 'push' | 'inapp';
38
+ subject?: string;
39
+ body?: string;
40
+ /** Email steps: render this MJML template instead of an inline body. */
41
+ templateKey?: string;
42
+ delaySeconds?: number;
43
+ digest?: {
44
+ windowSeconds: number;
45
+ itemTemplate?: string;
46
+ };
47
+ /** All must pass; evaluated over payload + subscriber at fan-out. */
48
+ conditions?: Array<{
49
+ field: string;
50
+ op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'exists' | 'not_exists';
51
+ value?: unknown;
52
+ }>;
53
+ /** Skip at delivery time if an earlier step reached one of these states. */
54
+ skipIfStep?: {
55
+ stepIndex: number;
56
+ statusIn: string[];
57
+ };
58
+ }
59
+ declare class AsyncifyError extends Error {
60
+ readonly status: number;
61
+ constructor(status: number, message: string);
62
+ }
63
+ interface AsyncifyClientOptions {
64
+ apiKey: string;
65
+ /** Defaults to http://localhost:3000 — point at your deployment. */
66
+ baseUrl?: string;
67
+ }
68
+ declare class AsyncifyClient {
69
+ private readonly apiKey;
70
+ private readonly baseUrl;
71
+ constructor(options: AsyncifyClientOptions);
72
+ private request;
73
+ /** Fire a workflow for specific recipients. */
74
+ trigger(workflowKey: string, options: TriggerOptions): Promise<TriggerResult>;
75
+ /** Send a workflow to EVERY subscriber in the environment (bulk tier by default). */
76
+ broadcast(workflowKey: string, options?: {
77
+ payload?: Record<string, unknown>;
78
+ priority?: Priority;
79
+ transactionId?: string;
80
+ }): Promise<TriggerResult & {
81
+ broadcast: boolean;
82
+ }>;
83
+ readonly workflows: {
84
+ upsert: (workflow: {
85
+ key: string;
86
+ name: string;
87
+ steps: WorkflowStep[];
88
+ }) => Promise<{
89
+ id: string;
90
+ key: string;
91
+ }>;
92
+ list: () => Promise<{
93
+ workflows: unknown[];
94
+ }>;
95
+ };
96
+ readonly subscribers: {
97
+ upsert: (subscriber: Recipient) => Promise<{
98
+ id: string;
99
+ subscriberId: string;
100
+ }>;
101
+ };
102
+ readonly templates: {
103
+ upsert: (template: {
104
+ key: string;
105
+ name: string;
106
+ subject: string;
107
+ mjml: string;
108
+ }) => Promise<{
109
+ key: string;
110
+ version: number;
111
+ }>;
112
+ list: () => Promise<{
113
+ templates: unknown[];
114
+ }>;
115
+ get: (key: string) => Promise<{
116
+ template: unknown;
117
+ }>;
118
+ delete: (key: string) => Promise<{
119
+ deleted: boolean;
120
+ }>;
121
+ };
122
+ readonly topics: {
123
+ upsert: (key: string, name: string) => Promise<{
124
+ id: string;
125
+ key: string;
126
+ }>;
127
+ list: () => Promise<{
128
+ topics: unknown[];
129
+ }>;
130
+ addSubscribers: (key: string, subscriberIds: string[]) => Promise<{
131
+ added: number;
132
+ }>;
133
+ removeSubscribers: (key: string, subscriberIds: string[]) => Promise<{
134
+ removed: number;
135
+ }>;
136
+ delete: (key: string) => Promise<{
137
+ deleted: boolean;
138
+ }>;
139
+ };
140
+ readonly events: {
141
+ /** Delivery status of one trigger. */
142
+ get: (transactionId: string) => Promise<{
143
+ status: string;
144
+ messages: unknown[];
145
+ }>;
146
+ };
147
+ /**
148
+ * Mint a short-lived token scoped to one subscriber — pass it to the
149
+ * <NotificationInbox /> widget in your frontend. Never ship the api key.
150
+ */
151
+ subscriberToken(subscriberId: string, ttlSeconds?: number): Promise<{
152
+ token: string;
153
+ expiresAt: number;
154
+ }>;
155
+ }
156
+
157
+ export { AsyncifyClient, type AsyncifyClientOptions, AsyncifyError, type Priority, type Recipient, type TriggerOptions, type TriggerRecipient, type TriggerResult, type WorkflowStep };
package/dist/index.js ADDED
@@ -0,0 +1,84 @@
1
+ // src/index.ts
2
+ var AsyncifyError = class extends Error {
3
+ constructor(status, message) {
4
+ super(message);
5
+ this.status = status;
6
+ this.name = "AsyncifyError";
7
+ }
8
+ status;
9
+ };
10
+ var AsyncifyClient = class {
11
+ apiKey;
12
+ baseUrl;
13
+ constructor(options) {
14
+ if (!options.apiKey) throw new Error("apiKey is required");
15
+ this.apiKey = options.apiKey;
16
+ this.baseUrl = (options.baseUrl ?? "http://localhost:3000").replace(/\/$/, "");
17
+ }
18
+ async request(method, path, body) {
19
+ const res = await fetch(`${this.baseUrl}${path}`, {
20
+ method,
21
+ headers: { "content-type": "application/json", "x-api-key": this.apiKey },
22
+ body: body === void 0 ? void 0 : JSON.stringify(body)
23
+ });
24
+ const data = await res.json().catch(() => ({}));
25
+ if (!res.ok) {
26
+ throw new AsyncifyError(res.status, data.error ?? `request failed (${res.status})`);
27
+ }
28
+ return data;
29
+ }
30
+ /** Fire a workflow for specific recipients. */
31
+ trigger(workflowKey, options) {
32
+ return this.request("POST", "/v1/events/trigger", { workflowKey, ...options });
33
+ }
34
+ /** Send a workflow to EVERY subscriber in the environment (bulk tier by default). */
35
+ broadcast(workflowKey, options = {}) {
36
+ return this.request("POST", "/v1/events/broadcast", { workflowKey, ...options });
37
+ }
38
+ workflows = {
39
+ upsert: (workflow) => this.request("PUT", "/v1/workflows", workflow),
40
+ list: () => this.request("GET", "/v1/workflows")
41
+ };
42
+ subscribers = {
43
+ upsert: (subscriber) => this.request("PUT", "/v1/subscribers", subscriber)
44
+ };
45
+ templates = {
46
+ upsert: (template) => this.request("PUT", "/v1/templates", template),
47
+ list: () => this.request("GET", "/v1/templates"),
48
+ get: (key) => this.request("GET", `/v1/templates/${encodeURIComponent(key)}`),
49
+ delete: (key) => this.request("DELETE", `/v1/templates/${encodeURIComponent(key)}`)
50
+ };
51
+ topics = {
52
+ upsert: (key, name) => this.request("PUT", "/v1/topics", { key, name }),
53
+ list: () => this.request("GET", "/v1/topics"),
54
+ addSubscribers: (key, subscriberIds) => this.request(
55
+ "POST",
56
+ `/v1/topics/${encodeURIComponent(key)}/subscribers`,
57
+ { subscriberIds }
58
+ ),
59
+ removeSubscribers: (key, subscriberIds) => this.request(
60
+ "DELETE",
61
+ `/v1/topics/${encodeURIComponent(key)}/subscribers`,
62
+ { subscriberIds }
63
+ ),
64
+ delete: (key) => this.request("DELETE", `/v1/topics/${encodeURIComponent(key)}`)
65
+ };
66
+ events = {
67
+ /** Delivery status of one trigger. */
68
+ get: (transactionId) => this.request(
69
+ "GET",
70
+ `/v1/events/${encodeURIComponent(transactionId)}`
71
+ )
72
+ };
73
+ /**
74
+ * Mint a short-lived token scoped to one subscriber — pass it to the
75
+ * <NotificationInbox /> widget in your frontend. Never ship the api key.
76
+ */
77
+ subscriberToken(subscriberId, ttlSeconds = 3600) {
78
+ return this.request("POST", "/v1/subscriber-tokens", { subscriberId, ttlSeconds });
79
+ }
80
+ };
81
+ export {
82
+ AsyncifyClient,
83
+ AsyncifyError
84
+ };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@asyncify-hq/node",
3
+ "version": "0.1.0",
4
+ "description": "Server-side SDK for Asyncify — multi-channel notification infrastructure (email, SMS, push, in-app)",
5
+ "keywords": ["notifications", "email", "sms", "push", "in-app", "asyncify", "notification-infrastructure"],
6
+ "homepage": "https://asyncify.org",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/shubam14dec/Scalable-Notification-System.git",
10
+ "directory": "packages/sdk-node"
11
+ },
12
+ "license": "MIT",
13
+ "author": "Shubam Patil",
14
+ "type": "module",
15
+ "main": "./dist/index.cjs",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.cjs"
23
+ }
24
+ },
25
+ "files": ["dist"],
26
+ "sideEffects": false,
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "scripts": {
31
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
32
+ "prepublishOnly": "npm run build"
33
+ },
34
+ "devDependencies": {
35
+ "tsup": "^8.3.5",
36
+ "typescript": "^5.7.2"
37
+ },
38
+ "engines": {
39
+ "node": ">=18"
40
+ }
41
+ }