@drawbridge/drawbridge-utils 0.0.118 → 0.0.124
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/connections/index.cjs +1610 -183
- package/dist/connections/index.d.cts +2480 -275
- package/dist/connections/index.d.ts +2480 -275
- package/dist/connections/index.js +1601 -179
- package/dist/phone.d.cts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/providers.cjs +1587 -240
- package/dist/providers.d.cts +117 -128
- package/dist/providers.d.ts +117 -128
- package/dist/providers.js +1581 -234
- package/dist/sendgrid.cjs +4 -6
- package/dist/sendgrid.d.cts +19 -14
- package/dist/sendgrid.d.ts +19 -14
- package/dist/sendgrid.js +4 -6
- package/dist/twilio.cjs +2 -3
- package/dist/twilio.d.cts +11 -3
- package/dist/twilio.d.ts +11 -3
- package/dist/twilio.js +2 -3
- package/package.json +1 -1
package/dist/sendgrid.cjs
CHANGED
|
@@ -100,11 +100,11 @@ var sendWithRetry = async (send, { delays = RETRY_DELAYS_MS } = {}) => {
|
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
102
|
var sendgridRequest = ({ apiKey, body, method, path, query, request: request2 = request }) => {
|
|
103
|
-
|
|
103
|
+
if (!apiKey) throw new Error("SendGrid API key missing \u2014 pass apiKey (the drawbridge provider's apiKey)");
|
|
104
104
|
return request2({
|
|
105
105
|
body,
|
|
106
106
|
headers: {
|
|
107
|
-
"Authorization": "Bearer " +
|
|
107
|
+
"Authorization": "Bearer " + apiKey
|
|
108
108
|
},
|
|
109
109
|
method,
|
|
110
110
|
query,
|
|
@@ -118,10 +118,8 @@ var sendgrid = {
|
|
|
118
118
|
send: async ({ apiKey, from, headers, html, request: request2, subject, text, to }) => {
|
|
119
119
|
var _a, _b;
|
|
120
120
|
try {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
name: "Drawbridge"
|
|
124
|
-
};
|
|
121
|
+
if (!(from == null ? void 0 : from.email)) throw new Error("SendGrid sender missing \u2014 pass from.email (the drawbridge provider's accountSender)");
|
|
122
|
+
const sender = { name: "Drawbridge", ...from };
|
|
125
123
|
await sendWithRetry(() => sendgridRequest({
|
|
126
124
|
apiKey,
|
|
127
125
|
...request2 && { request: request2 },
|
package/dist/sendgrid.d.cts
CHANGED
|
@@ -10,10 +10,10 @@ import { createLogger } from '@drawbridge/drawbridge-telemetry';
|
|
|
10
10
|
// other — the private `drawbridge` manifest declares email.send, email.notify
|
|
11
11
|
// and email.digest, so its transport belongs beside its manifest.
|
|
12
12
|
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
13
|
+
// THE CREDENTIAL IS THE CALLER'S TO PASS. It used to fall back to process.env;
|
|
14
|
+
// it lives encrypted in the `provider` collection now (lib/providers.js), and a
|
|
15
|
+
// published package reading a deployment's environment is precisely the thing
|
|
16
|
+
// `client : { id : 'KLAVIYO_OAUTH_CLIENT_ID' }` exists to avoid.
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
const logger = createLogger();
|
|
@@ -90,12 +90,17 @@ const sendWithRetry = async ( send, { delays = RETRY_DELAYS_MS } = {} ) => {
|
|
|
90
90
|
// manifest hook), and it is the only thing that works across the boundary.
|
|
91
91
|
const sendgridRequest = ({ apiKey, body, method, path, query, request: request$1 = request }) => {
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
// THROWS RATHER THAN DEGRADES. Sending with no key is not a degraded send, it
|
|
94
|
+
// is an unauthenticated request SendGrid answers 401 — and the alternative,
|
|
95
|
+
// no-opping, is mail that stops with no error anywhere: no exception, no
|
|
96
|
+
// failed job, nothing to alert on, just people who never received the code
|
|
97
|
+
// they are waiting for. A missing credential has to be loud.
|
|
98
|
+
if( ! apiKey ) throw new Error( 'SendGrid API key missing — pass apiKey (the drawbridge provider\'s apiKey)' );
|
|
94
99
|
|
|
95
100
|
return request$1({
|
|
96
101
|
body,
|
|
97
102
|
headers : {
|
|
98
|
-
'Authorization' : 'Bearer ' +
|
|
103
|
+
'Authorization' : 'Bearer ' + apiKey
|
|
99
104
|
},
|
|
100
105
|
method,
|
|
101
106
|
query,
|
|
@@ -113,14 +118,14 @@ const sendgrid = {
|
|
|
113
118
|
|
|
114
119
|
try {
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
// SAME REASON AS THE KEY. The account sender is stored, not deployed,
|
|
122
|
+
// and a send from no address is one SendGrid rejects — quietly, from
|
|
123
|
+
// the caller's point of view, since the throw would otherwise never
|
|
124
|
+
// name the thing that is actually missing. The display name still
|
|
125
|
+
// defaults, because that is a label rather than a credential.
|
|
126
|
+
if( ! from?.email ) throw new Error( 'SendGrid sender missing — pass from.email (the drawbridge provider\'s accountSender)' );
|
|
127
|
+
|
|
128
|
+
const sender = { name : 'Drawbridge', ...from };
|
|
124
129
|
|
|
125
130
|
await sendWithRetry( () => sendgridRequest({
|
|
126
131
|
apiKey,
|
package/dist/sendgrid.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ import { createLogger } from '@drawbridge/drawbridge-telemetry';
|
|
|
10
10
|
// other — the private `drawbridge` manifest declares email.send, email.notify
|
|
11
11
|
// and email.digest, so its transport belongs beside its manifest.
|
|
12
12
|
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
13
|
+
// THE CREDENTIAL IS THE CALLER'S TO PASS. It used to fall back to process.env;
|
|
14
|
+
// it lives encrypted in the `provider` collection now (lib/providers.js), and a
|
|
15
|
+
// published package reading a deployment's environment is precisely the thing
|
|
16
|
+
// `client : { id : 'KLAVIYO_OAUTH_CLIENT_ID' }` exists to avoid.
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
const logger = createLogger();
|
|
@@ -90,12 +90,17 @@ const sendWithRetry = async ( send, { delays = RETRY_DELAYS_MS } = {} ) => {
|
|
|
90
90
|
// manifest hook), and it is the only thing that works across the boundary.
|
|
91
91
|
const sendgridRequest = ({ apiKey, body, method, path, query, request: request$1 = request }) => {
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
// THROWS RATHER THAN DEGRADES. Sending with no key is not a degraded send, it
|
|
94
|
+
// is an unauthenticated request SendGrid answers 401 — and the alternative,
|
|
95
|
+
// no-opping, is mail that stops with no error anywhere: no exception, no
|
|
96
|
+
// failed job, nothing to alert on, just people who never received the code
|
|
97
|
+
// they are waiting for. A missing credential has to be loud.
|
|
98
|
+
if( ! apiKey ) throw new Error( 'SendGrid API key missing — pass apiKey (the drawbridge provider\'s apiKey)' );
|
|
94
99
|
|
|
95
100
|
return request$1({
|
|
96
101
|
body,
|
|
97
102
|
headers : {
|
|
98
|
-
'Authorization' : 'Bearer ' +
|
|
103
|
+
'Authorization' : 'Bearer ' + apiKey
|
|
99
104
|
},
|
|
100
105
|
method,
|
|
101
106
|
query,
|
|
@@ -113,14 +118,14 @@ const sendgrid = {
|
|
|
113
118
|
|
|
114
119
|
try {
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
// SAME REASON AS THE KEY. The account sender is stored, not deployed,
|
|
122
|
+
// and a send from no address is one SendGrid rejects — quietly, from
|
|
123
|
+
// the caller's point of view, since the throw would otherwise never
|
|
124
|
+
// name the thing that is actually missing. The display name still
|
|
125
|
+
// defaults, because that is a label rather than a credential.
|
|
126
|
+
if( ! from?.email ) throw new Error( 'SendGrid sender missing — pass from.email (the drawbridge provider\'s accountSender)' );
|
|
127
|
+
|
|
128
|
+
const sender = { name : 'Drawbridge', ...from };
|
|
124
129
|
|
|
125
130
|
await sendWithRetry( () => sendgridRequest({
|
|
126
131
|
apiKey,
|
package/dist/sendgrid.js
CHANGED
|
@@ -73,11 +73,11 @@ var sendWithRetry = async (send, { delays = RETRY_DELAYS_MS } = {}) => {
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
var sendgridRequest = ({ apiKey, body, method, path, query, request: request2 = request }) => {
|
|
76
|
-
|
|
76
|
+
if (!apiKey) throw new Error("SendGrid API key missing \u2014 pass apiKey (the drawbridge provider's apiKey)");
|
|
77
77
|
return request2({
|
|
78
78
|
body,
|
|
79
79
|
headers: {
|
|
80
|
-
"Authorization": "Bearer " +
|
|
80
|
+
"Authorization": "Bearer " + apiKey
|
|
81
81
|
},
|
|
82
82
|
method,
|
|
83
83
|
query,
|
|
@@ -91,10 +91,8 @@ var sendgrid = {
|
|
|
91
91
|
send: async ({ apiKey, from, headers, html, request: request2, subject, text, to }) => {
|
|
92
92
|
var _a, _b;
|
|
93
93
|
try {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
name: "Drawbridge"
|
|
97
|
-
};
|
|
94
|
+
if (!(from == null ? void 0 : from.email)) throw new Error("SendGrid sender missing \u2014 pass from.email (the drawbridge provider's accountSender)");
|
|
95
|
+
const sender = { name: "Drawbridge", ...from };
|
|
98
96
|
await sendWithRetry(() => sendgridRequest({
|
|
99
97
|
apiKey,
|
|
100
98
|
...request2 && { request: request2 },
|
package/dist/twilio.cjs
CHANGED
|
@@ -81,9 +81,8 @@ var twilio = {
|
|
|
81
81
|
title,
|
|
82
82
|
to
|
|
83
83
|
}) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
from = from || process.env.TWILIO_ACCOUNT_FROM;
|
|
84
|
+
const missing = Object.entries({ accountSid, authToken, from }).filter(([, value]) => !value).map(([name]) => name);
|
|
85
|
+
if (missing.length) throw new Error("Twilio credentials missing \u2014 " + missing.join(", ") + " (the drawbridge provider's smsSid, smsToken and smsFrom)");
|
|
87
86
|
const body = [
|
|
88
87
|
title,
|
|
89
88
|
message,
|
package/dist/twilio.d.cts
CHANGED
|
@@ -26,9 +26,17 @@ const twilio = {
|
|
|
26
26
|
to
|
|
27
27
|
}) => {
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// THROWS RATHER THAN DEGRADES. These used to fall back to process.env;
|
|
30
|
+
// they live encrypted in the `provider` collection now and the caller
|
|
31
|
+
// passes them. Missing, there is no send to degrade to — a no-op here is
|
|
32
|
+
// SMS that stops with nothing raised anywhere, which reads as delivered
|
|
33
|
+
// right up until someone reports that the code never arrived. Naming the
|
|
34
|
+
// missing ones is the difference between a five-minute fix and a hunt.
|
|
35
|
+
const missing = Object.entries({ accountSid, authToken, from })
|
|
36
|
+
.filter( ( [ , value ] ) => ! value )
|
|
37
|
+
.map( ( [ name ] ) => name );
|
|
38
|
+
|
|
39
|
+
if( missing.length ) throw new Error( 'Twilio credentials missing — ' + missing.join( ', ' ) + ' (the drawbridge provider\'s smsSid, smsToken and smsFrom)' );
|
|
32
40
|
|
|
33
41
|
// Newline-separated, brand/title first, and no "Your prize is" /
|
|
34
42
|
// "Click here to verify your prize" phrasing — textbook carrier-filter
|
package/dist/twilio.d.ts
CHANGED
|
@@ -26,9 +26,17 @@ const twilio = {
|
|
|
26
26
|
to
|
|
27
27
|
}) => {
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// THROWS RATHER THAN DEGRADES. These used to fall back to process.env;
|
|
30
|
+
// they live encrypted in the `provider` collection now and the caller
|
|
31
|
+
// passes them. Missing, there is no send to degrade to — a no-op here is
|
|
32
|
+
// SMS that stops with nothing raised anywhere, which reads as delivered
|
|
33
|
+
// right up until someone reports that the code never arrived. Naming the
|
|
34
|
+
// missing ones is the difference between a five-minute fix and a hunt.
|
|
35
|
+
const missing = Object.entries({ accountSid, authToken, from })
|
|
36
|
+
.filter( ( [ , value ] ) => ! value )
|
|
37
|
+
.map( ( [ name ] ) => name );
|
|
38
|
+
|
|
39
|
+
if( missing.length ) throw new Error( 'Twilio credentials missing — ' + missing.join( ', ' ) + ' (the drawbridge provider\'s smsSid, smsToken and smsFrom)' );
|
|
32
40
|
|
|
33
41
|
// Newline-separated, brand/title first, and no "Your prize is" /
|
|
34
42
|
// "Click here to verify your prize" phrasing — textbook carrier-filter
|
package/dist/twilio.js
CHANGED
|
@@ -56,9 +56,8 @@ var twilio = {
|
|
|
56
56
|
title,
|
|
57
57
|
to
|
|
58
58
|
}) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
from = from || process.env.TWILIO_ACCOUNT_FROM;
|
|
59
|
+
const missing = Object.entries({ accountSid, authToken, from }).filter(([, value]) => !value).map(([name]) => name);
|
|
60
|
+
if (missing.length) throw new Error("Twilio credentials missing \u2014 " + missing.join(", ") + " (the drawbridge provider's smsSid, smsToken and smsFrom)");
|
|
62
61
|
const body = [
|
|
63
62
|
title,
|
|
64
63
|
message,
|
package/package.json
CHANGED