asma-helpers 0.3.13 → 0.3.14

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.
Files changed (92) hide show
  1. package/.prettierrc +15 -15
  2. package/.vscode/settings.json +40 -39
  3. package/README.md +0 -0
  4. package/lib/clients/srvAuth.d.ts +1 -1
  5. package/lib/clients/srvAuth.js +6 -6
  6. package/lib/global.d.ts +39 -39
  7. package/lib/global.js +4 -4
  8. package/lib/helpers/CapitalizeFistLetter.d.ts +2 -2
  9. package/lib/helpers/CapitalizeFistLetter.js +6 -6
  10. package/lib/helpers/Config.d.ts +5 -5
  11. package/lib/helpers/Config.js +44 -44
  12. package/lib/helpers/EnvironmentToOperateTypes.d.ts +7 -7
  13. package/lib/helpers/EnvironmentToOperateTypes.js +8 -8
  14. package/lib/helpers/EnvironmentsUrls.d.ts +93 -93
  15. package/lib/helpers/EnvironmentsUrls.js +89 -89
  16. package/lib/helpers/FormatNumberConstants.d.ts +26 -26
  17. package/lib/helpers/FormatNumberConstants.js +40 -40
  18. package/lib/helpers/InitializeIDBListenersOnMstSnapshots.d.ts +1 -1
  19. package/lib/helpers/InitializeIDBListenersOnMstSnapshots.js +49 -49
  20. package/lib/helpers/InitializeIDBListenersOnMstSnapshotsThenCatch.d.ts +8 -8
  21. package/lib/helpers/InitializeIDBListenersOnMstSnapshotsThenCatch.js +68 -68
  22. package/lib/helpers/IsAdcuris.d.ts +2 -2
  23. package/lib/helpers/IsAdcuris.js +4 -4
  24. package/lib/helpers/IsNotEmpty.d.ts +1 -1
  25. package/lib/helpers/IsNotEmpty.js +3 -3
  26. package/lib/helpers/NorwegianPostalCodes.d.ts +8 -8
  27. package/lib/helpers/NorwegianPostalCodes.js +3 -3
  28. package/lib/helpers/ProcessServerError.d.ts +2 -2
  29. package/lib/helpers/ProcessServerError.js +100 -100
  30. package/lib/helpers/attachUserJournalCredentials.d.ts +1 -1
  31. package/lib/helpers/attachUserJournalCredentials.js +16 -16
  32. package/lib/helpers/base64ToFile.d.ts +1 -1
  33. package/lib/helpers/base64ToFile.js +8 -8
  34. package/lib/helpers/clearCacheData.d.ts +1 -1
  35. package/lib/helpers/clearCacheData.js +12 -12
  36. package/lib/helpers/generateEnvConfigsBindings.d.ts +30 -30
  37. package/lib/helpers/generateEnvConfigsBindings.js +48 -48
  38. package/lib/helpers/generateGenqlClient.d.ts +19 -19
  39. package/lib/helpers/generateGenqlClient.js +72 -72
  40. package/lib/helpers/generateSrvAuthBindings.d.ts +65 -65
  41. package/lib/helpers/generateSrvAuthBindings.js +196 -196
  42. package/lib/helpers/getGqlOperationName.d.ts +1 -1
  43. package/lib/helpers/getGqlOperationName.js +15 -15
  44. package/lib/helpers/getSubdomain.d.ts +12 -12
  45. package/lib/helpers/getSubdomain.js +39 -39
  46. package/lib/helpers/isValidUrl.d.ts +1 -1
  47. package/lib/helpers/isValidUrl.js +9 -9
  48. package/lib/helpers/parseJwt.d.ts +1 -1
  49. package/lib/helpers/parseJwt.js +7 -7
  50. package/lib/helpers/userTypingSignal.d.ts +4 -4
  51. package/lib/helpers/userTypingSignal.js +32 -32
  52. package/lib/index.d.ts +28 -28
  53. package/lib/index.js +26 -26
  54. package/lib/interfaces/api/advoca/ISaveToDataBase.d.ts +16 -16
  55. package/lib/interfaces/api/advoca/ISaveToDataBase.js +1 -1
  56. package/lib/interfaces/api/advoca/IUploadedDocument.d.ts +26 -26
  57. package/lib/interfaces/api/advoca/IUploadedDocument.js +1 -1
  58. package/lib/interfaces/enums.d.ts +50 -50
  59. package/lib/interfaces/enums.js +59 -59
  60. package/lib/utility/fetch.d.ts +1 -1
  61. package/lib/utility/fetch.js +5 -5
  62. package/package.json +30 -30
  63. package/src/clients/srvAuth.ts +6 -6
  64. package/src/global.ts +46 -46
  65. package/src/helpers/CapitalizeFistLetter.ts +7 -7
  66. package/src/helpers/Config.ts +58 -58
  67. package/src/helpers/EnvironmentToOperateTypes.ts +6 -6
  68. package/src/helpers/EnvironmentsUrls.ts +102 -102
  69. package/src/helpers/FormatNumberConstants.ts +42 -42
  70. package/src/helpers/InitializeIDBListenersOnMstSnapshots.ts +62 -62
  71. package/src/helpers/InitializeIDBListenersOnMstSnapshotsThenCatch.ts +82 -82
  72. package/src/helpers/IsAdcuris.ts +4 -4
  73. package/src/helpers/IsNotEmpty.ts +2 -2
  74. package/src/helpers/NorwegianPostalCodes.ts +6 -6
  75. package/src/helpers/ProcessServerError.ts +92 -92
  76. package/src/helpers/attachUserJournalCredentials.ts +23 -23
  77. package/src/helpers/base64ToFile.ts +9 -9
  78. package/src/helpers/checkForRegisteredSubdomains.ts +76 -0
  79. package/src/helpers/clearCacheData.ts +12 -16
  80. package/src/helpers/generateEnvConfigsBindings.ts +82 -82
  81. package/src/helpers/generateGenqlClient.ts +113 -113
  82. package/src/helpers/generateSrvAuthBindings.ts +276 -272
  83. package/src/helpers/getGqlOperationName.ts +20 -20
  84. package/src/helpers/getSubdomain.ts +51 -50
  85. package/src/helpers/isValidUrl.ts +12 -12
  86. package/src/helpers/parseJwt.ts +10 -10
  87. package/src/index.ts +35 -34
  88. package/src/interfaces/api/advoca/ISaveToDataBase.ts +17 -17
  89. package/src/interfaces/api/advoca/IUploadedDocument.ts +23 -23
  90. package/src/interfaces/enums.ts +56 -56
  91. package/src/utility/fetch.ts +9 -9
  92. package/tsconfig.json +84 -84
