@pushary/server 1.3.3 → 1.4.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 +54 -0
- package/dist/adapters.cjs +452 -0
- package/dist/adapters.cjs.map +1 -0
- package/dist/adapters.d.cts +158 -0
- package/dist/adapters.d.ts +158 -0
- package/dist/adapters.js +156 -0
- package/dist/adapters.js.map +1 -0
- package/dist/chunk-22FUZ6F5.js +274 -0
- package/dist/chunk-22FUZ6F5.js.map +1 -0
- package/dist/index.d.cts +2 -412
- package/dist/index.d.ts +2 -412
- package/dist/index.js +9 -265
- package/dist/index.js.map +1 -1
- package/dist/util-Ihfh4f82.d.cts +419 -0
- package/dist/util-Ihfh4f82.d.ts +419 -0
- package/package.json +6 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// src/error.ts
|
|
2
|
+
var PusharyApiError = class _PusharyApiError extends Error {
|
|
3
|
+
constructor(message, init) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "PusharyApiError";
|
|
6
|
+
this.status = init.status;
|
|
7
|
+
this.statusText = init.statusText ?? "";
|
|
8
|
+
this.code = init.code;
|
|
9
|
+
this.body = init.body;
|
|
10
|
+
Object.setPrototypeOf(this, _PusharyApiError.prototype);
|
|
11
|
+
}
|
|
12
|
+
/** The key is missing, malformed, or revoked. Re-authenticate; do not retry. */
|
|
13
|
+
get isAuthError() {
|
|
14
|
+
return this.status === 401 || this.status === 403;
|
|
15
|
+
}
|
|
16
|
+
/** Rate limited. Back off and retry. */
|
|
17
|
+
get isRateLimited() {
|
|
18
|
+
return this.status === 429;
|
|
19
|
+
}
|
|
20
|
+
/** Server-side fault. Safe to retry an idempotent call. */
|
|
21
|
+
get isServerError() {
|
|
22
|
+
return this.status >= 500;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/util.ts
|
|
27
|
+
import { createHash } from "crypto";
|
|
28
|
+
var deterministicKey = (parts) => createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 40);
|
|
29
|
+
var AFFIRMATIVE = /* @__PURE__ */ new Set([
|
|
30
|
+
"yes",
|
|
31
|
+
"y",
|
|
32
|
+
"approve",
|
|
33
|
+
"approved",
|
|
34
|
+
"ok",
|
|
35
|
+
"okay",
|
|
36
|
+
"confirm",
|
|
37
|
+
"accept",
|
|
38
|
+
"true"
|
|
39
|
+
]);
|
|
40
|
+
var isApproved = (decision) => {
|
|
41
|
+
if (decision.status !== "answered") return false;
|
|
42
|
+
if (decision.type && decision.type !== "confirm") return true;
|
|
43
|
+
return decision.value != null && AFFIRMATIVE.has(decision.value.trim().toLowerCase());
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/request.ts
|
|
47
|
+
var buildUrl = (baseUrl, path, params) => {
|
|
48
|
+
const url = new URL(`${baseUrl}${path}`);
|
|
49
|
+
if (params) {
|
|
50
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
51
|
+
if (value !== void 0 && value !== null) {
|
|
52
|
+
url.searchParams.set(key, String(value));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return url.toString();
|
|
57
|
+
};
|
|
58
|
+
var handleResponse = async (response) => {
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
const body = await response.json().catch(() => ({}));
|
|
61
|
+
throw new PusharyApiError(body.message || body.error || `HTTP ${response.status}`, {
|
|
62
|
+
status: response.status,
|
|
63
|
+
statusText: response.statusText,
|
|
64
|
+
code: body.code,
|
|
65
|
+
body
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return response.json();
|
|
69
|
+
};
|
|
70
|
+
var createRequest = (ctx) => async (method, path, body) => {
|
|
71
|
+
const isGet = method === "GET";
|
|
72
|
+
const url = isGet && body ? buildUrl(ctx.baseUrl, path, body) : `${ctx.baseUrl}${path}`;
|
|
73
|
+
const response = await fetch(url, {
|
|
74
|
+
method,
|
|
75
|
+
headers: ctx.headers,
|
|
76
|
+
body: !isGet && body ? JSON.stringify(body) : void 0
|
|
77
|
+
});
|
|
78
|
+
return handleResponse(response);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/resources/subscribers.ts
|
|
82
|
+
var createSubscribersResource = (request) => Object.freeze({
|
|
83
|
+
list: (params) => request("GET", "/subscribers", params),
|
|
84
|
+
get: (id) => request("GET", `/subscribers/${id}`),
|
|
85
|
+
update: (id, data) => request("PATCH", `/subscribers/${id}`, data),
|
|
86
|
+
delete: (id) => request("DELETE", `/subscribers/${id}`),
|
|
87
|
+
count: () => request("GET", "/subscribers/count")
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// src/resources/campaigns.ts
|
|
91
|
+
var createCampaignsResource = (request) => Object.freeze({
|
|
92
|
+
list: (params) => request("GET", "/campaigns", params),
|
|
93
|
+
create: (data) => request("POST", "/campaigns", data),
|
|
94
|
+
get: (id) => request("GET", `/campaigns/${id}`),
|
|
95
|
+
update: (id, data) => request("PATCH", `/campaigns/${id}`, data),
|
|
96
|
+
delete: (id) => request("DELETE", `/campaigns/${id}`),
|
|
97
|
+
send: (id) => request("POST", `/campaigns/${id}/send`),
|
|
98
|
+
pause: (id) => request("POST", `/campaigns/${id}/pause`),
|
|
99
|
+
resume: (id) => request("POST", `/campaigns/${id}/resume`),
|
|
100
|
+
stats: (id) => request("GET", `/campaigns/${id}/stats`)
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// src/resources/templates.ts
|
|
104
|
+
var createTemplatesResource = (request) => Object.freeze({
|
|
105
|
+
list: (params) => request("GET", "/templates", params),
|
|
106
|
+
create: (data) => request("POST", "/templates", data),
|
|
107
|
+
get: (id) => request("GET", `/templates/${id}`),
|
|
108
|
+
update: (id, data) => request("PATCH", `/templates/${id}`, data),
|
|
109
|
+
delete: (id) => request("DELETE", `/templates/${id}`)
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// src/resources/notifications.ts
|
|
113
|
+
var createNotificationsResource = (request) => Object.freeze({
|
|
114
|
+
send: (data) => request("POST", "/send", data)
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// src/resources/flows.ts
|
|
118
|
+
var createFlowsResource = (request) => Object.freeze({
|
|
119
|
+
list: (params) => request("GET", "/flows", params),
|
|
120
|
+
create: (data) => request("POST", "/flows", data),
|
|
121
|
+
get: (id) => request("GET", `/flows/${id}`),
|
|
122
|
+
update: (id, data) => request("PATCH", `/flows/${id}`, data),
|
|
123
|
+
delete: (id) => request("DELETE", `/flows/${id}`),
|
|
124
|
+
activate: (id) => request("POST", `/flows/${id}/activate`),
|
|
125
|
+
pause: (id) => request("POST", `/flows/${id}/pause`)
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// src/resources/decisions.ts
|
|
129
|
+
import { randomUUID } from "crypto";
|
|
130
|
+
var POLL_WINDOW_SECONDS = 50;
|
|
131
|
+
var DEFAULT_ASK_TIMEOUT_MS = 55e3;
|
|
132
|
+
var createDecisionsResource = (request) => {
|
|
133
|
+
const ask = async (data) => {
|
|
134
|
+
const idempotencyKey = data.idempotencyKey ?? randomUUID();
|
|
135
|
+
const created = await request("POST", "/decisions", {
|
|
136
|
+
question: data.question,
|
|
137
|
+
type: data.type,
|
|
138
|
+
options: data.options,
|
|
139
|
+
externalId: data.externalId,
|
|
140
|
+
email: data.email,
|
|
141
|
+
agentName: data.agentName,
|
|
142
|
+
context: data.context,
|
|
143
|
+
placeholder: data.placeholder,
|
|
144
|
+
expiresInSeconds: data.expiresInSeconds,
|
|
145
|
+
poweredBy: data.poweredBy,
|
|
146
|
+
callbackUrl: data.callbackUrl,
|
|
147
|
+
requireReachable: data.requireReachable,
|
|
148
|
+
idempotencyKey,
|
|
149
|
+
wait: false
|
|
150
|
+
});
|
|
151
|
+
const type = created.type ?? data.type ?? "confirm";
|
|
152
|
+
let status = created.status;
|
|
153
|
+
let answered = created.answered;
|
|
154
|
+
let value = created.value ?? null;
|
|
155
|
+
const deadline = Date.now() + Math.max(0, data.timeoutMs ?? DEFAULT_ASK_TIMEOUT_MS);
|
|
156
|
+
while (status === "pending" && Date.now() < deadline) {
|
|
157
|
+
const waitSeconds = Math.max(
|
|
158
|
+
1,
|
|
159
|
+
Math.min(POLL_WINDOW_SECONDS, Math.ceil((deadline - Date.now()) / 1e3))
|
|
160
|
+
);
|
|
161
|
+
const polled = await request("GET", `/decisions/${created.decisionId}`, {
|
|
162
|
+
wait: waitSeconds
|
|
163
|
+
});
|
|
164
|
+
status = polled.status;
|
|
165
|
+
answered = polled.answered;
|
|
166
|
+
value = polled.value;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
decisionId: created.decisionId,
|
|
170
|
+
status,
|
|
171
|
+
answered,
|
|
172
|
+
value,
|
|
173
|
+
type,
|
|
174
|
+
approved: isApproved({ status, type, value }),
|
|
175
|
+
// Surfaced from the create response so a caller can tell an unanswered
|
|
176
|
+
// decision that reached nobody (reachable:false) apart from a real decline.
|
|
177
|
+
reachable: created.reachable,
|
|
178
|
+
reachableChannels: created.reachableChannels,
|
|
179
|
+
deviceCount: created.deviceCount
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
return Object.freeze({
|
|
183
|
+
create: (data) => request("POST", "/decisions", data),
|
|
184
|
+
get: (id, opts) => request("GET", `/decisions/${id}`, opts?.wait ? { wait: opts.wait } : void 0),
|
|
185
|
+
ask,
|
|
186
|
+
answer: (id, answer) => request("POST", `/decisions/${id}`, { answer }),
|
|
187
|
+
cancel: (id) => request("DELETE", `/decisions/${id}`),
|
|
188
|
+
getWebhookSecret: () => request("GET", "/webhook-secret"),
|
|
189
|
+
rotateWebhookSecret: () => request("POST", "/webhook-secret")
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/resources/keys.ts
|
|
194
|
+
var createKeysResource = (request) => Object.freeze({
|
|
195
|
+
issue: (data) => request("POST", "/keys", data),
|
|
196
|
+
list: () => request("GET", "/keys").then((r) => r.keys),
|
|
197
|
+
revoke: (keyPrefix) => request("DELETE", `/keys/${encodeURIComponent(keyPrefix)}`)
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// src/client.ts
|
|
201
|
+
var DEFAULT_BASE_URL = "https://pushary.com/api/v1/server";
|
|
202
|
+
var validateApiKey = (apiKey) => {
|
|
203
|
+
if (!apiKey) {
|
|
204
|
+
throw new Error("API key is required. Get your API key from https://pushary.com/dashboard/settings");
|
|
205
|
+
}
|
|
206
|
+
if (!apiKey.includes(".")) {
|
|
207
|
+
throw new Error("Invalid API key format. Use the full API key (pk_xxx.sk_xxx)");
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
var createContext = (config) => {
|
|
211
|
+
validateApiKey(config.apiKey);
|
|
212
|
+
return Object.freeze({
|
|
213
|
+
baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,
|
|
214
|
+
headers: Object.freeze({
|
|
215
|
+
"Content-Type": "application/json",
|
|
216
|
+
"Authorization": `Bearer ${config.apiKey}`
|
|
217
|
+
})
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
var createPusharyServer = (config) => {
|
|
221
|
+
const ctx = createContext(config);
|
|
222
|
+
const request = createRequest(ctx);
|
|
223
|
+
return Object.freeze({
|
|
224
|
+
subscribers: createSubscribersResource(request),
|
|
225
|
+
campaigns: createCampaignsResource(request),
|
|
226
|
+
templates: createTemplatesResource(request),
|
|
227
|
+
notifications: createNotificationsResource(request),
|
|
228
|
+
flows: createFlowsResource(request),
|
|
229
|
+
decisions: createDecisionsResource(request),
|
|
230
|
+
keys: createKeysResource(request),
|
|
231
|
+
enroll: (externalId) => request("POST", "/enroll", { externalId })
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// src/webhook.ts
|
|
236
|
+
import { createHmac, timingSafeEqual } from "crypto";
|
|
237
|
+
var SIGNATURE_HEADER = "x-pushary-signature";
|
|
238
|
+
var verifyWebhookSignature = (rawBody, signature, secret) => {
|
|
239
|
+
if (!signature || !secret) return false;
|
|
240
|
+
const expected = createHmac("sha256", secret).update(rawBody).digest("hex");
|
|
241
|
+
const a = Buffer.from(expected);
|
|
242
|
+
const b = Buffer.from(signature);
|
|
243
|
+
if (a.length !== b.length) return false;
|
|
244
|
+
return timingSafeEqual(a, b);
|
|
245
|
+
};
|
|
246
|
+
var parseDecisionCallback = (rawBody) => {
|
|
247
|
+
let parsed;
|
|
248
|
+
try {
|
|
249
|
+
parsed = JSON.parse(rawBody);
|
|
250
|
+
} catch {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
254
|
+
const p = parsed;
|
|
255
|
+
if (typeof p.correlationId !== "string" || typeof p.answer !== "string") return null;
|
|
256
|
+
return {
|
|
257
|
+
correlationId: p.correlationId,
|
|
258
|
+
answer: p.answer,
|
|
259
|
+
value: typeof p.value === "string" ? p.value : p.answer,
|
|
260
|
+
answeredAt: typeof p.answeredAt === "string" ? p.answeredAt : "",
|
|
261
|
+
...typeof p.context === "string" ? { context: p.context } : {}
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export {
|
|
266
|
+
PusharyApiError,
|
|
267
|
+
deterministicKey,
|
|
268
|
+
isApproved,
|
|
269
|
+
createPusharyServer,
|
|
270
|
+
SIGNATURE_HEADER,
|
|
271
|
+
verifyWebhookSignature,
|
|
272
|
+
parseDecisionCallback
|
|
273
|
+
};
|
|
274
|
+
//# sourceMappingURL=chunk-22FUZ6F5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error.ts","../src/util.ts","../src/request.ts","../src/resources/subscribers.ts","../src/resources/campaigns.ts","../src/resources/templates.ts","../src/resources/notifications.ts","../src/resources/flows.ts","../src/resources/decisions.ts","../src/resources/keys.ts","../src/client.ts","../src/webhook.ts"],"sourcesContent":["/**\n * Thrown for any non-2xx response from the API.\n *\n * Extends Error rather than replacing it, so every existing `catch (e)` that\n * reads `e.message` keeps working unchanged. What it adds is the thing callers\n * previously had to string-match the message for: an HTTP status they can branch\n * on. Telling a revoked key (401) apart from a plan limit (403), a bad argument\n * (400) and an outage (5xx) is the difference between \"stop and re-authenticate\"\n * and \"retry in a minute\", and message text is not a stable API to decide that on.\n */\nexport class PusharyApiError extends Error {\n /** HTTP status of the response that failed. */\n readonly status: number\n /** HTTP status text, when the runtime provides one. */\n readonly statusText: string\n /** The API's own machine-readable error code, when it sent one. */\n readonly code?: string\n /** The parsed response body, for anything the fields above do not cover. */\n readonly body?: unknown\n\n constructor(\n message: string,\n init: { status: number; statusText?: string; code?: string; body?: unknown }\n ) {\n super(message)\n this.name = 'PusharyApiError'\n this.status = init.status\n this.statusText = init.statusText ?? ''\n this.code = init.code\n this.body = init.body\n // Restores the prototype chain so `err instanceof PusharyApiError` holds\n // even when this package is consumed as ES5-targeted CommonJS.\n Object.setPrototypeOf(this, PusharyApiError.prototype)\n }\n\n /** The key is missing, malformed, or revoked. Re-authenticate; do not retry. */\n get isAuthError(): boolean {\n return this.status === 401 || this.status === 403\n }\n\n /** Rate limited. Back off and retry. */\n get isRateLimited(): boolean {\n return this.status === 429\n }\n\n /** Server-side fault. Safe to retry an idempotent call. */\n get isServerError(): boolean {\n return this.status >= 500\n }\n}\n","import { createHash } from 'crypto'\nimport type { DecisionStatus, DecisionType } from './types'\n\n// A collision-safe idempotency key that is STABLE across process restarts\n// (unlike the builtin salted hash()), so a retried create reuses the same key\n// and never asks the same human twice. Pass the parts that make the ask unique\n// (e.g. [externalId, stepId, question]). Parts are joined with a NUL separator\n// so ['a', 'bc'] and ['ab', 'c'] never collide.\nexport const deterministicKey = (parts: readonly string[]): string =>\n createHash('sha256').update(parts.join('\\x00')).digest('hex').slice(0, 40)\n\nconst AFFIRMATIVE: ReadonlySet<string> = new Set([\n 'yes',\n 'y',\n 'approve',\n 'approved',\n 'ok',\n 'okay',\n 'confirm',\n 'accept',\n 'true',\n])\n\n// Fail-closed approval check. A `confirm` decision is approved ONLY on an\n// affirmative answer; `select`/`input` decisions are \"approved\" once answered.\n// Anything not answered — pending, expired, or cancelled — is NOT approved.\nexport const isApproved = (decision: {\n readonly status: DecisionStatus\n readonly type?: DecisionType\n readonly value: string | null\n}): boolean => {\n if (decision.status !== 'answered') return false\n if (decision.type && decision.type !== 'confirm') return true\n return decision.value != null && AFFIRMATIVE.has(decision.value.trim().toLowerCase())\n}\n","import type { RequestContext, RequestFn } from './types'\nimport { PusharyApiError } from './error'\n\nconst buildUrl = (baseUrl: string, path: string, params?: Record<string, unknown>): string => {\n // Build from the full absolute URL so the base path (e.g. /api/v1/server) is\n // preserved. `new URL(path, baseUrl)` treats a leading-slash path as absolute\n // and would drop that prefix, sending GET-with-query calls to the wrong URL.\n const url = new URL(`${baseUrl}${path}`)\n\n if (params) {\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value))\n }\n })\n }\n \n return url.toString()\n}\n\nconst handleResponse = async <T>(response: Response): Promise<T> => {\n if (!response.ok) {\n // The API returns its reason under `error`; older paths use `message`. Read\n // both so callers get the real reason (e.g. \"No subscribers found\") instead\n // of a bare \"HTTP 400\" they cannot classify.\n const body = (await response.json().catch(() => ({}))) as {\n message?: string\n error?: string\n code?: string\n }\n // PusharyApiError extends Error, so an existing `catch (e) { e.message }`\n // is unaffected. It carries the status too, because the reason to branch on\n // a failure (re-authenticate vs back off vs retry) was previously only\n // recoverable by string-matching this message, which is not a stable API.\n throw new PusharyApiError(body.message || body.error || `HTTP ${response.status}`, {\n status: response.status,\n statusText: response.statusText,\n code: body.code,\n body,\n })\n }\n return response.json() as Promise<T>\n}\n\nexport const createRequest = (ctx: RequestContext): RequestFn =>\n async <T>(method: string, path: string, body?: unknown): Promise<T> => {\n const isGet = method === 'GET'\n const url = isGet && body \n ? buildUrl(ctx.baseUrl, path, body as Record<string, unknown>)\n : `${ctx.baseUrl}${path}`\n \n const response = await fetch(url, {\n method,\n headers: ctx.headers,\n body: !isGet && body ? JSON.stringify(body) : undefined,\n })\n \n return handleResponse<T>(response)\n }\n\n","import type {\n RequestFn,\n Subscriber,\n SubscriberListParams,\n UpdateSubscriber,\n PaginatedResponse,\n SubscriberCount,\n} from '../types'\n\nexport interface SubscribersResource {\n readonly list: (params?: SubscriberListParams) => Promise<PaginatedResponse<Subscriber>>\n readonly get: (id: string) => Promise<Subscriber>\n readonly update: (id: string, data: UpdateSubscriber) => Promise<Subscriber>\n readonly delete: (id: string) => Promise<void>\n readonly count: () => Promise<SubscriberCount>\n}\n\nexport const createSubscribersResource = (request: RequestFn): SubscribersResource =>\n Object.freeze({\n list: (params?: SubscriberListParams) =>\n request<PaginatedResponse<Subscriber>>('GET', '/subscribers', params),\n \n get: (id: string) =>\n request<Subscriber>('GET', `/subscribers/${id}`),\n \n update: (id: string, data: UpdateSubscriber) =>\n request<Subscriber>('PATCH', `/subscribers/${id}`, data),\n \n delete: (id: string) =>\n request<void>('DELETE', `/subscribers/${id}`),\n \n count: () =>\n request<SubscriberCount>('GET', '/subscribers/count'),\n })\n\n","import type {\n RequestFn,\n Campaign,\n CreateCampaign,\n UpdateCampaign,\n ListParams,\n PaginatedResponse,\n CampaignStats,\n} from '../types'\n\nexport interface CampaignsResource {\n readonly list: (params?: ListParams) => Promise<PaginatedResponse<Campaign>>\n readonly create: (data: CreateCampaign) => Promise<Campaign>\n readonly get: (id: string) => Promise<Campaign>\n readonly update: (id: string, data: UpdateCampaign) => Promise<Campaign>\n readonly delete: (id: string) => Promise<void>\n readonly send: (id: string) => Promise<Campaign>\n readonly pause: (id: string) => Promise<Campaign>\n readonly resume: (id: string) => Promise<Campaign>\n readonly stats: (id: string) => Promise<CampaignStats>\n}\n\nexport const createCampaignsResource = (request: RequestFn): CampaignsResource =>\n Object.freeze({\n list: (params?: ListParams) =>\n request<PaginatedResponse<Campaign>>('GET', '/campaigns', params),\n \n create: (data: CreateCampaign) =>\n request<Campaign>('POST', '/campaigns', data),\n \n get: (id: string) =>\n request<Campaign>('GET', `/campaigns/${id}`),\n \n update: (id: string, data: UpdateCampaign) =>\n request<Campaign>('PATCH', `/campaigns/${id}`, data),\n \n delete: (id: string) =>\n request<void>('DELETE', `/campaigns/${id}`),\n \n send: (id: string) =>\n request<Campaign>('POST', `/campaigns/${id}/send`),\n \n pause: (id: string) =>\n request<Campaign>('POST', `/campaigns/${id}/pause`),\n \n resume: (id: string) =>\n request<Campaign>('POST', `/campaigns/${id}/resume`),\n \n stats: (id: string) =>\n request<CampaignStats>('GET', `/campaigns/${id}/stats`),\n })\n\n","import type {\n RequestFn,\n Template,\n CreateTemplate,\n UpdateTemplate,\n ListParams,\n PaginatedResponse,\n} from '../types'\n\nexport interface TemplatesResource {\n readonly list: (params?: ListParams) => Promise<PaginatedResponse<Template>>\n readonly create: (data: CreateTemplate) => Promise<Template>\n readonly get: (id: string) => Promise<Template>\n readonly update: (id: string, data: UpdateTemplate) => Promise<Template>\n readonly delete: (id: string) => Promise<void>\n}\n\nexport const createTemplatesResource = (request: RequestFn): TemplatesResource =>\n Object.freeze({\n list: (params?: ListParams) =>\n request<PaginatedResponse<Template>>('GET', '/templates', params),\n \n create: (data: CreateTemplate) =>\n request<Template>('POST', '/templates', data),\n \n get: (id: string) =>\n request<Template>('GET', `/templates/${id}`),\n \n update: (id: string, data: UpdateTemplate) =>\n request<Template>('PATCH', `/templates/${id}`, data),\n \n delete: (id: string) =>\n request<void>('DELETE', `/templates/${id}`),\n })\n\n","import type { RequestFn, SendNotification, SendResult } from '../types'\n\nexport interface NotificationsResource {\n readonly send: (data: SendNotification) => Promise<SendResult>\n}\n\nexport const createNotificationsResource = (request: RequestFn): NotificationsResource =>\n Object.freeze({\n send: (data: SendNotification) =>\n request<SendResult>('POST', '/send', data),\n })\n\n","import type {\n RequestFn,\n Flow,\n CreateFlow,\n UpdateFlow,\n FlowListParams,\n PaginatedResponse,\n} from '../types'\n\nexport interface FlowsResource {\n readonly list: (params?: FlowListParams) => Promise<PaginatedResponse<Flow>>\n readonly create: (data: CreateFlow) => Promise<Flow>\n readonly get: (id: string) => Promise<Flow>\n readonly update: (id: string, data: UpdateFlow) => Promise<Flow>\n readonly delete: (id: string) => Promise<void>\n readonly activate: (id: string) => Promise<Flow>\n readonly pause: (id: string) => Promise<Flow>\n}\n\nexport const createFlowsResource = (request: RequestFn): FlowsResource =>\n Object.freeze({\n list: (params?: FlowListParams) =>\n request<PaginatedResponse<Flow>>('GET', '/flows', params),\n \n create: (data: CreateFlow) =>\n request<Flow>('POST', '/flows', data),\n \n get: (id: string) =>\n request<Flow>('GET', `/flows/${id}`),\n \n update: (id: string, data: UpdateFlow) =>\n request<Flow>('PATCH', `/flows/${id}`, data),\n \n delete: (id: string) =>\n request<void>('DELETE', `/flows/${id}`),\n \n activate: (id: string) =>\n request<Flow>('POST', `/flows/${id}/activate`),\n \n pause: (id: string) =>\n request<Flow>('POST', `/flows/${id}/pause`),\n })\n","import type {\n RequestFn,\n CreateDecision,\n DecisionResult,\n Decision,\n DecisionAnswerResult,\n CancelDecisionResult,\n WebhookSecret,\n AskDecision,\n AskResult,\n DecisionType,\n DecisionStatus,\n} from '../types'\nimport { randomUUID } from 'crypto'\nimport { isApproved } from '../util'\n\n// A single long-poll window. The server clamps GET ?wait to 55s, so ask() loops\n// windows of this size until the decision resolves or the caller deadline passes.\nconst POLL_WINDOW_SECONDS = 50\nconst DEFAULT_ASK_TIMEOUT_MS = 55_000\n\n// Human-in-the-loop decisions: ask a specific end-user to approve, then resume\n// on their answer via webhook or poll. See the Partner integration guide.\nexport interface DecisionsResource {\n // Create a decision. Defaults to async (returns immediately with a decisionId);\n // pass wait:true to block up to ~55s for a fast answer. Always pass\n // idempotencyKey so a retried call does not ask the same human twice.\n readonly create: (data: CreateDecision) => Promise<DecisionResult>\n // Poll for the outcome. opts.wait long-polls up to N seconds. Reads durably, so\n // it still resolves after the live window closes.\n readonly get: (id: string, opts?: { readonly wait?: number }) => Promise<Decision>\n // Create a decision and block until the human answers or the deadline passes,\n // polling durably (so a crashed/resumed process still gets the answer). Returns\n // a fail-closed `approved` flag. Default deadline 55s (serverless-safe); the\n // decision stays answerable for its full TTL, so an {answered:false} return is\n // resolvable later via get() or a callbackUrl. This is the one call most agents\n // need. Each call reaches the human: without an idempotencyKey a fresh unique\n // key is generated per call, so two asks with the same text never collapse into\n // one silent auto-approval. Pass your own stable idempotencyKey (tied to your\n // operation id) only when you WANT a retried call to dedupe.\n readonly ask: (data: AskDecision) => Promise<AskResult>\n // Relay the end-user's answer from your own authenticated app (delegated auth).\n readonly answer: (id: string, answer: string) => Promise<DecisionAnswerResult>\n readonly cancel: (id: string) => Promise<CancelDecisionResult>\n // Your webhook signing secret (created on first call). Verify callbacks with\n // verifyWebhookSignature(rawBody, header, secret).\n readonly getWebhookSecret: () => Promise<WebhookSecret>\n readonly rotateWebhookSecret: () => Promise<WebhookSecret>\n}\n\nexport const createDecisionsResource = (request: RequestFn): DecisionsResource => {\n const ask = async (data: AskDecision): Promise<AskResult> => {\n // Idempotency is caller intent, never inferred from content: two asks with the\n // same text are usually two distinct decisions, so a content hash would make\n // the second silently replay the first answer (auto-approving a second refund,\n // or blocking a re-ask for the server's whole idempotency window). Default to a\n // unique key per call so every ask reaches the human; callers wanting retry\n // dedup pass their own stable key tied to their operation.\n const idempotencyKey = data.idempotencyKey ?? randomUUID()\n\n const created = await request<DecisionResult>('POST', '/decisions', {\n question: data.question,\n type: data.type,\n options: data.options,\n externalId: data.externalId,\n email: data.email,\n agentName: data.agentName,\n context: data.context,\n placeholder: data.placeholder,\n expiresInSeconds: data.expiresInSeconds,\n poweredBy: data.poweredBy,\n callbackUrl: data.callbackUrl,\n requireReachable: data.requireReachable,\n idempotencyKey,\n wait: false,\n })\n\n const type: DecisionType = created.type ?? data.type ?? 'confirm'\n let status: DecisionStatus = created.status\n let answered = created.answered\n let value: string | null = created.value ?? null\n\n const deadline = Date.now() + Math.max(0, data.timeoutMs ?? DEFAULT_ASK_TIMEOUT_MS)\n while (status === 'pending' && Date.now() < deadline) {\n const waitSeconds = Math.max(\n 1,\n Math.min(POLL_WINDOW_SECONDS, Math.ceil((deadline - Date.now()) / 1000)),\n )\n const polled = await request<Decision>('GET', `/decisions/${created.decisionId}`, {\n wait: waitSeconds,\n })\n status = polled.status\n answered = polled.answered\n value = polled.value\n }\n\n return {\n decisionId: created.decisionId,\n status,\n answered,\n value,\n type,\n approved: isApproved({ status, type, value }),\n // Surfaced from the create response so a caller can tell an unanswered\n // decision that reached nobody (reachable:false) apart from a real decline.\n reachable: created.reachable,\n reachableChannels: created.reachableChannels,\n deviceCount: created.deviceCount,\n }\n }\n\n return Object.freeze({\n create: (data: CreateDecision) => request<DecisionResult>('POST', '/decisions', data),\n get: (id: string, opts?: { readonly wait?: number }) =>\n request<Decision>('GET', `/decisions/${id}`, opts?.wait ? { wait: opts.wait } : undefined),\n ask,\n answer: (id: string, answer: string) =>\n request<DecisionAnswerResult>('POST', `/decisions/${id}`, { answer }),\n cancel: (id: string) => request<CancelDecisionResult>('DELETE', `/decisions/${id}`),\n getWebhookSecret: () => request<WebhookSecret>('GET', '/webhook-secret'),\n rotateWebhookSecret: () => request<WebhookSecret>('POST', '/webhook-secret'),\n })\n}\n","import type {\n RequestFn,\n IssueBoundKey,\n BoundKeyResult,\n BoundKeySummary,\n RevokeKeyResult,\n} from '../types'\n\n// Per-end-user (bound) key issuance for multi-tenant Partners. Call issue() from\n// your backend with your own (unbound, Partner-plan) key to mint a child key bound\n// to one end-user, hand that key to the agent runtime acting for that user, then\n// revoke() it when the session ends. A bound key can only create/resolve decisions\n// and enroll that exact end-user, so a prompt-injected agent can never reach\n// another of your users. Requires the Partner plan.\nexport interface KeysResource {\n // Mint a key bound to externalId. The full key is returned once in `apiKey` and\n // cannot be retrieved again — store it as the session credential.\n readonly issue: (data: IssueBoundKey) => Promise<BoundKeyResult>\n // List this site's bound keys (never the secret) for audit/rotation.\n readonly list: () => Promise<readonly BoundKeySummary[]>\n // Revoke (deactivate) a bound key by its prefix. Returns revoked:false if the\n // prefix is unknown or already inactive.\n readonly revoke: (keyPrefix: string) => Promise<RevokeKeyResult>\n}\n\nexport const createKeysResource = (request: RequestFn): KeysResource =>\n Object.freeze({\n issue: (data: IssueBoundKey) => request<BoundKeyResult>('POST', '/keys', data),\n list: () =>\n request<{ keys: readonly BoundKeySummary[] }>('GET', '/keys').then((r) => r.keys),\n revoke: (keyPrefix: string) =>\n request<RevokeKeyResult>('DELETE', `/keys/${encodeURIComponent(keyPrefix)}`),\n })\n","import type { PusharyConfig, RequestContext, EnrollResult } from './types'\nimport { createRequest } from './request'\nimport { createSubscribersResource, type SubscribersResource } from './resources/subscribers'\nimport { createCampaignsResource, type CampaignsResource } from './resources/campaigns'\nimport { createTemplatesResource, type TemplatesResource } from './resources/templates'\nimport { createNotificationsResource, type NotificationsResource } from './resources/notifications'\nimport { createFlowsResource, type FlowsResource } from './resources/flows'\nimport { createDecisionsResource, type DecisionsResource } from './resources/decisions'\nimport { createKeysResource, type KeysResource } from './resources/keys'\n\nconst DEFAULT_BASE_URL = 'https://pushary.com/api/v1/server'\n\nexport interface PusharyServer {\n readonly subscribers: SubscribersResource\n readonly campaigns: CampaignsResource\n readonly templates: TemplatesResource\n readonly notifications: NotificationsResource\n readonly flows: FlowsResource\n readonly decisions: DecisionsResource\n // Mint/rotate per-end-user bound keys for multi-tenant Partner integrations.\n readonly keys: KeysResource\n // Connect one of your end-users' phones (keyless, no Pushary account for them).\n // Returns a single-use universalLink to show them; one tap turns on approvals.\n // Requires the Partner plan.\n readonly enroll: (externalId: string) => Promise<EnrollResult>\n}\n\nconst validateApiKey = (apiKey: string): void => {\n if (!apiKey) {\n throw new Error('API key is required. Get your API key from https://pushary.com/dashboard/settings')\n }\n \n if (!apiKey.includes('.')) {\n throw new Error('Invalid API key format. Use the full API key (pk_xxx.sk_xxx)')\n }\n}\n\nconst createContext = (config: PusharyConfig): RequestContext => {\n validateApiKey(config.apiKey)\n \n return Object.freeze({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n headers: Object.freeze({\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${config.apiKey}`,\n }),\n })\n}\n\nexport const createPusharyServer = (config: PusharyConfig): PusharyServer => {\n const ctx = createContext(config)\n const request = createRequest(ctx)\n \n return Object.freeze({\n subscribers: createSubscribersResource(request),\n campaigns: createCampaignsResource(request),\n templates: createTemplatesResource(request),\n notifications: createNotificationsResource(request),\n flows: createFlowsResource(request),\n decisions: createDecisionsResource(request),\n keys: createKeysResource(request),\n enroll: (externalId: string) => request<EnrollResult>('POST', '/enroll', { externalId }),\n })\n}\n\n","import { createHmac, timingSafeEqual } from 'crypto'\nimport type { DecisionCallback } from './types'\n\n// The header carrying the HMAC-SHA256 signature of the raw callback body.\nexport const SIGNATURE_HEADER = 'x-pushary-signature'\n\n// Verify a Pushary webhook. Pass the RAW request body (not re-serialized JSON),\n// the X-Pushary-Signature header, and your webhook secret (decisions.getWebhookSecret()).\n// Constant-time comparison; returns false on any mismatch.\nexport const verifyWebhookSignature = (\n rawBody: string,\n signature: string | null | undefined,\n secret: string,\n): boolean => {\n if (!signature || !secret) return false\n const expected = createHmac('sha256', secret).update(rawBody).digest('hex')\n const a = Buffer.from(expected)\n const b = Buffer.from(signature)\n if (a.length !== b.length) return false\n return timingSafeEqual(a, b)\n}\n\n// Parse a verified decision callback body into a typed object. Returns null if the\n// body is not a decision callback (missing correlationId/answer). Verify the\n// signature FIRST — this does no verification. Read `answer` (canonical) keyed by\n// `correlationId`; `context` echoes what you passed at create time.\nexport const parseDecisionCallback = (rawBody: string): DecisionCallback | null => {\n let parsed: unknown\n try {\n parsed = JSON.parse(rawBody)\n } catch {\n return null\n }\n if (!parsed || typeof parsed !== 'object') return null\n const p = parsed as Record<string, unknown>\n if (typeof p.correlationId !== 'string' || typeof p.answer !== 'string') return null\n return {\n correlationId: p.correlationId,\n answer: p.answer,\n value: typeof p.value === 'string' ? p.value : p.answer,\n answeredAt: typeof p.answeredAt === 'string' ? p.answeredAt : '',\n ...(typeof p.context === 'string' ? { context: p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