@primitivedotdev/sdk 0.35.1 → 0.35.2

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.
@@ -0,0 +1,91 @@
1
+ //#region src/parser/address-parser.d.ts
2
+ /**
3
+ * A validated RFC 5322 address. Returned by the strict parser, which
4
+ * deliberately does not expose a display name.
5
+ *
6
+ * `address` is normalized to lowercase. Both the local-part and the
7
+ * domain are lowercased: RFC 5321 §2.4 permits case-sensitive local-
8
+ * parts, but every consumer mailbox in practice treats them as
9
+ * case-insensitive, and a case-sensitive grant key would split
10
+ * `Bob@x.com` from `bob@x.com` into separate rows and defeat the
11
+ * primary-key index on lookup.
12
+ */
13
+ interface ValidatedAddress {
14
+ address: string;
15
+ }
16
+ /**
17
+ * A parsed RFC 5322 address with its display name. Returned by the
18
+ * loose parser for display-only call sites.
19
+ *
20
+ * `address` is lowercased on the same rationale as
21
+ * {@link ValidatedAddress}. The display name is preserved as provided
22
+ * (after addressparser's quote / encoded-word handling), or null if the
23
+ * header had no display name. Names from the loose parser are NOT
24
+ * trustworthy for downstream mail building: addressparser's recovery
25
+ * mode can fold trailing tokens or a second bracketed address into the
26
+ * name field. Treat as opaque text, sanitize before re-emitting.
27
+ */
28
+ interface ParsedAddress {
29
+ address: string;
30
+ name: string | null;
31
+ }
32
+ /**
33
+ * Reason a strict From-header parse rejected the input. Stable enum so
34
+ * callers can branch on the reason without parsing message text.
35
+ */
36
+ type ParseFromHeaderFailureReason = "empty" | "too_long" | "multiple_addresses" | "group_syntax" | "invalid_address";
37
+ type ParseFromHeaderResult = {
38
+ ok: true;
39
+ value: ValidatedAddress;
40
+ } | {
41
+ ok: false;
42
+ reason: ParseFromHeaderFailureReason;
43
+ };
44
+ /**
45
+ * Strict parser for RFC 5322 From-style headers in security-bearing
46
+ * contexts (allowlist gates, permission grants).
47
+ *
48
+ * Rejects, without falling back to a "best guess":
49
+ * - empty / whitespace-only input
50
+ * - inputs longer than RFC 5322's 998-octet line limit
51
+ * - multi-address From (RFC 5322 allows it but it is vanishingly
52
+ * rare and ambiguous as an identity)
53
+ * - group syntax ("Friends: a@b.com, c@d.com;")
54
+ * - any address that fails validator's isEmail check with our chosen
55
+ * options. That covers per-part length limits, dot-atom rules,
56
+ * hostname-label rules, TLD requirement, and other RFC 5321/5322
57
+ * conformance checks.
58
+ *
59
+ * Returns ONLY the validated address, with no display name. Strict
60
+ * exists for gating decisions, where the address is the security-
61
+ * bearing field. Display names from addressparser are not trustworthy
62
+ * here: weird inputs like `Name <user@x.com> <attacker@y.com>` get
63
+ * parsed as a single entry whose `name` silently includes the second
64
+ * address. Surfacing that as a "parsed name" would invite downstream
65
+ * misuse, so we drop it. If you need the name, call
66
+ * {@link parseFromHeaderLoose} alongside (it returns null on failure
67
+ * anyway, so you can still gate on strict's Result).
68
+ *
69
+ * Returns a typed Result so callers can map the failure reason to
70
+ * stable error codes without inspecting message text.
71
+ */
72
+ declare function parseFromHeader(header: string | null | undefined): ParseFromHeaderResult;
73
+ /**
74
+ * Lenient parser for display-only call sites (inbox card "from",
75
+ * log lines, debugging). Returns the first parseable address with its
76
+ * display name, or null.
77
+ *
78
+ * Differences from {@link parseFromHeader}:
79
+ * - Multi-address From returns the first address instead of rejecting
80
+ * - Group syntax is flattened into its member addresses
81
+ * - Returns null instead of a typed reason on failure
82
+ * - Includes the parsed display name in the result
83
+ *
84
+ * Do not use for permission gates or any decision that grants access.
85
+ * That is what {@link parseFromHeader} is for. Names returned here can
86
+ * include addressparser's recovery output (trailing tokens, garbage
87
+ * before the address); treat as opaque text for display.
88
+ */
89
+ declare function parseFromHeaderLoose(header: string | null | undefined): ParsedAddress | null;
90
+ //#endregion
91
+ export { parseFromHeader as a, ValidatedAddress as i, ParseFromHeaderResult as n, parseFromHeaderLoose as o, ParsedAddress as r, ParseFromHeaderFailureReason as t };
@@ -0,0 +1,2 @@
1
+ import { a as parseFromHeader, i as ValidatedAddress, n as ParseFromHeaderResult, o as parseFromHeaderLoose, r as ParsedAddress, t as ParseFromHeaderFailureReason } from "../address-parser-CA6G7R-h.js";
2
+ export { type ParseFromHeaderFailureReason, type ParseFromHeaderResult, type ParsedAddress, type ValidatedAddress, parseFromHeader, parseFromHeaderLoose };
@@ -0,0 +1,2 @@
1
+ import { n as parseFromHeaderLoose, t as parseFromHeader } from "../address-parser-CQbFjgRC.js";
2
+ export { parseFromHeader, parseFromHeaderLoose };
@@ -1,95 +1,6 @@
1
1
  import { M as WebhookAttachment, S as ParsedDataComplete, s as EmailAddress } from "../types-yNU-Oiea.js";
