@drawbridge/drawbridge-utils 0.0.166 → 0.0.167

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/sendgrid.cjs CHANGED
@@ -142,14 +142,27 @@ var domain = {
142
142
  // Asks SendGrid to look the records up now. `records` carries per-record
143
143
  // validity so a UI can say WHICH record has not landed rather than only that
144
144
  // something has not; `valid` is the whole domain's verdict.
145
+ //
146
+ // TWO CALLS, because SendGrid splits the answer. POST …/validate is what
147
+ // makes it look DNS up now, and it answers per KEY with only `valid` and
148
+ // `reason` — no host, type or data (docs: validation_results.mail_cname /
149
+ // dkim1 / dkim2 / spf, each { valid, reason }). The rows themselves live on
150
+ // the domain, GET …/domains/:id, keyed the same way with host/type/data
151
+ // (and a `valid` of its own, which the validate verdict overrides). Feeding
152
+ // validation_results straight to dnsRows filtered every entry out for want
153
+ // of a host, so this returned `records : []` and no check ever updated a
154
+ // record — the verdicts on screen were the ones from registration.
145
155
  validate: async ({ apiKey, reference, via = sendgridRequest }) => {
146
- const result = await via({
147
- apiKey,
148
- method: "POST",
149
- path: "/v3/whitelabel/domains/" + encodeURIComponent(reference) + "/validate"
150
- });
156
+ const path = "/v3/whitelabel/domains/" + encodeURIComponent(reference);
157
+ const result = await via({ apiKey, method: "POST", path: path + "/validate" });
158
+ const doc = await via({ apiKey, method: "GET", path });
159
+ const verdicts = (result == null ? void 0 : result.validation_results) || {};
160
+ const merged = Object.fromEntries(Object.entries((doc == null ? void 0 : doc.dns) || {}).map(([key, row]) => [
161
+ key,
162
+ { ...row, ...verdicts[key] && { reason: verdicts[key].reason, valid: verdicts[key].valid } }
163
+ ]));
151
164
  return {
152
- records: dnsRows(result == null ? void 0 : result.validation_results),
165
+ records: dnsRows(merged),
153
166
  valid: Boolean(result == null ? void 0 : result.valid)
154
167
  };
155
168
  }
@@ -169,16 +169,33 @@ const domain = {
169
169
  // Asks SendGrid to look the records up now. `records` carries per-record
170
170
  // validity so a UI can say WHICH record has not landed rather than only that
171
171
  // something has not; `valid` is the whole domain's verdict.
172
+ //
173
+ // TWO CALLS, because SendGrid splits the answer. POST …/validate is what
174
+ // makes it look DNS up now, and it answers per KEY with only `valid` and
175
+ // `reason` — no host, type or data (docs: validation_results.mail_cname /
176
+ // dkim1 / dkim2 / spf, each { valid, reason }). The rows themselves live on
177
+ // the domain, GET …/domains/:id, keyed the same way with host/type/data
178
+ // (and a `valid` of its own, which the validate verdict overrides). Feeding
179
+ // validation_results straight to dnsRows filtered every entry out for want
180
+ // of a host, so this returned `records : []` and no check ever updated a
181
+ // record — the verdicts on screen were the ones from registration.
172
182
  validate : async ({ apiKey, reference, via = sendgridRequest }) => {
173
183
 
174
- const result = await via({
175
- apiKey,
176
- method : 'POST',
177
- path : '/v3/whitelabel/domains/' + encodeURIComponent( reference ) + '/validate'
178
- });
184
+ const path = '/v3/whitelabel/domains/' + encodeURIComponent( reference );
185
+
186
+ const result = await via({ apiKey, method : 'POST', path : path + '/validate' });
187
+ const doc = await via({ apiKey, method : 'GET', path });
188
+
189
+ const verdicts = result?.validation_results || {};
190
+
191
+ // `spf` has a verdict but no row; the host/type filter in dnsRows drops it.
192
+ const merged = Object.fromEntries( Object.entries( doc?.dns || {} ).map( ( [ key, row ] ) => [
193
+ key,
194
+ { ...row, ...( verdicts[ key ] && { reason : verdicts[ key ].reason, valid : verdicts[ key ].valid } ) }
195
+ ] ) );
179
196
 
180
197
  return {
181
- records : dnsRows( result?.validation_results ),
198
+ records : dnsRows( merged ),
182
199
  valid : Boolean( result?.valid )
183
200
  };
184
201
 
@@ -169,16 +169,33 @@ const domain = {
169
169
  // Asks SendGrid to look the records up now. `records` carries per-record
170
170
  // validity so a UI can say WHICH record has not landed rather than only that
171
171
  // something has not; `valid` is the whole domain's verdict.
172
+ //
173
+ // TWO CALLS, because SendGrid splits the answer. POST …/validate is what
174
+ // makes it look DNS up now, and it answers per KEY with only `valid` and
175
+ // `reason` — no host, type or data (docs: validation_results.mail_cname /
176
+ // dkim1 / dkim2 / spf, each { valid, reason }). The rows themselves live on
177
+ // the domain, GET …/domains/:id, keyed the same way with host/type/data
178
+ // (and a `valid` of its own, which the validate verdict overrides). Feeding
179
+ // validation_results straight to dnsRows filtered every entry out for want
180
+ // of a host, so this returned `records : []` and no check ever updated a
181
+ // record — the verdicts on screen were the ones from registration.
172
182
  validate : async ({ apiKey, reference, via = sendgridRequest }) => {
173
183
 
174
- const result = await via({
175
- apiKey,
176
- method : 'POST',
177
- path : '/v3/whitelabel/domains/' + encodeURIComponent( reference ) + '/validate'
178
- });
184
+ const path = '/v3/whitelabel/domains/' + encodeURIComponent( reference );
185
+
186
+ const result = await via({ apiKey, method : 'POST', path : path + '/validate' });
187
+ const doc = await via({ apiKey, method : 'GET', path });
188
+
189
+ const verdicts = result?.validation_results || {};
190
+
191
+ // `spf` has a verdict but no row; the host/type filter in dnsRows drops it.
192
+ const merged = Object.fromEntries( Object.entries( doc?.dns || {} ).map( ( [ key, row ] ) => [
193
+ key,
194
+ { ...row, ...( verdicts[ key ] && { reason : verdicts[ key ].reason, valid : verdicts[ key ].valid } ) }
195
+ ] ) );
179
196
 
180
197
  return {
181
- records : dnsRows( result?.validation_results ),
198
+ records : dnsRows( merged ),
182
199
  valid : Boolean( result?.valid )
183
200
  };
184
201
 
package/dist/sendgrid.js CHANGED
@@ -113,14 +113,27 @@ var domain = {
113
113
  // Asks SendGrid to look the records up now. `records` carries per-record
114
114
  // validity so a UI can say WHICH record has not landed rather than only that
115
115
  // something has not; `valid` is the whole domain's verdict.
116
+ //
117
+ // TWO CALLS, because SendGrid splits the answer. POST …/validate is what
118
+ // makes it look DNS up now, and it answers per KEY with only `valid` and
119
+ // `reason` — no host, type or data (docs: validation_results.mail_cname /
120
+ // dkim1 / dkim2 / spf, each { valid, reason }). The rows themselves live on
121
+ // the domain, GET …/domains/:id, keyed the same way with host/type/data
122
+ // (and a `valid` of its own, which the validate verdict overrides). Feeding
123
+ // validation_results straight to dnsRows filtered every entry out for want
124
+ // of a host, so this returned `records : []` and no check ever updated a
125
+ // record — the verdicts on screen were the ones from registration.
116
126
  validate: async ({ apiKey, reference, via = sendgridRequest }) => {
117
- const result = await via({
118
- apiKey,
119
- method: "POST",
120
- path: "/v3/whitelabel/domains/" + encodeURIComponent(reference) + "/validate"
121
- });
127
+ const path = "/v3/whitelabel/domains/" + encodeURIComponent(reference);
128
+ const result = await via({ apiKey, method: "POST", path: path + "/validate" });
129
+ const doc = await via({ apiKey, method: "GET", path });
130
+ const verdicts = (result == null ? void 0 : result.validation_results) || {};
131
+ const merged = Object.fromEntries(Object.entries((doc == null ? void 0 : doc.dns) || {}).map(([key, row]) => [
132
+ key,
133
+ { ...row, ...verdicts[key] && { reason: verdicts[key].reason, valid: verdicts[key].valid } }
134
+ ]));
122
135
  return {
123
- records: dnsRows(result == null ? void 0 : result.validation_results),
136
+ records: dnsRows(merged),
124
137
  valid: Boolean(result == null ? void 0 : result.valid)
125
138
  };
126
139
  }
package/package.json CHANGED
@@ -226,5 +226,5 @@
226
226
  "prepublishOnly": ". \"$HOME/.nvm/nvm.sh\" && nvm use && tsup && node --test"
227
227
  },
228
228
  "types": "dist/index.d.ts",
229
- "version": "0.0.166"
229
+ "version": "0.0.167"
230
230
  }