@allthings/sdk 10.1.1 → 10.1.2
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/cli.js +10 -10
- package/dist/lib.cjs.js +10 -10
- package/dist/package.json +3 -3
- package/dist/src/oauth/implicitGrant.js +1 -1
- package/dist/src/oauth/maybeUpdateToken.js +4 -4
- package/dist/src/rest/index.js +2 -2
- package/dist/src/rest/methods/ticket.d.ts +1 -1
- package/dist/src/rest/request.js +1 -1
- package/dist/src/utils/queryString.js +1 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ function createTokenStore(initialToken) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const version = "10.1.
|
|
15
|
+
const version = "10.1.2";
|
|
16
16
|
|
|
17
17
|
const environment = typeof process !== 'undefined' && process.env ? process.env : {};
|
|
18
18
|
|
|
@@ -40,7 +40,7 @@ const USER_AGENT = `Allthings Node SDK REST Client/${version}`;
|
|
|
40
40
|
function buildQueryString(params) {
|
|
41
41
|
const usp = new URLSearchParams();
|
|
42
42
|
for (const [key, value] of Object.entries(params).sort(([a], [b]) => a.localeCompare(b))) {
|
|
43
|
-
if (value
|
|
43
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
44
44
|
usp.append(key, String(value));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -917,7 +917,7 @@ const castToAuthorizationRequestParameters = (parameters) => {
|
|
|
917
917
|
}
|
|
918
918
|
return {
|
|
919
919
|
client_id: clientId,
|
|
920
|
-
redirect_uri: redirectUri ||
|
|
920
|
+
redirect_uri: redirectUri || globalThis.location.href,
|
|
921
921
|
response_type: RESPONSE_TYPE,
|
|
922
922
|
...(scope ? { scope } : {}),
|
|
923
923
|
...(state ? { state } : {}),
|
|
@@ -978,15 +978,15 @@ async function maybeUpdateToken(oauthTokenStore, tokenFetcher, options, mustRefr
|
|
|
978
978
|
if (isEligible(options)) {
|
|
979
979
|
return oauthTokenStore.set(await requestToken(tokenFetcher, options));
|
|
980
980
|
}
|
|
981
|
-
if (
|
|
982
|
-
const parsedLocationHash = parseQueryString(window.location.hash);
|
|
981
|
+
if (globalThis.window !== undefined && options.implicit) {
|
|
982
|
+
const parsedLocationHash = parseQueryString(globalThis.window.location.hash);
|
|
983
983
|
const accessToken = parsedLocationHash.access_token;
|
|
984
984
|
if (accessToken) {
|
|
985
|
-
window.history.replaceState({}, '', window.location.href.split('#')[0]);
|
|
985
|
+
globalThis.window.history.replaceState({}, '', globalThis.window.location.href.split('#')[0]);
|
|
986
986
|
return oauthTokenStore.set({ accessToken });
|
|
987
987
|
}
|
|
988
988
|
if (isEligibleForClientRedirect(options)) {
|
|
989
|
-
window.location.href = getRedirectUrl(options);
|
|
989
|
+
globalThis.window.location.href = getRedirectUrl(options);
|
|
990
990
|
return;
|
|
991
991
|
}
|
|
992
992
|
}
|
|
@@ -1108,7 +1108,7 @@ function makeApiRequest(oauthTokenStore, oauthTokenRequester, options, httpMetho
|
|
|
1108
1108
|
options.clientId ??
|
|
1109
1109
|
'no client id present'}`,
|
|
1110
1110
|
...(hasForm ? {} : { 'content-type': 'application/json' }),
|
|
1111
|
-
...(
|
|
1111
|
+
...(globalThis.window === undefined &&
|
|
1112
1112
|
typeof document === 'undefined' && { 'user-agent': USER_AGENT }),
|
|
1113
1113
|
...payload?.headers,
|
|
1114
1114
|
};
|
|
@@ -1240,8 +1240,8 @@ function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) {
|
|
|
1240
1240
|
}
|
|
1241
1241
|
if (!options.clientId &&
|
|
1242
1242
|
!(options.accessToken || options.tokenStore) &&
|
|
1243
|
-
|
|
1244
|
-
throw new Error('Missing required "clientId" or "accessToken" parameter
|
|
1243
|
+
globalThis.window === undefined) {
|
|
1244
|
+
throw new Error('Missing required "clientId" or "accessToken" parameter.');
|
|
1245
1245
|
}
|
|
1246
1246
|
const tokenRequester = makeFetchTokenRequester(`${options.oauthUrl}/oauth/token`);
|
|
1247
1247
|
const tokenStore = options.tokenStore ||
|
package/dist/lib.cjs.js
CHANGED
|
@@ -11,7 +11,7 @@ function createTokenStore(initialToken) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const version = "10.1.
|
|
14
|
+
const version = "10.1.2";
|
|
15
15
|
|
|
16
16
|
const environment = typeof process !== 'undefined' && process.env ? process.env : {};
|
|
17
17
|
|
|
@@ -39,7 +39,7 @@ const USER_AGENT = `Allthings Node SDK REST Client/${version}`;
|
|
|
39
39
|
function buildQueryString(params) {
|
|
40
40
|
const usp = new URLSearchParams();
|
|
41
41
|
for (const [key, value] of Object.entries(params).sort(([a], [b]) => a.localeCompare(b))) {
|
|
42
|
-
if (value
|
|
42
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
43
43
|
usp.append(key, String(value));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -916,7 +916,7 @@ const castToAuthorizationRequestParameters = (parameters) => {
|
|
|
916
916
|
}
|
|
917
917
|
return {
|
|
918
918
|
client_id: clientId,
|
|
919
|
-
redirect_uri: redirectUri ||
|
|
919
|
+
redirect_uri: redirectUri || globalThis.location.href,
|
|
920
920
|
response_type: RESPONSE_TYPE,
|
|
921
921
|
...(scope ? { scope } : {}),
|
|
922
922
|
...(state ? { state } : {}),
|
|
@@ -977,15 +977,15 @@ async function maybeUpdateToken(oauthTokenStore, tokenFetcher, options, mustRefr
|
|
|
977
977
|
if (isEligible(options)) {
|
|
978
978
|
return oauthTokenStore.set(await requestToken(tokenFetcher, options));
|
|
979
979
|
}
|
|
980
|
-
if (
|
|
981
|
-
const parsedLocationHash = parseQueryString(window.location.hash);
|
|
980
|
+
if (globalThis.window !== undefined && options.implicit) {
|
|
981
|
+
const parsedLocationHash = parseQueryString(globalThis.window.location.hash);
|
|
982
982
|
const accessToken = parsedLocationHash.access_token;
|
|
983
983
|
if (accessToken) {
|
|
984
|
-
window.history.replaceState({}, '', window.location.href.split('#')[0]);
|
|
984
|
+
globalThis.window.history.replaceState({}, '', globalThis.window.location.href.split('#')[0]);
|
|
985
985
|
return oauthTokenStore.set({ accessToken });
|
|
986
986
|
}
|
|
987
987
|
if (isEligibleForClientRedirect(options)) {
|
|
988
|
-
window.location.href = getRedirectUrl(options);
|
|
988
|
+
globalThis.window.location.href = getRedirectUrl(options);
|
|
989
989
|
return;
|
|
990
990
|
}
|
|
991
991
|
}
|
|
@@ -1107,7 +1107,7 @@ function makeApiRequest(oauthTokenStore, oauthTokenRequester, options, httpMetho
|
|
|
1107
1107
|
options.clientId ??
|
|
1108
1108
|
'no client id present'}`,
|
|
1109
1109
|
...(hasForm ? {} : { 'content-type': 'application/json' }),
|
|
1110
|
-
...(
|
|
1110
|
+
...(globalThis.window === undefined &&
|
|
1111
1111
|
typeof document === 'undefined' && { 'user-agent': USER_AGENT }),
|
|
1112
1112
|
...payload?.headers,
|
|
1113
1113
|
};
|
|
@@ -1239,8 +1239,8 @@ function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) {
|
|
|
1239
1239
|
}
|
|
1240
1240
|
if (!options.clientId &&
|
|
1241
1241
|
!(options.accessToken || options.tokenStore) &&
|
|
1242
|
-
|
|
1243
|
-
throw new Error('Missing required "clientId" or "accessToken" parameter
|
|
1242
|
+
globalThis.window === undefined) {
|
|
1243
|
+
throw new Error('Missing required "clientId" or "accessToken" parameter.');
|
|
1244
1244
|
}
|
|
1245
1245
|
const tokenRequester = makeFetchTokenRequester(`${options.oauthUrl}/oauth/token`);
|
|
1246
1246
|
const tokenStore = options.tokenStore ||
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allthings/sdk",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Allthings GmbH",
|
|
6
6
|
"keywords": [
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"bottleneck": "2.19.5"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@allthings/eslint-config": "
|
|
76
|
+
"@allthings/eslint-config": "4.0.0",
|
|
77
77
|
"@commitlint/cli": "21.0.1",
|
|
78
78
|
"@commitlint/config-conventional": "21.0.1",
|
|
79
79
|
"@rollup/plugin-commonjs": "29.0.2",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@types/node": "24.12.4",
|
|
84
84
|
"aws-sdk-client-mock": "4.1.0",
|
|
85
85
|
"coveralls": "3.1.1",
|
|
86
|
-
"eslint": "
|
|
86
|
+
"eslint": "10.4.0",
|
|
87
87
|
"husky": "9.1.7",
|
|
88
88
|
"jest": "30.4.2",
|
|
89
89
|
"jest-environment-jsdom": "30.4.1",
|
|
@@ -7,7 +7,7 @@ const castToAuthorizationRequestParameters = (parameters) => {
|
|
|
7
7
|
}
|
|
8
8
|
return {
|
|
9
9
|
client_id: clientId,
|
|
10
|
-
redirect_uri: redirectUri ||
|
|
10
|
+
redirect_uri: redirectUri || globalThis.location.href,
|
|
11
11
|
response_type: RESPONSE_TYPE,
|
|
12
12
|
...(scope ? { scope } : {}),
|
|
13
13
|
...(state ? { state } : {}),
|
|
@@ -18,15 +18,15 @@ export default async function maybeUpdateToken(oauthTokenStore, tokenFetcher, op
|
|
|
18
18
|
if (passwordGrant.isEligible(options)) {
|
|
19
19
|
return oauthTokenStore.set(await passwordGrant.requestToken(tokenFetcher, options));
|
|
20
20
|
}
|
|
21
|
-
if (
|
|
22
|
-
const parsedLocationHash = parseQueryString(window.location.hash);
|
|
21
|
+
if (globalThis.window !== undefined && options.implicit) {
|
|
22
|
+
const parsedLocationHash = parseQueryString(globalThis.window.location.hash);
|
|
23
23
|
const accessToken = parsedLocationHash.access_token;
|
|
24
24
|
if (accessToken) {
|
|
25
|
-
window.history.replaceState({}, '', window.location.href.split('#')[0]);
|
|
25
|
+
globalThis.window.history.replaceState({}, '', globalThis.window.location.href.split('#')[0]);
|
|
26
26
|
return oauthTokenStore.set({ accessToken });
|
|
27
27
|
}
|
|
28
28
|
if (implicitGrant.isEligibleForClientRedirect(options)) {
|
|
29
|
-
window.location.href = implicitGrant.getRedirectUrl(options);
|
|
29
|
+
globalThis.window.location.href = implicitGrant.getRedirectUrl(options);
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
}
|
package/dist/src/rest/index.js
CHANGED
|
@@ -112,8 +112,8 @@ export default function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) {
|
|
|
112
112
|
}
|
|
113
113
|
if (!options.clientId &&
|
|
114
114
|
!(options.accessToken || options.tokenStore) &&
|
|
115
|
-
|
|
116
|
-
throw new Error('Missing required "clientId" or "accessToken" parameter
|
|
115
|
+
globalThis.window === undefined) {
|
|
116
|
+
throw new Error('Missing required "clientId" or "accessToken" parameter.');
|
|
117
117
|
}
|
|
118
118
|
const tokenRequester = makeFetchTokenRequester(`${options.oauthUrl}/oauth/token`);
|
|
119
119
|
const tokenStore = options.tokenStore ||
|
|
@@ -74,8 +74,8 @@ export interface ITicket {
|
|
|
74
74
|
readonly channels: readonly string[];
|
|
75
75
|
readonly commentCount: number;
|
|
76
76
|
readonly createdAt: string;
|
|
77
|
-
readonly customSettings?: readonly ICustomSettingsItem[];
|
|
78
77
|
readonly customerWaitingSinceIndicator: ETrafficLightColor;
|
|
78
|
+
readonly customSettings?: readonly ICustomSettingsItem[];
|
|
79
79
|
readonly description: string;
|
|
80
80
|
readonly files: readonly string[];
|
|
81
81
|
readonly id: string;
|
package/dist/src/rest/request.js
CHANGED
|
@@ -107,7 +107,7 @@ export function makeApiRequest(oauthTokenStore, oauthTokenRequester, options, ht
|
|
|
107
107
|
options.clientId ??
|
|
108
108
|
'no client id present'}`,
|
|
109
109
|
...(hasForm ? {} : { 'content-type': 'application/json' }),
|
|
110
|
-
...(
|
|
110
|
+
...(globalThis.window === undefined &&
|
|
111
111
|
typeof document === 'undefined' && { 'user-agent': USER_AGENT }),
|
|
112
112
|
...payload?.headers,
|
|
113
113
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function buildQueryString(params) {
|
|
2
2
|
const usp = new URLSearchParams();
|
|
3
3
|
for (const [key, value] of Object.entries(params).sort(([a], [b]) => a.localeCompare(b))) {
|
|
4
|
-
if (value
|
|
4
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
5
5
|
usp.append(key, String(value));
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allthings/sdk",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Allthings GmbH",
|
|
6
6
|
"keywords": [
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"bottleneck": "2.19.5"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@allthings/eslint-config": "
|
|
76
|
+
"@allthings/eslint-config": "4.0.0",
|
|
77
77
|
"@commitlint/cli": "21.0.1",
|
|
78
78
|
"@commitlint/config-conventional": "21.0.1",
|
|
79
79
|
"@rollup/plugin-commonjs": "29.0.2",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@types/node": "24.12.4",
|
|
84
84
|
"aws-sdk-client-mock": "4.1.0",
|
|
85
85
|
"coveralls": "3.1.1",
|
|
86
|
-
"eslint": "
|
|
86
|
+
"eslint": "10.4.0",
|
|
87
87
|
"husky": "9.1.7",
|
|
88
88
|
"jest": "30.4.2",
|
|
89
89
|
"jest-environment-jsdom": "30.4.1",
|