@openfn/language-http 7.1.0 → 7.2.0

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.
@@ -35,6 +35,16 @@
35
35
  "format": "uri",
36
36
  "minLength": 1,
37
37
  "examples": ["https://instance_name.surveycto.com"]
38
+ },
39
+ "tls":{
40
+ "title": "TLS Options",
41
+ "type": "object",
42
+ "description": "TLS options to use for HTTPS requests. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions",
43
+ "writeOnly": true,
44
+ "examples": [
45
+ {
46
+ "cert": "-----BEGIN CERTIFICATE-----\nMIIDXTCCAkWgAwIBAgIJAL5z1k3f4b2wMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdTYW4gSm9zZTET\n-----END CERTIFICATE-----"
47
+ }]
38
48
  }
39
49
  },
40
50
  "type": "object",
package/dist/index.cjs CHANGED
@@ -106,6 +106,7 @@ __export(util_exports, {
106
106
  CONTENT_TYPES: () => CONTENT_TYPES,
107
107
  decode: () => import_util.decode,
108
108
  encode: () => import_util.encode,
109
+ getTLSOptions: () => getTLSOptions,
109
110
  request: () => request,
110
111
  uuid: () => import_util.uuid,
111
112
  xmlParser: () => xmlParser
@@ -132,6 +133,11 @@ function encodeFormBody(data) {
132
133
  }
133
134
  return form;
134
135
  }
136
+ function getTLSOptions(state, requestOptions) {
137
+ const { tls: tlsConfig } = state.configuration || {};
138
+ const tls = requestOptions.tls ?? requestOptions.agentOptions ?? tlsConfig;
139
+ return tls;
140
+ }
135
141
  var assertUrl = (pathOrUrl, baseUrl) => {
136
142
  if (!baseUrl && pathOrUrl && !/^https?:\/\//.test(pathOrUrl)) {
137
143
  const e = new Error("UNEXPECTED_RELATIVE_URL");
@@ -184,10 +190,10 @@ function request(method, path, params) {
184
190
  addAuth(state.configuration, headers);
185
191
  }
186
192
  const maxRedirections = resolvedParams.maxRedirections ?? (resolvedParams.followAllRedirects === false ? 0 : 5);
187
- const tls = resolvedParams.tls ?? resolvedParams.agentOptions;
193
+ const tls = getTLSOptions(state, resolvedParams);
188
194
  if (resolvedParams.agentOptions) {
189
195
  console.warn(
190
- "WARNING: The `agentOptions` option has been deprecated. Use `tls` instead"
196
+ "WARNING: The `agentOptions` option has been deprecated. Add `tls` to state.configuration instead."
191
197
  );
192
198
  }
193
199
  const options = {
package/dist/index.js CHANGED
@@ -48,6 +48,7 @@ __export(util_exports, {
48
48
  CONTENT_TYPES: () => CONTENT_TYPES,
49
49
  decode: () => decode,
50
50
  encode: () => encode,
51
+ getTLSOptions: () => getTLSOptions,
51
52
  request: () => request,
52
53
  uuid: () => uuid,
53
54
  xmlParser: () => xmlParser
@@ -82,6 +83,11 @@ function encodeFormBody(data) {
82
83
  }
83
84
  return form;
84
85
  }
86
+ function getTLSOptions(state, requestOptions) {
87
+ const { tls: tlsConfig } = state.configuration || {};
88
+ const tls = requestOptions.tls ?? requestOptions.agentOptions ?? tlsConfig;
89
+ return tls;
90
+ }
85
91
  var assertUrl = (pathOrUrl, baseUrl) => {
86
92
  if (!baseUrl && pathOrUrl && !/^https?:\/\//.test(pathOrUrl)) {
87
93
  const e = new Error("UNEXPECTED_RELATIVE_URL");
@@ -134,10 +140,10 @@ function request(method, path, params) {
134
140
  addAuth(state.configuration, headers);
135
141
  }
136
142
  const maxRedirections = resolvedParams.maxRedirections ?? (resolvedParams.followAllRedirects === false ? 0 : 5);
137
- const tls = resolvedParams.tls ?? resolvedParams.agentOptions;
143
+ const tls = getTLSOptions(state, resolvedParams);
138
144
  if (resolvedParams.agentOptions) {
139
145
  console.warn(
140
- "WARNING: The `agentOptions` option has been deprecated. Use `tls` instead"
146
+ "WARNING: The `agentOptions` option has been deprecated. Add `tls` to state.configuration instead."
141
147
  );
142
148
  }
143
149
  const options = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openfn/language-http",
3
3
  "label": "HTTP",
4
- "version": "7.1.0",
4
+ "version": "7.2.0",
5
5
  "description": "An HTTP request language package for use with Open Function",
6
6
  "homepage": "https://docs.openfn.org",
7
7
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "cheerio": "1.0.0-rc.12",
31
31
  "cheerio-tableparser": "^1.0.1",
32
- "@openfn/language-common": "3.0.0"
32
+ "@openfn/language-common": "3.0.2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "chai": "^4.3.10",
package/types/util.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export function getTLSOptions(state: any, requestOptions: any): any;
1
2
  /**
2
3
  * Request helper function
3
4
  * @function