2
+ import { a as parseFromHeader, i as ValidatedAddress, n as ParseFromHeaderResult, o as parseFromHeaderLoose, r as ParsedAddress, t as ParseFromHeaderFailureReason } from "../address-parser-CA6G7R-h.js";
2
3
 
3
- //#region src/parser/address-parser.d.ts
4
- /**
5
- * A validated RFC 5322 address. Returned by the strict parser, which
6
- * deliberately does not expose a display name.
7
- *
8
- * `address` is normalized to lowercase. Both the local-part and the
9
- * domain are lowercased: RFC 5321 §2.4 permits case-sensitive local-
10
- * parts, but every consumer mailbox in practice treats them as
11
- * case-insensitive, and a case-sensitive grant key would split
12
- * `Bob@x.com` from `bob@x.com` into separate rows and defeat the
13
- * primary-key index on lookup.
14
- */
15
- interface ValidatedAddress {
16
- address: string;
17
- }
18
- /**
19
- * A parsed RFC 5322 address with its display name. Returned by the
20
- * loose parser for display-only call sites.
21
- *
22
- * `address` is lowercased on the same rationale as
23
- * {@link ValidatedAddress}. The display name is preserved as provided
24
- * (after addressparser's quote / encoded-word handling), or null if the
25
- * header had no display name. Names from the loose parser are NOT
26
- * trustworthy for downstream mail building: addressparser's recovery
27
- * mode can fold trailing tokens or a second bracketed address into the
28
- * name field. Treat as opaque text, sanitize before re-emitting.
29
- */
30
- interface ParsedAddress {
31
- address: string;
32
- name: string | null;
33
- }
34
- /**
35
- * Reason a strict From-header parse rejected the input. Stable enum so
36
- * callers can branch on the reason without parsing message text.
37
- */
38
- type ParseFromHeaderFailureReason = "empty" | "too_long" | "multiple_addresses" | "group_syntax" | "invalid_address";
39
- type ParseFromHeaderResult = {
40
- ok: true;
41
- value: ValidatedAddress;
42
- } | {
43
- ok: false;
44
- reason: ParseFromHeaderFailureReason;
45
- };
46
- /**
47
- * Strict parser for RFC 5322 From-style headers in security-bearing
48
- * contexts (allowlist gates, permission grants).
49
- *
50
- * Rejects, without falling back to a "best guess":
51
- * - empty / whitespace-only input
52
- * - inputs longer than RFC 5322's 998-octet line limit
53
- * - multi-address From (RFC 5322 allows it but it is vanishingly
54
- * rare and ambiguous as an identity)
55
- * - group syntax ("Friends: a@b.com, c@d.com;")
56
- * - any address that fails validator's isEmail check with our chosen
57
- * options. That covers per-part length limits, dot-atom rules,
58
- * hostname-label rules, TLD requirement, and other RFC 5321/5322
59
- * conformance checks.
60
- *
61
- * Returns ONLY the validated address, with no display name. Strict
62
- * exists for gating decisions, where the address is the security-
63
- * bearing field. Display names from addressparser are not trustworthy
64
- * here: weird inputs like `Name <user@x.com> <attacker@y.com>` get
65
- * parsed as a single entry whose `name` silently includes the second
66
- * address. Surfacing that as a "parsed name" would invite downstream
67
- * misuse, so we drop it. If you need the name, call
68
- * {@link parseFromHeaderLoose} alongside (it returns null on failure
69
- * anyway, so you can still gate on strict's Result).
70
- *
71
- * Returns a typed Result so callers can map the failure reason to
72
- * stable error codes without inspecting message text.
73
- */
74
- declare function parseFromHeader(header: string | null | undefined): ParseFromHeaderResult;
75
- /**
76
- * Lenient parser for display-only call sites (inbox card "from",
77
- * log lines, debugging). Returns the first parseable address with its
78
- * display name, or null.
79
- *
80
- * Differences from {@link parseFromHeader}:
81
- * - Multi-address From returns the first address instead of rejecting
82
- * - Group syntax is flattened into its member addresses
83
- * - Returns null instead of a typed reason on failure
84
- * - Includes the parsed display name in the result
85
- *
86
- * Do not use for permission gates or any decision that grants access.
87
- * That is what {@link parseFromHeader} is for. Names returned here can
88
- * include addressparser's recovery output (trailing tokens, garbage
89
- * before the address); treat as opaque text for display.
90
- */
91
- declare function parseFromHeaderLoose(header: string | null | undefined): ParsedAddress | null;
92
- //#endregion
93
4
  //#region src/parser/attachment-parser.d.ts
94
5
  interface ParsedAttachment {
95
6
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitivedotdev/sdk",
3
- "version": "0.35.1",
3
+ "version": "0.35.2",
4
4
  "description": "Official Primitive Node.js SDK: webhook, api, openapi, contract, and parser runtime modules.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -35,6 +35,11 @@
35
35
  "types": "./dist/parser/index.d.ts",
36
36
  "import": "./dist/parser/index.js",
37
37
  "default": "./dist/parser/index.js"
38
+ },
39
+ "./parser/address": {
40
+ "types": "./dist/parser/address.d.ts",
41
+ "import": "./dist/parser/address.js",
42
+ "default": "./dist/parser/address.js"
38
43
  }
39
44
  },
40
45
  "sideEffects": false,