@getjones/test-infra 5.2.14 → 5.2.16
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/eslint.config.mjs +156 -156
- package/package.json +43 -43
- package/src/common/commonFlows/auth/auth.js +95 -95
- package/src/common/commonFlows/index.js +5 -5
- package/src/common/commonFlows/records/records.js +452 -452
- package/src/common/commonFlows/users/users.js +15 -15
- package/src/common/consts/accountSettings.js +112 -112
- package/src/common/consts/activationStatuses.js +6 -6
- package/src/common/consts/analysisStatuses.js +7 -7
- package/src/common/consts/autocomplete.js +10 -10
- package/src/common/consts/constantsForRecordsSortingAndFilters.js +49 -49
- package/src/common/consts/dashboardCharts.js +18 -18
- package/src/common/consts/homepage/AttentionTab.js +6 -6
- package/src/common/consts/homepage/sortOptions.js +19 -19
- package/src/common/consts/projectSettings.js +28 -28
- package/src/common/consts/recordTypes.js +5 -5
- package/src/common/consts/requirementActions.js +10 -10
- package/src/common/consts/s3FileTypes.js +12 -12
- package/src/common/consts/userRoles.js +21 -21
- package/src/common/consts/userTypes.js +16 -16
- package/src/common/errorCodes.js +13 -13
- package/src/common/httpResponseStatusCodes.json +19 -19
- package/src/common/httpResponseTypes.json +2 -2
- package/src/common/requests/apiKeyAuth/requests.js +45 -45
- package/src/common/requests/cookieAuth/requests.js +40 -40
- package/src/common/requests/internalAuth/requests.js +48 -48
- package/src/common/requests/requestHandlers.js +112 -112
- package/src/common/utils/arrayUtils.js +19 -19
- package/src/common/utils/complianceUtil.js +114 -114
- package/src/common/utils/configsUtil.js +22 -22
- package/src/common/utils/dataTypeUtils.js +41 -41
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/objectUtils.js +102 -102
- package/src/common/utils/timeUtils.js +202 -202
- package/src/common/validations/typeValidations.js +36 -36
- package/src/defaults/configs/attributes.js +170 -170
- package/src/defaults/configs/auditConfigs.js +129 -129
- package/src/defaults/configs/coverage.js +144 -144
- package/src/defaults/configs/polices.js +28 -28
- package/src/defaults/configs/requirement.js +218 -218
- package/src/defaults/index.js +7 -7
- package/src/env.js +58 -58
- package/src/factory/globalRecord/globalRecord.js +43 -43
- package/src/factory/index.js +8 -8
- package/src/factory/records/records.js +295 -295
- package/src/factory/users/users.js +70 -70
- package/src/index.js +118 -118
- package/src/reporters/mochaReporter.js +273 -273
- package/src/saas/internal-api/accountDirectory/api/accountDirectory.api.js +152 -152
- package/src/saas/internal-api/accountDirectory/api/accountDirectory.service.js +576 -576
- package/src/saas/internal-api/accountDirectory/consts/accountDirectory.consts.js +75 -75
- package/src/saas/internal-api/accountDirectory/index.js +5 -5
- package/src/saas/internal-api/accountDirectory/models/accountDirectory.models.js +172 -172
- package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +54 -54
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +114 -114
- package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.api.js +29 -29
- package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +60 -60
- package/src/saas/internal-api/accounts/api/emailCustomization/consts.js +8 -8
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +54 -54
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +67 -67
- package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
- package/src/saas/internal-api/accounts/api/settings/settings.service.js +58 -58
- package/src/saas/internal-api/accounts/consts/consts.js +8 -8
- package/src/saas/internal-api/accounts/index.js +22 -22
- package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +110 -110
- package/src/saas/internal-api/accounts/utils/utils.js +60 -60
- package/src/saas/internal-api/agreement/api/agreement.api.js +39 -39
- package/src/saas/internal-api/agreement/api/agreement.service.js +121 -121
- package/src/saas/internal-api/agreement/consts/consts.js +11 -11
- package/src/saas/internal-api/agreement/index.js +12 -12
- package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
- package/src/saas/internal-api/agreement/models/createAgreementByAuditorModel.js +11 -11
- package/src/saas/internal-api/agreement/models/createAgreementByPMModel.js +13 -13
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +49 -49
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +121 -121
- package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +40 -40
- package/src/saas/internal-api/auditCustomerRules/index.js +7 -7
- package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +55 -55
- package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +70 -70
- package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
- package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +116 -116
- package/src/saas/internal-api/auditNotes/index.js +4 -4
- package/src/saas/internal-api/auditNotes/models/audit.note.model.js +32 -32
- package/src/saas/internal-api/auditorComments/api/auditor.comments.api.js +20 -20
- package/src/saas/internal-api/auditorComments/api/auditor.comments.service.js +27 -27
- package/src/saas/internal-api/auditorComments/consts/auditor.comment.js +16 -16
- package/src/saas/internal-api/auditorComments/index.js +5 -5
- package/src/saas/internal-api/auditorComments/models/auditor.comment.model.js +40 -40
- package/src/saas/internal-api/auth/api/auth.api.js +78 -78
- package/src/saas/internal-api/auth/api/auth.service.js +217 -217
- package/src/saas/internal-api/auth/index.js +3 -3
- package/src/saas/internal-api/certificial/api/certificial.api.js +15 -15
- package/src/saas/internal-api/certificial/api/certificial.service.js +24 -24
- package/src/saas/internal-api/certificial/consts.js +8 -8
- package/src/saas/internal-api/certificial/index.js +4 -4
- package/src/saas/internal-api/coi/api/coi.api.js +76 -76
- package/src/saas/internal-api/coi/api/coi.service.js +104 -104
- package/src/saas/internal-api/coi/consts/{uploaderStatuses.js → coiUploaderTypes.js} +9 -9
- package/src/saas/internal-api/coi/consts/duplicateHandling.js +7 -7
- package/src/saas/internal-api/coi/consts/hashes.js +5 -5
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +3 -3
- package/src/saas/internal-api/coi/index.js +17 -17
- package/src/saas/internal-api/coi/models/Combine.last.two.cois.model.js +25 -25
- package/src/saas/internal-api/coi/models/submit.coi.batch.model.js +23 -23
- package/src/saas/internal-api/coi/models/submit.coi.model.js +23 -23
- package/src/saas/internal-api/coi/utils/utils.js +186 -185
- package/src/saas/internal-api/compliance/api/amBestRating/am.best.rating.api.js +12 -12
- package/src/saas/internal-api/compliance/api/amBestRating/am.best.rating.service.js +14 -14
- package/src/saas/internal-api/compliance/api/audit/aiAudit/aiAudit.api.js +63 -63
- package/src/saas/internal-api/compliance/api/audit/aiAudit/aiAudit.service.js +99 -99
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +124 -124
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +390 -390
- package/src/saas/internal-api/compliance/api/complianceSnapshot/compliance.snapshot.api.js +32 -32
- package/src/saas/internal-api/compliance/api/complianceSnapshot/compliance.snapshot.service.js +73 -73
- package/src/saas/internal-api/compliance/api/convert/convert.api.js +12 -12
- package/src/saas/internal-api/compliance/api/convert/convert.service.js +7 -7
- package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
- package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +46 -46
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +86 -86
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +300 -300
- package/src/saas/internal-api/compliance/consts/audit.js +130 -130
- package/src/saas/internal-api/compliance/consts/overrideGapRequest/override.gap.request.js +7 -7
- package/src/saas/internal-api/compliance/index.js +41 -41
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +109 -109
- package/src/saas/internal-api/compliance/models/overrideGapRequest/override.gap.request.model.js +16 -16
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +112 -112
- package/src/saas/internal-api/compliance/utils/auditUtil.js +308 -308
- package/src/saas/internal-api/compliance/utils/coverageUtil.js +45 -45
- package/src/saas/internal-api/contractors/api/contractors.api.js +251 -251
- package/src/saas/internal-api/contractors/api/contractors.service.js +482 -482
- package/src/saas/internal-api/contractors/consts/consts.js +6 -6
- package/src/saas/internal-api/contractors/index.js +8 -8
- package/src/saas/internal-api/contractors/models/assign.requirement.model.js +11 -11
- package/src/saas/internal-api/contractors/models/edit.contractor.model.js +73 -73
- package/src/saas/internal-api/contractors/models/link.request.model.js +10 -10
- package/src/saas/internal-api/contractors/models/verification.contractor.model.js +29 -29
- package/src/saas/internal-api/contractors/utils.js +25 -25
- package/src/saas/internal-api/customTags/api/customTags.api.js +47 -47
- package/src/saas/internal-api/customTags/api/customTags.service.js +96 -96
- package/src/saas/internal-api/customTags/index.js +4 -4
- package/src/saas/internal-api/customTags/models/customTagsModels.js +17 -17
- package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
- package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
- package/src/saas/internal-api/dashboard/index.js +5 -5
- package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
- package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +209 -209
- package/src/saas/internal-api/dbEmails/consts/consts.js +66 -66
- package/src/saas/internal-api/dbEmails/index.js +6 -6
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
- package/src/saas/internal-api/dbEmails/utils/util.js +82 -82
- package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
- package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
- package/src/saas/internal-api/emailCustomization/index.js +3 -3
- package/src/saas/internal-api/fileScan/api/file.scan.api.js +14 -14
- package/src/saas/internal-api/fileScan/api/file.scan.service.js +35 -35
- package/src/saas/internal-api/fileScan/index.js +3 -3
- package/src/saas/internal-api/fileScan/models/update.scan.status.model.js +13 -13
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +112 -112
- package/src/saas/internal-api/globalRecord/consts.js +20 -20
- package/src/saas/internal-api/globalRecord/index.js +6 -6
- package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
- package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
- package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
- package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
- package/src/saas/internal-api/homepageCharts/index.js +3 -3
- package/src/saas/internal-api/notificationCenter/api/notification.center.api.js +32 -32
- package/src/saas/internal-api/notificationCenter/api/notification.center.service.js +49 -49
- package/src/saas/internal-api/notificationCenter/consts.js +9 -9
- package/src/saas/internal-api/notificationCenter/index.js +4 -4
- package/src/saas/internal-api/outlook/api/outlook.api.js +14 -14
- package/src/saas/internal-api/outlook/api/outlook.service.js +14 -14
- package/src/saas/internal-api/outlook/index.js +3 -3
- package/src/saas/internal-api/policyFile/api/policy.file.api.js +43 -43
- package/src/saas/internal-api/policyFile/api/policy.file.service.js +117 -117
- package/src/saas/internal-api/policyFile/consts.js +21 -21
- package/src/saas/internal-api/policyFile/index.js +11 -11
- package/src/saas/internal-api/policyFile/models/create.policy.file.model.js +11 -11
- package/src/saas/internal-api/policyFile/models/set.publish.flag.to.policy.model.js +13 -13
- package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
- package/src/saas/internal-api/projects/api/core/projects.service.js +77 -77
- package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
- package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
- package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
- package/src/saas/internal-api/projects/index.js +24 -24
- package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
- package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
- package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +56 -56
- package/src/saas/internal-api/projects/utils/utils.js +159 -159
- package/src/saas/internal-api/recordHub/api/record.hub.api.js +20 -20
- package/src/saas/internal-api/recordHub/api/record.hub.service.js +86 -86
- package/src/saas/internal-api/recordHub/index.js +3 -3
- package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +56 -56
- package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
- package/src/saas/internal-api/recordNotes/index.js +3 -3
- package/src/saas/internal-api/relatedDocs/api/related.docs.api.js +98 -98
- package/src/saas/internal-api/relatedDocs/api/related.docs.service.js +180 -180
- package/src/saas/internal-api/relatedDocs/index.js +4 -4
- package/src/saas/internal-api/relatedDocs/models/related.doc.model.js +36 -36
- package/src/saas/internal-api/reports/api/reports.api.js +56 -56
- package/src/saas/internal-api/reports/api/reports.service.js +68 -68
- package/src/saas/internal-api/reports/consts/consts.js +71 -71
- package/src/saas/internal-api/reports/index.js +15 -15
- package/src/saas/internal-api/reports/models/report.model.js +27 -27
- package/src/saas/internal-api/requests/api/requests.api.js +132 -132
- package/src/saas/internal-api/requests/api/requests.service.js +315 -315
- package/src/saas/internal-api/requests/index.js +21 -21
- package/src/saas/internal-api/requests/models/create.request.model.js +39 -39
- package/src/saas/internal-api/requests/models/draft.request.criteria.model.js +18 -18
- package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/homepageRequestCriteriaModel.js +19 -19
- package/src/saas/internal-api/requests/models/requestListCriteriaModel.js +17 -17
- package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
- package/src/saas/internal-api/requests/utils.js +16 -16
- package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
- package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
- package/src/saas/internal-api/requestsTable/index.js +3 -3
- package/src/saas/internal-api/requirements/api/lease/lease.api.js +74 -74
- package/src/saas/internal-api/requirements/api/lease/lease.service.js +167 -167
- package/src/saas/internal-api/requirements/api/requirements.api.js +65 -65
- package/src/saas/internal-api/requirements/api/requirements.service.js +198 -198
- package/src/saas/internal-api/requirements/consts/attributeTypes.json +8 -8
- package/src/saas/internal-api/requirements/consts/consts.js +22 -22
- package/src/saas/internal-api/requirements/index.js +22 -22
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
- package/src/saas/internal-api/requirements/models/extraction.request.model.js +16 -16
- package/src/saas/internal-api/requirements/models/policy.model.js +35 -35
- package/src/saas/internal-api/requirements/models/tab.extraction.request.model.js +14 -14
- package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
- package/src/saas/internal-api/requirements/utils/utils.js +129 -129
- package/src/saas/internal-api/sampleCoi/api/sample.coi.api.js +15 -15
- package/src/saas/internal-api/sampleCoi/api/sample.coi.service.js +48 -48
- package/src/saas/internal-api/sampleCoi/consts/consts.js +22 -22
- package/src/saas/internal-api/sampleCoi/index.js +4 -4
- package/src/saas/internal-api/schedulerJobRun/api/scheduler.job.run.api.js +31 -31
- package/src/saas/internal-api/schedulerJobRun/api/scheduler.job.run.service.js +56 -56
- package/src/saas/internal-api/schedulerJobRun/index.js +3 -3
- package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
- package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
- package/src/saas/internal-api/serviceArea/index.js +4 -4
- package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
- package/src/saas/internal-api/tableOfContents/api/table.of.contents.api.js +37 -37
- package/src/saas/internal-api/tableOfContents/api/table.of.contents.service.js +19 -19
- package/src/saas/internal-api/tableOfContents/index.js +3 -3
- package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
- package/src/saas/internal-api/tabs/api/tabs.service.js +60 -60
- package/src/saas/internal-api/tabs/index.js +3 -3
- package/src/saas/internal-api/tabs/models/tabs.model.js +19 -19
- package/src/saas/internal-api/thread-scheduler/runner.js +86 -86
- package/src/saas/internal-api/thread-scheduler/schedulerJobs.js +10 -10
- package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +49 -49
- package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +176 -176
- package/src/saas/internal-api/uploadFiles/consts.js +36 -36
- package/src/saas/internal-api/uploadFiles/index.js +5 -5
- package/src/saas/internal-api/uploadFiles/utils.js +34 -34
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +38 -38
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +109 -109
- package/src/saas/internal-api/users/api/users.api.js +158 -158
- package/src/saas/internal-api/users/api/users.service.js +363 -363
- package/src/saas/internal-api/users/index.js +17 -17
- package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
- package/src/saas/internal-api/users/models/notification.settings.model.js +15 -15
- package/src/saas/internal-api/users/models/tenant.user.model.js +11 -11
- package/src/saas/internal-api/users/models/users.model.js +43 -43
- package/src/saas/internal-api/users/utils/util.js +50 -50
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +26 -26
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +19 -19
- package/src/saas/internal-api/vendorProfile/index.js +3 -3
- package/src/saas/openapi/accounts/accounts.api.js +17 -17
- package/src/saas/openapi/accounts/accounts.service.js +11 -11
- package/src/saas/openapi/coi/coi.api.js +35 -35
- package/src/saas/openapi/coi/coi.service.js +53 -53
- package/src/saas/openapi/projects/projects.api.js +83 -83
- package/src/saas/openapi/projects/projects.service.js +89 -89
- package/src/saas/openapi/relatedDocs/related.docs.api.js +30 -30
- package/src/saas/openapi/relatedDocs/related.docs.service.js +56 -56
- package/src/saas/openapi/requests/index.js +7 -7
- package/src/saas/openapi/requests/models/invite.request.model.js +42 -42
- package/src/saas/openapi/requests/models/update.request.model.js +37 -37
- package/src/saas/openapi/requests/requests.api.js +93 -93
- package/src/saas/openapi/requests/requests.service.js +100 -100
- package/src/saas/openapi/requirements/index.js +6 -6
- package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
- package/src/saas/openapi/requirements/requirements.api.js +41 -41
- package/src/saas/openapi/requirements/requirements.service.js +61 -61
- package/src/saas/openapi/tabs/index.js +6 -6
- package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
- package/src/saas/openapi/tabs/tabs.api.js +27 -27
- package/src/saas/openapi/tabs/tabs.service.js +26 -26
- package/src/saas/openapi/users/user.model.js +10 -10
- package/src/saas/openapi/users/users.api.js +33 -33
- package/src/saas/openapi/users/users.service.js +51 -51
|
@@ -1,217 +1,217 @@
|
|
|
1
|
-
const { getEnv, requiredValidation, getSystemUserIdentity, addUserIdentity } = require('../../../../env');
|
|
2
|
-
const { credentials } = getEnv();
|
|
3
|
-
|
|
4
|
-
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
5
|
-
|
|
6
|
-
const authApi = require('./auth.api');
|
|
7
|
-
const timeUtils = require('../../../../common/utils/timeUtils');
|
|
8
|
-
|
|
9
|
-
const RETRYABLE_LOGIN_STATUSES = [
|
|
10
|
-
httpResponseStatusCodes.BAD_GATEWAY,
|
|
11
|
-
httpResponseStatusCodes.SERVICE_UNAVAILABLE,
|
|
12
|
-
httpResponseStatusCodes.GATEWAY_TIMEOUT
|
|
13
|
-
];
|
|
14
|
-
const MAX_LOGIN_ATTEMPTS = 3;
|
|
15
|
-
const LOGIN_RETRY_STEP_TIMEOUT = 2000;
|
|
16
|
-
const LOGIN_RETRY_RANGE_TIMEOUT = 5000;
|
|
17
|
-
|
|
18
|
-
// Parallel callers for the same user share one login request
|
|
19
|
-
const pendingLogins = new Map();
|
|
20
|
-
|
|
21
|
-
const getAuthCookie = async (email, password) => {
|
|
22
|
-
const systemUser = getSystemUserIdentity(email);
|
|
23
|
-
|
|
24
|
-
if (systemUser) {
|
|
25
|
-
return systemUser.cookie;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!pendingLogins.has(email)) {
|
|
29
|
-
const login = loginAndCacheCookie(email, password).finally(() => pendingLogins.delete(email));
|
|
30
|
-
pendingLogins.set(email, login);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return pendingLogins.get(email);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const loginWithRetry = async (email, password) => {
|
|
37
|
-
for (let attempt = 1; ; attempt++) {
|
|
38
|
-
const response = await authApi.login(email, password);
|
|
39
|
-
|
|
40
|
-
if (!RETRYABLE_LOGIN_STATUSES.includes(response.status) || attempt === MAX_LOGIN_ATTEMPTS) {
|
|
41
|
-
return response;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
console.warn(`Login for ${email} failed with status ${response.status}, retrying`);
|
|
45
|
-
const retryRandomTimeout = attempt * LOGIN_RETRY_STEP_TIMEOUT + Math.random() * LOGIN_RETRY_RANGE_TIMEOUT;
|
|
46
|
-
await timeUtils.waitFor(retryRandomTimeout).mSeconds;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const loginAndCacheCookie = async (email, password) => {
|
|
51
|
-
try {
|
|
52
|
-
const response = await loginWithRetry(email, password);
|
|
53
|
-
|
|
54
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
55
|
-
throw Error(`Error: ${JSON.stringify(response.data)}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const authCookie = response.headers['set-cookie'].find(item => item.startsWith('JonesToken='));
|
|
59
|
-
|
|
60
|
-
addUserIdentity(email, authCookie, response.data.user.id);
|
|
61
|
-
|
|
62
|
-
return authCookie;
|
|
63
|
-
} catch (error) {
|
|
64
|
-
throw new Error(`Failed to login with email: ${email}\nError: ${error}`);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const verifyEmail = email => {
|
|
69
|
-
return authApi.verifyEmail(email);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const createOneTimeSession = email => {
|
|
73
|
-
return authApi.createOneTimeSession(email);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const getHubUserCookie = async (email, oneTimeCode) => {
|
|
77
|
-
try {
|
|
78
|
-
const response = await authApi.verifyUser(email, oneTimeCode);
|
|
79
|
-
|
|
80
|
-
if (response.status !== httpResponseStatusCodes.OK && response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
81
|
-
throw Error(`Error: ${JSON.stringify(response.data)}`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const authCookie = response.headers['set-cookie'].find(item => item.startsWith('JonesToken='));
|
|
85
|
-
|
|
86
|
-
return authCookie;
|
|
87
|
-
} catch (error) {
|
|
88
|
-
throw new Error(`Failed to login to vendor hub by email:${email}`, error);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const getIcsCookie = () => {
|
|
93
|
-
const { superUser, superUserPassword } = credentials;
|
|
94
|
-
|
|
95
|
-
requiredValidation({
|
|
96
|
-
'credentials.superUser': superUser,
|
|
97
|
-
'credentials.superUserPassword': superUserPassword
|
|
98
|
-
});
|
|
99
|
-
return getAuthCookie(superUser, superUserPassword);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const getAuditorCookie = () => {
|
|
103
|
-
const { auditorUser, auditorPassword } = credentials;
|
|
104
|
-
requiredValidation({
|
|
105
|
-
'credentials.auditorUser': auditorUser,
|
|
106
|
-
'credentials.auditorPassword': auditorPassword
|
|
107
|
-
});
|
|
108
|
-
return getAuthCookie(auditorUser, auditorPassword);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const getOperatorCookie = () => {
|
|
112
|
-
const { operatorUser, operatorPassword } = credentials;
|
|
113
|
-
requiredValidation({
|
|
114
|
-
'credentials.operatorUser': operatorUser,
|
|
115
|
-
'credentials.operatorPassword': operatorPassword
|
|
116
|
-
});
|
|
117
|
-
return getAuthCookie(operatorUser, operatorPassword);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const login = (email, password) => {
|
|
121
|
-
return authApi.login(email, password);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const twoFAResendCode = (email, pendingSessionToken) => {
|
|
125
|
-
return authApi.twoFAResendCode(email, pendingSessionToken);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const twoFAVerify = (email, code, pendingSessionToken) => {
|
|
129
|
-
return authApi.twoFAVerify(email, code, pendingSessionToken);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const getAuthenticatedUser = context => {
|
|
133
|
-
return authApi.getAuthenticatedUser(context);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// The id the backend stamps into the session on login — the same value
|
|
137
|
-
// getLoggedInUserId() resolves from the JWT. Available only after the email
|
|
138
|
-
// has logged in (getAuthCookie caches it); returns null otherwise.
|
|
139
|
-
const getUserId = email => {
|
|
140
|
-
const identity = getSystemUserIdentity(email);
|
|
141
|
-
return identity ? identity.id : null;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const isHubUser = async (email, { expectError } = {}) => {
|
|
145
|
-
const response = await authApi.isHubUser(email);
|
|
146
|
-
|
|
147
|
-
if (!expectError && response.status !== httpResponseStatusCodes.OK) {
|
|
148
|
-
throw new Error(`is-hub-user failed for ${email}: ${JSON.stringify(response.data)}`);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return response.data;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const resetPassword = async (password, linkData, { expectError = false } = {}) => {
|
|
155
|
-
const response = await authApi.resetPassword(password, linkData);
|
|
156
|
-
|
|
157
|
-
if (!expectError && response.status !== httpResponseStatusCodes.OK) {
|
|
158
|
-
throw Error(`Failed to reset password. Status code: ${response.status}`);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return response;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// Reads the user_login_attempt row via the ICS-secured test-only endpoint.
|
|
165
|
-
// A 404 (no row ever created) is a distinct state from a cleared row (200, counter 0, null dates);
|
|
166
|
-
// pass { expectError: true } to receive the raw response and tell them apart, otherwise the
|
|
167
|
-
// wrapper throws on any non-200 rather than flattening a 404 into a zeroed row.
|
|
168
|
-
const getLoginAttempts = async (email, { expectError } = {}) => {
|
|
169
|
-
const response = await authApi.getLoginAttempts(email, await getIcsCookie());
|
|
170
|
-
|
|
171
|
-
if (!expectError && response.status !== httpResponseStatusCodes.OK) {
|
|
172
|
-
throw new Error(`getLoginAttempts failed for ${email}: ${JSON.stringify(response.data)}`);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return expectError ? response : response.data;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
// Backdates the failed-login timestamps for an existing row. The endpoint returns 204 No Content.
|
|
179
|
-
const backdateLoginAttempt = async (email, { dateLastFailedLogin, dateFirstFailedLogin } = {}) => {
|
|
180
|
-
const response = await authApi.backdateLoginAttempt(
|
|
181
|
-
{ email, dateLastFailedLogin, dateFirstFailedLogin }, await getIcsCookie());
|
|
182
|
-
|
|
183
|
-
if (response.status !== httpResponseStatusCodes.NO_CONTENT && response.status !== httpResponseStatusCodes.OK) {
|
|
184
|
-
throw new Error(`backdateLoginAttempt failed for ${email}: ${JSON.stringify(response.data)}`);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// Clears the user_login_attempt row for an email via the ICS-secured test-only endpoint.
|
|
189
|
-
// Idempotent: the endpoint returns 204 whether or not a row existed, so this is safe to call
|
|
190
|
-
// on non-existent-email subjects when resetting lockout state between runs.
|
|
191
|
-
const deleteLoginAttempt = async email => {
|
|
192
|
-
const response = await authApi.deleteLoginAttempt(email, await getIcsCookie());
|
|
193
|
-
|
|
194
|
-
if (response.status !== httpResponseStatusCodes.NO_CONTENT && response.status !== httpResponseStatusCodes.OK) {
|
|
195
|
-
throw new Error(`deleteLoginAttempt failed for ${email}: ${JSON.stringify(response.data)}`);
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
module.exports = {
|
|
200
|
-
getAuthCookie,
|
|
201
|
-
verifyEmail,
|
|
202
|
-
createOneTimeSession,
|
|
203
|
-
getHubUserCookie,
|
|
204
|
-
getIcsCookie,
|
|
205
|
-
getAuditorCookie,
|
|
206
|
-
getOperatorCookie,
|
|
207
|
-
login,
|
|
208
|
-
twoFAResendCode,
|
|
209
|
-
twoFAVerify,
|
|
210
|
-
getAuthenticatedUser,
|
|
211
|
-
getUserId,
|
|
212
|
-
isHubUser,
|
|
213
|
-
resetPassword,
|
|
214
|
-
getLoginAttempts,
|
|
215
|
-
backdateLoginAttempt,
|
|
216
|
-
deleteLoginAttempt
|
|
217
|
-
};
|
|
1
|
+
const { getEnv, requiredValidation, getSystemUserIdentity, addUserIdentity } = require('../../../../env');
|
|
2
|
+
const { credentials } = getEnv();
|
|
3
|
+
|
|
4
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
5
|
+
|
|
6
|
+
const authApi = require('./auth.api');
|
|
7
|
+
const timeUtils = require('../../../../common/utils/timeUtils');
|
|
8
|
+
|
|
9
|
+
const RETRYABLE_LOGIN_STATUSES = [
|
|
10
|
+
httpResponseStatusCodes.BAD_GATEWAY,
|
|
11
|
+
httpResponseStatusCodes.SERVICE_UNAVAILABLE,
|
|
12
|
+
httpResponseStatusCodes.GATEWAY_TIMEOUT
|
|
13
|
+
];
|
|
14
|
+
const MAX_LOGIN_ATTEMPTS = 3;
|
|
15
|
+
const LOGIN_RETRY_STEP_TIMEOUT = 2000;
|
|
16
|
+
const LOGIN_RETRY_RANGE_TIMEOUT = 5000;
|
|
17
|
+
|
|
18
|
+
// Parallel callers for the same user share one login request
|
|
19
|
+
const pendingLogins = new Map();
|
|
20
|
+
|
|
21
|
+
const getAuthCookie = async (email, password) => {
|
|
22
|
+
const systemUser = getSystemUserIdentity(email);
|
|
23
|
+
|
|
24
|
+
if (systemUser) {
|
|
25
|
+
return systemUser.cookie;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!pendingLogins.has(email)) {
|
|
29
|
+
const login = loginAndCacheCookie(email, password).finally(() => pendingLogins.delete(email));
|
|
30
|
+
pendingLogins.set(email, login);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return pendingLogins.get(email);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const loginWithRetry = async (email, password) => {
|
|
37
|
+
for (let attempt = 1; ; attempt++) {
|
|
38
|
+
const response = await authApi.login(email, password);
|
|
39
|
+
|
|
40
|
+
if (!RETRYABLE_LOGIN_STATUSES.includes(response.status) || attempt === MAX_LOGIN_ATTEMPTS) {
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.warn(`Login for ${email} failed with status ${response.status}, retrying`);
|
|
45
|
+
const retryRandomTimeout = attempt * LOGIN_RETRY_STEP_TIMEOUT + Math.random() * LOGIN_RETRY_RANGE_TIMEOUT;
|
|
46
|
+
await timeUtils.waitFor(retryRandomTimeout).mSeconds;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const loginAndCacheCookie = async (email, password) => {
|
|
51
|
+
try {
|
|
52
|
+
const response = await loginWithRetry(email, password);
|
|
53
|
+
|
|
54
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
55
|
+
throw Error(`Error: ${JSON.stringify(response.data)}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const authCookie = response.headers['set-cookie'].find(item => item.startsWith('JonesToken='));
|
|
59
|
+
|
|
60
|
+
addUserIdentity(email, authCookie, response.data.user.id);
|
|
61
|
+
|
|
62
|
+
return authCookie;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new Error(`Failed to login with email: ${email}\nError: ${error}`);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const verifyEmail = email => {
|
|
69
|
+
return authApi.verifyEmail(email);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const createOneTimeSession = email => {
|
|
73
|
+
return authApi.createOneTimeSession(email);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const getHubUserCookie = async (email, oneTimeCode) => {
|
|
77
|
+
try {
|
|
78
|
+
const response = await authApi.verifyUser(email, oneTimeCode);
|
|
79
|
+
|
|
80
|
+
if (response.status !== httpResponseStatusCodes.OK && response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
81
|
+
throw Error(`Error: ${JSON.stringify(response.data)}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const authCookie = response.headers['set-cookie'].find(item => item.startsWith('JonesToken='));
|
|
85
|
+
|
|
86
|
+
return authCookie;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
throw new Error(`Failed to login to vendor hub by email:${email}`, error);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const getIcsCookie = () => {
|
|
93
|
+
const { superUser, superUserPassword } = credentials;
|
|
94
|
+
|
|
95
|
+
requiredValidation({
|
|
96
|
+
'credentials.superUser': superUser,
|
|
97
|
+
'credentials.superUserPassword': superUserPassword
|
|
98
|
+
});
|
|
99
|
+
return getAuthCookie(superUser, superUserPassword);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const getAuditorCookie = () => {
|
|
103
|
+
const { auditorUser, auditorPassword } = credentials;
|
|
104
|
+
requiredValidation({
|
|
105
|
+
'credentials.auditorUser': auditorUser,
|
|
106
|
+
'credentials.auditorPassword': auditorPassword
|
|
107
|
+
});
|
|
108
|
+
return getAuthCookie(auditorUser, auditorPassword);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const getOperatorCookie = () => {
|
|
112
|
+
const { operatorUser, operatorPassword } = credentials;
|
|
113
|
+
requiredValidation({
|
|
114
|
+
'credentials.operatorUser': operatorUser,
|
|
115
|
+
'credentials.operatorPassword': operatorPassword
|
|
116
|
+
});
|
|
117
|
+
return getAuthCookie(operatorUser, operatorPassword);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const login = (email, password) => {
|
|
121
|
+
return authApi.login(email, password);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const twoFAResendCode = (email, pendingSessionToken) => {
|
|
125
|
+
return authApi.twoFAResendCode(email, pendingSessionToken);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const twoFAVerify = (email, code, pendingSessionToken) => {
|
|
129
|
+
return authApi.twoFAVerify(email, code, pendingSessionToken);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const getAuthenticatedUser = context => {
|
|
133
|
+
return authApi.getAuthenticatedUser(context);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// The id the backend stamps into the session on login — the same value
|
|
137
|
+
// getLoggedInUserId() resolves from the JWT. Available only after the email
|
|
138
|
+
// has logged in (getAuthCookie caches it); returns null otherwise.
|
|
139
|
+
const getUserId = email => {
|
|
140
|
+
const identity = getSystemUserIdentity(email);
|
|
141
|
+
return identity ? identity.id : null;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const isHubUser = async (email, { expectError } = {}) => {
|
|
145
|
+
const response = await authApi.isHubUser(email);
|
|
146
|
+
|
|
147
|
+
if (!expectError && response.status !== httpResponseStatusCodes.OK) {
|
|
148
|
+
throw new Error(`is-hub-user failed for ${email}: ${JSON.stringify(response.data)}`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return response.data;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const resetPassword = async (password, linkData, { expectError = false } = {}) => {
|
|
155
|
+
const response = await authApi.resetPassword(password, linkData);
|
|
156
|
+
|
|
157
|
+
if (!expectError && response.status !== httpResponseStatusCodes.OK) {
|
|
158
|
+
throw Error(`Failed to reset password. Status code: ${response.status}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return response;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// Reads the user_login_attempt row via the ICS-secured test-only endpoint.
|
|
165
|
+
// A 404 (no row ever created) is a distinct state from a cleared row (200, counter 0, null dates);
|
|
166
|
+
// pass { expectError: true } to receive the raw response and tell them apart, otherwise the
|
|
167
|
+
// wrapper throws on any non-200 rather than flattening a 404 into a zeroed row.
|
|
168
|
+
const getLoginAttempts = async (email, { expectError } = {}) => {
|
|
169
|
+
const response = await authApi.getLoginAttempts(email, await getIcsCookie());
|
|
170
|
+
|
|
171
|
+
if (!expectError && response.status !== httpResponseStatusCodes.OK) {
|
|
172
|
+
throw new Error(`getLoginAttempts failed for ${email}: ${JSON.stringify(response.data)}`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return expectError ? response : response.data;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// Backdates the failed-login timestamps for an existing row. The endpoint returns 204 No Content.
|
|
179
|
+
const backdateLoginAttempt = async (email, { dateLastFailedLogin, dateFirstFailedLogin } = {}) => {
|
|
180
|
+
const response = await authApi.backdateLoginAttempt(
|
|
181
|
+
{ email, dateLastFailedLogin, dateFirstFailedLogin }, await getIcsCookie());
|
|
182
|
+
|
|
183
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT && response.status !== httpResponseStatusCodes.OK) {
|
|
184
|
+
throw new Error(`backdateLoginAttempt failed for ${email}: ${JSON.stringify(response.data)}`);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Clears the user_login_attempt row for an email via the ICS-secured test-only endpoint.
|
|
189
|
+
// Idempotent: the endpoint returns 204 whether or not a row existed, so this is safe to call
|
|
190
|
+
// on non-existent-email subjects when resetting lockout state between runs.
|
|
191
|
+
const deleteLoginAttempt = async email => {
|
|
192
|
+
const response = await authApi.deleteLoginAttempt(email, await getIcsCookie());
|
|
193
|
+
|
|
194
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT && response.status !== httpResponseStatusCodes.OK) {
|
|
195
|
+
throw new Error(`deleteLoginAttempt failed for ${email}: ${JSON.stringify(response.data)}`);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
module.exports = {
|
|
200
|
+
getAuthCookie,
|
|
201
|
+
verifyEmail,
|
|
202
|
+
createOneTimeSession,
|
|
203
|
+
getHubUserCookie,
|
|
204
|
+
getIcsCookie,
|
|
205
|
+
getAuditorCookie,
|
|
206
|
+
getOperatorCookie,
|
|
207
|
+
login,
|
|
208
|
+
twoFAResendCode,
|
|
209
|
+
twoFAVerify,
|
|
210
|
+
getAuthenticatedUser,
|
|
211
|
+
getUserId,
|
|
212
|
+
isHubUser,
|
|
213
|
+
resetPassword,
|
|
214
|
+
getLoginAttempts,
|
|
215
|
+
backdateLoginAttempt,
|
|
216
|
+
deleteLoginAttempt
|
|
217
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const services = require('./api/auth.service');
|
|
2
|
-
|
|
3
|
-
module.exports = { services };
|
|
1
|
+
const services = require('./api/auth.service');
|
|
2
|
+
|
|
3
|
+
module.exports = { services };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
-
const { backendUrl, threadSchedulerSecret } = require('../../../../env').getEnv();
|
|
3
|
-
|
|
4
|
-
const Endpoints = {
|
|
5
|
-
enrollments: `${backendUrl}/schedulerJob/certificial/enrollments`
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// Authenticated by x-scheduler-secret, not a cookie, so no ics context is passed.
|
|
9
|
-
const getEnrollments = recordIds => {
|
|
10
|
-
const headers = { 'x-scheduler-secret': threadSchedulerSecret };
|
|
11
|
-
|
|
12
|
-
return requests.getRequestHandler(Endpoints.enrollments, { recordIds: recordIds.toString() }, null, headers);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
module.exports = { getEnrollments };
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const { backendUrl, threadSchedulerSecret } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
enrollments: `${backendUrl}/schedulerJob/certificial/enrollments`
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// Authenticated by x-scheduler-secret, not a cookie, so no ics context is passed.
|
|
9
|
+
const getEnrollments = recordIds => {
|
|
10
|
+
const headers = { 'x-scheduler-secret': threadSchedulerSecret };
|
|
11
|
+
|
|
12
|
+
return requests.getRequestHandler(Endpoints.enrollments, { recordIds: recordIds.toString() }, null, headers);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports = { getEnrollments };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const certificialApi = require('./certificial.api');
|
|
2
|
-
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
3
|
-
|
|
4
|
-
// One row per requested record id. A record with no enrollment comes back with null fields, not a 404.
|
|
5
|
-
const getEnrollmentStates = async recordIds => {
|
|
6
|
-
const response = await certificialApi.getEnrollments(recordIds);
|
|
7
|
-
|
|
8
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
9
|
-
throw new Error(`Failed to read Certificial enrollment state for records ${recordIds}, response status - ${response.status}`);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return response.data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const getEnrollmentState = async recordId => {
|
|
16
|
-
const [enrollmentState] = await getEnrollmentStates([recordId]);
|
|
17
|
-
|
|
18
|
-
return enrollmentState;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
getEnrollmentStates,
|
|
23
|
-
getEnrollmentState
|
|
24
|
-
};
|
|
1
|
+
const certificialApi = require('./certificial.api');
|
|
2
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
3
|
+
|
|
4
|
+
// One row per requested record id. A record with no enrollment comes back with null fields, not a 404.
|
|
5
|
+
const getEnrollmentStates = async recordIds => {
|
|
6
|
+
const response = await certificialApi.getEnrollments(recordIds);
|
|
7
|
+
|
|
8
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
9
|
+
throw new Error(`Failed to read Certificial enrollment state for records ${recordIds}, response status - ${response.status}`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return response.data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getEnrollmentState = async recordId => {
|
|
16
|
+
const [enrollmentState] = await getEnrollmentStates([recordId]);
|
|
17
|
+
|
|
18
|
+
return enrollmentState;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
getEnrollmentStates,
|
|
23
|
+
getEnrollmentState
|
|
24
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// PENDING means Certificial never answered, so the row is never auto-retried.
|
|
2
|
-
const ENROLLMENT_STATUSES = {
|
|
3
|
-
PENDING: 'PENDING',
|
|
4
|
-
ENROLLED: 'ENROLLED',
|
|
5
|
-
REJECTED: 'REJECTED'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
module.exports = { ENROLLMENT_STATUSES };
|
|
1
|
+
// PENDING means Certificial never answered, so the row is never auto-retried.
|
|
2
|
+
const ENROLLMENT_STATUSES = {
|
|
3
|
+
PENDING: 'PENDING',
|
|
4
|
+
ENROLLED: 'ENROLLED',
|
|
5
|
+
REJECTED: 'REJECTED'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
module.exports = { ENROLLMENT_STATUSES };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const services = require('./api/certificial.service');
|
|
2
|
-
const consts = require('./consts');
|
|
3
|
-
|
|
4
|
-
module.exports = { services, consts };
|
|
1
|
+
const services = require('./api/certificial.service');
|
|
2
|
+
const consts = require('./consts');
|
|
3
|
+
|
|
4
|
+
module.exports = { services, consts };
|