@gofynd/fdk-client-javascript 1.0.3 → 1.1.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/README.md +51 -2
- package/index.d.ts +7 -4
- package/index.js +22 -7
- package/package.json +23 -14
- package/partner.d.ts +4 -0
- package/partner.js +7 -0
- package/sdk/application/ApplicationAPIClient.js +2 -4
- package/sdk/application/Cart/CartApplicationClient.js +29 -28
- package/sdk/application/Cart/CartApplicationModel.js +3 -1
- package/sdk/application/Catalog/CatalogApplicationClient.js +43 -42
- package/sdk/application/Catalog/CatalogApplicationModel.js +5 -3
- package/sdk/application/Common/CommonApplicationClient.js +5 -4
- package/sdk/application/Communication/CommunicationApplicationClient.js +6 -5
- package/sdk/application/Configuration/ConfigurationApplicationClient.js +21 -20
- package/sdk/application/Content/ContentApplicationClient.js +26 -25
- package/sdk/application/FileStorage/FileStorageApplicationClient.js +6 -5
- package/sdk/application/Lead/LeadApplicationClient.js +10 -9
- package/sdk/application/Logistic/LogisticApplicationClient.d.ts +1 -3
- package/sdk/application/Logistic/LogisticApplicationClient.js +11 -12
- package/sdk/application/Logistic/LogisticApplicationValidator.js +0 -1
- package/sdk/application/Order/OrderApplicationClient.js +15 -14
- package/sdk/application/Order/OrderApplicationModel.js +9 -0
- package/sdk/application/Payment/PaymentApplicationClient.js +42 -41
- package/sdk/application/PosCart/PosCartApplicationClient.js +30 -29
- package/sdk/application/PosCart/PosCartApplicationModel.js +3 -1
- package/sdk/application/Rewards/RewardsApplicationClient.js +11 -10
- package/sdk/application/Share/ShareApplicationClient.js +10 -9
- package/sdk/application/Theme/ThemeApplicationClient.js +7 -6
- package/sdk/application/User/UserApplicationClient.js +38 -37
- package/sdk/common/AxiosHelper.js +17 -6
- package/sdk/common/BaseOAuthClient.d.ts +17 -0
- package/sdk/common/BaseOAuthClient.js +67 -0
- package/sdk/common/RequestSigner.js +0 -5
- package/sdk/partner/OAuthClient.d.ts +14 -0
- package/sdk/partner/OAuthClient.js +112 -0
- package/sdk/partner/PartnerAPIClient.d.ts +12 -0
- package/sdk/partner/PartnerAPIClient.js +42 -0
- package/sdk/partner/PartnerClient.d.ts +6 -0
- package/sdk/partner/PartnerClient.js +17 -0
- package/sdk/partner/PartnerConfig.d.ts +30 -0
- package/sdk/partner/PartnerConfig.js +39 -0
- package/sdk/partner/index.d.ts +3 -0
- package/sdk/partner/index.js +5 -0
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +3 -1
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Analytics/AnalyticsPlatformClient.js +5 -4
- package/sdk/platform/Analytics/AnalyticsPlatformValidator.js +1 -0
- package/sdk/platform/AuditTrail/AuditTrailPlatformClient.js +3 -2
- package/sdk/platform/AuditTrail/AuditTrailPlatformValidator.js +1 -0
- package/sdk/platform/Billing/BillingPlatformClient.d.ts +24 -0
- package/sdk/platform/Billing/BillingPlatformClient.js +137 -2
- package/sdk/platform/Billing/BillingPlatformModel.d.ts +4 -0
- package/sdk/platform/Billing/BillingPlatformModel.js +44 -0
- package/sdk/platform/Billing/BillingPlatformValidator.d.ts +2 -0
- package/sdk/platform/Billing/BillingPlatformValidator.js +15 -0
- package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +27 -0
- package/sdk/platform/Cart/CartPlatformApplicationClient.js +177 -1
- package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +3 -0
- package/sdk/platform/Cart/CartPlatformApplicationValidator.js +17 -1
- package/sdk/platform/Cart/CartPlatformModel.js +7 -3
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +3 -1
- package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +2 -2
- package/sdk/platform/Catalog/CatalogPlatformClient.js +6 -9
- package/sdk/platform/Catalog/CatalogPlatformModel.js +9 -9
- package/sdk/platform/Catalog/CatalogPlatformValidator.js +2 -1
- package/sdk/platform/Common/CommonPlatformClient.js +7 -18
- package/sdk/platform/Common/CommonPlatformValidator.js +1 -0
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +3 -1
- package/sdk/platform/Communication/CommunicationPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Communication/CommunicationPlatformClient.js +4 -3
- package/sdk/platform/Communication/CommunicationPlatformValidator.js +1 -0
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +5 -4
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformValidator.js +1 -0
- package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +3 -1
- package/sdk/platform/Configuration/ConfigurationPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Configuration/ConfigurationPlatformClient.js +9 -8
- package/sdk/platform/Configuration/ConfigurationPlatformValidator.js +1 -0
- package/sdk/platform/Content/ContentPlatformApplicationClient.js +3 -1
- package/sdk/platform/Content/ContentPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Discount/DiscountPlatformClient.js +3 -2
- package/sdk/platform/Discount/DiscountPlatformValidator.js +1 -0
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.d.ts +3 -3
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.js +27 -5
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationValidator.js +1 -1
- package/sdk/platform/FileStorage/FileStoragePlatformClient.d.ts +3 -3
- package/sdk/platform/FileStorage/FileStoragePlatformClient.js +28 -6
- package/sdk/platform/FileStorage/FileStoragePlatformValidator.js +1 -0
- package/sdk/platform/Inventory/InventoryPlatformClient.js +3 -2
- package/sdk/platform/Inventory/InventoryPlatformValidator.js +1 -0
- package/sdk/platform/Lead/LeadPlatformApplicationClient.js +3 -1
- package/sdk/platform/Lead/LeadPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Lead/LeadPlatformClient.js +4 -3
- package/sdk/platform/Lead/LeadPlatformValidator.js +1 -0
- package/sdk/platform/OAuthClient.js +3 -9
- package/sdk/platform/Order/OrderPlatformApplicationClient.js +3 -1
- package/sdk/platform/Order/OrderPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Order/OrderPlatformClient.d.ts +1 -1
- package/sdk/platform/Order/OrderPlatformClient.js +16 -3
- package/sdk/platform/Order/OrderPlatformModel.js +1 -0
- package/sdk/platform/Order/OrderPlatformValidator.js +1 -0
- package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +3 -1
- package/sdk/platform/Partner/PartnerPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +1 -1
- package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +14 -14
- package/sdk/platform/Payment/PaymentPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Payment/PaymentPlatformClient.js +3 -2
- package/sdk/platform/Payment/PaymentPlatformValidator.js +1 -0
- package/sdk/platform/PlatformApplicationClient.d.ts +5 -1
- package/sdk/platform/PlatformApplicationClient.js +4 -0
- package/sdk/platform/PlatformClient.d.ts +51 -12
- package/sdk/platform/PlatformClient.js +54 -11
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +17 -19
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +88 -83
- package/sdk/platform/Rewards/RewardsPlatformApplicationValidator.d.ts +1 -1
- package/sdk/platform/Rewards/RewardsPlatformApplicationValidator.js +8 -9
- package/sdk/platform/Share/SharePlatformApplicationClient.js +3 -1
- package/sdk/platform/Share/SharePlatformApplicationValidator.js +1 -1
- package/sdk/platform/Theme/ThemePlatformApplicationClient.js +3 -1
- package/sdk/platform/Theme/ThemePlatformApplicationValidator.js +1 -1
- package/sdk/platform/User/UserPlatformApplicationClient.js +3 -1
- package/sdk/platform/User/UserPlatformApplicationValidator.js +1 -1
- package/sdk/platform/Webhook/WebhookPlatformClient.js +3 -2
- package/sdk/platform/Webhook/WebhookPlatformValidator.js +1 -0
- package/sdk/public/Configuration/ConfigurationPublicClient.js +2 -0
- package/sdk/public/Inventory/InventoryPublicClient.js +2 -0
- package/sdk/public/Webhook/WebhookPublicClient.js +2 -0
- package/.github/workflows/on_create_release.yml +0 -23
- package/.github/workflows/on_merge_main.yml +0 -38
- package/.github/workflows/on_pull_request.yml +0 -35
- package/.prettierrc +0 -5
- package/documentation/application/CART.md +0 -8771
- package/documentation/application/CATALOG.md +0 -8690
- package/documentation/application/COMMON.md +0 -325
- package/documentation/application/COMMUNICATION.md +0 -387
- package/documentation/application/CONFIGURATION.md +0 -2212
- package/documentation/application/CONTENT.md +0 -2629
- package/documentation/application/FILESTORAGE.md +0 -442
- package/documentation/application/LEAD.md +0 -1549
- package/documentation/application/LOGISTIC.md +0 -689
- package/documentation/application/ORDER.md +0 -2937
- package/documentation/application/PAYMENT.md +0 -4475
- package/documentation/application/POSCART.md +0 -9375
- package/documentation/application/README.md +0 -21
- package/documentation/application/REWARDS.md +0 -554
- package/documentation/application/SHARE.md +0 -635
- package/documentation/application/THEME.md +0 -5517
- package/documentation/application/USER.md +0 -3798
- package/documentation/platform/ANALYTICS.md +0 -1012
- package/documentation/platform/AUDITTRAIL.md +0 -493
- package/documentation/platform/BILLING.md +0 -1889
- package/documentation/platform/CART.md +0 -4711
- package/documentation/platform/CATALOG.md +0 -20522
- package/documentation/platform/COMMON.md +0 -325
- package/documentation/platform/COMMUNICATION.md +0 -4970
- package/documentation/platform/COMPANYPROFILE.md +0 -1646
- package/documentation/platform/CONFIGURATION.md +0 -6316
- package/documentation/platform/CONTENT.md +0 -8364
- package/documentation/platform/DISCOUNT.md +0 -767
- package/documentation/platform/FILESTORAGE.md +0 -945
- package/documentation/platform/INVENTORY.md +0 -1136
- package/documentation/platform/LEAD.md +0 -4394
- package/documentation/platform/ORDER.md +0 -6525
- package/documentation/platform/PARTNER.md +0 -193
- package/documentation/platform/PAYMENT.md +0 -3138
- package/documentation/platform/README.md +0 -27
- package/documentation/platform/REWARDS.md +0 -919
- package/documentation/platform/SHARE.md +0 -513
- package/documentation/platform/THEME.md +0 -35446
- package/documentation/platform/USER.md +0 -2174
- package/documentation/platform/WEBHOOK.md +0 -485
- package/documentation/public/CONFIGURATION.md +0 -325
- package/documentation/public/INVENTORY.md +0 -508
- package/documentation/public/WEBHOOK.md +0 -246
- package/jest.config.d.ts +0 -4
- package/jest.config.js +0 -6
- package/tests/application/catalog.spec.js +0 -54
- package/tests/common/action-url.spec.js +0 -35
- package/tests/common/schema/action-url.json +0 -178
- package/tests/common/schema/url-action.json +0 -683
- package/tests/common/url-action.spec.js +0 -48
- package/tests/helpers/cookie.helper.js +0 -31
- package/tests/helpers/oauth.helper.js +0 -43
- package/tests/platform/catalog.spec.js +0 -49
- package/tests/public/location.spec.js +0 -39
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ApplicationAPIClient = require("../ApplicationAPIClient");
|
|
2
|
+
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
2
3
|
const constructUrl = require("../constructUrl");
|
|
3
4
|
const Paginator = require("../../common/Paginator");
|
|
4
|
-
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
5
5
|
const ShareValidator = require("./ShareApplicationValidator");
|
|
6
6
|
const ShareModel = require("./ShareApplicationModel");
|
|
7
7
|
const { Logger } = require("./../../common/Logger");
|
|
8
|
+
const Joi = require("joi");
|
|
8
9
|
|
|
9
10
|
class Share {
|
|
10
11
|
constructor(_conf) {
|
|
@@ -71,7 +72,7 @@ class Share {
|
|
|
71
72
|
|
|
72
73
|
const xHeaders = {};
|
|
73
74
|
|
|
74
|
-
const response = await
|
|
75
|
+
const response = await ApplicationAPIClient.execute(
|
|
75
76
|
this._conf,
|
|
76
77
|
"post",
|
|
77
78
|
constructUrl({
|
|
@@ -131,7 +132,7 @@ class Share {
|
|
|
131
132
|
|
|
132
133
|
const xHeaders = {};
|
|
133
134
|
|
|
134
|
-
const response = await
|
|
135
|
+
const response = await ApplicationAPIClient.execute(
|
|
135
136
|
this._conf,
|
|
136
137
|
"post",
|
|
137
138
|
constructUrl({
|
|
@@ -195,7 +196,7 @@ class Share {
|
|
|
195
196
|
|
|
196
197
|
const xHeaders = {};
|
|
197
198
|
|
|
198
|
-
const response = await
|
|
199
|
+
const response = await ApplicationAPIClient.execute(
|
|
199
200
|
this._conf,
|
|
200
201
|
"post",
|
|
201
202
|
constructUrl({
|
|
@@ -260,7 +261,7 @@ class Share {
|
|
|
260
261
|
|
|
261
262
|
const xHeaders = {};
|
|
262
263
|
|
|
263
|
-
const response = await
|
|
264
|
+
const response = await ApplicationAPIClient.execute(
|
|
264
265
|
this._conf,
|
|
265
266
|
"get",
|
|
266
267
|
constructUrl({
|
|
@@ -324,7 +325,7 @@ class Share {
|
|
|
324
325
|
|
|
325
326
|
const xHeaders = {};
|
|
326
327
|
|
|
327
|
-
const response = await
|
|
328
|
+
const response = await ApplicationAPIClient.execute(
|
|
328
329
|
this._conf,
|
|
329
330
|
"post",
|
|
330
331
|
constructUrl({
|
|
@@ -386,7 +387,7 @@ class Share {
|
|
|
386
387
|
|
|
387
388
|
const xHeaders = {};
|
|
388
389
|
|
|
389
|
-
const response = await
|
|
390
|
+
const response = await ApplicationAPIClient.execute(
|
|
390
391
|
this._conf,
|
|
391
392
|
"get",
|
|
392
393
|
constructUrl({
|
|
@@ -448,7 +449,7 @@ class Share {
|
|
|
448
449
|
|
|
449
450
|
const xHeaders = {};
|
|
450
451
|
|
|
451
|
-
const response = await
|
|
452
|
+
const response = await ApplicationAPIClient.execute(
|
|
452
453
|
this._conf,
|
|
453
454
|
"post",
|
|
454
455
|
constructUrl({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ApplicationAPIClient = require("../ApplicationAPIClient");
|
|
2
|
+
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
2
3
|
const constructUrl = require("../constructUrl");
|
|
3
4
|
const Paginator = require("../../common/Paginator");
|
|
4
|
-
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
5
5
|
const ThemeValidator = require("./ThemeApplicationValidator");
|
|
6
6
|
const ThemeModel = require("./ThemeApplicationModel");
|
|
7
7
|
const { Logger } = require("./../../common/Logger");
|
|
8
|
+
const Joi = require("joi");
|
|
8
9
|
|
|
9
10
|
class Theme {
|
|
10
11
|
constructor(_conf) {
|
|
@@ -64,7 +65,7 @@ class Theme {
|
|
|
64
65
|
|
|
65
66
|
const xHeaders = {};
|
|
66
67
|
|
|
67
|
-
const response = await
|
|
68
|
+
const response = await ApplicationAPIClient.execute(
|
|
68
69
|
this._conf,
|
|
69
70
|
"get",
|
|
70
71
|
constructUrl({
|
|
@@ -126,7 +127,7 @@ class Theme {
|
|
|
126
127
|
|
|
127
128
|
const xHeaders = {};
|
|
128
129
|
|
|
129
|
-
const response = await
|
|
130
|
+
const response = await ApplicationAPIClient.execute(
|
|
130
131
|
this._conf,
|
|
131
132
|
"get",
|
|
132
133
|
constructUrl({
|
|
@@ -188,7 +189,7 @@ class Theme {
|
|
|
188
189
|
|
|
189
190
|
const xHeaders = {};
|
|
190
191
|
|
|
191
|
-
const response = await
|
|
192
|
+
const response = await ApplicationAPIClient.execute(
|
|
192
193
|
this._conf,
|
|
193
194
|
"get",
|
|
194
195
|
constructUrl({
|
|
@@ -251,7 +252,7 @@ class Theme {
|
|
|
251
252
|
|
|
252
253
|
const xHeaders = {};
|
|
253
254
|
|
|
254
|
-
const response = await
|
|
255
|
+
const response = await ApplicationAPIClient.execute(
|
|
255
256
|
this._conf,
|
|
256
257
|
"get",
|
|
257
258
|
constructUrl({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ApplicationAPIClient = require("../ApplicationAPIClient");
|
|
2
|
+
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
2
3
|
const constructUrl = require("../constructUrl");
|
|
3
4
|
const Paginator = require("../../common/Paginator");
|
|
4
|
-
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
5
5
|
const UserValidator = require("./UserApplicationValidator");
|
|
6
6
|
const UserModel = require("./UserApplicationModel");
|
|
7
7
|
const { Logger } = require("./../../common/Logger");
|
|
8
|
+
const Joi = require("joi");
|
|
8
9
|
|
|
9
10
|
class User {
|
|
10
11
|
constructor(_conf) {
|
|
@@ -118,7 +119,7 @@ class User {
|
|
|
118
119
|
|
|
119
120
|
const xHeaders = {};
|
|
120
121
|
|
|
121
|
-
const response = await
|
|
122
|
+
const response = await ApplicationAPIClient.execute(
|
|
122
123
|
this._conf,
|
|
123
124
|
"put",
|
|
124
125
|
constructUrl({
|
|
@@ -183,7 +184,7 @@ class User {
|
|
|
183
184
|
|
|
184
185
|
const xHeaders = {};
|
|
185
186
|
|
|
186
|
-
const response = await
|
|
187
|
+
const response = await ApplicationAPIClient.execute(
|
|
187
188
|
this._conf,
|
|
188
189
|
"put",
|
|
189
190
|
constructUrl({
|
|
@@ -260,7 +261,7 @@ class User {
|
|
|
260
261
|
|
|
261
262
|
const xHeaders = {};
|
|
262
263
|
|
|
263
|
-
const response = await
|
|
264
|
+
const response = await ApplicationAPIClient.execute(
|
|
264
265
|
this._conf,
|
|
265
266
|
"delete",
|
|
266
267
|
constructUrl({
|
|
@@ -344,7 +345,7 @@ class User {
|
|
|
344
345
|
|
|
345
346
|
const xHeaders = {};
|
|
346
347
|
|
|
347
|
-
const response = await
|
|
348
|
+
const response = await ApplicationAPIClient.execute(
|
|
348
349
|
this._conf,
|
|
349
350
|
"delete",
|
|
350
351
|
constructUrl({
|
|
@@ -405,7 +406,7 @@ class User {
|
|
|
405
406
|
|
|
406
407
|
const xHeaders = {};
|
|
407
408
|
|
|
408
|
-
const response = await
|
|
409
|
+
const response = await ApplicationAPIClient.execute(
|
|
409
410
|
this._conf,
|
|
410
411
|
"post",
|
|
411
412
|
constructUrl({
|
|
@@ -468,7 +469,7 @@ class User {
|
|
|
468
469
|
|
|
469
470
|
const xHeaders = {};
|
|
470
471
|
|
|
471
|
-
const response = await
|
|
472
|
+
const response = await ApplicationAPIClient.execute(
|
|
472
473
|
this._conf,
|
|
473
474
|
"post",
|
|
474
475
|
constructUrl({
|
|
@@ -530,7 +531,7 @@ class User {
|
|
|
530
531
|
|
|
531
532
|
const xHeaders = {};
|
|
532
533
|
|
|
533
|
-
const response = await
|
|
534
|
+
const response = await ApplicationAPIClient.execute(
|
|
534
535
|
this._conf,
|
|
535
536
|
"get",
|
|
536
537
|
constructUrl({
|
|
@@ -592,7 +593,7 @@ class User {
|
|
|
592
593
|
|
|
593
594
|
const xHeaders = {};
|
|
594
595
|
|
|
595
|
-
const response = await
|
|
596
|
+
const response = await ApplicationAPIClient.execute(
|
|
596
597
|
this._conf,
|
|
597
598
|
"get",
|
|
598
599
|
constructUrl({
|
|
@@ -654,7 +655,7 @@ class User {
|
|
|
654
655
|
|
|
655
656
|
const xHeaders = {};
|
|
656
657
|
|
|
657
|
-
const response = await
|
|
658
|
+
const response = await ApplicationAPIClient.execute(
|
|
658
659
|
this._conf,
|
|
659
660
|
"get",
|
|
660
661
|
constructUrl({
|
|
@@ -714,7 +715,7 @@ class User {
|
|
|
714
715
|
|
|
715
716
|
const xHeaders = {};
|
|
716
717
|
|
|
717
|
-
const response = await
|
|
718
|
+
const response = await ApplicationAPIClient.execute(
|
|
718
719
|
this._conf,
|
|
719
720
|
"get",
|
|
720
721
|
constructUrl({
|
|
@@ -779,7 +780,7 @@ class User {
|
|
|
779
780
|
|
|
780
781
|
const xHeaders = {};
|
|
781
782
|
|
|
782
|
-
const response = await
|
|
783
|
+
const response = await ApplicationAPIClient.execute(
|
|
783
784
|
this._conf,
|
|
784
785
|
"post",
|
|
785
786
|
constructUrl({
|
|
@@ -842,7 +843,7 @@ class User {
|
|
|
842
843
|
|
|
843
844
|
const xHeaders = {};
|
|
844
845
|
|
|
845
|
-
const response = await
|
|
846
|
+
const response = await ApplicationAPIClient.execute(
|
|
846
847
|
this._conf,
|
|
847
848
|
"post",
|
|
848
849
|
constructUrl({
|
|
@@ -905,7 +906,7 @@ class User {
|
|
|
905
906
|
|
|
906
907
|
const xHeaders = {};
|
|
907
908
|
|
|
908
|
-
const response = await
|
|
909
|
+
const response = await ApplicationAPIClient.execute(
|
|
909
910
|
this._conf,
|
|
910
911
|
"post",
|
|
911
912
|
constructUrl({
|
|
@@ -968,7 +969,7 @@ class User {
|
|
|
968
969
|
|
|
969
970
|
const xHeaders = {};
|
|
970
971
|
|
|
971
|
-
const response = await
|
|
972
|
+
const response = await ApplicationAPIClient.execute(
|
|
972
973
|
this._conf,
|
|
973
974
|
"post",
|
|
974
975
|
constructUrl({
|
|
@@ -1031,7 +1032,7 @@ class User {
|
|
|
1031
1032
|
|
|
1032
1033
|
const xHeaders = {};
|
|
1033
1034
|
|
|
1034
|
-
const response = await
|
|
1035
|
+
const response = await ApplicationAPIClient.execute(
|
|
1035
1036
|
this._conf,
|
|
1036
1037
|
"post",
|
|
1037
1038
|
constructUrl({
|
|
@@ -1094,7 +1095,7 @@ class User {
|
|
|
1094
1095
|
|
|
1095
1096
|
const xHeaders = {};
|
|
1096
1097
|
|
|
1097
|
-
const response = await
|
|
1098
|
+
const response = await ApplicationAPIClient.execute(
|
|
1098
1099
|
this._conf,
|
|
1099
1100
|
"post",
|
|
1100
1101
|
constructUrl({
|
|
@@ -1157,7 +1158,7 @@ class User {
|
|
|
1157
1158
|
|
|
1158
1159
|
const xHeaders = {};
|
|
1159
1160
|
|
|
1160
|
-
const response = await
|
|
1161
|
+
const response = await ApplicationAPIClient.execute(
|
|
1161
1162
|
this._conf,
|
|
1162
1163
|
"post",
|
|
1163
1164
|
constructUrl({
|
|
@@ -1218,7 +1219,7 @@ class User {
|
|
|
1218
1219
|
|
|
1219
1220
|
const xHeaders = {};
|
|
1220
1221
|
|
|
1221
|
-
const response = await
|
|
1222
|
+
const response = await ApplicationAPIClient.execute(
|
|
1222
1223
|
this._conf,
|
|
1223
1224
|
"post",
|
|
1224
1225
|
constructUrl({
|
|
@@ -1278,7 +1279,7 @@ class User {
|
|
|
1278
1279
|
|
|
1279
1280
|
const xHeaders = {};
|
|
1280
1281
|
|
|
1281
|
-
const response = await
|
|
1282
|
+
const response = await ApplicationAPIClient.execute(
|
|
1282
1283
|
this._conf,
|
|
1283
1284
|
"get",
|
|
1284
1285
|
constructUrl({
|
|
@@ -1341,7 +1342,7 @@ class User {
|
|
|
1341
1342
|
|
|
1342
1343
|
const xHeaders = {};
|
|
1343
1344
|
|
|
1344
|
-
const response = await
|
|
1345
|
+
const response = await ApplicationAPIClient.execute(
|
|
1345
1346
|
this._conf,
|
|
1346
1347
|
"post",
|
|
1347
1348
|
constructUrl({
|
|
@@ -1406,7 +1407,7 @@ class User {
|
|
|
1406
1407
|
|
|
1407
1408
|
const xHeaders = {};
|
|
1408
1409
|
|
|
1409
|
-
const response = await
|
|
1410
|
+
const response = await ApplicationAPIClient.execute(
|
|
1410
1411
|
this._conf,
|
|
1411
1412
|
"post",
|
|
1412
1413
|
constructUrl({
|
|
@@ -1469,7 +1470,7 @@ class User {
|
|
|
1469
1470
|
|
|
1470
1471
|
const xHeaders = {};
|
|
1471
1472
|
|
|
1472
|
-
const response = await
|
|
1473
|
+
const response = await ApplicationAPIClient.execute(
|
|
1473
1474
|
this._conf,
|
|
1474
1475
|
"post",
|
|
1475
1476
|
constructUrl({
|
|
@@ -1532,7 +1533,7 @@ class User {
|
|
|
1532
1533
|
|
|
1533
1534
|
const xHeaders = {};
|
|
1534
1535
|
|
|
1535
|
-
const response = await
|
|
1536
|
+
const response = await ApplicationAPIClient.execute(
|
|
1536
1537
|
this._conf,
|
|
1537
1538
|
"post",
|
|
1538
1539
|
constructUrl({
|
|
@@ -1599,7 +1600,7 @@ class User {
|
|
|
1599
1600
|
|
|
1600
1601
|
const xHeaders = {};
|
|
1601
1602
|
|
|
1602
|
-
const response = await
|
|
1603
|
+
const response = await ApplicationAPIClient.execute(
|
|
1603
1604
|
this._conf,
|
|
1604
1605
|
"post",
|
|
1605
1606
|
constructUrl({
|
|
@@ -1662,7 +1663,7 @@ class User {
|
|
|
1662
1663
|
|
|
1663
1664
|
const xHeaders = {};
|
|
1664
1665
|
|
|
1665
|
-
const response = await
|
|
1666
|
+
const response = await ApplicationAPIClient.execute(
|
|
1666
1667
|
this._conf,
|
|
1667
1668
|
"post",
|
|
1668
1669
|
constructUrl({
|
|
@@ -1730,7 +1731,7 @@ class User {
|
|
|
1730
1731
|
|
|
1731
1732
|
const xHeaders = {};
|
|
1732
1733
|
|
|
1733
|
-
const response = await
|
|
1734
|
+
const response = await ApplicationAPIClient.execute(
|
|
1734
1735
|
this._conf,
|
|
1735
1736
|
"post",
|
|
1736
1737
|
constructUrl({
|
|
@@ -1799,7 +1800,7 @@ class User {
|
|
|
1799
1800
|
|
|
1800
1801
|
const xHeaders = {};
|
|
1801
1802
|
|
|
1802
|
-
const response = await
|
|
1803
|
+
const response = await ApplicationAPIClient.execute(
|
|
1803
1804
|
this._conf,
|
|
1804
1805
|
"post",
|
|
1805
1806
|
constructUrl({
|
|
@@ -1863,7 +1864,7 @@ class User {
|
|
|
1863
1864
|
|
|
1864
1865
|
const xHeaders = {};
|
|
1865
1866
|
|
|
1866
|
-
const response = await
|
|
1867
|
+
const response = await ApplicationAPIClient.execute(
|
|
1867
1868
|
this._conf,
|
|
1868
1869
|
"post",
|
|
1869
1870
|
constructUrl({
|
|
@@ -1926,7 +1927,7 @@ class User {
|
|
|
1926
1927
|
|
|
1927
1928
|
const xHeaders = {};
|
|
1928
1929
|
|
|
1929
|
-
const response = await
|
|
1930
|
+
const response = await ApplicationAPIClient.execute(
|
|
1930
1931
|
this._conf,
|
|
1931
1932
|
"post",
|
|
1932
1933
|
constructUrl({
|
|
@@ -1987,7 +1988,7 @@ class User {
|
|
|
1987
1988
|
|
|
1988
1989
|
const xHeaders = {};
|
|
1989
1990
|
|
|
1990
|
-
const response = await
|
|
1991
|
+
const response = await ApplicationAPIClient.execute(
|
|
1991
1992
|
this._conf,
|
|
1992
1993
|
"post",
|
|
1993
1994
|
constructUrl({
|
|
@@ -2052,7 +2053,7 @@ class User {
|
|
|
2052
2053
|
|
|
2053
2054
|
const xHeaders = {};
|
|
2054
2055
|
|
|
2055
|
-
const response = await
|
|
2056
|
+
const response = await ApplicationAPIClient.execute(
|
|
2056
2057
|
this._conf,
|
|
2057
2058
|
"post",
|
|
2058
2059
|
constructUrl({
|
|
@@ -2115,7 +2116,7 @@ class User {
|
|
|
2115
2116
|
|
|
2116
2117
|
const xHeaders = {};
|
|
2117
2118
|
|
|
2118
|
-
const response = await
|
|
2119
|
+
const response = await ApplicationAPIClient.execute(
|
|
2119
2120
|
this._conf,
|
|
2120
2121
|
"post",
|
|
2121
2122
|
constructUrl({
|
|
@@ -2180,7 +2181,7 @@ class User {
|
|
|
2180
2181
|
|
|
2181
2182
|
const xHeaders = {};
|
|
2182
2183
|
|
|
2183
|
-
const response = await
|
|
2184
|
+
const response = await ApplicationAPIClient.execute(
|
|
2184
2185
|
this._conf,
|
|
2185
2186
|
"post",
|
|
2186
2187
|
constructUrl({
|
|
@@ -2241,7 +2242,7 @@ class User {
|
|
|
2241
2242
|
|
|
2242
2243
|
const xHeaders = {};
|
|
2243
2244
|
|
|
2244
|
-
const response = await
|
|
2245
|
+
const response = await ApplicationAPIClient.execute(
|
|
2245
2246
|
this._conf,
|
|
2246
2247
|
"post",
|
|
2247
2248
|
constructUrl({
|
|
@@ -2306,7 +2307,7 @@ class User {
|
|
|
2306
2307
|
|
|
2307
2308
|
const xHeaders = {};
|
|
2308
2309
|
|
|
2309
|
-
const response = await
|
|
2310
|
+
const response = await ApplicationAPIClient.execute(
|
|
2310
2311
|
this._conf,
|
|
2311
2312
|
"post",
|
|
2312
2313
|
constructUrl({
|
|
@@ -102,7 +102,11 @@ fdkAxios.interceptors.request.use(
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
function (error) {
|
|
105
|
-
Logger({
|
|
105
|
+
Logger({
|
|
106
|
+
level: "ERROR",
|
|
107
|
+
message: error.data || error.message,
|
|
108
|
+
stack: error.data.stack || error.stack,
|
|
109
|
+
});
|
|
106
110
|
}
|
|
107
111
|
);
|
|
108
112
|
|
|
@@ -115,16 +119,19 @@ fdkAxios.interceptors.response.use(
|
|
|
115
119
|
Logger({
|
|
116
120
|
level: "DEBUG",
|
|
117
121
|
type: "RESPONSE",
|
|
118
|
-
message: response.
|
|
122
|
+
message: response.data,
|
|
119
123
|
url: response.config.url,
|
|
120
|
-
response: response.data,
|
|
121
124
|
});
|
|
122
125
|
return response.data; // IF 2XX then return response.data only
|
|
123
126
|
},
|
|
124
127
|
function (error) {
|
|
125
128
|
if (error.response) {
|
|
126
129
|
// Request made and server responded
|
|
127
|
-
Logger({
|
|
130
|
+
Logger({
|
|
131
|
+
level: "ERROR",
|
|
132
|
+
message: error.response.data || error.message,
|
|
133
|
+
stack: error.response.data.stack || error.stack,
|
|
134
|
+
});
|
|
128
135
|
throw new FDKServerResponseError(
|
|
129
136
|
error.response.data.message || error.message,
|
|
130
137
|
error.response.data.stack || error.stack,
|
|
@@ -134,7 +141,11 @@ fdkAxios.interceptors.response.use(
|
|
|
134
141
|
);
|
|
135
142
|
} else if (error.request) {
|
|
136
143
|
// The request was made but no error.response was received
|
|
137
|
-
Logger({
|
|
144
|
+
Logger({
|
|
145
|
+
level: "ERROR",
|
|
146
|
+
message: error.data || error.message,
|
|
147
|
+
stack: error.data.stack || error.stack,
|
|
148
|
+
});
|
|
138
149
|
throw new FDKServerResponseError(
|
|
139
150
|
error.message,
|
|
140
151
|
error.stack,
|
|
@@ -143,7 +154,7 @@ fdkAxios.interceptors.response.use(
|
|
|
143
154
|
);
|
|
144
155
|
} else {
|
|
145
156
|
// Something happened in setting up the request that triggered an Error
|
|
146
|
-
Logger({ level: "ERROR", message: error });
|
|
157
|
+
Logger({ level: "ERROR", message: error.message });
|
|
147
158
|
throw new FDKServerResponseError(error.message, error.stack);
|
|
148
159
|
}
|
|
149
160
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export = BaseOAuthClient;
|
|
2
|
+
declare class BaseOAuthClient {
|
|
3
|
+
constructor(config: any);
|
|
4
|
+
config: any;
|
|
5
|
+
token: any;
|
|
6
|
+
refreshToken: any;
|
|
7
|
+
retryOAuthTokenTimer: NodeJS.Timeout;
|
|
8
|
+
raw_token: any;
|
|
9
|
+
token_expires_in: any;
|
|
10
|
+
token_expires_at: number;
|
|
11
|
+
useAutoRenewTimer: any;
|
|
12
|
+
getAccessToken(): Promise<any>;
|
|
13
|
+
isTokenExpired(ttl?: number): boolean;
|
|
14
|
+
setToken(token: any): void;
|
|
15
|
+
retryOAuthToken(expires_in: any): void;
|
|
16
|
+
renewAccessToken(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const { Logger } = require("./Logger");
|
|
2
|
+
|
|
3
|
+
class BaseOAuthClient {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.config = config;
|
|
6
|
+
this.token = null;
|
|
7
|
+
this.refreshToken = null;
|
|
8
|
+
this.retryOAuthTokenTimer = null;
|
|
9
|
+
this.raw_token = null;
|
|
10
|
+
this.token_expires_in = null;
|
|
11
|
+
this.token_expires_at = 0;
|
|
12
|
+
this.useAutoRenewTimer =
|
|
13
|
+
config.useAutoRenewTimer !== undefined ? config.useAutoRenewTimer : true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getAccessToken() {
|
|
17
|
+
if (
|
|
18
|
+
!this.useAutoRenewTimer &&
|
|
19
|
+
this.refreshToken &&
|
|
20
|
+
this.isTokenExpired(120)
|
|
21
|
+
) {
|
|
22
|
+
// Check if token is about to expire in less than 2 mins.
|
|
23
|
+
// Renew if to be expired and auto renew timer is not enabled.
|
|
24
|
+
await this.renewAccessToken();
|
|
25
|
+
}
|
|
26
|
+
return this.token;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// default TTL checked 0 seconds
|
|
30
|
+
isTokenExpired(ttl = 0) {
|
|
31
|
+
const currentTimestamp = new Date().getTime();
|
|
32
|
+
// Check if token is about to expire in less than 2 mins
|
|
33
|
+
if ((this.token_expires_at - currentTimestamp) / 1000 < ttl) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setToken(token) {
|
|
40
|
+
this.raw_token = token;
|
|
41
|
+
this.token_expires_in = token.expires_in;
|
|
42
|
+
this.token = token.access_token;
|
|
43
|
+
this.token_expires_at = token.expires_at || this.token_expires_at;
|
|
44
|
+
this.refreshToken = token.refresh_token ? token.refresh_token : null;
|
|
45
|
+
if (this.refreshToken && this.useAutoRenewTimer) {
|
|
46
|
+
this.retryOAuthToken(token.expires_in);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
retryOAuthToken(expires_in) {
|
|
51
|
+
Logger({ type: "INFO", message: "Retrying OAuth Token" });
|
|
52
|
+
if (this.retryOAuthTokenTimer) {
|
|
53
|
+
clearTimeout(this.retryOAuthTokenTimer);
|
|
54
|
+
}
|
|
55
|
+
if (expires_in > 60) {
|
|
56
|
+
this.retryOAuthTokenTimer = setTimeout(() => {
|
|
57
|
+
this.renewAccessToken();
|
|
58
|
+
}, (expires_in - 60) * 1000);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async renewAccessToken() {
|
|
63
|
+
// Impementation to renew Access Token
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = BaseOAuthClient;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const url = require("url");
|
|
4
3
|
const querystring = require("query-string");
|
|
5
4
|
const sha256 = require("crypto-js/sha256");
|
|
6
5
|
const hmacSHA256 = require("crypto-js/hmac-sha256");
|
|
@@ -39,10 +38,6 @@ const HEADERS_TO_INCLUDE = ["x-fp-.*", "host"];
|
|
|
39
38
|
// request: { path | body, [host], [method], [headers], [service], [region] }
|
|
40
39
|
class RequestSigner {
|
|
41
40
|
constructor(request) {
|
|
42
|
-
if (typeof request === "string") {
|
|
43
|
-
request = url.parse(request);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
let headers = (request.headers = request.headers || {});
|
|
47
42
|
this.request = request;
|
|
48
43
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export = OAuthClient;
|
|
2
|
+
declare class OAuthClient extends BaseOAuthClient {
|
|
3
|
+
startAuthorization(options: any): string;
|
|
4
|
+
verifyCallback(query: any): Promise<void>;
|
|
5
|
+
renewAccessToken(isOfflineToken?: boolean): Promise<any>;
|
|
6
|
+
getNewAccessToken(): Promise<any>;
|
|
7
|
+
getAccesstokenObj({ grant_type, client_id, client_secret, scope }: {
|
|
8
|
+
grant_type: any;
|
|
9
|
+
client_id: any;
|
|
10
|
+
client_secret: any;
|
|
11
|
+
scope: any;
|
|
12
|
+
}): Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
import BaseOAuthClient = require("../common/BaseOAuthClient");
|