plures 0.0.0-stage → 1.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 Plures Labs LLC
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 CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # plures
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The official JavaScript and TypeScript client for [Plures](https://plures.si): human judgment as an API for AI agents. Send a decision to ID verified people and get their consensus back before your agent acts. A human in the loop step you can call like any other API.
4
+
5
+ ```bash
6
+ npm install plures
7
+ ```
8
+
9
+ Works in Node 18+, Bun, Deno and edge runtimes. No dependencies.
10
+
11
+ ## Use it
12
+
13
+ ```ts
14
+ import { Plures } from "plures";
15
+
16
+ const plures = new Plures(); // reads PLURES_API_KEY, or pass the key: new Plures("pk_test_...")
17
+
18
+ // Send it and wait for the answer (handy in scripts and agent tools)
19
+ const task = await plures.verify({
20
+ question: "Does the invoice match the order?",
21
+ context: "Order: 48 chairs, $4,218. Invoice: 48 chairs plus $180 freight, $4,398.",
22
+ options: ["Matches", "Does not match"],
23
+ verifiers: 3,
24
+ });
25
+ console.log(task.result?.answer, task.result?.agreement);
26
+ ```
27
+
28
+ Get a free test key at [plures.si](https://plures.si/?for=developers#join). Test keys complete at once with the first option (or `metadata.test_answer`) and never reach real people. Set `metadata.test_outcome` to `split`, `tie`, `expired` or `slow` to test the cases you route to your own team.
29
+
30
+ ## Production: webhooks
31
+
32
+ ```ts
33
+ await plures.tasks.create(
34
+ { question, context, options: ["Approve", "Decline"], webhook_url: "https://your.app/plures", metadata: { orderId } },
35
+ { idempotencyKey: `refund-${orderId}` },
36
+ );
37
+
38
+ // In your webhook handler, pass the raw body exactly as received
39
+ const event = await Plures.verifyWebhook(rawBody, req.headers.get("plures-signature"), process.env.PLURES_WEBHOOK_SECRET!);
40
+ if (event.type === "task.completed" && event.data.result?.agreement === 1) {
41
+ // act on event.data.result.answer
42
+ }
43
+ ```
44
+
45
+ ## API
46
+
47
+ - `plures.tasks.create(params, { idempotencyKey? })`: send a task. Params: `question`, `options` (2 to 8, strings or `{ id, label }`), `context`, `image_url`, `instructions`, `verifiers` (1, 3, 5, 7 or 9), `max_verifiers`, `presence_check` (default true), `webhook_url`, `metadata`, `expires_in`.
48
+ - `plures.tasks.retrieve(id)`, `plures.tasks.list({ status?, limit?, starting_after? })`, `plures.tasks.cancel(id)`
49
+ - `plures.tasks.waitFor(id, { timeoutMs?, intervalMs? })`: poll until settled
50
+ - `plures.verify(params, { timeoutMs?, idempotencyKey? })`: create and wait
51
+ - `Plures.verifyWebhook(rawBody, signatureHeader, secret)`: check a webhook and return the event
52
+
53
+ Errors throw `PluresError` with `status` and `type`. Server errors are retried twice.
54
+
55
+ The result: `answer` (the option id most people chose, or null on a tie or expiry), `agreement` (0 to 1), `answers`, and `votes`. A good default is to act automatically at `agreement === 1` and send anything lower to your team.
56
+
57
+ Full reference: [plures.si/docs](https://plures.si/docs). For agents that speak MCP, see [plures-mcp](https://www.npmjs.com/package/plures-mcp).
package/dist/index.cjs ADDED
@@ -0,0 +1,119 @@
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
+ Plures: () => Plures,
24
+ PluresError: () => PluresError,
25
+ VERSION: () => VERSION,
26
+ default: () => index_default
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ var VERSION = "1.1.0";
30
+ var PluresError = class extends Error {
31
+ constructor(message, status, type) {
32
+ super(message);
33
+ this.status = status;
34
+ this.type = type;
35
+ }
36
+ status;
37
+ type;
38
+ };
39
+ var Plures = class {
40
+ base;
41
+ apiKey;
42
+ constructor(apiKey, opts = {}) {
43
+ const key = apiKey ?? (typeof process !== "undefined" ? process.env?.PLURES_API_KEY : void 0);
44
+ if (!key) throw new Error("Pass your Plures API key, or set PLURES_API_KEY. Get a free test key at https://plures.si/?for=developers#join");
45
+ this.apiKey = key;
46
+ this.base = (opts.baseUrl ?? (typeof process !== "undefined" ? process.env?.PLURES_BASE_URL : void 0) ?? "https://plures.si").replace(/\/$/, "");
47
+ }
48
+ async req(method, path, body, headers = {}) {
49
+ for (let attempt = 0; ; attempt++) {
50
+ const r = await fetch(this.base + path, {
51
+ method,
52
+ headers: { authorization: `Bearer ${this.apiKey}`, "user-agent": `plures-js/${VERSION}`, ...body ? { "content-type": "application/json" } : {}, ...headers },
53
+ body: body ? JSON.stringify(body) : void 0
54
+ });
55
+ if (r.status >= 500 && attempt < 2) {
56
+ await sleep(500 * 2 ** attempt);
57
+ continue;
58
+ }
59
+ const data = await r.json().catch(() => ({}));
60
+ if (!r.ok) throw new PluresError(data?.error?.message ?? `HTTP ${r.status}`, r.status, data?.error?.type ?? "api_error");
61
+ return data;
62
+ }
63
+ }
64
+ tasks = {
65
+ /** Sends a question to verified people. Pass an idempotency key to make retries safe. */
66
+ create: (params, opts = {}) => this.req("POST", "/api/v1/tasks", params, opts.idempotencyKey ? { "idempotency-key": opts.idempotencyKey } : {}),
67
+ retrieve: (id) => this.req("GET", `/api/v1/tasks/${encodeURIComponent(id)}`),
68
+ list: (params = {}) => {
69
+ const q = new URLSearchParams(Object.entries(params).filter(([, v]) => v != null).map(([k, v]) => [k, String(v)]));
70
+ return this.req("GET", `/api/v1/tasks${q.size ? `?${q}` : ""}`);
71
+ },
72
+ cancel: (id) => this.req("POST", `/api/v1/tasks/${encodeURIComponent(id)}/cancel`),
73
+ /** Polls until the task is settled. Prefer webhooks in production. */
74
+ waitFor: async (id, opts = {}) => {
75
+ const end = Date.now() + (opts.timeoutMs ?? 10 * 6e4);
76
+ for (; ; ) {
77
+ const t = await this.tasks.retrieve(id);
78
+ if (t.status !== "pending") return t;
79
+ if (Date.now() > end) return t;
80
+ await sleep(opts.intervalMs ?? 3e3);
81
+ }
82
+ }
83
+ };
84
+ /** Creates a task and waits for people to answer it. */
85
+ async verify(params, opts = {}) {
86
+ const t = await this.tasks.create(params, { idempotencyKey: opts.idempotencyKey });
87
+ return t.status === "pending" ? this.tasks.waitFor(t.id, { timeoutMs: opts.timeoutMs }) : t;
88
+ }
89
+ /**
90
+ * Checks the Plures-Signature header on a webhook and returns the parsed event.
91
+ * Pass the raw request body exactly as received. Throws if the signature is wrong
92
+ * or older than toleranceSec.
93
+ */
94
+ static async verifyWebhook(rawBody, signatureHeader, secret, toleranceSec = 300) {
95
+ const parts = Object.fromEntries((signatureHeader ?? "").split(",").map((p) => p.split("=", 2)));
96
+ const t = Number(parts.t);
97
+ if (!t || !parts.v1) throw new Error("Missing Plures-Signature header");
98
+ if (Math.abs(Date.now() / 1e3 - t) > toleranceSec) throw new Error("Webhook timestamp is too old");
99
+ const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
100
+ const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(`${t}.${rawBody}`)));
101
+ const expected = Array.from(mac, (b) => b.toString(16).padStart(2, "0")).join("");
102
+ if (!timingSafeEqual(expected, parts.v1)) throw new Error("Webhook signature does not match");
103
+ return JSON.parse(rawBody);
104
+ }
105
+ };
106
+ function timingSafeEqual(a, b) {
107
+ if (a.length !== b.length) return false;
108
+ let diff = 0;
109
+ for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
110
+ return diff === 0;
111
+ }
112
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
113
+ var index_default = Plures;
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ Plures,
117
+ PluresError,
118
+ VERSION
119
+ });
@@ -0,0 +1,118 @@
1
+ type Option = {
2
+ id: string;
3
+ label: string;
4
+ };
5
+ type TaskStatus = "pending" | "completed" | "expired" | "canceled";
6
+ type Result = {
7
+ answer: string | null;
8
+ label: string | null;
9
+ agreement: number;
10
+ answers: number;
11
+ votes: Record<string, number>;
12
+ tie?: boolean;
13
+ /** Who made the final call: verified people, or your team after verifiers didn't all agree. */
14
+ decided_by?: "verifiers" | "team";
15
+ /** The team member who decided, when decided_by is "team". */
16
+ reviewer?: string;
17
+ note?: string;
18
+ };
19
+ /** Set when verifiers didn't all agree and the decision went to your team. */
20
+ type Escalation = {
21
+ reason: "split" | "tie" | "no_answer";
22
+ escalated_at: string;
23
+ verifiers: Result | null;
24
+ team_deadline?: string;
25
+ };
26
+ type Task = {
27
+ id: string;
28
+ object: "task";
29
+ mode: "live" | "test";
30
+ status: TaskStatus;
31
+ question: string;
32
+ context: string | null;
33
+ image_url: string | null;
34
+ instructions: string | null;
35
+ options: Option[];
36
+ verifiers: number;
37
+ presence_check?: boolean;
38
+ result: Result | null;
39
+ escalation?: Escalation | null;
40
+ metadata: Record<string, unknown>;
41
+ webhook_url: string | null;
42
+ created_at: string;
43
+ completed_at: string | null;
44
+ expires_at: string;
45
+ };
46
+ type CreateTask = {
47
+ question: string;
48
+ options: (string | Option)[];
49
+ context?: string;
50
+ image_url?: string;
51
+ instructions?: string;
52
+ verifiers?: 1 | 3 | 5 | 7 | 9;
53
+ max_verifiers?: number;
54
+ /** Confirm every answer with the verifier's Face ID, fingerprint or passkey. Default true. */
55
+ presence_check?: boolean;
56
+ webhook_url?: string;
57
+ metadata?: Record<string, unknown>;
58
+ expires_in?: number;
59
+ /** Send to your team when verifiers don't agree enough. Default: on when you've added a team. */
60
+ escalate?: boolean;
61
+ /** Agreement below which this task goes to your team, 0 to 1. Default from your dashboard. */
62
+ escalate_below?: number;
63
+ };
64
+ type WebhookEvent = {
65
+ id: string;
66
+ type: "task.completed" | "task.expired" | "task.canceled";
67
+ created_at: string;
68
+ data: Task;
69
+ };
70
+ declare const VERSION = "1.1.0";
71
+ declare class PluresError extends Error {
72
+ readonly status: number;
73
+ readonly type: string;
74
+ constructor(message: string, status: number, type: string);
75
+ }
76
+ declare class Plures {
77
+ private base;
78
+ private apiKey;
79
+ constructor(apiKey?: string, opts?: {
80
+ baseUrl?: string;
81
+ });
82
+ private req;
83
+ tasks: {
84
+ /** Sends a question to verified people. Pass an idempotency key to make retries safe. */
85
+ create: (params: CreateTask, opts?: {
86
+ idempotencyKey?: string;
87
+ }) => Promise<Task>;
88
+ retrieve: (id: string) => Promise<Task>;
89
+ list: (params?: {
90
+ status?: TaskStatus;
91
+ limit?: number;
92
+ starting_after?: string;
93
+ }) => Promise<{
94
+ object: "list";
95
+ data: Task[];
96
+ has_more: boolean;
97
+ }>;
98
+ cancel: (id: string) => Promise<Task>;
99
+ /** Polls until the task is settled. Prefer webhooks in production. */
100
+ waitFor: (id: string, opts?: {
101
+ timeoutMs?: number;
102
+ intervalMs?: number;
103
+ }) => Promise<Task>;
104
+ };
105
+ /** Creates a task and waits for people to answer it. */
106
+ verify(params: CreateTask, opts?: {
107
+ timeoutMs?: number;
108
+ idempotencyKey?: string;
109
+ }): Promise<Task>;
110
+ /**
111
+ * Checks the Plures-Signature header on a webhook and returns the parsed event.
112
+ * Pass the raw request body exactly as received. Throws if the signature is wrong
113
+ * or older than toleranceSec.
114
+ */
115
+ static verifyWebhook(rawBody: string, signatureHeader: string | null, secret: string, toleranceSec?: number): Promise<WebhookEvent>;
116
+ }
117
+
118
+ export { type CreateTask, type Escalation, type Option, Plures, PluresError, type Result, type Task, type TaskStatus, VERSION, type WebhookEvent, Plures as default };
@@ -0,0 +1,118 @@
1
+ type Option = {
2
+ id: string;
3
+ label: string;
4
+ };
5
+ type TaskStatus = "pending" | "completed" | "expired" | "canceled";
6
+ type Result = {
7
+ answer: string | null;
8
+ label: string | null;
9
+ agreement: number;
10
+ answers: number;
11
+ votes: Record<string, number>;
12
+ tie?: boolean;
13
+ /** Who made the final call: verified people, or your team after verifiers didn't all agree. */
14
+ decided_by?: "verifiers" | "team";
15
+ /** The team member who decided, when decided_by is "team". */
16
+ reviewer?: string;
17
+ note?: string;
18
+ };
19
+ /** Set when verifiers didn't all agree and the decision went to your team. */
20
+ type Escalation = {
21
+ reason: "split" | "tie" | "no_answer";
22
+ escalated_at: string;
23
+ verifiers: Result | null;
24
+ team_deadline?: string;
25
+ };
26
+ type Task = {
27
+ id: string;
28
+ object: "task";
29
+ mode: "live" | "test";
30
+ status: TaskStatus;
31
+ question: string;
32
+ context: string | null;
33
+ image_url: string | null;
34
+ instructions: string | null;
35
+ options: Option[];
36
+ verifiers: number;
37
+ presence_check?: boolean;
38
+ result: Result | null;
39
+ escalation?: Escalation | null;
40
+ metadata: Record<string, unknown>;
41
+ webhook_url: string | null;
42
+ created_at: string;
43
+ completed_at: string | null;
44
+ expires_at: string;
45
+ };
46
+ type CreateTask = {
47
+ question: string;
48
+ options: (string | Option)[];
49
+ context?: string;
50
+ image_url?: string;
51
+ instructions?: string;
52
+ verifiers?: 1 | 3 | 5 | 7 | 9;
53
+ max_verifiers?: number;
54
+ /** Confirm every answer with the verifier's Face ID, fingerprint or passkey. Default true. */
55
+ presence_check?: boolean;
56
+ webhook_url?: string;
57
+ metadata?: Record<string, unknown>;
58
+ expires_in?: number;
59
+ /** Send to your team when verifiers don't agree enough. Default: on when you've added a team. */
60
+ escalate?: boolean;
61
+ /** Agreement below which this task goes to your team, 0 to 1. Default from your dashboard. */
62
+ escalate_below?: number;
63
+ };
64
+ type WebhookEvent = {
65
+ id: string;
66
+ type: "task.completed" | "task.expired" | "task.canceled";
67
+ created_at: string;
68
+ data: Task;
69
+ };
70
+ declare const VERSION = "1.1.0";
71
+ declare class PluresError extends Error {
72
+ readonly status: number;
73
+ readonly type: string;
74
+ constructor(message: string, status: number, type: string);
75
+ }
76
+ declare class Plures {
77
+ private base;
78
+ private apiKey;
79
+ constructor(apiKey?: string, opts?: {
80
+ baseUrl?: string;
81
+ });
82
+ private req;
83
+ tasks: {
84
+ /** Sends a question to verified people. Pass an idempotency key to make retries safe. */
85
+ create: (params: CreateTask, opts?: {
86
+ idempotencyKey?: string;
87
+ }) => Promise<Task>;
88
+ retrieve: (id: string) => Promise<Task>;
89
+ list: (params?: {
90
+ status?: TaskStatus;
91
+ limit?: number;
92
+ starting_after?: string;
93
+ }) => Promise<{
94
+ object: "list";
95
+ data: Task[];
96
+ has_more: boolean;
97
+ }>;
98
+ cancel: (id: string) => Promise<Task>;
99
+ /** Polls until the task is settled. Prefer webhooks in production. */
100
+ waitFor: (id: string, opts?: {
101
+ timeoutMs?: number;
102
+ intervalMs?: number;
103
+ }) => Promise<Task>;
104
+ };
105
+ /** Creates a task and waits for people to answer it. */
106
+ verify(params: CreateTask, opts?: {
107
+ timeoutMs?: number;
108
+ idempotencyKey?: string;
109
+ }): Promise<Task>;
110
+ /**
111
+ * Checks the Plures-Signature header on a webhook and returns the parsed event.
112
+ * Pass the raw request body exactly as received. Throws if the signature is wrong
113
+ * or older than toleranceSec.
114
+ */
115
+ static verifyWebhook(rawBody: string, signatureHeader: string | null, secret: string, toleranceSec?: number): Promise<WebhookEvent>;
116
+ }
117
+
118
+ export { type CreateTask, type Escalation, type Option, Plures, PluresError, type Result, type Task, type TaskStatus, VERSION, type WebhookEvent, Plures as default };
package/dist/index.js ADDED
@@ -0,0 +1,92 @@
1
+ // src/index.ts
2
+ var VERSION = "1.1.0";
3
+ var PluresError = class extends Error {
4
+ constructor(message, status, type) {
5
+ super(message);
6
+ this.status = status;
7
+ this.type = type;
8
+ }
9
+ status;
10
+ type;
11
+ };
12
+ var Plures = class {
13
+ base;
14
+ apiKey;
15
+ constructor(apiKey, opts = {}) {
16
+ const key = apiKey ?? (typeof process !== "undefined" ? process.env?.PLURES_API_KEY : void 0);
17
+ if (!key) throw new Error("Pass your Plures API key, or set PLURES_API_KEY. Get a free test key at https://plures.si/?for=developers#join");
18
+ this.apiKey = key;
19
+ this.base = (opts.baseUrl ?? (typeof process !== "undefined" ? process.env?.PLURES_BASE_URL : void 0) ?? "https://plures.si").replace(/\/$/, "");
20
+ }
21
+ async req(method, path, body, headers = {}) {
22
+ for (let attempt = 0; ; attempt++) {
23
+ const r = await fetch(this.base + path, {
24
+ method,
25
+ headers: { authorization: `Bearer ${this.apiKey}`, "user-agent": `plures-js/${VERSION}`, ...body ? { "content-type": "application/json" } : {}, ...headers },
26
+ body: body ? JSON.stringify(body) : void 0
27
+ });
28
+ if (r.status >= 500 && attempt < 2) {
29
+ await sleep(500 * 2 ** attempt);
30
+ continue;
31
+ }
32
+ const data = await r.json().catch(() => ({}));
33
+ if (!r.ok) throw new PluresError(data?.error?.message ?? `HTTP ${r.status}`, r.status, data?.error?.type ?? "api_error");
34
+ return data;
35
+ }
36
+ }
37
+ tasks = {
38
+ /** Sends a question to verified people. Pass an idempotency key to make retries safe. */
39
+ create: (params, opts = {}) => this.req("POST", "/api/v1/tasks", params, opts.idempotencyKey ? { "idempotency-key": opts.idempotencyKey } : {}),
40
+ retrieve: (id) => this.req("GET", `/api/v1/tasks/${encodeURIComponent(id)}`),
41
+ list: (params = {}) => {
42
+ const q = new URLSearchParams(Object.entries(params).filter(([, v]) => v != null).map(([k, v]) => [k, String(v)]));
43
+ return this.req("GET", `/api/v1/tasks${q.size ? `?${q}` : ""}`);
44
+ },
45
+ cancel: (id) => this.req("POST", `/api/v1/tasks/${encodeURIComponent(id)}/cancel`),
46
+ /** Polls until the task is settled. Prefer webhooks in production. */
47
+ waitFor: async (id, opts = {}) => {
48
+ const end = Date.now() + (opts.timeoutMs ?? 10 * 6e4);
49
+ for (; ; ) {
50
+ const t = await this.tasks.retrieve(id);
51
+ if (t.status !== "pending") return t;
52
+ if (Date.now() > end) return t;
53
+ await sleep(opts.intervalMs ?? 3e3);
54
+ }
55
+ }
56
+ };
57
+ /** Creates a task and waits for people to answer it. */
58
+ async verify(params, opts = {}) {
59
+ const t = await this.tasks.create(params, { idempotencyKey: opts.idempotencyKey });
60
+ return t.status === "pending" ? this.tasks.waitFor(t.id, { timeoutMs: opts.timeoutMs }) : t;
61
+ }
62
+ /**
63
+ * Checks the Plures-Signature header on a webhook and returns the parsed event.
64
+ * Pass the raw request body exactly as received. Throws if the signature is wrong
65
+ * or older than toleranceSec.
66
+ */
67
+ static async verifyWebhook(rawBody, signatureHeader, secret, toleranceSec = 300) {
68
+ const parts = Object.fromEntries((signatureHeader ?? "").split(",").map((p) => p.split("=", 2)));
69
+ const t = Number(parts.t);
70
+ if (!t || !parts.v1) throw new Error("Missing Plures-Signature header");
71
+ if (Math.abs(Date.now() / 1e3 - t) > toleranceSec) throw new Error("Webhook timestamp is too old");
72
+ const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
73
+ const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(`${t}.${rawBody}`)));
74
+ const expected = Array.from(mac, (b) => b.toString(16).padStart(2, "0")).join("");
75
+ if (!timingSafeEqual(expected, parts.v1)) throw new Error("Webhook signature does not match");
76
+ return JSON.parse(rawBody);
77
+ }
78
+ };
79
+ function timingSafeEqual(a, b) {
80
+ if (a.length !== b.length) return false;
81
+ let diff = 0;
82
+ for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
83
+ return diff === 0;
84
+ }
85
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
86
+ var index_default = Plures;
87
+ export {
88
+ Plures,
89
+ PluresError,
90
+ VERSION,
91
+ index_default as default
92
+ };
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "plures",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "Human judgment as an API for AI agents. Send a decision to ID verified people and get their consensus back.",
5
+ "keywords": [
6
+ "human-in-the-loop",
7
+ "hitl",
8
+ "ai-agents",
9
+ "human-review",
10
+ "human-approval",
11
+ "agents",
12
+ "llm",
13
+ "verification",
14
+ "plures"
15
+ ],
16
+ "homepage": "https://plures.si/docs",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/plureslabs/plures.git",
20
+ "directory": "js"
21
+ },
22
+ "bugs": "https://github.com/plureslabs/plures/issues",
23
+ "license": "MIT",
24
+ "author": "Plures Labs LLC <hello@plures.si>",
25
+ "type": "module",
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "import": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/index.d.cts",
37
+ "default": "./dist/index.cjs"
38
+ }
39
+ }
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "README.md"
44
+ ],
45
+ "sideEffects": false,
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "scripts": {
50
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
51
+ "prepublishOnly": "npm run build"
52
+ },
53
+ "devDependencies": {
54
+ "tsup": "^8.3.5",
55
+ "typescript": "^5.6.3",
56
+ "@types/node": "^22.10.0"
57
+ }
58
+ }