@drawbridge/drawbridge-utils 0.0.73 → 0.0.75

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/sanitize.cjs CHANGED
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
 
29
19
  // lib/sanitize.js
@@ -37,10 +27,17 @@ __export(sanitize_exports, {
37
27
  sanitizeUrl: () => sanitizeUrl
38
28
  });
39
29
  module.exports = __toCommonJS(sanitize_exports);
40
- var import_disposable_email_domains = __toESM(require("disposable-email-domains"), 1);
30
+
31
+ // node_modules/tsup/assets/cjs_shims.js
32
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
33
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
34
+
35
+ // lib/sanitize.js
36
+ var import_node_module = require("module");
37
+ var disposableDomains = (0, import_node_module.createRequire)(importMetaUrl)("disposable-email-domains");
41
38
  var SCOPE_KEYS = ["organization", "account", "user", "owner"];
42
39
  var DANGEROUS_OPERATORS = ["$where", "$function", "$accumulator"];
43
- var disposableBlacklist = new Set(import_disposable_email_domains.default.map((d) => d.toLowerCase()));
40
+ var disposableBlacklist = new Set(disposableDomains.map((d) => d.toLowerCase()));
44
41
  var stripDangerousOperators = (value) => {
45
42
  if (Array.isArray(value)) {
46
43
  return value.map(stripDangerousOperators);
@@ -88,8 +85,8 @@ var sanitizeHttps = (val) => {
88
85
  return value ? "https://" + value : "";
89
86
  };
90
87
  var sanitizeUrl = (url) => {
91
- var _a, _b;
92
- return (_b = (_a = url == null ? void 0 : url.replace(/^http:\/\//, "https://")) == null ? void 0 : _a.replace(/^https:\/\/www\./, "https://")) == null ? void 0 : _b.replace(/\/$/, "");
88
+ if (!url) return url;
89
+ return sanitizeHttps(url).replace(/^https:\/\/www\./, "https://").replace(/\/$/, "");
93
90
  };
94
91
  var sanitizeEmail = (raw) => {
95
92
  if (typeof raw !== "string") return {
@@ -1,4 +1,11 @@
1
- import disposableDomains from 'disposable-email-domains';
1
+ import { createRequire } from 'node:module';
2
+
3
+ // The package's entry is a bare index.json; a static ESM import of it needs a
4
+ // JSON import attribute that Node only understands from ~20.10, so the ESM
5
+ // dist build was un-importable under plain Node (bundlers papered over it).
6
+ // createRequire loads it with CJS semantics on every Node version — tsup's
7
+ // `shims` option makes import.meta.url safe in the CJS build.
8
+ const disposableDomains = createRequire( import.meta.url )( 'disposable-email-domains' );
2
9
 
3
10
  const SCOPE_KEYS = [ 'organization', 'account', 'user', 'owner' ];
4
11
  const DANGEROUS_OPERATORS = [ '$where', '$function', '$accumulator' ];
@@ -101,10 +108,19 @@ const sanitizeHttps = ( val ) => {
101
108
 
102
109
  };
103
110
 
104
- const sanitizeUrl = ( url ) => url
105
- ?.replace( /^http:\/\//, 'https://' )
106
- ?.replace( /^https:\/\/www\./, 'https://' )
107
- ?.replace( /\/$/, '' );
111
+ // Full write-path normalizer for finished urls: canonical https prefix
112
+ // (via sanitizeHttps regex.url validation alone still lets a doubled
113
+ // https://https:// prefix through), then strip www. and any trailing slash.
114
+ // Keystroke-time inputs want sanitizeHttps alone — this one fights typing.
115
+ const sanitizeUrl = ( url ) => {
116
+
117
+ if( ! url ) return url;
118
+
119
+ return sanitizeHttps( url )
120
+ .replace( /^https:\/\/www\./, 'https://' )
121
+ .replace( /\/$/, '' );
122
+
123
+ };
108
124
 
109
125
  // Normalize + validate an email address. Trim, lowercase, basic shape
110
126
  // check, and reject disposable-domain providers. Returns the normalized
@@ -1,4 +1,11 @@
1
- import disposableDomains from 'disposable-email-domains';
1
+ import { createRequire } from 'node:module';
2
+
3
+ // The package's entry is a bare index.json; a static ESM import of it needs a
4
+ // JSON import attribute that Node only understands from ~20.10, so the ESM
5
+ // dist build was un-importable under plain Node (bundlers papered over it).
6
+ // createRequire loads it with CJS semantics on every Node version — tsup's
7
+ // `shims` option makes import.meta.url safe in the CJS build.
8
+ const disposableDomains = createRequire( import.meta.url )( 'disposable-email-domains' );
2
9
 
3
10
  const SCOPE_KEYS = [ 'organization', 'account', 'user', 'owner' ];
4
11
  const DANGEROUS_OPERATORS = [ '$where', '$function', '$accumulator' ];
@@ -101,10 +108,19 @@ const sanitizeHttps = ( val ) => {
101
108
 
102
109
  };
103
110
 
104
- const sanitizeUrl = ( url ) => url
105
- ?.replace( /^http:\/\//, 'https://' )
106
- ?.replace( /^https:\/\/www\./, 'https://' )
107
- ?.replace( /\/$/, '' );
111
+ // Full write-path normalizer for finished urls: canonical https prefix
112
+ // (via sanitizeHttps regex.url validation alone still lets a doubled
113
+ // https://https:// prefix through), then strip www. and any trailing slash.
114
+ // Keystroke-time inputs want sanitizeHttps alone — this one fights typing.
115
+ const sanitizeUrl = ( url ) => {
116
+
117
+ if( ! url ) return url;
118
+
119
+ return sanitizeHttps( url )
120
+ .replace( /^https:\/\/www\./, 'https://' )
121
+ .replace( /\/$/, '' );
122
+
123
+ };
108
124
 
109
125
  // Normalize + validate an email address. Trim, lowercase, basic shape
110
126
  // check, and reject disposable-domain providers. Returns the normalized
package/dist/sanitize.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // lib/sanitize.js
2
- import disposableDomains from "disposable-email-domains";
2
+ import { createRequire } from "module";
3
+ var disposableDomains = createRequire(import.meta.url)("disposable-email-domains");
3
4
  var SCOPE_KEYS = ["organization", "account", "user", "owner"];
4
5
  var DANGEROUS_OPERATORS = ["$where", "$function", "$accumulator"];
5
6
  var disposableBlacklist = new Set(disposableDomains.map((d) => d.toLowerCase()));
@@ -50,8 +51,8 @@ var sanitizeHttps = (val) => {
50
51
  return value ? "https://" + value : "";
51
52
  };
52
53
  var sanitizeUrl = (url) => {
53
- var _a, _b;
54
- return (_b = (_a = url == null ? void 0 : url.replace(/^http:\/\//, "https://")) == null ? void 0 : _a.replace(/^https:\/\/www\./, "https://")) == null ? void 0 : _b.replace(/\/$/, "");
54
+ if (!url) return url;
55
+ return sanitizeHttps(url).replace(/^https:\/\/www\./, "https://").replace(/\/$/, "");
55
56
  };
56
57
  var sanitizeEmail = (raw) => {
57
58
  if (typeof raw !== "string") return {
package/package.json CHANGED
@@ -155,8 +155,9 @@
155
155
  },
156
156
  "scripts": {
157
157
  "sync": ". \"$HOME/.nvm/nvm.sh\" && nvm use && npm prune && npm install && npx drawbridge-agents-sync",
158
- "build": "tsup && npm publish"
158
+ "build": "tsup && npm publish",
159
+ "test": "node --test test/"
159
160
  },
160
161
  "types": "dist/index.d.ts",
161
- "version": "0.0.73"
162
+ "version": "0.0.75"
162
163
  }