@openfn/language-common 1.9.0 → 1.10.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.
- package/dist/util.cjs +20 -2
- package/dist/util.js +18 -1
- package/package.json +1 -1
package/dist/util.cjs
CHANGED
|
@@ -19,7 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/util.js
|
|
20
20
|
var util_exports = {};
|
|
21
21
|
__export(util_exports, {
|
|
22
|
-
expandReferences: () => expandReferences
|
|
22
|
+
expandReferences: () => expandReferences,
|
|
23
|
+
normalizeOauthConfig: () => normalizeOauthConfig
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(util_exports);
|
|
25
26
|
function expandReferences(state, ...args) {
|
|
@@ -39,7 +40,24 @@ function expandReference(state, value) {
|
|
|
39
40
|
}
|
|
40
41
|
return value;
|
|
41
42
|
}
|
|
43
|
+
function normalizeOauthConfig(configuration) {
|
|
44
|
+
const { access_token, accessToken } = configuration;
|
|
45
|
+
if (access_token && accessToken)
|
|
46
|
+
throw new Error(
|
|
47
|
+
'Both "accessToken" & "access_token" keys found in configuration; please use only "access_token" for OAuth2 credentials.'
|
|
48
|
+
);
|
|
49
|
+
if (access_token)
|
|
50
|
+
return { ...configuration, accessToken: access_token };
|
|
51
|
+
console.log(
|
|
52
|
+
'Key "access_token" not found in state.configuration;',
|
|
53
|
+
"is this a standard OAuth 2.0 JSON credential?"
|
|
54
|
+
);
|
|
55
|
+
if (accessToken)
|
|
56
|
+
console.log('Using "accessToken" from state.configuration');
|
|
57
|
+
return configuration;
|
|
58
|
+
}
|
|
42
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
60
|
0 && (module.exports = {
|
|
44
|
-
expandReferences
|
|
61
|
+
expandReferences,
|
|
62
|
+
normalizeOauthConfig
|
|
45
63
|
});
|
package/dist/util.js
CHANGED
|
@@ -16,6 +16,23 @@ function expandReference(state, value) {
|
|
|
16
16
|
}
|
|
17
17
|
return value;
|
|
18
18
|
}
|
|
19
|
+
function normalizeOauthConfig(configuration) {
|
|
20
|
+
const { access_token, accessToken } = configuration;
|
|
21
|
+
if (access_token && accessToken)
|
|
22
|
+
throw new Error(
|
|
23
|
+
'Both "accessToken" & "access_token" keys found in configuration; please use only "access_token" for OAuth2 credentials.'
|
|
24
|
+
);
|
|
25
|
+
if (access_token)
|
|
26
|
+
return { ...configuration, accessToken: access_token };
|
|
27
|
+
console.log(
|
|
28
|
+
'Key "access_token" not found in state.configuration;',
|
|
29
|
+
"is this a standard OAuth 2.0 JSON credential?"
|
|
30
|
+
);
|
|
31
|
+
if (accessToken)
|
|
32
|
+
console.log('Using "accessToken" from state.configuration');
|
|
33
|
+
return configuration;
|
|
34
|
+
}
|
|
19
35
|
export {
|
|
20
|
-
expandReferences
|
|
36
|
+
expandReferences,
|
|
37
|
+
normalizeOauthConfig
|
|
21
38
|
};
|