@primitivedotdev/sdk 0.27.1 → 0.28.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/dist/api/index.d.ts +4 -4
- package/dist/api/index.js +3 -3
- package/dist/{api-CZIBnM4Q.js → api-3znV8SSN.js} +59 -8
- package/dist/contract/index.d.ts +8 -2
- package/dist/contract/index.js +7 -2
- package/dist/{errors-T_0JE528.d.ts → errors-CO-rv_nK.d.ts} +1 -1
- package/dist/{index-9Rqocr-c.d.ts → index-BKeS9sOb.d.ts} +209 -19
- package/dist/{index-EQZK4vWT.d.ts → index-D_v8-0zX.d.ts} +19 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/openapi/index.js +1 -1
- package/dist/{operations.generated-T3exFpgJ.js → operations.generated-x1Go1Xkb.js} +485 -11
- package/dist/parser/index.d.ts +2 -1
- package/dist/parser/index.js +2 -0
- package/dist/{types-Nslo1CU0.d.ts → types-BRWDMD7H.d.ts} +8 -0
- package/dist/webhook/index.d.ts +3 -3
- package/dist/webhook/index.js +1 -1
- package/dist/{webhook-Bra-g1q8.js → webhook-D4FTpj38.js} +643 -460
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ const openapiDocument = {
|
|
|
10
10
|
"info": {
|
|
11
11
|
"title": "Primitive API",
|
|
12
12
|
"version": "1.0.0",
|
|
13
|
-
"description": "The Primitive API lets you manage domains, emails, webhook endpoints,\nfilters, and account settings programmatically.\n\n## Authentication\n\
|
|
13
|
+
"description": "The Primitive API lets you manage domains, emails, webhook endpoints,\nfilters, and account settings programmatically.\n\n## Authentication\n\nMost endpoints require a Bearer token in the `Authorization` header:\n\n```\nAuthorization: Bearer prim_<your_api_key>\n```\n\nAPI keys are org-scoped. Create and manage them in your dashboard\nunder Settings > API Keys. CLI login and signup endpoints explicitly\ndeclare `security: []`; they do not require an API key because they\nare used to mint one.\n\n## Rate Limiting\n\nThe API enforces a sliding window rate limit of **120 requests per\n60 seconds** per organization. When exceeded, the API returns `429`\nwith a `Retry-After` header indicating how many seconds to wait.\n\n## Pagination\n\nList endpoints use cursor-based pagination. Responses include a\n`meta` object with `total`, `limit`, and `cursor` fields. Pass the\n`cursor` value as a query parameter to fetch the next page. When\n`cursor` is `null`, there are no more results.\n\n## Response Format\n\nAll responses use a consistent envelope:\n\n```json\n{\n \"success\": true,\n \"data\": { ... },\n \"meta\": { \"total\": 42, \"limit\": 50, \"cursor\": \"...\" }\n}\n```\n\nErrors follow the same pattern:\n\n```json\n{\n \"success\": false,\n \"error\": { \"code\": \"not_found\", \"message\": \"Email not found\" }\n}\n```\n\n## Webhook signing\n\nOutbound webhook deliveries (configured via the `endpoints` API)\nare signed so receivers can verify they came from Primitive and\nhave not been tampered with in transit. The signing scheme is\ndeliberately simple so it can be reimplemented in any language\nin a few lines. The Node SDK's `verifyWebhookSignature` helper\nis the reference implementation; the wire details below let you\nwrite a verifier in Python, Go, Ruby, etc. without reading our\nsource.\n\n**Header**: `Primitive-Signature: t=<unix-seconds>,v1=<hex>`\n\nA legacy `MyMX-Signature` header is also sent on every delivery\nwith the same value, retained for back-compatibility with\nintegrations written before the rename. New code should read\n`Primitive-Signature`.\n\n**Signed string**: `${timestamp}.${rawBody}` where `timestamp`\nis the Unix-seconds integer from the `t=` parameter and\n`rawBody` is the exact bytes of the HTTP request body BEFORE\nany JSON decoding. Verify against the raw body, not a\nre-serialized parse, or you will silently mismatch on\ninsignificant whitespace.\n\n**Signature**: HMAC-SHA256 of the signed string, hex-encoded\n(lowercase). Use the account's webhook secret as the HMAC key,\nas a UTF-8 byte sequence.\n\n**Secret**: returned by `GET /account/webhook-secret`. The\nstring looks base64-shaped (e.g. `XNHBBW8VqoBjRfNs1tkZj11jTk...`)\nbut is NOT base64; use it AS-IS as a UTF-8 string for the HMAC\nkey. Base64-decoding before HMAC will silently produce\nmismatched signatures.\n\n**Tolerance**: by convention, reject deliveries whose `t=`\ntimestamp is more than 5 minutes off your wall-clock to defend\nagainst replay attacks. The Node SDK's helper enforces this by\ndefault.\n\n**Verification recipe** (any language):\n\n```\n1. Read the raw HTTP body (do not parse).\n2. Read `Primitive-Signature: t=<ts>,v1=<sig>`.\n3. Reject if abs(now - ts) > 300 seconds.\n4. expected = HMAC_SHA256_hex(secret_utf8, f\"{ts}.{rawBody}\")\n5. Constant-time compare expected to sig. Reject if not equal.\n```\n\nFor Node, use `verifyWebhookSignature` from\n`@primitivedotdev/sdk/webhook` (or the higher-level\n`handleWebhook` helper if you want a one-liner). For other\nlanguages, the recipe above is everything you need.\n\nTest deliveries: `POST /endpoints/{id}/test` triggers a fake\ndelivery to your endpoint URL, signed with your real account\nsecret, so you can confirm verification end-to-end without\nneeding real inbound mail. The test response carries the exact\n`signature` header value sent on the wire so you can compare\nstrings directly.\n",
|
|
14
14
|
"contact": {
|
|
15
15
|
"name": "Primitive",
|
|
16
16
|
"url": "https://primitive.dev"
|
|
@@ -182,6 +182,97 @@ const openapiDocument = {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
} },
|
|
185
|
+
"/cli/signup/start": { "post": {
|
|
186
|
+
"operationId": "startCliSignup",
|
|
187
|
+
"summary": "Start CLI account signup",
|
|
188
|
+
"description": "Starts a terminal-native CLI signup. The API validates the signup code,\ncreates a pending signup session, sends an email verification code, and\nreturns an opaque signup token used by the resend and verify steps. This\nendpoint does not require an API key.\n",
|
|
189
|
+
"tags": ["CLI"],
|
|
190
|
+
"security": [],
|
|
191
|
+
"requestBody": {
|
|
192
|
+
"required": true,
|
|
193
|
+
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/StartCliSignupInput" } } }
|
|
194
|
+
},
|
|
195
|
+
"responses": {
|
|
196
|
+
"201": {
|
|
197
|
+
"description": "CLI signup session created and verification email sent",
|
|
198
|
+
"headers": { "Cache-Control": {
|
|
199
|
+
"schema": { "type": "string" },
|
|
200
|
+
"description": "Always `no-store`"
|
|
201
|
+
} },
|
|
202
|
+
"content": { "application/json": { "schema": { "allOf": [{ "$ref": "#/components/schemas/SuccessEnvelope" }, {
|
|
203
|
+
"type": "object",
|
|
204
|
+
"properties": { "data": { "$ref": "#/components/schemas/CliSignupStartResult" } }
|
|
205
|
+
}] } } }
|
|
206
|
+
},
|
|
207
|
+
"400": { "$ref": "#/components/responses/ValidationError" },
|
|
208
|
+
"429": { "$ref": "#/components/responses/RateLimited" }
|
|
209
|
+
}
|
|
210
|
+
} },
|
|
211
|
+
"/cli/signup/resend": { "post": {
|
|
212
|
+
"operationId": "resendCliSignupVerification",
|
|
213
|
+
"summary": "Resend CLI signup verification code",
|
|
214
|
+
"description": "Sends a new email verification code for a pending CLI signup session.\nThis endpoint does not require an API key.\n",
|
|
215
|
+
"tags": ["CLI"],
|
|
216
|
+
"security": [],
|
|
217
|
+
"requestBody": {
|
|
218
|
+
"required": true,
|
|
219
|
+
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/ResendCliSignupVerificationInput" } } }
|
|
220
|
+
},
|
|
221
|
+
"responses": {
|
|
222
|
+
"200": {
|
|
223
|
+
"description": "Verification email resent",
|
|
224
|
+
"headers": { "Cache-Control": {
|
|
225
|
+
"schema": { "type": "string" },
|
|
226
|
+
"description": "Always `no-store`"
|
|
227
|
+
} },
|
|
228
|
+
"content": { "application/json": { "schema": { "allOf": [{ "$ref": "#/components/schemas/SuccessEnvelope" }, {
|
|
229
|
+
"type": "object",
|
|
230
|
+
"properties": { "data": { "$ref": "#/components/schemas/CliSignupResendResult" } }
|
|
231
|
+
}] } } }
|
|
232
|
+
},
|
|
233
|
+
"400": {
|
|
234
|
+
"description": "Invalid token or expired token",
|
|
235
|
+
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
|
|
236
|
+
},
|
|
237
|
+
"429": {
|
|
238
|
+
"description": "Global rate limit exceeded or resend requested too quickly",
|
|
239
|
+
"headers": { "Retry-After": {
|
|
240
|
+
"schema": { "type": "integer" },
|
|
241
|
+
"description": "Seconds to wait before retrying"
|
|
242
|
+
} },
|
|
243
|
+
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} },
|
|
247
|
+
"/cli/signup/verify": { "post": {
|
|
248
|
+
"operationId": "verifyCliSignup",
|
|
249
|
+
"summary": "Verify CLI signup and create API key",
|
|
250
|
+
"description": "Verifies the email code for a CLI signup session, creates the account,\nredeems the reserved signup code, mints an org-scoped CLI API key, and\nreturns the raw key exactly once. This endpoint does not require an API key.\n",
|
|
251
|
+
"tags": ["CLI"],
|
|
252
|
+
"security": [],
|
|
253
|
+
"requestBody": {
|
|
254
|
+
"required": true,
|
|
255
|
+
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/VerifyCliSignupInput" } } }
|
|
256
|
+
},
|
|
257
|
+
"responses": {
|
|
258
|
+
"200": {
|
|
259
|
+
"description": "CLI signup verified and API key created",
|
|
260
|
+
"headers": { "Cache-Control": {
|
|
261
|
+
"schema": { "type": "string" },
|
|
262
|
+
"description": "Always `no-store`"
|
|
263
|
+
} },
|
|
264
|
+
"content": { "application/json": { "schema": { "allOf": [{ "$ref": "#/components/schemas/SuccessEnvelope" }, {
|
|
265
|
+
"type": "object",
|
|
266
|
+
"properties": { "data": { "$ref": "#/components/schemas/CliSignupVerifyResult" } }
|
|
267
|
+
}] } } }
|
|
268
|
+
},
|
|
269
|
+
"400": {
|
|
270
|
+
"description": "Invalid request, invalid verification code, expired token, invalid signup code, rejected password, or account creation failure",
|
|
271
|
+
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
|
|
272
|
+
},
|
|
273
|
+
"429": { "$ref": "#/components/responses/RateLimited" }
|
|
274
|
+
}
|
|
275
|
+
} },
|
|
185
276
|
"/cli/logout": { "post": {
|
|
186
277
|
"operationId": "cliLogout",
|
|
187
278
|
"summary": "Revoke the current CLI API key",
|
|
@@ -1322,7 +1413,7 @@ const openapiDocument = {
|
|
|
1322
1413
|
"post": {
|
|
1323
1414
|
"operationId": "createFunction",
|
|
1324
1415
|
"summary": "Deploy a function",
|
|
1325
|
-
"description": "Creates and deploys a new function. The handler must be a single\nESM module whose default export is an object with an async\n`fetch(request, env)` method (Workers-style). The gateway\nHMAC-verifies the POST against the org's webhook secret before\ninvoking the handler; the request body parses to an\n`email.received` event (see `EmailReceivedEvent` and the\nWebhook payload section for the full schema). Code is bundled\nbefore being uploaded; ship a single self-contained file rather\nthan relying on external imports.\n\n**Code limits.** `code` is capped at 1 MiB UTF-8. `sourceMap`\n(optional) is capped at 5 MiB UTF-8
|
|
1416
|
+
"description": "Creates and deploys a new function. The handler must be a single\nESM module whose default export is an object with an async\n`fetch(request, env)` method (Workers-style). The gateway\nHMAC-verifies the POST against the org's webhook secret before\ninvoking the handler; the request body parses to an\n`email.received` event (see `EmailReceivedEvent` and the\nWebhook payload section for the full schema). Code is bundled\nbefore being uploaded; ship a single self-contained file rather\nthan relying on external imports.\n\n**Code limits.** `code` is capped at 1 MiB UTF-8. `sourceMap`\n(optional) is capped at 5 MiB UTF-8, stored with each deployment\nattempt, and sent to the runtime so stack traces can resolve to\noriginal source files.\n\n**Auto-wiring.** On successful deploy, Primitive automatically\ncreates a webhook endpoint that delivers inbound mail to the\nfunction. There is nothing to configure on the Endpoints API\nfor this to work; the gateway URL returned here is for\nreference only and is not directly callable from outside.\n\n**Secrets.** New functions ship with the managed secrets\n(`PRIMITIVE_WEBHOOK_SECRET`, `PRIMITIVE_API_KEY`) already\nbound. Add user-set secrets via\n`POST /functions/{id}/secrets`; secret writes only land in the\nrunning handler on the next redeploy.\n",
|
|
1326
1417
|
"tags": ["Functions"],
|
|
1327
1418
|
"requestBody": {
|
|
1328
1419
|
"required": true,
|
|
@@ -1336,13 +1427,18 @@ const openapiDocument = {
|
|
|
1336
1427
|
"properties": { "data": { "$ref": "#/components/schemas/CreateFunctionResult" } }
|
|
1337
1428
|
}] } } }
|
|
1338
1429
|
},
|
|
1339
|
-
"400": {
|
|
1430
|
+
"400": {
|
|
1431
|
+
"description": "Invalid request parameters or customer-correctable deploy rejection",
|
|
1432
|
+
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
|
|
1433
|
+
},
|
|
1340
1434
|
"401": { "$ref": "#/components/responses/Unauthorized" },
|
|
1341
1435
|
"409": {
|
|
1342
1436
|
"description": "A function with this name already exists in the org",
|
|
1343
1437
|
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
|
|
1344
1438
|
},
|
|
1345
|
-
"
|
|
1439
|
+
"424": { "$ref": "#/components/responses/DeployFailed" },
|
|
1440
|
+
"429": { "$ref": "#/components/responses/DeployFailed" },
|
|
1441
|
+
"503": { "$ref": "#/components/responses/DeployFailed" }
|
|
1346
1442
|
}
|
|
1347
1443
|
}
|
|
1348
1444
|
},
|
|
@@ -1368,7 +1464,7 @@ const openapiDocument = {
|
|
|
1368
1464
|
"put": {
|
|
1369
1465
|
"operationId": "updateFunction",
|
|
1370
1466
|
"summary": "Update and redeploy a function",
|
|
1371
|
-
"description": "Replaces the function's source code with the body's `code` and\ntriggers a redeploy. Same size limits as `POST /functions`.\nUse this verb to push secret writes into the running handler:\npassing the same `code` re-runs the deploy and refreshes the\nbinding set with the latest values from the secrets table.\n\nOn
|
|
1467
|
+
"description": "Replaces the function's source code with the body's `code` and\ntriggers a redeploy. Same size limits as `POST /functions`.\nUse this verb to push secret writes into the running handler:\npassing the same `code` re-runs the deploy and refreshes the\nbinding set with the latest values from the secrets table.\n\nOn deploy failure, the previously-deployed code stays live; the\nruntime never serves a half-built bundle. The response uses\n`error.code` `deploy_failed`, and the function's `deploy_error`\nfield carries the latest deploy error for dashboard/API reads.\n",
|
|
1372
1468
|
"tags": ["Functions"],
|
|
1373
1469
|
"requestBody": {
|
|
1374
1470
|
"required": true,
|
|
@@ -1382,10 +1478,15 @@ const openapiDocument = {
|
|
|
1382
1478
|
"properties": { "data": { "$ref": "#/components/schemas/FunctionDetail" } }
|
|
1383
1479
|
}] } } }
|
|
1384
1480
|
},
|
|
1385
|
-
"400": {
|
|
1481
|
+
"400": {
|
|
1482
|
+
"description": "Invalid request parameters or customer-correctable deploy rejection",
|
|
1483
|
+
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
|
|
1484
|
+
},
|
|
1386
1485
|
"401": { "$ref": "#/components/responses/Unauthorized" },
|
|
1387
1486
|
"404": { "$ref": "#/components/responses/NotFound" },
|
|
1388
|
-
"
|
|
1487
|
+
"424": { "$ref": "#/components/responses/DeployFailed" },
|
|
1488
|
+
"429": { "$ref": "#/components/responses/DeployFailed" },
|
|
1489
|
+
"503": { "$ref": "#/components/responses/DeployFailed" }
|
|
1389
1490
|
}
|
|
1390
1491
|
},
|
|
1391
1492
|
"delete": {
|
|
@@ -1704,6 +1805,19 @@ const openapiDocument = {
|
|
|
1704
1805
|
}
|
|
1705
1806
|
} }
|
|
1706
1807
|
},
|
|
1808
|
+
"DeployFailed": {
|
|
1809
|
+
"description": "Function deploy could not be completed; previously deployed code remains live",
|
|
1810
|
+
"content": { "application/json": {
|
|
1811
|
+
"schema": { "$ref": "#/components/schemas/ErrorResponse" },
|
|
1812
|
+
"example": {
|
|
1813
|
+
"success": false,
|
|
1814
|
+
"error": {
|
|
1815
|
+
"code": "deploy_failed",
|
|
1816
|
+
"message": "Function deploy failed"
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
} }
|
|
1820
|
+
},
|
|
1707
1821
|
"RateLimited": {
|
|
1708
1822
|
"description": "Rate limit exceeded",
|
|
1709
1823
|
"headers": { "Retry-After": {
|
|
@@ -2063,6 +2177,162 @@ const openapiDocument = {
|
|
|
2063
2177
|
"org_name"
|
|
2064
2178
|
]
|
|
2065
2179
|
},
|
|
2180
|
+
"StartCliSignupInput": {
|
|
2181
|
+
"type": "object",
|
|
2182
|
+
"additionalProperties": false,
|
|
2183
|
+
"properties": {
|
|
2184
|
+
"email": {
|
|
2185
|
+
"type": "string",
|
|
2186
|
+
"format": "email",
|
|
2187
|
+
"maxLength": 254
|
|
2188
|
+
},
|
|
2189
|
+
"signup_code": {
|
|
2190
|
+
"type": "string",
|
|
2191
|
+
"minLength": 1,
|
|
2192
|
+
"maxLength": 128
|
|
2193
|
+
},
|
|
2194
|
+
"terms_accepted": {
|
|
2195
|
+
"type": "boolean",
|
|
2196
|
+
"const": true,
|
|
2197
|
+
"description": "Must be true to confirm acceptance of Primitive's Terms of Service and Privacy Policy"
|
|
2198
|
+
},
|
|
2199
|
+
"device_name": {
|
|
2200
|
+
"type": "string",
|
|
2201
|
+
"minLength": 1,
|
|
2202
|
+
"maxLength": 80,
|
|
2203
|
+
"description": "Human-readable device name used for the created CLI API key"
|
|
2204
|
+
},
|
|
2205
|
+
"metadata": {
|
|
2206
|
+
"type": "object",
|
|
2207
|
+
"additionalProperties": true,
|
|
2208
|
+
"description": "Optional client metadata stored with the signup session; serialized JSON must be 2048 bytes or fewer"
|
|
2209
|
+
}
|
|
2210
|
+
},
|
|
2211
|
+
"required": [
|
|
2212
|
+
"email",
|
|
2213
|
+
"signup_code",
|
|
2214
|
+
"terms_accepted"
|
|
2215
|
+
]
|
|
2216
|
+
},
|
|
2217
|
+
"CliSignupStartResult": {
|
|
2218
|
+
"type": "object",
|
|
2219
|
+
"properties": {
|
|
2220
|
+
"signup_token": {
|
|
2221
|
+
"type": "string",
|
|
2222
|
+
"description": "Opaque token used to verify or resend the pending CLI signup"
|
|
2223
|
+
},
|
|
2224
|
+
"email": {
|
|
2225
|
+
"type": "string",
|
|
2226
|
+
"format": "email"
|
|
2227
|
+
},
|
|
2228
|
+
"expires_in": {
|
|
2229
|
+
"type": "integer",
|
|
2230
|
+
"description": "Seconds until the pending signup expires"
|
|
2231
|
+
},
|
|
2232
|
+
"resend_after": {
|
|
2233
|
+
"type": "integer",
|
|
2234
|
+
"description": "Minimum seconds before requesting another verification email"
|
|
2235
|
+
},
|
|
2236
|
+
"verification_code_length": {
|
|
2237
|
+
"type": "integer",
|
|
2238
|
+
"description": "Number of digits in the emailed verification code"
|
|
2239
|
+
}
|
|
2240
|
+
},
|
|
2241
|
+
"required": [
|
|
2242
|
+
"signup_token",
|
|
2243
|
+
"email",
|
|
2244
|
+
"expires_in",
|
|
2245
|
+
"resend_after",
|
|
2246
|
+
"verification_code_length"
|
|
2247
|
+
]
|
|
2248
|
+
},
|
|
2249
|
+
"ResendCliSignupVerificationInput": {
|
|
2250
|
+
"type": "object",
|
|
2251
|
+
"additionalProperties": false,
|
|
2252
|
+
"properties": { "signup_token": {
|
|
2253
|
+
"type": "string",
|
|
2254
|
+
"minLength": 1
|
|
2255
|
+
} },
|
|
2256
|
+
"required": ["signup_token"]
|
|
2257
|
+
},
|
|
2258
|
+
"CliSignupResendResult": {
|
|
2259
|
+
"type": "object",
|
|
2260
|
+
"properties": {
|
|
2261
|
+
"email": {
|
|
2262
|
+
"type": "string",
|
|
2263
|
+
"format": "email"
|
|
2264
|
+
},
|
|
2265
|
+
"expires_in": {
|
|
2266
|
+
"type": "integer",
|
|
2267
|
+
"description": "Seconds until the pending signup expires"
|
|
2268
|
+
},
|
|
2269
|
+
"resend_after": {
|
|
2270
|
+
"type": "integer",
|
|
2271
|
+
"description": "Minimum seconds before requesting another verification email"
|
|
2272
|
+
},
|
|
2273
|
+
"verification_code_length": {
|
|
2274
|
+
"type": "integer",
|
|
2275
|
+
"description": "Number of digits in the emailed verification code"
|
|
2276
|
+
}
|
|
2277
|
+
},
|
|
2278
|
+
"required": [
|
|
2279
|
+
"email",
|
|
2280
|
+
"expires_in",
|
|
2281
|
+
"resend_after",
|
|
2282
|
+
"verification_code_length"
|
|
2283
|
+
]
|
|
2284
|
+
},
|
|
2285
|
+
"VerifyCliSignupInput": {
|
|
2286
|
+
"type": "object",
|
|
2287
|
+
"additionalProperties": false,
|
|
2288
|
+
"properties": {
|
|
2289
|
+
"signup_token": {
|
|
2290
|
+
"type": "string",
|
|
2291
|
+
"minLength": 1
|
|
2292
|
+
},
|
|
2293
|
+
"verification_code": {
|
|
2294
|
+
"type": "string",
|
|
2295
|
+
"minLength": 1,
|
|
2296
|
+
"maxLength": 32
|
|
2297
|
+
},
|
|
2298
|
+
"password": {
|
|
2299
|
+
"type": "string",
|
|
2300
|
+
"minLength": 1,
|
|
2301
|
+
"maxLength": 1024
|
|
2302
|
+
}
|
|
2303
|
+
},
|
|
2304
|
+
"required": [
|
|
2305
|
+
"signup_token",
|
|
2306
|
+
"verification_code",
|
|
2307
|
+
"password"
|
|
2308
|
+
]
|
|
2309
|
+
},
|
|
2310
|
+
"CliSignupVerifyResult": {
|
|
2311
|
+
"type": "object",
|
|
2312
|
+
"properties": {
|
|
2313
|
+
"api_key": {
|
|
2314
|
+
"type": "string",
|
|
2315
|
+
"description": "Newly-created API key for CLI authentication"
|
|
2316
|
+
},
|
|
2317
|
+
"key_id": {
|
|
2318
|
+
"type": "string",
|
|
2319
|
+
"format": "uuid"
|
|
2320
|
+
},
|
|
2321
|
+
"key_prefix": { "type": "string" },
|
|
2322
|
+
"org_id": {
|
|
2323
|
+
"type": "string",
|
|
2324
|
+
"format": "uuid"
|
|
2325
|
+
},
|
|
2326
|
+
"org_name": { "type": ["string", "null"] }
|
|
2327
|
+
},
|
|
2328
|
+
"required": [
|
|
2329
|
+
"api_key",
|
|
2330
|
+
"key_id",
|
|
2331
|
+
"key_prefix",
|
|
2332
|
+
"org_id",
|
|
2333
|
+
"org_name"
|
|
2334
|
+
]
|
|
2335
|
+
},
|
|
2066
2336
|
"CliLogoutInput": {
|
|
2067
2337
|
"type": "object",
|
|
2068
2338
|
"additionalProperties": false,
|
|
@@ -3529,7 +3799,7 @@ const openapiDocument = {
|
|
|
3529
3799
|
"type": "string",
|
|
3530
3800
|
"minLength": 1,
|
|
3531
3801
|
"maxLength": 5242880,
|
|
3532
|
-
"description": "Optional source map for the bundle. Up to 5 MiB UTF-8.\nStored
|
|
3802
|
+
"description": "Optional source map for the bundle. Up to 5 MiB UTF-8.\nStored with the deployment attempt and sent to the runtime\nto symbolicate stack traces in the function's logs.\n"
|
|
3533
3803
|
}
|
|
3534
3804
|
},
|
|
3535
3805
|
"required": ["name", "code"]
|
|
@@ -4061,6 +4331,58 @@ const operationManifest = [
|
|
|
4061
4331
|
"tag": "CLI",
|
|
4062
4332
|
"tagCommand": "cli"
|
|
4063
4333
|
},
|
|
4334
|
+
{
|
|
4335
|
+
"binaryResponse": false,
|
|
4336
|
+
"bodyRequired": true,
|
|
4337
|
+
"command": "resend-cli-signup-verification",
|
|
4338
|
+
"description": "Sends a new email verification code for a pending CLI signup session.\nThis endpoint does not require an API key.\n",
|
|
4339
|
+
"hasJsonBody": true,
|
|
4340
|
+
"method": "POST",
|
|
4341
|
+
"operationId": "resendCliSignupVerification",
|
|
4342
|
+
"path": "/cli/signup/resend",
|
|
4343
|
+
"pathParams": [],
|
|
4344
|
+
"queryParams": [],
|
|
4345
|
+
"requestSchema": {
|
|
4346
|
+
"type": "object",
|
|
4347
|
+
"additionalProperties": false,
|
|
4348
|
+
"properties": { "signup_token": {
|
|
4349
|
+
"type": "string",
|
|
4350
|
+
"minLength": 1
|
|
4351
|
+
} },
|
|
4352
|
+
"required": ["signup_token"]
|
|
4353
|
+
},
|
|
4354
|
+
"responseSchema": {
|
|
4355
|
+
"type": "object",
|
|
4356
|
+
"properties": {
|
|
4357
|
+
"email": {
|
|
4358
|
+
"type": "string",
|
|
4359
|
+
"format": "email"
|
|
4360
|
+
},
|
|
4361
|
+
"expires_in": {
|
|
4362
|
+
"type": "integer",
|
|
4363
|
+
"description": "Seconds until the pending signup expires"
|
|
4364
|
+
},
|
|
4365
|
+
"resend_after": {
|
|
4366
|
+
"type": "integer",
|
|
4367
|
+
"description": "Minimum seconds before requesting another verification email"
|
|
4368
|
+
},
|
|
4369
|
+
"verification_code_length": {
|
|
4370
|
+
"type": "integer",
|
|
4371
|
+
"description": "Number of digits in the emailed verification code"
|
|
4372
|
+
}
|
|
4373
|
+
},
|
|
4374
|
+
"required": [
|
|
4375
|
+
"email",
|
|
4376
|
+
"expires_in",
|
|
4377
|
+
"resend_after",
|
|
4378
|
+
"verification_code_length"
|
|
4379
|
+
]
|
|
4380
|
+
},
|
|
4381
|
+
"sdkName": "resendCliSignupVerification",
|
|
4382
|
+
"summary": "Resend CLI signup verification code",
|
|
4383
|
+
"tag": "CLI",
|
|
4384
|
+
"tagCommand": "cli"
|
|
4385
|
+
},
|
|
4064
4386
|
{
|
|
4065
4387
|
"binaryResponse": false,
|
|
4066
4388
|
"bodyRequired": false,
|
|
@@ -4132,6 +4454,158 @@ const operationManifest = [
|
|
|
4132
4454
|
"tag": "CLI",
|
|
4133
4455
|
"tagCommand": "cli"
|
|
4134
4456
|
},
|
|
4457
|
+
{
|
|
4458
|
+
"binaryResponse": false,
|
|
4459
|
+
"bodyRequired": true,
|
|
4460
|
+
"command": "start-cli-signup",
|
|
4461
|
+
"description": "Starts a terminal-native CLI signup. The API validates the signup code,\ncreates a pending signup session, sends an email verification code, and\nreturns an opaque signup token used by the resend and verify steps. This\nendpoint does not require an API key.\n",
|
|
4462
|
+
"hasJsonBody": true,
|
|
4463
|
+
"method": "POST",
|
|
4464
|
+
"operationId": "startCliSignup",
|
|
4465
|
+
"path": "/cli/signup/start",
|
|
4466
|
+
"pathParams": [],
|
|
4467
|
+
"queryParams": [],
|
|
4468
|
+
"requestSchema": {
|
|
4469
|
+
"type": "object",
|
|
4470
|
+
"additionalProperties": false,
|
|
4471
|
+
"properties": {
|
|
4472
|
+
"email": {
|
|
4473
|
+
"type": "string",
|
|
4474
|
+
"format": "email",
|
|
4475
|
+
"maxLength": 254
|
|
4476
|
+
},
|
|
4477
|
+
"signup_code": {
|
|
4478
|
+
"type": "string",
|
|
4479
|
+
"minLength": 1,
|
|
4480
|
+
"maxLength": 128
|
|
4481
|
+
},
|
|
4482
|
+
"terms_accepted": {
|
|
4483
|
+
"type": "boolean",
|
|
4484
|
+
"const": true,
|
|
4485
|
+
"description": "Must be true to confirm acceptance of Primitive's Terms of Service and Privacy Policy"
|
|
4486
|
+
},
|
|
4487
|
+
"device_name": {
|
|
4488
|
+
"type": "string",
|
|
4489
|
+
"minLength": 1,
|
|
4490
|
+
"maxLength": 80,
|
|
4491
|
+
"description": "Human-readable device name used for the created CLI API key"
|
|
4492
|
+
},
|
|
4493
|
+
"metadata": {
|
|
4494
|
+
"type": "object",
|
|
4495
|
+
"additionalProperties": true,
|
|
4496
|
+
"description": "Optional client metadata stored with the signup session; serialized JSON must be 2048 bytes or fewer"
|
|
4497
|
+
}
|
|
4498
|
+
},
|
|
4499
|
+
"required": [
|
|
4500
|
+
"email",
|
|
4501
|
+
"signup_code",
|
|
4502
|
+
"terms_accepted"
|
|
4503
|
+
]
|
|
4504
|
+
},
|
|
4505
|
+
"responseSchema": {
|
|
4506
|
+
"type": "object",
|
|
4507
|
+
"properties": {
|
|
4508
|
+
"signup_token": {
|
|
4509
|
+
"type": "string",
|
|
4510
|
+
"description": "Opaque token used to verify or resend the pending CLI signup"
|
|
4511
|
+
},
|
|
4512
|
+
"email": {
|
|
4513
|
+
"type": "string",
|
|
4514
|
+
"format": "email"
|
|
4515
|
+
},
|
|
4516
|
+
"expires_in": {
|
|
4517
|
+
"type": "integer",
|
|
4518
|
+
"description": "Seconds until the pending signup expires"
|
|
4519
|
+
},
|
|
4520
|
+
"resend_after": {
|
|
4521
|
+
"type": "integer",
|
|
4522
|
+
"description": "Minimum seconds before requesting another verification email"
|
|
4523
|
+
},
|
|
4524
|
+
"verification_code_length": {
|
|
4525
|
+
"type": "integer",
|
|
4526
|
+
"description": "Number of digits in the emailed verification code"
|
|
4527
|
+
}
|
|
4528
|
+
},
|
|
4529
|
+
"required": [
|
|
4530
|
+
"signup_token",
|
|
4531
|
+
"email",
|
|
4532
|
+
"expires_in",
|
|
4533
|
+
"resend_after",
|
|
4534
|
+
"verification_code_length"
|
|
4535
|
+
]
|
|
4536
|
+
},
|
|
4537
|
+
"sdkName": "startCliSignup",
|
|
4538
|
+
"summary": "Start CLI account signup",
|
|
4539
|
+
"tag": "CLI",
|
|
4540
|
+
"tagCommand": "cli"
|
|
4541
|
+
},
|
|
4542
|
+
{
|
|
4543
|
+
"binaryResponse": false,
|
|
4544
|
+
"bodyRequired": true,
|
|
4545
|
+
"command": "verify-cli-signup",
|
|
4546
|
+
"description": "Verifies the email code for a CLI signup session, creates the account,\nredeems the reserved signup code, mints an org-scoped CLI API key, and\nreturns the raw key exactly once. This endpoint does not require an API key.\n",
|
|
4547
|
+
"hasJsonBody": true,
|
|
4548
|
+
"method": "POST",
|
|
4549
|
+
"operationId": "verifyCliSignup",
|
|
4550
|
+
"path": "/cli/signup/verify",
|
|
4551
|
+
"pathParams": [],
|
|
4552
|
+
"queryParams": [],
|
|
4553
|
+
"requestSchema": {
|
|
4554
|
+
"type": "object",
|
|
4555
|
+
"additionalProperties": false,
|
|
4556
|
+
"properties": {
|
|
4557
|
+
"signup_token": {
|
|
4558
|
+
"type": "string",
|
|
4559
|
+
"minLength": 1
|
|
4560
|
+
},
|
|
4561
|
+
"verification_code": {
|
|
4562
|
+
"type": "string",
|
|
4563
|
+
"minLength": 1,
|
|
4564
|
+
"maxLength": 32
|
|
4565
|
+
},
|
|
4566
|
+
"password": {
|
|
4567
|
+
"type": "string",
|
|
4568
|
+
"minLength": 1,
|
|
4569
|
+
"maxLength": 1024
|
|
4570
|
+
}
|
|
4571
|
+
},
|
|
4572
|
+
"required": [
|
|
4573
|
+
"signup_token",
|
|
4574
|
+
"verification_code",
|
|
4575
|
+
"password"
|
|
4576
|
+
]
|
|
4577
|
+
},
|
|
4578
|
+
"responseSchema": {
|
|
4579
|
+
"type": "object",
|
|
4580
|
+
"properties": {
|
|
4581
|
+
"api_key": {
|
|
4582
|
+
"type": "string",
|
|
4583
|
+
"description": "Newly-created API key for CLI authentication"
|
|
4584
|
+
},
|
|
4585
|
+
"key_id": {
|
|
4586
|
+
"type": "string",
|
|
4587
|
+
"format": "uuid"
|
|
4588
|
+
},
|
|
4589
|
+
"key_prefix": { "type": "string" },
|
|
4590
|
+
"org_id": {
|
|
4591
|
+
"type": "string",
|
|
4592
|
+
"format": "uuid"
|
|
4593
|
+
},
|
|
4594
|
+
"org_name": { "type": ["string", "null"] }
|
|
4595
|
+
},
|
|
4596
|
+
"required": [
|
|
4597
|
+
"api_key",
|
|
4598
|
+
"key_id",
|
|
4599
|
+
"key_prefix",
|
|
4600
|
+
"org_id",
|
|
4601
|
+
"org_name"
|
|
4602
|
+
]
|
|
4603
|
+
},
|
|
4604
|
+
"sdkName": "verifyCliSignup",
|
|
4605
|
+
"summary": "Verify CLI signup and create API key",
|
|
4606
|
+
"tag": "CLI",
|
|
4607
|
+
"tagCommand": "cli"
|
|
4608
|
+
},
|
|
4135
4609
|
{
|
|
4136
4610
|
"binaryResponse": false,
|
|
4137
4611
|
"bodyRequired": true,
|
|
@@ -5802,7 +6276,7 @@ const operationManifest = [
|
|
|
5802
6276
|
"binaryResponse": false,
|
|
5803
6277
|
"bodyRequired": true,
|
|
5804
6278
|
"command": "create-function",
|
|
5805
|
-
"description": "Creates and deploys a new function. The handler must be a single\nESM module whose default export is an object with an async\n`fetch(request, env)` method (Workers-style). The gateway\nHMAC-verifies the POST against the org's webhook secret before\ninvoking the handler; the request body parses to an\n`email.received` event (see `EmailReceivedEvent` and the\nWebhook payload section for the full schema). Code is bundled\nbefore being uploaded; ship a single self-contained file rather\nthan relying on external imports.\n\n**Code limits.** `code` is capped at 1 MiB UTF-8. `sourceMap`\n(optional) is capped at 5 MiB UTF-8
|
|
6279
|
+
"description": "Creates and deploys a new function. The handler must be a single\nESM module whose default export is an object with an async\n`fetch(request, env)` method (Workers-style). The gateway\nHMAC-verifies the POST against the org's webhook secret before\ninvoking the handler; the request body parses to an\n`email.received` event (see `EmailReceivedEvent` and the\nWebhook payload section for the full schema). Code is bundled\nbefore being uploaded; ship a single self-contained file rather\nthan relying on external imports.\n\n**Code limits.** `code` is capped at 1 MiB UTF-8. `sourceMap`\n(optional) is capped at 5 MiB UTF-8, stored with each deployment\nattempt, and sent to the runtime so stack traces can resolve to\noriginal source files.\n\n**Auto-wiring.** On successful deploy, Primitive automatically\ncreates a webhook endpoint that delivers inbound mail to the\nfunction. There is nothing to configure on the Endpoints API\nfor this to work; the gateway URL returned here is for\nreference only and is not directly callable from outside.\n\n**Secrets.** New functions ship with the managed secrets\n(`PRIMITIVE_WEBHOOK_SECRET`, `PRIMITIVE_API_KEY`) already\nbound. Add user-set secrets via\n`POST /functions/{id}/secrets`; secret writes only land in the\nrunning handler on the next redeploy.\n",
|
|
5806
6280
|
"hasJsonBody": true,
|
|
5807
6281
|
"method": "POST",
|
|
5808
6282
|
"operationId": "createFunction",
|
|
@@ -5828,7 +6302,7 @@ const operationManifest = [
|
|
|
5828
6302
|
"type": "string",
|
|
5829
6303
|
"minLength": 1,
|
|
5830
6304
|
"maxLength": 5242880,
|
|
5831
|
-
"description": "Optional source map for the bundle. Up to 5 MiB UTF-8.\nStored
|
|
6305
|
+
"description": "Optional source map for the bundle. Up to 5 MiB UTF-8.\nStored with the deployment attempt and sent to the runtime\nto symbolicate stack traces in the function's logs.\n"
|
|
5832
6306
|
}
|
|
5833
6307
|
},
|
|
5834
6308
|
"required": ["name", "code"]
|
|
@@ -6432,7 +6906,7 @@ const operationManifest = [
|
|
|
6432
6906
|
"binaryResponse": false,
|
|
6433
6907
|
"bodyRequired": true,
|
|
6434
6908
|
"command": "update-function",
|
|
6435
|
-
"description": "Replaces the function's source code with the body's `code` and\ntriggers a redeploy. Same size limits as `POST /functions`.\nUse this verb to push secret writes into the running handler:\npassing the same `code` re-runs the deploy and refreshes the\nbinding set with the latest values from the secrets table.\n\nOn
|
|
6909
|
+
"description": "Replaces the function's source code with the body's `code` and\ntriggers a redeploy. Same size limits as `POST /functions`.\nUse this verb to push secret writes into the running handler:\npassing the same `code` re-runs the deploy and refreshes the\nbinding set with the latest values from the secrets table.\n\nOn deploy failure, the previously-deployed code stays live; the\nruntime never serves a half-built bundle. The response uses\n`error.code` `deploy_failed`, and the function's `deploy_error`\nfield carries the latest deploy error for dashboard/API reads.\n",
|
|
6436
6910
|
"hasJsonBody": true,
|
|
6437
6911
|
"method": "PUT",
|
|
6438
6912
|
"operationId": "updateFunction",
|
package/dist/parser/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as WebhookAttachment, S as ParsedDataComplete, s as EmailAddress } from "../types-
|
|
1
|
+
import { M as WebhookAttachment, S as ParsedDataComplete, s as EmailAddress } from "../types-BRWDMD7H.js";
|
|
2
2
|
|
|
3
3
|
//#region src/parser/address-parser.d.ts
|
|
4
4
|
/**
|
|
@@ -121,6 +121,7 @@ interface ParsedEmailWithAttachments {
|
|
|
121
121
|
dateHeader: string | null;
|
|
122
122
|
from: string | null;
|
|
123
123
|
to: string | null;
|
|
124
|
+
toAddresses: EmailAddress[] | null;
|
|
124
125
|
replyTo: EmailAddress[] | null;
|
|
125
126
|
cc: EmailAddress[] | null;
|
|
126
127
|
bcc: EmailAddress[] | null;
|
package/dist/parser/index.js
CHANGED
|
@@ -301,6 +301,7 @@ async function parseEmailWithAttachments(emlBuffer, options) {
|
|
|
301
301
|
dateHeader: getOriginalHeaderValue(parsed, "date"),
|
|
302
302
|
from: parsed.from?.text ?? null,
|
|
303
303
|
to: Array.isArray(parsed.to) ? parsed.to.map((a) => a.text).join(", ") : parsed.to?.text ?? null,
|
|
304
|
+
toAddresses: extractAddresses(parsed.to),
|
|
304
305
|
replyTo: extractAddresses(parsed.replyTo),
|
|
305
306
|
cc: extractAddresses(parsed.cc),
|
|
306
307
|
bcc: extractAddresses(parsed.bcc),
|
|
@@ -480,6 +481,7 @@ function toParsedDataComplete(parsed, attachmentsDownloadUrl) {
|
|
|
480
481
|
reply_to: parsed.replyTo,
|
|
481
482
|
cc: parsed.cc,
|
|
482
483
|
bcc: parsed.bcc,
|
|
484
|
+
to_addresses: parsed.toAddresses,
|
|
483
485
|
in_reply_to: parsed.inReplyTo,
|
|
484
486
|
references: parsed.references,
|
|
485
487
|
attachments,
|