@aloma.io/integration-sdk 3.7.6 → 3.7.8

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.
@@ -120,6 +120,11 @@ ${text}
120
120
  this.startOAuth = async function (args) {
121
121
  if (!this._oauth)
122
122
  throw new Error("oauth not configured");
123
+ const authorizationURL = process.env.OAUTH_AUTHORIZATION_URL ||
124
+ decrypted.authorizationURL ||
125
+ that._oauth.authorizationURL;
126
+ if (!authorizationURL)
127
+ throw new Error("authorizationURL not configured");
123
128
  const clientId = process.env.OAUTH_CLIENT_ID ||
124
129
  decrypted.clientId ||
125
130
  this._oauth.clientId;
@@ -131,7 +136,7 @@ ${text}
131
136
  "";
132
137
  const useCodeChallenge = !!that._oauth.useCodeChallenge;
133
138
  return {
134
- url: this._oauth.authorizationURL
139
+ url: authorizationURL
135
140
  .replace(/\{\{clientId\}\}/gi, encodeURIComponent(clientId))
136
141
  .replace(/\{\{scope\}\}/gi, encodeURIComponent(scopes)),
137
142
  useCodeChallenge,
@@ -140,9 +145,12 @@ ${text}
140
145
  // @ts-ignore
141
146
  this.finishOAuth = async function (arg) {
142
147
  var that = this;
148
+ const tokenURL = process.env.OAUTH_TOKEN_URL ||
149
+ decrypted.tokenURL ||
150
+ that._oauth.tokenURL;
143
151
  if (!this._oauth)
144
152
  throw new Error("oauth not configured");
145
- if (!this._oauth.tokenURL && !this._oauth.finishOAuth)
153
+ if (!tokenURL && !this._oauth.finishOAuth)
146
154
  throw new Error("need tokenURL or finishOAuth(arg)");
147
155
  var data = null;
148
156
  const doFinish = async () => {
@@ -187,7 +195,7 @@ ${text}
187
195
  client_secret: clientSecret,
188
196
  };
189
197
  }
190
- const response = await fetch(that._oauth.tokenURL, {
198
+ const response = await fetch(tokenURL, {
191
199
  method: "POST",
192
200
  body: new URLSearchParams(body),
193
201
  headers,
@@ -236,6 +244,9 @@ ${text}
236
244
  };
237
245
  const that = this;
238
246
  const getRefreshToken = async (refreshToken) => {
247
+ const tokenURL = process.env.OAUTH_TOKEN_URL ||
248
+ decrypted.tokenURL ||
249
+ that._oauth.tokenURL;
239
250
  const clientId = process.env.OAUTH_CLIENT_ID ||
240
251
  decrypted.clientId ||
241
252
  that._oauth.clientId;
@@ -254,7 +265,7 @@ ${text}
254
265
  Authorization: `Basic ${btoa(`${clientId}:${clientSecret}`)}`,
255
266
  };
256
267
  }
257
- const response = await fetch(that._oauth.tokenURL, {
268
+ const response = await fetch(tokenURL, {
258
269
  method: "POST",
259
270
  body: new URLSearchParams({
260
271
  grant_type: "refresh_token",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.7.6",
3
+ "version": "3.7.8",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -139,6 +139,12 @@ ${text}
139
139
  this.startOAuth = async function (args) {
140
140
  if (!this._oauth) throw new Error("oauth not configured");
141
141
 
142
+ const authorizationURL = process.env.OAUTH_AUTHORIZATION_URL ||
143
+ decrypted.authorizationURL ||
144
+ that._oauth.authorizationURL;
145
+
146
+ if (!authorizationURL) throw new Error("authorizationURL not configured");
147
+
142
148
  const clientId =
143
149
  process.env.OAUTH_CLIENT_ID ||
144
150
  decrypted.clientId ||
@@ -154,7 +160,7 @@ ${text}
154
160
  const useCodeChallenge = !!that._oauth.useCodeChallenge;
155
161
 
156
162
  return {
157
- url: this._oauth.authorizationURL
163
+ url: authorizationURL
158
164
  .replace(/\{\{clientId\}\}/gi, encodeURIComponent(clientId))
159
165
  .replace(/\{\{scope\}\}/gi, encodeURIComponent(scopes)),
160
166
  useCodeChallenge,
@@ -165,8 +171,12 @@ ${text}
165
171
  this.finishOAuth = async function (arg) {
166
172
  var that = this;
167
173
 
174
+ const tokenURL = process.env.OAUTH_TOKEN_URL ||
175
+ decrypted.tokenURL ||
176
+ that._oauth.tokenURL;
177
+
168
178
  if (!this._oauth) throw new Error("oauth not configured");
169
- if (!this._oauth.tokenURL && !this._oauth.finishOAuth)
179
+ if (!tokenURL && !this._oauth.finishOAuth)
170
180
  throw new Error("need tokenURL or finishOAuth(arg)");
171
181
 
172
182
  var data = null;
@@ -222,7 +232,7 @@ ${text}
222
232
  };
223
233
  }
224
234
 
225
- const response = await fetch(that._oauth.tokenURL, {
235
+ const response = await fetch(tokenURL, {
226
236
  method: "POST",
227
237
  body: new URLSearchParams(body),
228
238
  headers,
@@ -282,6 +292,10 @@ ${text}
282
292
  const that = this;
283
293
 
284
294
  const getRefreshToken = async (refreshToken) => {
295
+ const tokenURL = process.env.OAUTH_TOKEN_URL ||
296
+ decrypted.tokenURL ||
297
+ that._oauth.tokenURL;
298
+
285
299
  const clientId =
286
300
  process.env.OAUTH_CLIENT_ID ||
287
301
  decrypted.clientId ||
@@ -305,7 +319,7 @@ ${text}
305
319
  };
306
320
  }
307
321
 
308
- const response = await fetch(that._oauth.tokenURL, {
322
+ const response = await fetch(tokenURL, {
309
323
  method: "POST",
310
324
  body: new URLSearchParams({
311
325
  grant_type: "refresh_token",