abmp-npm 10.0.77 → 10.0.79
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/backend/consts.js +1 -1
- package/backend/login/sso-methods.js +6 -7
- package/backend/pac-api-methods.js +19 -21
- package/package.json +1 -1
package/backend/consts.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const PAC_API_URL = 'https://members.abmp.com/eweb/api/Wix';
|
|
2
|
-
const TEST_PAC_API_URL = 'https://members.abmp.com/
|
|
2
|
+
const TEST_PAC_API_URL = 'https://members-test.abmp.com/eweb/api/Wix';
|
|
3
3
|
const BACKUP_API_URL = 'https://psdevteamenterpris.wixstudio.com/abmp-backup/_functions';
|
|
4
4
|
const SSO_TOKEN_AUTH_API_URL = 'https://members.professionalassistcorp.com/';
|
|
5
5
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { createHmac } = require('crypto');
|
|
2
2
|
|
|
3
|
+
const axios = require('axios');
|
|
3
4
|
const { decode } = require('jwt-js-decode');
|
|
4
5
|
|
|
5
6
|
const { CONFIG_KEYS, SSO_TOKEN_AUTH_API_URL } = require('../consts');
|
|
@@ -91,17 +92,15 @@ async function checkAndFetchSSO(token) {
|
|
|
91
92
|
const SSO_TOKEN_AUTH_API_KEY = await getSecret('SSO_TOKEN_AUTH_API_KEY');
|
|
92
93
|
const signature = createHmac('sha256', SSO_TOKEN_AUTH_API_KEY).update(token).digest('hex');
|
|
93
94
|
const professionalassistcorpUrl = `${SSO_TOKEN_AUTH_API_URL}/eweb/SSOToken.ashx?token=${token}&Partner=Wix&Signature=${signature}`;
|
|
94
|
-
const options = {
|
|
95
|
-
method: 'get',
|
|
96
|
-
};
|
|
97
95
|
try {
|
|
98
|
-
const httpResponse = await
|
|
96
|
+
const httpResponse = await axios.get(professionalassistcorpUrl);
|
|
99
97
|
console.log('httpResponse status', httpResponse.status);
|
|
100
|
-
if (
|
|
98
|
+
if (httpResponse.status < 200 || httpResponse.status >= 300) {
|
|
101
99
|
throw new Error('Fetch did not succeed with status: ' + httpResponse.status);
|
|
102
100
|
}
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
return typeof httpResponse.data === 'string'
|
|
102
|
+
? httpResponse.data
|
|
103
|
+
: JSON.stringify(httpResponse.data || '');
|
|
105
104
|
} catch (error) {
|
|
106
105
|
console.error('Error in checkAndFetchSSO', error);
|
|
107
106
|
return null;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
1
3
|
const { PAC_API_URL, TEST_PAC_API_URL, BACKUP_API_URL } = require('./consts');
|
|
2
4
|
const { getSecret } = require('./utils');
|
|
3
5
|
|
|
@@ -39,44 +41,40 @@ const fetchPACMembers = async ({ page, action, backupDate, isTestEnvironment })
|
|
|
39
41
|
|
|
40
42
|
try {
|
|
41
43
|
const headers = await getHeaders();
|
|
42
|
-
|
|
43
|
-
method: 'get',
|
|
44
|
-
headers,
|
|
45
|
-
};
|
|
46
|
-
console.log('[fetchPACMembers] fetchOptions', fetchOptions);
|
|
44
|
+
console.log('[fetchPACMembers] headers', headers);
|
|
47
45
|
console.log('[fetchPACMembers] url', url);
|
|
48
|
-
const response = await
|
|
49
|
-
|
|
50
|
-
const responseType = response.headers.get('content-type') || 'unknown';
|
|
46
|
+
const response = await axios.get(url, { headers });
|
|
47
|
+
const responseType = response.headers?.['content-type'] || 'unknown';
|
|
51
48
|
|
|
52
49
|
console.log('[fetchPACMembers] response', {
|
|
53
50
|
status: response.status,
|
|
54
|
-
ok: response.
|
|
51
|
+
ok: response.status >= 200 && response.status < 300,
|
|
55
52
|
contentType: responseType,
|
|
56
53
|
});
|
|
57
54
|
|
|
58
55
|
if (!responseType.includes('application/json')) {
|
|
59
|
-
const responseText = await response.text();
|
|
60
56
|
const errorMessage = `[fetchPACMembers] invalid responseType: ${responseType} for page ${page} and actionFilter ${action}`;
|
|
61
57
|
console.error(errorMessage, {
|
|
62
58
|
status: response.status,
|
|
63
|
-
bodySample:
|
|
59
|
+
bodySample: JSON.stringify(response.data)?.slice(0, 500),
|
|
64
60
|
});
|
|
65
61
|
throw new Error(errorMessage);
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
console.error(
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
return response.data;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (error?.response) {
|
|
67
|
+
console.error('[fetchPACMembers] request failed', {
|
|
68
|
+
page,
|
|
69
|
+
action,
|
|
70
|
+
backupDate: backupDate || null,
|
|
71
|
+
isTestEnvironment: Boolean(isTestEnvironment),
|
|
72
|
+
status: error.response.status,
|
|
73
|
+
contentType: error.response.headers?.['content-type'] || 'unknown',
|
|
74
|
+
bodySample: JSON.stringify(error.response.data)?.slice(0, 500),
|
|
74
75
|
});
|
|
75
|
-
throw
|
|
76
|
+
throw error;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
return response.json();
|
|
79
|
-
} catch (error) {
|
|
80
78
|
console.error('[fetchPACMembers] request failed', {
|
|
81
79
|
page,
|
|
82
80
|
action,
|