@yougrowai/node 0.1.0 → 0.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/test/vectors.json CHANGED
@@ -1,28 +1,5 @@
1
1
  {
2
- "description": "Signing vectors for the YouGrow product-connection protocol. 'vectors': product -> platform events, signature = 'v1=' + hex(HMAC-SHA256(secret, 'events:' + timestamp + '.' + body)), generated with openssl. 'outbound': platform -> product ES256 JWTs (context pulls, webhooks), signed once with a throwaway P-256 key whose private half was discarded; only the public JWK is kept. Both the server and the SDK test suites must accept every outbound token at nowMs and reject the listed tamperings.",
3
- "vectors": [
4
- {
5
- "secret": "ygs_test_secret_one",
6
- "direction": "events",
7
- "timestamp": 1758455000,
8
- "body": "{\"batch\":[{\"type\":\"identify\",\"messageId\":\"m1\",\"userId\":\"u1\",\"timestamp\":\"2026-09-21T10:00:00Z\",\"traits\":{\"email\":\"alex@acme.test\"}}]}",
9
- "signature": "v1=d4bdf726960d10a135b3493f4074b3d3d3773a23ec49955d6efb720bcd2ef914"
10
- },
11
- {
12
- "secret": "ygs_test_secret_two",
13
- "direction": "events",
14
- "timestamp": 1758455123,
15
- "body": "{\"batch\":[{\"type\":\"track\",\"messageId\":\"m2\",\"userId\":\"ü-用户\",\"timestamp\":\"2026-09-21T10:00:00+01:00\",\"event\":\"user.signed_up\"}]}",
16
- "signature": "v1=fadcda4cd874e1ad19b1f7059cca902b54afdfe9032c10dcfdffa75cc450b317"
17
- },
18
- {
19
- "secret": "ygs_test_secret_one",
20
- "direction": "events",
21
- "timestamp": 1758455000,
22
- "body": "",
23
- "signature": "v1=aae9033d246c64b2e62a630910f59e35531cfb71d5b1a4da90a1002323979eae"
24
- }
25
- ],
2
+ "description": "Signing vectors for the YouGrow product-connection protocol. 'outbound': platform -> product ES256 JWTs (context pulls, webhooks), signed once with a throwaway P-256 key whose private half was discarded; only the public JWK is kept. Both the server and the SDK test suites must accept every outbound token at nowMs and reject the listed tamperings.",
26
3
  "outbound": {
27
4
  "issuer": "https://yougrow.ai",
28
5
  "audience": "ygk_vectorsvectorsvectors0",
package/dist/signing.d.ts DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * Request signing for events your product sends to YouGrow:
3
- *
4
- * X-YouGrow-Signature: v1=<hex HMAC-SHA256(secret, `events:${timestamp}.${rawBody}`)>
5
- *
6
- * Timestamps are unix seconds; requests more than five minutes off are refused.
7
- * Pinned by test/vectors.json.
8
- *
9
- * Requests YouGrow sends YOU (context pulls, webhooks) are not signed with your
10
- * secret: they carry a JWT signed with YouGrow's own key. Verify those with
11
- * `createVerifier` from "@yougrowai/node/server".
12
- */
13
- export type Direction = "events";
14
- export declare const HEADERS: {
15
- readonly keyId: "x-yougrow-key-id";
16
- readonly timestamp: "x-yougrow-timestamp";
17
- readonly signature: "x-yougrow-signature";
18
- };
19
- export declare function sign(secret: string, direction: Direction, timestampSec: number, rawBody: string): string;
package/dist/signing.js DELETED
@@ -1,10 +0,0 @@
1
- import { createHmac } from "node:crypto";
2
- export const HEADERS = {
3
- keyId: "x-yougrow-key-id",
4
- timestamp: "x-yougrow-timestamp",
5
- signature: "x-yougrow-signature",
6
- };
7
- export function sign(secret, direction, timestampSec, rawBody) {
8
- const mac = createHmac("sha256", secret).update(`${direction}:${timestampSec}.${rawBody}`).digest("hex");
9
- return `v1=${mac}`;
10
- }