@@ -1,197 +1,197 @@
1
- import axios from 'axios';
2
- import { EventBus } from 'asma-event-bus/lib/event-buss';
3
- import { EnvironmentEnums, parseJwt } from '..';
4
- //let logoutsuccesfull = false
5
- export const { dispatch: dispatchSrvAuthEvents, register: registerCallbackOnSrvAuthEvents } = EventBus('auth-bindings');
6
- function dispatchLogoutEvent() {
7
- dispatchSrvAuthEvents('logout_event', {}, false);
8
- }
9
- function dispatchJwtChangedEvent() {
10
- dispatchSrvAuthEvents('jwt_changed', {}, false);
11
- }
12
- export function generateSrvAuthBindings(SRV_AUTH, DEVELOPMENT, EnvironmentToOperateFn, logout) {
13
- var _a;
14
- if (logout) {
15
- registerCallbackOnSrvAuthEvents('logout_event', logout);
16
- }
17
- if ((_a = window.__ASMA__SHELL__) === null || _a === void 0 ? void 0 : _a.auth_bindings) {
18
- return window.__ASMA__SHELL__.auth_bindings;
19
- }
20
- let jwtToken = '';
21
- let features;
22
- let connector;
23
- let parsed_jwt;
24
- const isJwtInvalid = () => (jwtToken && accessTokenHasExpired()) || !jwtToken;
25
- const isJwtValid = () => !isJwtInvalid();
26
- const promiseRegistry = {};
27
- async function srvAuthGet(url, headers) {
28
- if (DEVELOPMENT() && EnvironmentToOperateFn()) {
29
- if (EnvironmentToOperateFn() in EnvironmentEnums) {
30
- url = `${url}&env=${EnvironmentToOperateFn()}`;
31
- // file deepcode ignore GlobalReplacementRegex: <it is intended to be replaced only first occurence>
32
- url = url.includes('&') && !url.includes('?') ? url.replace('&', '?') : url;
33
- }
34
- else {
35
- console.warn('EnvironmentToOperateFn() is not a valid EnvironmentEnums', 'shall be one of:', EnvironmentEnums, 'actual value:', EnvironmentToOperateFn());
36
- }
37
- }
38
- const promise = promiseRegistry[url] ||
39
- axios.get(`${SRV_AUTH()}${url}`, {
40
- headers: {
41
- ...headers,
42
- 'asma-origin': window.location.origin,
43
- },
44
- withCredentials: true,
45
- });
46
- if (!promiseRegistry[url]) {
47
- promiseRegistry[url] = promise;
48
- }
49
- const res = await promise.finally(() => {
50
- delete promiseRegistry[url];
51
- });
52
- return res;
53
- }
54
- function accessTokenHasExpired() {
55
- const tokenObj = getParsedJwt();
56
- const accessTokenExpDate = (tokenObj === null || tokenObj === void 0 ? void 0 : tokenObj.exp) || 0;
57
- const nowTime = Math.floor(new Date().getTime() / 1000);
58
- return accessTokenExpDate - 10 <= nowTime;
59
- }
60
- /**
61
- *
62
- * TODO: need to investigate smarter way of registerning and unregistering on `logout_event`
63
- **/
64
- registerCallbackOnSrvAuthEvents('logout_event', () => {
65
- setAuthData({ token: '' });
66
- srvAuthGet('/signout');
67
- });
68
- async function signin(url, headers) {
69
- const data = await srvAuthGet(url, headers);
70
- setAuthData(data === null || data === void 0 ? void 0 : data.data);
71
- return data;
72
- }
73
- function getUserId() {
74
- var _a;
75
- return ((_a = getParsedJwt()) === null || _a === void 0 ? void 0 : _a['user_id']) || '-1';
76
- }
77
- function setAuthData(data) {
78
- if (data === null || data === void 0 ? void 0 : data.token) {
79
- jwtToken = data === null || data === void 0 ? void 0 : data.token;
80
- features = new Set(data.features);
81
- connector = data.connector;
82
- parsed_jwt = parseJwt(jwtToken);
83
- dispatchJwtChangedEvent();
84
- return;
85
- }
86
- jwtToken = '';
87
- parsed_jwt = undefined;
88
- features = undefined;
89
- connector = undefined;
90
- }
91
- function getJwtToken() {
92
- return jwtToken;
93
- }
94
- async function getCachedJwt() {
95
- if (isJwtInvalid()) {
96
- const new_jwt = await getNewJwtToken();
97
- return new_jwt;
98
- }
99
- else {
100
- return jwtToken;
101
- }
102
- }
103
- async function setReqConfig(data, responseType) {
104
- const token = await getCachedJwt();
105
- const res = {
106
- data: data,
107
- responseType: responseType,
108
- headers: {},
109
- };
110
- if (token) {
111
- res.headers['Authorization'] = `Bearer ${token}`;
112
- }
113
- return res;
114
- }
115
- async function getNewJwtToken() {
116
- var _a;
117
- try {
118
- /* if (!fetchJwtPromise) {
119
- fetchJwtPromise = srvAuthGet('/token')
120
- } */
121
- const data = await srvAuthGet('/token');
122
- if (!data || ((_a = data.data) === null || _a === void 0 ? void 0 : _a.errors) || !data.data.token) {
123
- dispatchLogoutEvent();
124
- return;
125
- }
126
- setAuthData({ token: data.data.token, features: data.data.features || [], connector: data.data.connector });
127
- return jwtToken;
128
- }
129
- catch (error) {
130
- dispatchLogoutEvent();
131
- console.error(error);
132
- return jwtToken;
133
- }
134
- }
135
- function getParsedJwt() {
136
- if (!parsed_jwt) {
137
- parsed_jwt = parseJwt(jwtToken);
138
- }
139
- return parsed_jwt;
140
- }
141
- function getFeatures() {
142
- return features;
143
- }
144
- /**
145
- *
146
- * @param featureName feature_name_enums add this: generateSrvAuthBindings<feature_name_enums.>(...)
147
- * @returns boolean
148
- */
149
- function hasFeature(featureName) {
150
- return !!(features === null || features === void 0 ? void 0 : features.has(featureName));
151
- }
152
- function getConnector() {
153
- return connector;
154
- }
155
- const auth_bindings = {
156
- hasFeature,
157
- getConnector,
158
- getFeatures,
159
- isJwtValid,
160
- signin,
161
- srvAuthGet,
162
- /**
163
- * @deprecated use dispatchLogoutEvent directly
164
- */
165
- signoutAuth: dispatchLogoutEvent,
166
- dispatchLogoutEvent,
167
- setReqConfig,
168
- /**
169
- * @deprecated use getCachedJwt
170
- * */
171
- getJwtTokenAsync: getCachedJwt,
172
- getCachedJwt,
173
- getNewJwtToken,
174
- /**
175
- * @deprecated use registerCallbackOnSrvAuthEvents directly
176
- */
177
- registerOnJwtChanges: registerCallbackOnSrvAuthEvents,
178
- getUserId,
179
- getParsedJwt,
180
- getJwtToken,
181
- // cancelRequest,
182
- accessTokenHasExpired,
183
- };
184
- window.__ASMA__SHELL__ = window.__ASMA__SHELL__ || {};
185
- window.__ASMA__SHELL__.auth_bindings = auth_bindings;
186
- return auth_bindings;
187
- }
188
- /**
189
- * @deprecated use generateSrvAuthBindings
190
- *
191
- */
192
- export function generateSrvAuthBindingsMicroApp(SRV_AUTH, DEVELOPMENT, ENVIRONMENT_TO_OPERATE, logout) {
193
- var _a;
194
- return (((_a = window.__ASMA__SHELL__) === null || _a === void 0 ? void 0 : _a.auth_bindings) ||
195
- generateSrvAuthBindings(SRV_AUTH, DEVELOPMENT, ENVIRONMENT_TO_OPERATE, logout));
196
- }
1
+ import axios from 'axios';
2
+ import { EventBus } from 'asma-event-bus/lib/event-buss';
3
+ import { EnvironmentEnums, parseJwt } from '..';
4
+ //let logoutsuccesfull = false
5
+ export const { dispatch: dispatchSrvAuthEvents, register: registerCallbackOnSrvAuthEvents } = EventBus('auth-bindings');
6
+ function dispatchLogoutEvent() {
7
+ dispatchSrvAuthEvents('logout_event', {}, false);
8
+ }
9
+ function dispatchJwtChangedEvent() {
10
+ dispatchSrvAuthEvents('jwt_changed', {}, false);
11
+ }
12
+ export function generateSrvAuthBindings(SRV_AUTH, DEVELOPMENT, EnvironmentToOperateFn, logout) {
13
+ var _a;
14
+ if (logout) {
15
+ registerCallbackOnSrvAuthEvents('logout_event', logout);
16
+ }
17
+ if ((_a = window.__ASMA__SHELL__) === null || _a === void 0 ? void 0 : _a.auth_bindings) {
18
+ return window.__ASMA__SHELL__.auth_bindings;
19
+ }
20
+ let jwtToken = '';
21
+ let features;
22
+ let connector;
23
+ let parsed_jwt;
24
+ const isJwtInvalid = () => (jwtToken && accessTokenHasExpired()) || !jwtToken;
25
+ const isJwtValid = () => !isJwtInvalid();
26
+ const promiseRegistry = {};
27
+ async function srvAuthGet(url, headers) {
28
+ if (DEVELOPMENT() && EnvironmentToOperateFn()) {
29
+ if (EnvironmentToOperateFn() in EnvironmentEnums) {
30
+ url = `${url}&env=${EnvironmentToOperateFn()}`;
31
+ // file deepcode ignore GlobalReplacementRegex: <it is intended to be replaced only first occurence>
32
+ url = url.includes('&') && !url.includes('?') ? url.replace('&', '?') : url;
33
+ }
34
+ else {
35
+ console.warn('EnvironmentToOperateFn() is not a valid EnvironmentEnums', 'shall be one of:', EnvironmentEnums, 'actual value:', EnvironmentToOperateFn());
36
+ }
37
+ }
38
+ const promise = promiseRegistry[url] ||
39
+ axios.get(`${SRV_AUTH()}${url}`, {
40
+ headers: {
41
+ ...headers,
42
+ 'asma-origin': window.location.origin,
43
+ },
44
+ withCredentials: true,
45
+ });
46
+ if (!promiseRegistry[url]) {
47
+ promiseRegistry[url] = promise;
48
+ }
49
+ const res = await promise.finally(() => {
50
+ delete promiseRegistry[url];
51
+ });
52
+ return res;
53
+ }
54
+ function accessTokenHasExpired() {
55
+ const tokenObj = getParsedJwt();
56
+ const accessTokenExpDate = (tokenObj === null || tokenObj === void 0 ? void 0 : tokenObj.exp) || 0;
57
+ const nowTime = Math.floor(new Date().getTime() / 1000);
58
+ return accessTokenExpDate - 10 <= nowTime;
59
+ }
60
+ /**
61
+ *
62
+ * TODO: need to investigate smarter way of registerning and unregistering on `logout_event`
63
+ **/
64
+ registerCallbackOnSrvAuthEvents('logout_event', () => {
65
+ setAuthData({ token: '' });
66
+ srvAuthGet('/signout');
67
+ });
68
+ async function signin(url, headers) {
69
+ const data = await srvAuthGet(url, headers);
70
+ setAuthData(data === null || data === void 0 ? void 0 : data.data);
71
+ return data;
72
+ }
73
+ function getUserId() {
74
+ var _a;
75
+ return ((_a = getParsedJwt()) === null || _a === void 0 ? void 0 : _a['user_id']) || '-1';
76
+ }
77
+ function setAuthData(data) {
78
+ if (data === null || data === void 0 ? void 0 : data.token) {
79
+ jwtToken = data === null || data === void 0 ? void 0 : data.token;
80
+ features = new Set(data.features);
81
+ connector = data.connector;
82
+ parsed_jwt = parseJwt(jwtToken);
83
+ dispatchJwtChangedEvent();
84
+ return;
85
+ }
86
+ jwtToken = '';
87
+ parsed_jwt = undefined;
88
+ features = undefined;
89
+ connector = undefined;
90
+ }
91
+ function getJwtToken() {
92
+ return jwtToken;
93
+ }
94
+ async function getCachedJwt() {
95
+ if (isJwtInvalid()) {
96
+ const new_jwt = await getNewJwtToken();
97
+ return new_jwt;
98
+ }
99
+ else {
100
+ return jwtToken;
101
+ }
102
+ }
103
+ async function setReqConfig(data, responseType) {
104
+ const token = await getCachedJwt();
105
+ const res = {
106
+ data: data,
107
+ responseType: responseType,
108
+ headers: {},
109
+ };
110
+ if (token) {
111
+ res.headers['Authorization'] = `Bearer ${token}`;
112
+ }
113
+ return res;
114
+ }
115
+ async function getNewJwtToken() {
116
+ var _a;
117
+ try {
118
+ /* if (!fetchJwtPromise) {
119
+ fetchJwtPromise = srvAuthGet('/token')
120
+ } */
121
+ const data = await srvAuthGet('/token');
122
+ if (!data || ((_a = data.data) === null || _a === void 0 ? void 0 : _a.errors) || !data.data.token) {
123
+ dispatchLogoutEvent();
124
+ return;
125
+ }
126
+ setAuthData({ token: data.data.token, features: data.data.features || [], connector: data.data.connector });
127
+ return jwtToken;
128
+ }
129
+ catch (error) {
130
+ dispatchLogoutEvent();
131
+ console.error(error);
132
+ return jwtToken;
133
+ }
134
+ }
135
+ function getParsedJwt() {
136
+ if (!parsed_jwt) {
137
+ parsed_jwt = parseJwt(jwtToken);
138
+ }
139
+ return parsed_jwt;
140
+ }
141
+ function getFeatures() {
142
+ return features;
143
+ }
144
+ /**
145
+ *
146
+ * @param featureName feature_name_enums add this: generateSrvAuthBindings<feature_name_enums.>(...)
147
+ * @returns boolean
148
+ */
149
+ function hasFeature(featureName) {
150
+ return !!(features === null || features === void 0 ? void 0 : features.has(featureName));
151
+ }
152
+ function getConnector() {
153
+ return connector;
154
+ }
155
+ const auth_bindings = {
156
+ hasFeature,
157
+ getConnector,
158
+ getFeatures,
159
+ isJwtValid,
160
+ signin,
161
+ srvAuthGet,
162
+ /**
163
+ * @deprecated use dispatchLogoutEvent directly
164
+ */
165
+ signoutAuth: dispatchLogoutEvent,
166
+ dispatchLogoutEvent,
167
+ setReqConfig,
168
+ /**
169
+ * @deprecated use getCachedJwt
170
+ * */
171
+ getJwtTokenAsync: getCachedJwt,
172
+ getCachedJwt,
173
+ getNewJwtToken,
174
+ /**
175
+ * @deprecated use registerCallbackOnSrvAuthEvents directly
176
+ */
177
+ registerOnJwtChanges: registerCallbackOnSrvAuthEvents,
178
+ getUserId,
179
+ getParsedJwt,
180
+ getJwtToken,
181
+ // cancelRequest,
182
+ accessTokenHasExpired,
183
+ };
184
+ window.__ASMA__SHELL__ = window.__ASMA__SHELL__ || {};
185
+ window.__ASMA__SHELL__.auth_bindings = auth_bindings;
186
+ return auth_bindings;
187
+ }
188
+ /**
189
+ * @deprecated use generateSrvAuthBindings
190
+ *
191
+ */
192
+ export function generateSrvAuthBindingsMicroApp(SRV_AUTH, DEVELOPMENT, ENVIRONMENT_TO_OPERATE, logout) {
193
+ var _a;
194
+ return (((_a = window.__ASMA__SHELL__) === null || _a === void 0 ? void 0 : _a.auth_bindings) ||
195
+ generateSrvAuthBindings(SRV_AUTH, DEVELOPMENT, ENVIRONMENT_TO_OPERATE, logout));
196
+ }
197
197
  //# sourceMappingURL=generateSrvAuthBindings.js.map
