@drawbridge/drawbridge-utils 0.0.160 → 0.0.162

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/html.cjs ADDED
@@ -0,0 +1,29 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // lib/html.js
20
+ var html_exports = {};
21
+ __export(html_exports, {
22
+ escapeHtml: () => escapeHtml
23
+ });
24
+ module.exports = __toCommonJS(html_exports);
25
+ var escapeHtml = (value) => String(value ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ escapeHtml
29
+ });
@@ -0,0 +1,32 @@
1
+ // Escaping for values interpolated into HTML we generate ourselves.
2
+ //
3
+ // ITS OWN MODULE, not part of sanitize.js, because that one imports the
4
+ // ~120K-entry disposable-domain set at load — about 6MB of RSS its own comment
5
+ // flags as a footprint to watch. Every email sync renders would have paid that
6
+ // to escape five characters.
7
+ //
8
+ // Three copies of this existed before it moved here: drawbridge-api's oembed
9
+ // route, drawbridge-sync's email renderer, and drawbridge-emails' signature
10
+ // builder. They had already drifted — the signature builder escapes four
11
+ // characters and omits the apostrophe. Harmless where it sits (its output lands
12
+ // in text content and one double-quoted href, and the input is a config of our
13
+ // own staff), which is exactly why it survived: a divergence with no symptom is
14
+ // the kind that is only found by looking.
15
+
16
+ // The five characters that change meaning inside markup. `&` FIRST — escaping it
17
+ // after the others would re-escape the ampersands they just introduced and turn
18
+ // `&lt;` into `&amp;lt;`.
19
+ //
20
+ // Escapes for BOTH contexts, text and attribute, rather than asking callers
21
+ // which they are in: `"` and `'` are inert in text content and cost nothing to
22
+ // escape there, while getting it wrong in an attribute is an injection. A single
23
+ // function nobody has to think about beats two that are chosen correctly most of
24
+ // the time.
25
+ const escapeHtml = ( value ) => String( value ?? '' )
26
+ .replace( /&/g, '&amp;' )
27
+ .replace( /</g, '&lt;' )
28
+ .replace( />/g, '&gt;' )
29
+ .replace( /"/g, '&quot;' )
30
+ .replace( /'/g, '&#39;' );
31
+
32
+ export { escapeHtml };
package/dist/html.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ // Escaping for values interpolated into HTML we generate ourselves.
2
+ //
3
+ // ITS OWN MODULE, not part of sanitize.js, because that one imports the
4
+ // ~120K-entry disposable-domain set at load — about 6MB of RSS its own comment
5
+ // flags as a footprint to watch. Every email sync renders would have paid that
6
+ // to escape five characters.
7
+ //
8
+ // Three copies of this existed before it moved here: drawbridge-api's oembed
9
+ // route, drawbridge-sync's email renderer, and drawbridge-emails' signature
10
+ // builder. They had already drifted — the signature builder escapes four
11
+ // characters and omits the apostrophe. Harmless where it sits (its output lands
12
+ // in text content and one double-quoted href, and the input is a config of our
13
+ // own staff), which is exactly why it survived: a divergence with no symptom is
14
+ // the kind that is only found by looking.
15
+
16
+ // The five characters that change meaning inside markup. `&` FIRST — escaping it
17
+ // after the others would re-escape the ampersands they just introduced and turn
18
+ // `&lt;` into `&amp;lt;`.
19
+ //
20
+ // Escapes for BOTH contexts, text and attribute, rather than asking callers
21
+ // which they are in: `"` and `'` are inert in text content and cost nothing to
22
+ // escape there, while getting it wrong in an attribute is an injection. A single
23
+ // function nobody has to think about beats two that are chosen correctly most of
24
+ // the time.
25
+ const escapeHtml = ( value ) => String( value ?? '' )
26
+ .replace( /&/g, '&amp;' )
27
+ .replace( /</g, '&lt;' )
28
+ .replace( />/g, '&gt;' )
29
+ .replace( /"/g, '&quot;' )
30
+ .replace( /'/g, '&#39;' );
31
+
32
+ export { escapeHtml };
package/dist/html.js ADDED
@@ -0,0 +1,5 @@
1
+ // lib/html.js
2
+ var escapeHtml = (value) => String(value ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3
+ export {
4
+ escapeHtml
5
+ };
@@ -77,16 +77,12 @@ var messageWarnings = ({ message }) => {
77
77
  };
78
78
  var notificationWarnings = ({
79
79
  brand,
80
- channel = "email",
81
80
  message,
82
81
  subject
83
- } = {}) => {
84
- if (channel !== "email") return { message: [], subject: [] };
85
- return {
86
- message: messageWarnings({ message }),
87
- subject: subjectWarnings({ brand, subject })
88
- };
89
- };
82
+ } = {}) => ({
83
+ message: messageWarnings({ message }),
84
+ subject: subjectWarnings({ brand, subject })
85
+ });
90
86
  // Annotate the CommonJS export names for ESM import in node:
91
87
  0 && (module.exports = {
92
88
  notificationWarnings
@@ -131,25 +131,32 @@ const messageWarnings = ({ message }) => {
131
131
  // ONE ENTRY POINT, answering per field so each warning renders against the
132
132
  // input it is about rather than as a pile at the bottom of the form.
133
133
  //
134
- // `channel` is accepted and only 'email' is implemented. SMS is a genuinely
135
- // different problem — carriers filter on SHAFT categories, link shorteners and
136
- // opt-out wording, none of which these rules look at — and returning email
137
- // advice for an SMS would be confidently wrong. It returns nothing instead,
138
- // until someone writes the carrier rules properly.
134
+ // NO CHANNEL ARGUMENT, deliberately, and it is worth saying why since one was
135
+ // tried twice.
136
+ //
137
+ // First it gated SMS to silence, on the grounds that carriers filter on things
138
+ // these rules do not look at. That much is true, and it does not follow:
139
+ // shouting, repeated punctuation, currency amounts and scam-shaped phrasing
140
+ // matter at least as much on a phone, and an unbranded text is the exact shape
141
+ // of a smishing attempt. Then a hedge value was added for copy that could go
142
+ // either way, a caller passed it to a build that did not have it, and a whole
143
+ // form went quiet with nothing to show for the caution.
144
+ //
145
+ // Every rule here is one a person would want to hear wherever the words end up.
146
+ // Sorting them by channel bought accuracy on a single warning — the subject
147
+ // display limit, which is really an email idea — and cost the other six.
148
+ //
149
+ // SMS still has no rules of its OWN: SHAFT categories, link shorteners, opt-out
150
+ // wording, and the segment mechanics where one emoji drops the limit from 160
151
+ // characters to 70. Those belong with the SMS connection work rather than here,
152
+ // and their absence is a reason to write them, not to stay quiet meanwhile.
139
153
  const notificationWarnings = ({
140
154
  brand,
141
- channel = 'email',
142
155
  message,
143
156
  subject
144
- } = {}) => {
145
-
146
- if( channel !== 'email' ) return { message : [], subject : [] };
147
-
148
- return {
149
- message : messageWarnings({ message }),
150
- subject : subjectWarnings({ brand, subject })
151
- };
152
-
153
- };
157
+ } = {}) => ({
158
+ message : messageWarnings({ message }),
159
+ subject : subjectWarnings({ brand, subject })
160
+ });
154
161
 
155
162
  export { notificationWarnings };
@@ -131,25 +131,32 @@ const messageWarnings = ({ message }) => {
131
131
  // ONE ENTRY POINT, answering per field so each warning renders against the
132
132
  // input it is about rather than as a pile at the bottom of the form.
133
133
  //
134
- // `channel` is accepted and only 'email' is implemented. SMS is a genuinely
135
- // different problem — carriers filter on SHAFT categories, link shorteners and
136
- // opt-out wording, none of which these rules look at — and returning email
137
- // advice for an SMS would be confidently wrong. It returns nothing instead,
138
- // until someone writes the carrier rules properly.
134
+ // NO CHANNEL ARGUMENT, deliberately, and it is worth saying why since one was
135
+ // tried twice.
136
+ //
137
+ // First it gated SMS to silence, on the grounds that carriers filter on things
138
+ // these rules do not look at. That much is true, and it does not follow:
139
+ // shouting, repeated punctuation, currency amounts and scam-shaped phrasing
140
+ // matter at least as much on a phone, and an unbranded text is the exact shape
141
+ // of a smishing attempt. Then a hedge value was added for copy that could go
142
+ // either way, a caller passed it to a build that did not have it, and a whole
143
+ // form went quiet with nothing to show for the caution.
144
+ //
145
+ // Every rule here is one a person would want to hear wherever the words end up.
146
+ // Sorting them by channel bought accuracy on a single warning — the subject
147
+ // display limit, which is really an email idea — and cost the other six.
148
+ //
149
+ // SMS still has no rules of its OWN: SHAFT categories, link shorteners, opt-out
150
+ // wording, and the segment mechanics where one emoji drops the limit from 160
151
+ // characters to 70. Those belong with the SMS connection work rather than here,
152
+ // and their absence is a reason to write them, not to stay quiet meanwhile.
139
153
  const notificationWarnings = ({
140
154
  brand,
141
- channel = 'email',
142
155
  message,
143
156
  subject
144
- } = {}) => {
145
-
146
- if( channel !== 'email' ) return { message : [], subject : [] };
147
-
148
- return {
149
- message : messageWarnings({ message }),
150
- subject : subjectWarnings({ brand, subject })
151
- };
152
-
153
- };
157
+ } = {}) => ({
158
+ message : messageWarnings({ message }),
159
+ subject : subjectWarnings({ brand, subject })
160
+ });
154
161
 
155
162
  export { notificationWarnings };
@@ -54,16 +54,12 @@ var messageWarnings = ({ message }) => {
54
54
  };
55
55
  var notificationWarnings = ({
56
56
  brand,
57
- channel = "email",
58
57
  message,
59
58
  subject
60
- } = {}) => {
61
- if (channel !== "email") return { message: [], subject: [] };
62
- return {
63
- message: messageWarnings({ message }),
64
- subject: subjectWarnings({ brand, subject })
65
- };
66
- };
59
+ } = {}) => ({
60
+ message: messageWarnings({ message }),
61
+ subject: subjectWarnings({ brand, subject })
62
+ });
67
63
  export {
68
64
  notificationWarnings
69
65
  };
package/package.json CHANGED
@@ -148,6 +148,11 @@
148
148
  "import": "./dist/twilio.js",
149
149
  "require": "./dist/twilio.cjs"
150
150
  },
151
+ "./html": {
152
+ "types": "./dist/html.d.ts",
153
+ "import": "./dist/html.js",
154
+ "require": "./dist/html.cjs"
155
+ },
151
156
  "./http": {
152
157
  "types": "./dist/http.d.ts",
153
158
  "import": "./dist/http.js",
@@ -221,5 +226,5 @@
221
226
  "prepublishOnly": ". \"$HOME/.nvm/nvm.sh\" && nvm use && tsup && node --test"
222
227
  },
223
228
  "types": "dist/index.d.ts",
224
- "version": "0.0.160"
229
+ "version": "0.0.162"
225
230
  }