@@ -1,2 +1,2 @@
1
- export declare function getGqlOperationName(query: string): string | undefined;
1
+ export declare function getGqlOperationName(query: string): string | undefined;
2
2
  //# sourceMappingURL=getGqlOperationName.d.ts.map
@@ -1,16 +1,16 @@
1
- export function getGqlOperationName(query) {
2
- var _a, _b, _c, _d, _e;
3
- const is_query = query.includes('query') ? 'query' : undefined;
4
- const is_mutation = query.includes('mutation') ? 'mutation' : undefined;
5
- const is_subscription = query.includes('subscription') ? 'subscription' : undefined;
6
- const split_word = is_query || is_mutation || is_subscription;
7
- if (!split_word) {
8
- return undefined;
9
- }
10
- let operationName = (_e = (_d = (_c = (_b = (_a = query === null || query === void 0 ? void 0 : query.split(split_word, 2)) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.split('{', 1)[0]) === null || _c === void 0 ? void 0 : _c.split(' ')) === null || _d === void 0 ? void 0 : _d[1]) === null || _e === void 0 ? void 0 : _e.trim();
11
- if (operationName === null || operationName === void 0 ? void 0 : operationName.includes('(')) {
12
- operationName = operationName.split('(', 1)[0];
13
- }
14
- return operationName;
15
- }
1
+ export function getGqlOperationName(query) {
2
+ var _a, _b, _c, _d, _e;
3
+ const is_query = query.includes('query') ? 'query' : undefined;
4
+ const is_mutation = query.includes('mutation') ? 'mutation' : undefined;
5
+ const is_subscription = query.includes('subscription') ? 'subscription' : undefined;
6
+ const split_word = is_query || is_mutation || is_subscription;
7
+ if (!split_word) {
8
+ return undefined;
9
+ }
10
+ let operationName = (_e = (_d = (_c = (_b = (_a = query === null || query === void 0 ? void 0 : query.split(split_word, 2)) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.split('{', 1)[0]) === null || _c === void 0 ? void 0 : _c.split(' ')) === null || _d === void 0 ? void 0 : _d[1]) === null || _e === void 0 ? void 0 : _e.trim();
11
+ if (operationName === null || operationName === void 0 ? void 0 : operationName.includes('(')) {
12
+ operationName = operationName.split('(', 1)[0];
13
+ }
14
+ return operationName;
15
+ }
16
16
  //# sourceMappingURL=getGqlOperationName.js.map
@@ -1,13 +1,13 @@
1
- /**
2
- * @deprecated moved to asma-genql-directory use from there
3
- */
4
- export declare const subdomain: string;
5
- /**
6
- * @deprecated moved to asma-genql-directory use from there
7
- */
8
- export declare function redirectFromSubdomainToDomain(): null;
9
- /**
10
- * @deprecated moved to asma-genql-directory use from there
11
- */
12
- export declare function createDomainUrlFromSubdomain(): string;
1
+ /**
2
+ * @deprecated moved to asma-genql-directory use from there
3
+ */
4
+ export declare const subdomain: string;
5
+ /**
6
+ * @deprecated moved to asma-genql-directory use from there
7
+ */
8
+ export declare function redirectFromSubdomainToDomain(): null;
9
+ /**
10
+ * @deprecated moved to asma-genql-directory use from there
11
+ */
12
+ export declare function createDomainUrlFromSubdomain(): string;
13
13
  //# sourceMappingURL=getSubdomain.d.ts.map
@@ -1,40 +1,40 @@
1
- /**
2
- * @deprecated moved to asma-genql-directory use from there
3
- */
4
- function getSubdomain() {
5
- const hostname_arr = window.location.hostname.split('.'); // fretex-dfsf.advoca.no
6
- let subdomain = '';
7
- if (hostname_arr.length === 3 &&
8
- hostname_arr[0] &&
9
- !['dev', 'test', 'stage', 'intern', 'www'].find((sub) => sub === hostname_arr[0])) {
10
- subdomain = hostname_arr[0];
11
- const subdomain_arr = subdomain.split('-');
12
- if (subdomain_arr.length === 2 && subdomain_arr[0]) {
13
- subdomain = subdomain_arr[0];
14
- }
15
- }
16
- return subdomain;
17
- }
18
- /**
19
- * @deprecated moved to asma-genql-directory use from there
20
- */
21
- export const subdomain = getSubdomain();
22
- /**
23
- * @deprecated moved to asma-genql-directory use from there
24
- */
25
- export function redirectFromSubdomainToDomain() {
26
- const domain_hostname = `${createDomainUrlFromSubdomain()}${window.location.pathname}`;
27
- window.location.href = domain_hostname;
28
- return null;
29
- }
30
- /**
31
- * @deprecated moved to asma-genql-directory use from there
32
- */
33
- export function createDomainUrlFromSubdomain() {
34
- let hostname = window.location.hostname.replace(subdomain, '');
35
- (hostname.startsWith('-') && (hostname = hostname.substring(1))) ||
36
- (hostname.startsWith('.') && (hostname = 'www' + hostname));
37
- const { port, protocol } = window.location;
38
- return protocol + '//' + hostname + (port ? `:${port}` : '');
39
- }
1
+ /**
2
+ * @deprecated moved to asma-genql-directory use from there
3
+ */
4
+ function getSubdomain() {
5
+ const hostname_arr = window.location.hostname.split('.'); // fretex-dfsf.advoca.no
6
+ let subdomain = '';
7
+ if (hostname_arr.length === 3 &&
8
+ hostname_arr[0] &&
9
+ !['dev', 'test', 'stage', 'intern', 'www'].find((sub) => sub === hostname_arr[0])) {
10
+ subdomain = hostname_arr[0];
11
+ const subdomain_arr = subdomain.split('-');
12
+ if (subdomain_arr.length === 2 && subdomain_arr[0]) {
13
+ subdomain = subdomain_arr[0];
14
+ }
15
+ }
16
+ return subdomain;
17
+ }
18
+ /**
19
+ * @deprecated moved to asma-genql-directory use from there
20
+ */
21
+ export const subdomain = getSubdomain();
22
+ /**
23
+ * @deprecated moved to asma-genql-directory use from there
24
+ */
25
+ export function redirectFromSubdomainToDomain() {
26
+ const domain_hostname = `${createDomainUrlFromSubdomain()}${window.location.pathname}`;
27
+ window.location.href = domain_hostname;
28
+ return null;
29
+ }
30
+ /**
31
+ * @deprecated moved to asma-genql-directory use from there
32
+ */
33
+ export function createDomainUrlFromSubdomain() {
34
+ let hostname = window.location.hostname.replace(subdomain, '');
35
+ (hostname.startsWith('-') && (hostname = hostname.substring(1))) ||
36
+ (hostname.startsWith('.') && (hostname = 'www' + hostname));
37
+ const { port, protocol } = window.location;
38
+ return protocol + '//' + hostname + (port ? `:${port}` : '');
39
+ }
40
40
  //# sourceMappingURL=getSubdomain.js.map
@@ -1,2 +1,2 @@
1
- export declare function isValidUrl(urlString: string): boolean;
1
+ export declare function isValidUrl(urlString: string): boolean;
2
2
  //# sourceMappingURL=isValidUrl.d.ts.map
@@ -1,10 +1,10 @@
1
- export function isValidUrl(urlString) {
2
- const urlPattern = new RegExp('^(https?:\\/\\/)?' + // validate protocol
3
- '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // validate domain name
4
- '((\\d{1,3}\\.){3}\\d{1,3}))' + // validate OR ip (v4) address
5
- '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // validate port and path
6
- '(\\?[;&a-z\\d%_.~+=-]*)?' + // validate query string
7
- '(\\#[-a-z\\d_]*)?$', 'i');
8
- return !!urlPattern.test(urlString);
9
- }
1
+ export function isValidUrl(urlString) {
2
+ const urlPattern = new RegExp('^(https?:\\/\\/)?' + // validate protocol
3
+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // validate domain name
4
+ '((\\d{1,3}\\.){3}\\d{1,3}))' + // validate OR ip (v4) address
5
+ '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // validate port and path
6
+ '(\\?[;&a-z\\d%_.~+=-]*)?' + // validate query string
7
+ '(\\#[-a-z\\d_]*)?$', 'i');
8
+ return !!urlPattern.test(urlString);
9
+ }
10
10
  //# sourceMappingURL=isValidUrl.js.map
@@ -1,2 +1,2 @@
1
- export declare function parseJwt<R>(jwtToken: string): R | undefined;
1
+ export declare function parseJwt<R>(jwtToken: string): R | undefined;
2
2
  //# sourceMappingURL=parseJwt.d.ts.map
@@ -1,8 +1,8 @@
1
- export function parseJwt(jwtToken) {
2
- const base64Url = jwtToken === null || jwtToken === void 0 ? void 0 : jwtToken.split('.')[1];
3
- if (!base64Url) {
4
- return;
5
- }
6
- return JSON.parse(decodeURIComponent(escape(window.atob(base64Url))));
7
- }
1
+ export function parseJwt(jwtToken) {
2
+ const base64Url = jwtToken === null || jwtToken === void 0 ? void 0 : jwtToken.split('.')[1];
3
+ if (!base64Url) {
4
+ return;
5
+ }
6
+ return JSON.parse(decodeURIComponent(escape(window.atob(base64Url))));
7
+ }
8
8
  //# sourceMappingURL=parseJwt.js.map
@@ -1,5 +1,5 @@
1
- export declare function userTypingSignal(insertUserLastTyped: () => Promise<unknown>): {
2
- initiateUserTyping: () => void;
3
- setLastTyped: () => void;
4
- };
1
+ export declare function userTypingSignal(insertUserLastTyped: () => Promise<unknown>): {
2
+ initiateUserTyping: () => void;
3
+ setLastTyped: () => void;
4
+ };
5
5
  //# sourceMappingURL=userTypingSignal.d.ts.map