@icure/api 8.6.18 → 8.7.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/icc-api/api/IccDocumentApi.d.ts +10 -2
- package/icc-api/api/IccDocumentApi.js +22 -4
- package/icc-api/api/IccDocumentApi.js.map +1 -1
- package/icc-api/api/IccReceiptApi.d.ts +17 -0
- package/icc-api/api/IccReceiptApi.js +52 -0
- package/icc-api/api/IccReceiptApi.js.map +1 -1
- package/icc-api/model/DataAttachment.d.ts +22 -0
- package/icc-api/model/DataAttachment.js.map +1 -1
- package/icc-api/model/Document.d.ts +6 -0
- package/icc-api/model/Document.js.map +1 -1
- package/icc-api/model/Receipt.d.ts +6 -0
- package/icc-api/model/Receipt.js.map +1 -1
- package/icc-x-api/crypto/BaseExchangeDataManager.js +2 -2
- package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
- package/icc-x-api/crypto/ExchangeDataManager.js +3 -3
- package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtils.d.ts +1 -1
- package/icc-x-api/crypto/ExtendedApisUtils.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +1 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +8 -2
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
- package/icc-x-api/crypto/RecoveryDataEncryption.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.js +7 -7
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.js +7 -7
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.js +4 -5
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-code-x-api.d.ts +2 -2
- package/icc-x-api/icc-code-x-api.js +3 -33
- package/icc-x-api/icc-code-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.js +20 -33
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +8 -7
- package/icc-x-api/icc-document-x-api.js +64 -22
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.js +3 -4
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.js +11 -11
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.js +3 -4
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.js +3 -3
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.js +29 -29
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +40 -0
- package/icc-x-api/icc-receipt-x-api.js +79 -1
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-topic-x-api.js.map +1 -1
- package/icc-x-api/index.js +1 -1
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/utils/code-util.d.ts +23 -0
- package/icc-x-api/utils/code-util.js +39 -2
- package/icc-x-api/utils/code-util.js.map +1 -1
- package/icc-x-api/utils/collection-utils.d.ts +13 -0
- package/icc-x-api/utils/collection-utils.js +69 -0
- package/icc-x-api/utils/collection-utils.js.map +1 -1
- package/icc-x-api/utils/compression-utils.d.ts +28 -0
- package/icc-x-api/utils/compression-utils.js +106 -0
- package/icc-x-api/utils/compression-utils.js.map +1 -0
- package/icc-x-api/utils/crypto-utils.js +7 -7
- package/icc-x-api/utils/crypto-utils.js.map +1 -1
- package/icc-x-api/utils/formatting-util.d.ts +1 -3
- package/icc-x-api/utils/formatting-util.js +15 -17
- package/icc-x-api/utils/formatting-util.js.map +1 -1
- package/icc-x-api/utils/hcp-util.js +2 -3
- package/icc-x-api/utils/hcp-util.js.map +1 -1
- package/icc-x-api/utils/insurability-util.js +10 -8
- package/icc-x-api/utils/insurability-util.js.map +1 -1
- package/icc-x-api/utils/lzma-wasm.d.ts +6 -0
- package/icc-x-api/utils/lzma-wasm.js +81 -0
- package/icc-x-api/utils/lzma-wasm.js.map +1 -0
- package/icc-x-api/utils/mutex.d.ts +12 -0
- package/icc-x-api/utils/mutex.js +26 -0
- package/icc-x-api/utils/mutex.js.map +1 -0
- package/icc-x-api/utils/websocket.js +7 -7
- package/icc-x-api/utils/websocket.js.map +1 -1
- package/icc-x-api/wasm/lzma/lzma.js +2 -0
- package/icc-x-api/wasm/lzma/lzma.wasm +0 -0
- package/package.json +2 -11
- package/icc-x-api/utils/uuid-encoder.d.ts +0 -44
- package/icc-x-api/utils/uuid-encoder.js +0 -114
- package/icc-x-api/utils/uuid-encoder.js.map +0 -1
- package/test/icc-api/api/IccAgendaApi.d.ts +0 -1
- package/test/icc-api/api/IccAgendaApi.js +0 -64
- package/test/icc-api/api/IccAgendaApi.js.map +0 -1
- package/test/icc-api/api/IccAnonymousAccessApi.d.ts +0 -1
- package/test/icc-api/api/IccAnonymousAccessApi.js +0 -58
- package/test/icc-api/api/IccAnonymousAccessApi.js.map +0 -1
- package/test/icc-api/api/IccCalendarItemApi.d.ts +0 -1
- package/test/icc-api/api/IccCalendarItemApi.js +0 -67
- package/test/icc-api/api/IccCalendarItemApi.js.map +0 -1
- package/test/icc-api/api/IccCalendarItemTypeApi.d.ts +0 -1
- package/test/icc-api/api/IccCalendarItemTypeApi.js +0 -96
- package/test/icc-api/api/IccCalendarItemTypeApi.js.map +0 -1
- package/test/icc-api/api/IccCodeApi.d.ts +0 -1
- package/test/icc-api/api/IccCodeApi.js +0 -38
- package/test/icc-api/api/IccCodeApi.js.map +0 -1
- package/test/icc-api/api/IccDocumentApi.d.ts +0 -1
- package/test/icc-api/api/IccDocumentApi.js +0 -199
- package/test/icc-api/api/IccDocumentApi.js.map +0 -1
- package/test/icc-api/api/IccGroupApi.d.ts +0 -1
- package/test/icc-api/api/IccGroupApi.js +0 -50
- package/test/icc-api/api/IccGroupApi.js.map +0 -1
- package/test/icc-api/api/IccKeywordApi.d.ts +0 -1
- package/test/icc-api/api/IccKeywordApi.js +0 -64
- package/test/icc-api/api/IccKeywordApi.js.map +0 -1
- package/test/icc-api/api/IccMedicalLocationApi.d.ts +0 -1
- package/test/icc-api/api/IccMedicalLocationApi.js +0 -64
- package/test/icc-api/api/IccMedicalLocationApi.js.map +0 -1
- package/test/icc-api/api/IccPlaceApi.d.ts +0 -1
- package/test/icc-api/api/IccPlaceApi.js +0 -64
- package/test/icc-api/api/IccPlaceApi.js.map +0 -1
- package/test/icc-api/api/IccRecoveryDataApi.d.ts +0 -1
- package/test/icc-api/api/IccRecoveryDataApi.js +0 -95
- package/test/icc-api/api/IccRecoveryDataApi.js.map +0 -1
- package/test/icc-api/api/IccRoleApi.d.ts +0 -1
- package/test/icc-api/api/IccRoleApi.js +0 -34
- package/test/icc-api/api/IccRoleApi.js.map +0 -1
- package/test/icc-api/api/IccUserApi.d.ts +0 -1
- package/test/icc-api/api/IccUserApi.js +0 -96
- package/test/icc-api/api/IccUserApi.js.map +0 -1
- package/test/icc-api/e2e/IccCalendarItemApi.d.ts +0 -1
- package/test/icc-api/e2e/IccCalendarItemApi.js +0 -46
- package/test/icc-api/e2e/IccCalendarItemApi.js.map +0 -1
- package/test/icc-api/model/modelHelpersTest.d.ts +0 -1
- package/test/icc-api/model/modelHelpersTest.js +0 -45
- package/test/icc-api/model/modelHelpersTest.js.map +0 -1
- package/test/icc-x-api/auth/group-switch-test.d.ts +0 -1
- package/test/icc-x-api/auth/group-switch-test.js +0 -81
- package/test/icc-x-api/auth/group-switch-test.js.map +0 -1
- package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +0 -2
- package/test/icc-x-api/auth/jwt-concurrency-test.js +0 -112
- package/test/icc-x-api/auth/jwt-concurrency-test.js.map +0 -1
- package/test/icc-x-api/auth/jwt-provider-test.d.ts +0 -1
- package/test/icc-x-api/auth/jwt-provider-test.js +0 -197
- package/test/icc-x-api/auth/jwt-provider-test.js.map +0 -1
- package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +0 -1
- package/test/icc-x-api/auth/smart-auth-provider-test.js +0 -224
- package/test/icc-x-api/auth/smart-auth-provider-test.js.map +0 -1
- package/test/icc-x-api/autofix-anonymity-test.d.ts +0 -1
- package/test/icc-x-api/autofix-anonymity-test.js +0 -122
- package/test/icc-x-api/autofix-anonymity-test.js.map +0 -1
- package/test/icc-x-api/confidential-entities-test.d.ts +0 -1
- package/test/icc-x-api/confidential-entities-test.js +0 -168
- package/test/icc-x-api/confidential-entities-test.js.map +0 -1
- package/test/icc-x-api/crud/comprehensive-crud-test.d.ts +0 -1
- package/test/icc-x-api/crud/comprehensive-crud-test.js +0 -276
- package/test/icc-x-api/crud/comprehensive-crud-test.js.map +0 -1
- package/test/icc-x-api/crud/entities-crud-test-interface.d.ts +0 -16
- package/test/icc-x-api/crud/entities-crud-test-interface.js +0 -408
- package/test/icc-x-api/crud/entities-crud-test-interface.js.map +0 -1
- package/test/icc-x-api/crypto/anonymous-delegations-test.d.ts +0 -1
- package/test/icc-x-api/crypto/anonymous-delegations-test.js +0 -587
- package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +0 -1
- package/test/icc-x-api/crypto/concurrency.d.ts +0 -1
- package/test/icc-x-api/crypto/concurrency.js +0 -35
- package/test/icc-x-api/crypto/concurrency.js.map +0 -1
- package/test/icc-x-api/crypto/crypto-utils.d.ts +0 -1
- package/test/icc-x-api/crypto/crypto-utils.js +0 -79
- package/test/icc-x-api/crypto/crypto-utils.js.map +0 -1
- package/test/icc-x-api/crypto/cryptoTest.d.ts +0 -2
- package/test/icc-x-api/crypto/cryptoTest.js +0 -402
- package/test/icc-x-api/crypto/cryptoTest.js.map +0 -1
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +0 -1
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +0 -166
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +0 -1
- package/test/icc-x-api/crypto/exchange-data-manager-test.d.ts +0 -1
- package/test/icc-x-api/crypto/exchange-data-manager-test.js +0 -674
- package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +0 -1
- package/test/icc-x-api/crypto/full-crypto-test.d.ts +0 -1
- package/test/icc-x-api/crypto/full-crypto-test.js +0 -454
- package/test/icc-x-api/crypto/full-crypto-test.js.map +0 -1
- package/test/icc-x-api/crypto/legacy-metadata-migration-test.d.ts +0 -1
- package/test/icc-x-api/crypto/legacy-metadata-migration-test.js +0 -379
- package/test/icc-x-api/crypto/legacy-metadata-migration-test.js.map +0 -1
- package/test/icc-x-api/crypto/secure-delegations-manager-test.d.ts +0 -1
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js +0 -278
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +0 -1
- package/test/icc-x-api/crypto/shamir.d.ts +0 -2
- package/test/icc-x-api/crypto/shamir.js +0 -167
- package/test/icc-x-api/crypto/shamir.js.map +0 -1
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +0 -1
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +0 -71
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +0 -1
- package/test/icc-x-api/crypto/soft-deleted-data-owners.d.ts +0 -2
- package/test/icc-x-api/crypto/soft-deleted-data-owners.js +0 -113
- package/test/icc-x-api/crypto/soft-deleted-data-owners.js.map +0 -1
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.d.ts +0 -1
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +0 -246
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +0 -1
- package/test/icc-x-api/entity-with-attachments-api-test.d.ts +0 -1
- package/test/icc-x-api/entity-with-attachments-api-test.js +0 -142
- package/test/icc-x-api/entity-with-attachments-api-test.js.map +0 -1
- package/test/icc-x-api/filters/filters.d.ts +0 -1
- package/test/icc-x-api/filters/filters.js +0 -49
- package/test/icc-x-api/filters/filters.js.map +0 -1
- package/test/icc-x-api/filters/healthelement.d.ts +0 -1
- package/test/icc-x-api/filters/healthelement.js +0 -333
- package/test/icc-x-api/filters/healthelement.js.map +0 -1
- package/test/icc-x-api/icc-accesslog-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-accesslog-x-api.js +0 -106
- package/test/icc-x-api/icc-accesslog-x-api.js.map +0 -1
- package/test/icc-x-api/icc-application-settings-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-application-settings-x-api.js +0 -91
- package/test/icc-x-api/icc-application-settings-x-api.js.map +0 -1
- package/test/icc-x-api/icc-auth-api.d.ts +0 -1
- package/test/icc-x-api/icc-auth-api.js +0 -47
- package/test/icc-x-api/icc-auth-api.js.map +0 -1
- package/test/icc-x-api/icc-calendar-item-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-calendar-item-x-api.js +0 -150
- package/test/icc-x-api/icc-calendar-item-x-api.js.map +0 -1
- package/test/icc-x-api/icc-contact-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-contact-x-api.js +0 -355
- package/test/icc-x-api/icc-contact-x-api.js.map +0 -1
- package/test/icc-x-api/icc-document-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-document-x-api.js +0 -76
- package/test/icc-x-api/icc-document-x-api.js.map +0 -1
- package/test/icc-x-api/icc-form-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-form-x-api.js +0 -413
- package/test/icc-x-api/icc-form-x-api.js.map +0 -1
- package/test/icc-x-api/icc-hcparty-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-hcparty-x-api-test.js +0 -43
- package/test/icc-x-api/icc-hcparty-x-api-test.js.map +0 -1
- package/test/icc-x-api/icc-helement-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-helement-x-api-test.js +0 -155
- package/test/icc-x-api/icc-helement-x-api-test.js.map +0 -1
- package/test/icc-x-api/icc-invoice-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-invoice-x-api.js +0 -99
- package/test/icc-x-api/icc-invoice-x-api.js.map +0 -1
- package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-maintenance-task-x-api-test.js +0 -222
- package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +0 -1
- package/test/icc-x-api/icc-message-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-message-x-api.js +0 -54
- package/test/icc-x-api/icc-message-x-api.js.map +0 -1
- package/test/icc-x-api/icc-patient-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-patient-x-api-test.js +0 -165
- package/test/icc-x-api/icc-patient-x-api-test.js.map +0 -1
- package/test/icc-x-api/icc-recovery-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-recovery-x-api.js +0 -175
- package/test/icc-x-api/icc-recovery-x-api.js.map +0 -1
- package/test/icc-x-api/icc-topic-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-topic-x-api.js +0 -269
- package/test/icc-x-api/icc-topic-x-api.js.map +0 -1
- package/test/icc-x-api/icc-user-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-user-x-api-test.js +0 -99
- package/test/icc-x-api/icc-user-x-api-test.js.map +0 -1
- package/test/icc-x-api/keyless-api.d.ts +0 -1
- package/test/icc-x-api/keyless-api.js +0 -125
- package/test/icc-x-api/keyless-api.js.map +0 -1
- package/test/icc-x-api/patient-user.d.ts +0 -2
- package/test/icc-x-api/patient-user.js +0 -103
- package/test/icc-x-api/patient-user.js.map +0 -1
- package/test/icc-x-api/storage/storage.d.ts +0 -1
- package/test/icc-x-api/storage/storage.js +0 -48
- package/test/icc-x-api/storage/storage.js.map +0 -1
- package/test/icc-x-api/test-api-no-parent.d.ts +0 -1
- package/test/icc-x-api/test-api-no-parent.js +0 -79
- package/test/icc-x-api/test-api-no-parent.js.map +0 -1
- package/test/icc-x-api/test-legacy-data-support.d.ts +0 -1
- package/test/icc-x-api/test-legacy-data-support.js +0 -375
- package/test/icc-x-api/test-legacy-data-support.js.map +0 -1
- package/test/icc-x-api/utils/graph-test.d.ts +0 -1
- package/test/icc-x-api/utils/graph-test.js +0 -54
- package/test/icc-x-api/utils/graph-test.js.map +0 -1
- package/test/icc-x-api/utils/lru-temporised-async-cache-test.d.ts +0 -1
- package/test/icc-x-api/utils/lru-temporised-async-cache-test.js +0 -364
- package/test/icc-x-api/utils/lru-temporised-async-cache-test.js.map +0 -1
- package/test/support/CSM-185.d.ts +0 -1
- package/test/support/CSM-185.js +0 -124
- package/test/support/CSM-185.js.map +0 -1
- package/test/support/CSM-243.d.ts +0 -1
- package/test/support/CSM-243.js +0 -120
- package/test/support/CSM-243.js.map +0 -1
- package/test/support/CSM-543.d.ts +0 -1
- package/test/support/CSM-543.js +0 -164
- package/test/support/CSM-543.js.map +0 -1
- package/test/support/CSM-729.d.ts +0 -1
- package/test/support/CSM-729.js +0 -225
- package/test/support/CSM-729.js.map +0 -1
- package/test/support/CSM-87.d.ts +0 -0
- package/test/support/CSM-87.js +0 -21
- package/test/support/CSM-87.js.map +0 -1
- package/test/support/CSM-93.d.ts +0 -1
- package/test/support/CSM-93.js +0 -112
- package/test/support/CSM-93.js.map +0 -1
- package/test/utils/FakeDataOwnerApi.d.ts +0 -32
- package/test/utils/FakeDataOwnerApi.js +0 -136
- package/test/utils/FakeDataOwnerApi.js.map +0 -1
- package/test/utils/FakeEncryptionKeysManager.d.ts +0 -36
- package/test/utils/FakeEncryptionKeysManager.js +0 -98
- package/test/utils/FakeEncryptionKeysManager.js.map +0 -1
- package/test/utils/FakeExchangeDataApi.d.ts +0 -32
- package/test/utils/FakeExchangeDataApi.js +0 -92
- package/test/utils/FakeExchangeDataApi.js.map +0 -1
- package/test/utils/FakeExchangeDataManager.d.ts +0 -48
- package/test/utils/FakeExchangeDataManager.js +0 -82
- package/test/utils/FakeExchangeDataManager.js.map +0 -1
- package/test/utils/FakeExchangeDataMapManager.d.ts +0 -12
- package/test/utils/FakeExchangeDataMapManager.js +0 -38
- package/test/utils/FakeExchangeDataMapManager.js.map +0 -1
- package/test/utils/FakeGenericApi.d.ts +0 -16
- package/test/utils/FakeGenericApi.js +0 -65
- package/test/utils/FakeGenericApi.js.map +0 -1
- package/test/utils/KeylessCryptoStrategies.d.ts +0 -23
- package/test/utils/KeylessCryptoStrategies.js +0 -26
- package/test/utils/KeylessCryptoStrategies.js.map +0 -1
- package/test/utils/TestApi.d.ts +0 -3
- package/test/utils/TestApi.js +0 -30
- package/test/utils/TestApi.js.map +0 -1
- package/test/utils/TestCollectionUtils.d.ts +0 -1
- package/test/utils/TestCollectionUtils.js +0 -109
- package/test/utils/TestCollectionUtils.js.map +0 -1
- package/test/utils/TestCryptoStrategies.d.ts +0 -42
- package/test/utils/TestCryptoStrategies.js +0 -80
- package/test/utils/TestCryptoStrategies.js.map +0 -1
- package/test/utils/TestStorage.d.ts +0 -23
- package/test/utils/TestStorage.js +0 -61
- package/test/utils/TestStorage.js.map +0 -1
- package/test/utils/roles.d.ts +0 -14
- package/test/utils/roles.js +0 -345
- package/test/utils/roles.js.map +0 -1
- package/test/utils/test_utils.d.ts +0 -87
- package/test/utils/test_utils.js +0 -452
- package/test/utils/test_utils.js.map +0 -1
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const test_utils_1 = require("../../utils/test_utils");
|
|
13
|
-
const types_1 = require("@icure/test-setup/types");
|
|
14
|
-
require("isomorphic-fetch");
|
|
15
|
-
const icc_api_1 = require("../../../icc-api");
|
|
16
|
-
const AuthenticationProvider_1 = require("../../../icc-x-api/auth/AuthenticationProvider");
|
|
17
|
-
const chai_1 = require("chai");
|
|
18
|
-
const chaiAsPromised = require("chai-as-promised");
|
|
19
|
-
const SmartAuthProvider_1 = require("../../../icc-x-api/auth/SmartAuthProvider");
|
|
20
|
-
(0, chai_1.use)(chaiAsPromised);
|
|
21
|
-
(0, test_utils_1.setLocalStorage)(fetch);
|
|
22
|
-
let host;
|
|
23
|
-
let userDetails;
|
|
24
|
-
(0, test_utils_1.describeNoLite)('Authentication providers should be able to switch group', function () {
|
|
25
|
-
before(function () {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
this.timeout(600000);
|
|
28
|
-
const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
|
|
29
|
-
const env = yield initializer.execute((0, types_1.getEnvVariables)());
|
|
30
|
-
host = env.iCureUrl;
|
|
31
|
-
userDetails = yield (0, test_utils_1.createUserInMultipleGroups)(env);
|
|
32
|
-
console.log('Users created');
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
const authenticationProviders = [
|
|
36
|
-
['Basic', () => Promise.resolve(new AuthenticationProvider_1.BasicAuthenticationProvider(userDetails.userLogin, userDetails.userPw12))],
|
|
37
|
-
[
|
|
38
|
-
'Jwt',
|
|
39
|
-
() => Promise.resolve(new AuthenticationProvider_1.JwtAuthenticationProvider(new icc_api_1.IccAuthApi(host, {}, new AuthenticationProvider_1.NoAuthenticationProvider(), fetch), userDetails.userLogin, userDetails.userPw12)),
|
|
40
|
-
],
|
|
41
|
-
[
|
|
42
|
-
'Ensemble',
|
|
43
|
-
() => Promise.resolve(new AuthenticationProvider_1.EnsembleAuthenticationProvider(new icc_api_1.IccAuthApi(host, {}, new AuthenticationProvider_1.NoAuthenticationProvider(), fetch), userDetails.userLogin, userDetails.userPw12)),
|
|
44
|
-
],
|
|
45
|
-
[
|
|
46
|
-
'Smart',
|
|
47
|
-
() => SmartAuthProvider_1.SmartAuthProvider.initialise(new icc_api_1.IccAuthApi(host, {}, new AuthenticationProvider_1.NoAuthenticationProvider(), fetch), userDetails.userLogin, {
|
|
48
|
-
getSecret(acceptedSecrets, previousAttempts) {
|
|
49
|
-
(0, chai_1.expect)(acceptedSecrets).to.include(SmartAuthProvider_1.AuthSecretType.PASSWORD);
|
|
50
|
-
return Promise.resolve({ value: userDetails.userPw12, secretType: SmartAuthProvider_1.AuthSecretType.PASSWORD });
|
|
51
|
-
},
|
|
52
|
-
}),
|
|
53
|
-
],
|
|
54
|
-
];
|
|
55
|
-
for (const [providerType, providerFactory] of authenticationProviders) {
|
|
56
|
-
it(`should be able to switch to another group if the username-password is the same in the new group (${providerType})`, () => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const provider = yield providerFactory();
|
|
58
|
-
const initialUserApi = new icc_api_1.IccUserApi(host, {}, provider, fetch);
|
|
59
|
-
const initialUser = yield initialUserApi.getCurrentUser();
|
|
60
|
-
(0, chai_1.expect)(initialUser.id).to.be.oneOf([userDetails.user1.id, userDetails.user2.id]);
|
|
61
|
-
const matches = yield initialUserApi.getMatchingUsers();
|
|
62
|
-
(0, chai_1.expect)(matches.map((x) => x.userId)).to.have.members([userDetails.user1.id, userDetails.user2.id]);
|
|
63
|
-
const switchedToGroup2Provider = yield provider.switchGroup(userDetails.group2.id, matches);
|
|
64
|
-
const userApiGroup2 = new icc_api_1.IccUserApi(host, {}, switchedToGroup2Provider, fetch);
|
|
65
|
-
const userGroup2 = yield userApiGroup2.getCurrentUser();
|
|
66
|
-
(0, chai_1.expect)(userGroup2.id).to.equal(userDetails.user2.id);
|
|
67
|
-
const switchedToGroup1Provider = yield switchedToGroup2Provider.switchGroup(userDetails.group1.id, matches);
|
|
68
|
-
const userApiGroup1 = new icc_api_1.IccUserApi(host, {}, switchedToGroup1Provider, fetch);
|
|
69
|
-
const userGroup1 = yield userApiGroup1.getCurrentUser();
|
|
70
|
-
(0, chai_1.expect)(userGroup1.id).to.equal(userDetails.user1.id);
|
|
71
|
-
}));
|
|
72
|
-
it(`should not be able to switch to another group if the username-password is different in the new group (${providerType})`, () => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const provider = yield providerFactory();
|
|
74
|
-
const initialUserApi = new icc_api_1.IccUserApi(host, {}, provider, fetch);
|
|
75
|
-
const matches = yield initialUserApi.getMatchingUsers();
|
|
76
|
-
(0, chai_1.expect)(matches.map((x) => x.userId)).to.not.contain(userDetails.user3.id);
|
|
77
|
-
yield (0, chai_1.expect)(provider.switchGroup(userDetails.group3.id, matches)).to.be.rejected;
|
|
78
|
-
}));
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
//# sourceMappingURL=group-switch-test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group-switch-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/auth/group-switch-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uDAM+B;AAC/B,mDAAyD;AACzD,4BAAyB;AACzB,8CAAyD;AACzD,2FAMuD;AACvD,+BAA6C;AAC7C,mDAAkD;AAClD,iFAAgH;AAEhH,IAAA,UAAO,EAAC,cAAc,CAAC,CAAA;AAEvB,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,IAAI,IAAY,CAAA;AAChB,IAAI,WAAoC,CAAA;AAExC,IAAA,2BAAc,EAAC,yDAAyD,EAAE;IACxE,MAAM,CAAC;;YACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;YACrD,MAAM,GAAG,GAAG,MAAM,WA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import {\n createUserInMultipleGroups,\n describeNoLite,\n getEnvironmentInitializer,\n setLocalStorage,\n UserInManyGroupsDetails,\n} from '../../utils/test_utils'\nimport { getEnvVariables } from '@icure/test-setup/types'\nimport 'isomorphic-fetch'\nimport { IccAuthApi, IccUserApi } from '../../../icc-api'\nimport {\n AuthenticationProvider,\n BasicAuthenticationProvider,\n EnsembleAuthenticationProvider,\n JwtAuthenticationProvider,\n NoAuthenticationProvider,\n} from '../../../icc-x-api/auth/AuthenticationProvider'\nimport { expect, use as chaiUse } from 'chai'\nimport * as chaiAsPromised from 'chai-as-promised'\nimport { AuthSecretDetails, AuthSecretType, SmartAuthProvider } from '../../../icc-x-api/auth/SmartAuthProvider'\n\nchaiUse(chaiAsPromised)\n\nsetLocalStorage(fetch)\n\nlet host: string\nlet userDetails: UserInManyGroupsDetails\n\ndescribeNoLite('Authentication providers should be able to switch group', function () {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n const env = await initializer.execute(getEnvVariables())\n host = env.iCureUrl\n userDetails = await createUserInMultipleGroups(env)\n console.log('Users created')\n })\n\n const authenticationProviders: [string, () => Promise<AuthenticationProvider>][] = [\n ['Basic', () => Promise.resolve(new BasicAuthenticationProvider(userDetails.userLogin, userDetails.userPw12))],\n [\n 'Jwt',\n () =>\n Promise.resolve(\n new JwtAuthenticationProvider(new IccAuthApi(host, {}, new NoAuthenticationProvider(), fetch), userDetails.userLogin, userDetails.userPw12)\n ),\n ],\n [\n 'Ensemble',\n () =>\n Promise.resolve(\n new EnsembleAuthenticationProvider(\n new IccAuthApi(host, {}, new NoAuthenticationProvider(), fetch),\n userDetails.userLogin,\n userDetails.userPw12\n )\n ),\n ],\n [\n 'Smart',\n () =>\n SmartAuthProvider.initialise(new IccAuthApi(host, {}, new NoAuthenticationProvider(), fetch), userDetails.userLogin, {\n getSecret(acceptedSecrets: AuthSecretType[], previousAttempts: AuthSecretDetails[]): Promise<AuthSecretDetails> {\n expect(acceptedSecrets).to.include(AuthSecretType.PASSWORD)\n return Promise.resolve({ value: userDetails.userPw12, secretType: AuthSecretType.PASSWORD })\n },\n }),\n ],\n ]\n\n for (const [providerType, providerFactory] of authenticationProviders) {\n it(`should be able to switch to another group if the username-password is the same in the new group (${providerType})`, async () => {\n const provider = await providerFactory()\n const initialUserApi = new IccUserApi(host, {}, provider, fetch)\n const initialUser = await initialUserApi.getCurrentUser()\n expect(initialUser.id).to.be.oneOf([userDetails.user1.id, userDetails.user2.id])\n const matches = await initialUserApi.getMatchingUsers()\n expect(matches.map((x) => x.userId)).to.have.members([userDetails.user1.id, userDetails.user2.id])\n const switchedToGroup2Provider = await provider.switchGroup(userDetails.group2.id!, matches)\n const userApiGroup2 = new IccUserApi(host, {}, switchedToGroup2Provider, fetch)\n const userGroup2 = await userApiGroup2.getCurrentUser()\n expect(userGroup2.id).to.equal(userDetails.user2.id)\n const switchedToGroup1Provider = await switchedToGroup2Provider.switchGroup(userDetails.group1.id!, matches)\n const userApiGroup1 = new IccUserApi(host, {}, switchedToGroup1Provider, fetch)\n const userGroup1 = await userApiGroup1.getCurrentUser()\n expect(userGroup1.id).to.equal(userDetails.user1.id)\n })\n\n it(`should not be able to switch to another group if the username-password is different in the new group (${providerType})`, async () => {\n const provider = await providerFactory()\n const initialUserApi = new IccUserApi(host, {}, provider, fetch)\n const matches = await initialUserApi.getMatchingUsers()\n expect(matches.map((x) => x.userId)).to.not.contain(userDetails.user3.id)\n await expect(provider.switchGroup(userDetails.group3.id!, matches)).to.be.rejected\n })\n }\n})\n"]}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.sleep = sleep;
|
|
13
|
-
require("isomorphic-fetch");
|
|
14
|
-
const mocha_1 = require("mocha");
|
|
15
|
-
const test_utils_1 = require("../../utils/test_utils");
|
|
16
|
-
const TestApi_1 = require("../../utils/TestApi");
|
|
17
|
-
const icc_x_api_1 = require("../../../icc-x-api");
|
|
18
|
-
const crypto_1 = require("crypto");
|
|
19
|
-
const chai_1 = require("chai");
|
|
20
|
-
const icc_api_1 = require("../../../icc-api");
|
|
21
|
-
const AuthenticationProvider_1 = require("../../../icc-x-api/auth/AuthenticationProvider");
|
|
22
|
-
const types_1 = require("@icure/test-setup/types");
|
|
23
|
-
(0, test_utils_1.setLocalStorage)(fetch);
|
|
24
|
-
let env;
|
|
25
|
-
function sleep(ms) {
|
|
26
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
27
|
-
}
|
|
28
|
-
describe('Jwt authentication concurrency test', () => {
|
|
29
|
-
(0, mocha_1.before)(function () {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
this.timeout(600000);
|
|
32
|
-
const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
|
|
33
|
-
env = yield initializer.execute((0, types_1.getEnvVariables)());
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
it('Can login simultaneously with the same user', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
const api = yield (0, TestApi_1.TestApi)(env.iCureUrl, env.dataOwnerDetails[test_utils_1.hcp1Username].user, env.dataOwnerDetails[test_utils_1.hcp1Username].password, crypto_1.webcrypto);
|
|
38
|
-
const users = yield Promise.all([...Array(5)].map(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
return yield api.userApi.getCurrentUser();
|
|
40
|
-
})));
|
|
41
|
-
users.forEach((u) => {
|
|
42
|
-
(0, chai_1.expect)(u.login).to.be.equal(env.dataOwnerDetails[test_utils_1.hcp1Username].user);
|
|
43
|
-
});
|
|
44
|
-
}));
|
|
45
|
-
it('After logging in, can make requests asynchronously', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
-
const api = yield (0, TestApi_1.TestApi)(env.iCureUrl, env.dataOwnerDetails[test_utils_1.hcp1Username].user, env.dataOwnerDetails[test_utils_1.hcp1Username].password, crypto_1.webcrypto);
|
|
47
|
-
yield api.userApi.getCurrentUser();
|
|
48
|
-
const users = yield Promise.all([...Array(5)].map(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
return yield api.userApi.getCurrentUser();
|
|
50
|
-
})));
|
|
51
|
-
users.forEach((u) => {
|
|
52
|
-
(0, chai_1.expect)(u.login).to.be.equal(env.dataOwnerDetails[test_utils_1.hcp1Username].user);
|
|
53
|
-
});
|
|
54
|
-
}));
|
|
55
|
-
it('It can refresh the token asynchronously', function () {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
if (!process.env.TEST_ENVIRONMENT || process.env.TEST_ENVIRONMENT === 'acceptance') {
|
|
58
|
-
this.skip();
|
|
59
|
-
}
|
|
60
|
-
const api = yield (0, TestApi_1.TestApi)(env.iCureUrl, env.dataOwnerDetails[test_utils_1.hcp1Username].user, env.dataOwnerDetails[test_utils_1.hcp1Username].password, crypto_1.webcrypto);
|
|
61
|
-
yield api.userApi.getCurrentUser();
|
|
62
|
-
yield sleep(20000);
|
|
63
|
-
const users = yield Promise.all([...Array(5)].map(() => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
return yield api.userApi.getCurrentUser();
|
|
65
|
-
})));
|
|
66
|
-
users.forEach((u) => {
|
|
67
|
-
(0, chai_1.expect)(u.login).to.be.equal(env.dataOwnerDetails[test_utils_1.hcp1Username].user);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
it('Can instantiate a x-api without provider and get a 401', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
-
const xUserApi = new icc_x_api_1.IccUserXApi(env.iCureUrl, {}, new AuthenticationProvider_1.NoAuthenticationProvider(), null);
|
|
73
|
-
xUserApi
|
|
74
|
-
.getCurrentUser()
|
|
75
|
-
.then(() => {
|
|
76
|
-
(0, chai_1.expect)(false).to.be.eq(true, 'I should not get here');
|
|
77
|
-
})
|
|
78
|
-
.catch((e) => {
|
|
79
|
-
(0, chai_1.expect)(e.statusCode).to.be.eq(401);
|
|
80
|
-
});
|
|
81
|
-
}));
|
|
82
|
-
it('Can instantiate a user-x-api with JWT provider and make requests', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
-
const authApi = new icc_api_1.IccAuthApi(env.iCureUrl, {});
|
|
84
|
-
const provider = new AuthenticationProvider_1.JwtAuthenticationProvider(authApi, env.dataOwnerDetails[test_utils_1.hcp1Username].user, env.dataOwnerDetails[test_utils_1.hcp1Username].password);
|
|
85
|
-
const xUserApi = new icc_x_api_1.IccUserXApi(env.iCureUrl, {}, provider, null);
|
|
86
|
-
const users = yield Promise.all([...Array(5)].map(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
-
return yield xUserApi.getCurrentUser();
|
|
88
|
-
})));
|
|
89
|
-
users.forEach((u) => {
|
|
90
|
-
(0, chai_1.expect)(u.login).to.be.equal(env.dataOwnerDetails[test_utils_1.hcp1Username].user);
|
|
91
|
-
});
|
|
92
|
-
const tokens = yield provider.getIcureTokens();
|
|
93
|
-
(0, chai_1.expect)(tokens).to.not.be.undefined;
|
|
94
|
-
const tokenOnlyProvider = new AuthenticationProvider_1.JwtAuthenticationProvider(authApi, undefined, undefined, undefined, tokens);
|
|
95
|
-
const xUserApiTokenOnly = new icc_x_api_1.IccUserXApi(env.iCureUrl, {}, tokenOnlyProvider, null);
|
|
96
|
-
const usersTokenOnly = yield Promise.all([...Array(5)].map(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
-
return yield xUserApiTokenOnly.getCurrentUser();
|
|
98
|
-
})));
|
|
99
|
-
usersTokenOnly.forEach((u) => {
|
|
100
|
-
(0, chai_1.expect)(u.login).to.be.equal(env.dataOwnerDetails[test_utils_1.hcp1Username].user);
|
|
101
|
-
});
|
|
102
|
-
}));
|
|
103
|
-
it('Can instantiate a user-x-api with Basic provider and make requests', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
-
const a = new AuthenticationProvider_1.BasicAuthenticationProvider(env.dataOwnerDetails[test_utils_1.hcp1Username].user, env.dataOwnerDetails[test_utils_1.hcp1Username].password);
|
|
105
|
-
const xUserApi = new icc_x_api_1.IccUserXApi(env.iCureUrl, {}, a, null);
|
|
106
|
-
const currentUser = yield xUserApi.getCurrentUser();
|
|
107
|
-
(0, chai_1.expect)(currentUser.login).to.be.equal(env.dataOwnerDetails[test_utils_1.hcp1Username].user);
|
|
108
|
-
const fetchedUser = yield xUserApi.getUser(currentUser.id);
|
|
109
|
-
(0, chai_1.expect)(fetchedUser.id).to.be.equal(currentUser.id);
|
|
110
|
-
}));
|
|
111
|
-
});
|
|
112
|
-
//# sourceMappingURL=jwt-concurrency-test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-concurrency-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/auth/jwt-concurrency-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAgBA,sBAEC;AAlBD,4BAAyB;AACzB,iCAA8B;AAC9B,uDAAiG;AACjG,iDAA6C;AAC7C,kDAAgD;AAChD,mCAAkC;AAClC,+BAA6B;AAG7B,8CAA6C;AAC7C,2FAAiJ;AACjJ,mDAAmE;AAEnE,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,SAAgB,KAAK,CAAC,EAAU;IAC9B,OAAO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CAAA,CAAC,CACH,CAAA;QACD,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC3B,IAAA,aAAM,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,yBAAY,CAAC,CAAC,IAAI,CAAC,CAAA;QACtE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA,CAAC,CAAA;IAEF,EAAE,CAAC,oEAAoE,EAAE,GAAS,EAAE;QAClF,MAAM,CAAC,GAAG,IAAI,oDAA2B,CAAC,GAAG,CAAC,gBAAgB,CAAC,yBAAY,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,gBAAgB,CAAC,yBAAY,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC/H,MAAM,QAAQ,GAAG,IAAI,uBAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,IAAW,CAAC,CAAA;QAElE,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,cAAc,EAAE,CAAA;QACnD,IAAA,aAAM,EAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,yBAAY,CAAC,CAAC,IAAI,CAAC,CAAA;QAE9E,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,EAAG,CAAC,CAAA;QAC3D,IAAA,aAAM,EAAC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IACpD,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { before } from 'mocha'\nimport { getEnvironmentInitializer, hcp1Username, setLocalStorage } from '../../utils/test_utils'\nimport { TestApi } from '../../utils/TestApi'\nimport { IccUserXApi } from '../../../icc-x-api'\nimport { webcrypto } from 'crypto'\nimport { expect } from 'chai'\nimport { XHR } from '../../../icc-api/api/XHR'\nimport XHRError = XHR.XHRError\nimport { IccAuthApi } from '../../../icc-api'\nimport { NoAuthenticationProvider, BasicAuthenticationProvider, JwtAuthenticationProvider } from '../../../icc-x-api/auth/AuthenticationProvider'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\nexport function sleep(ms: number): Promise<any> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\ndescribe('Jwt authentication concurrency test', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('Can login simultaneously with the same user', async () => {\n const api = await TestApi(\n env.iCureUrl,\n env.dataOwnerDetails[hcp1Username].user,\n env.dataOwnerDetails[hcp1Username].password,\n webcrypto as unknown as Crypto\n )\n const users = await Promise.all(\n [...Array<number>(5)].map(async () => {\n return await api.userApi.getCurrentUser()\n })\n )\n users.forEach((u) => {\n expect(u.login).to.be.equal(env.dataOwnerDetails[hcp1Username].user)\n })\n })\n\n it('After logging in, can make requests asynchronously', async () => {\n const api = await TestApi(\n env.iCureUrl,\n env.dataOwnerDetails[hcp1Username].user,\n env.dataOwnerDetails[hcp1Username].password,\n webcrypto as unknown as Crypto\n )\n\n await api.userApi.getCurrentUser()\n\n const users = await Promise.all(\n [...Array<number>(5)].map(async () => {\n return await api.userApi.getCurrentUser()\n })\n )\n users.forEach((u) => {\n expect(u.login).to.be.equal(env.dataOwnerDetails[hcp1Username].user)\n })\n })\n\n it('It can refresh the token asynchronously', async function () {\n if (!process.env.TEST_ENVIRONMENT || process.env.TEST_ENVIRONMENT === 'acceptance') {\n this.skip()\n }\n const api = await TestApi(\n env.iCureUrl,\n env.dataOwnerDetails[hcp1Username].user,\n env.dataOwnerDetails[hcp1Username].password,\n webcrypto as unknown as Crypto\n )\n await api.userApi.getCurrentUser()\n\n await sleep(20000)\n\n const users = await Promise.all(\n [...Array<number>(5)].map(async () => {\n return await api.userApi.getCurrentUser()\n })\n )\n users.forEach((u) => {\n expect(u.login).to.be.equal(env.dataOwnerDetails[hcp1Username].user)\n })\n })\n\n it('Can instantiate a x-api without provider and get a 401', async () => {\n const xUserApi = new IccUserXApi(env.iCureUrl, {}, new NoAuthenticationProvider(), null as any)\n xUserApi\n .getCurrentUser()\n .then(() => {\n expect(false).to.be.eq(true, 'I should not get here')\n })\n .catch((e: XHRError) => {\n expect(e.statusCode).to.be.eq(401)\n })\n })\n\n it('Can instantiate a user-x-api with JWT provider and make requests', async () => {\n const authApi = new IccAuthApi(env.iCureUrl, {})\n const provider = new JwtAuthenticationProvider(authApi, env.dataOwnerDetails[hcp1Username].user, env.dataOwnerDetails[hcp1Username].password)\n const xUserApi = new IccUserXApi(env.iCureUrl, {}, provider, null as any)\n\n const users = await Promise.all(\n [...Array<number>(5)].map(async () => {\n return await xUserApi.getCurrentUser()\n })\n )\n users.forEach((u) => {\n expect(u.login).to.be.equal(env.dataOwnerDetails[hcp1Username].user)\n })\n\n const tokens = await provider.getIcureTokens()\n expect(tokens).to.not.be.undefined\n const tokenOnlyProvider = new JwtAuthenticationProvider(authApi, undefined, undefined, undefined, tokens)\n const xUserApiTokenOnly = new IccUserXApi(env.iCureUrl, {}, tokenOnlyProvider, null as any)\n\n const usersTokenOnly = await Promise.all(\n [...Array<number>(5)].map(async () => {\n return await xUserApiTokenOnly.getCurrentUser()\n })\n )\n usersTokenOnly.forEach((u) => {\n expect(u.login).to.be.equal(env.dataOwnerDetails[hcp1Username].user)\n })\n })\n\n it('Can instantiate a user-x-api with Basic provider and make requests', async () => {\n const a = new BasicAuthenticationProvider(env.dataOwnerDetails[hcp1Username].user, env.dataOwnerDetails[hcp1Username].password)\n const xUserApi = new IccUserXApi(env.iCureUrl, {}, a, null as any)\n\n const currentUser = await xUserApi.getCurrentUser()\n expect(currentUser.login).to.be.equal(env.dataOwnerDetails[hcp1Username].user)\n\n const fetchedUser = await xUserApi.getUser(currentUser.id!)\n expect(fetchedUser.id).to.be.equal(currentUser.id)\n })\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const icc_api_1 = require("../../../icc-api");
|
|
13
|
-
const AuthenticationResponse_1 = require("../../../icc-api/model/AuthenticationResponse");
|
|
14
|
-
const ModelHelper_1 = require("../../../icc-api/model/ModelHelper");
|
|
15
|
-
const chai_1 = require("chai");
|
|
16
|
-
const JwtBridgedAuthService_1 = require("../../../icc-x-api/auth/JwtBridgedAuthService");
|
|
17
|
-
const JwtAuthService_1 = require("../../../icc-x-api/auth/JwtAuthService");
|
|
18
|
-
const XHR_1 = require("../../../icc-api/api/XHR");
|
|
19
|
-
var XHRError = XHR_1.XHR.XHRError;
|
|
20
|
-
const JwtError_1 = require("../../../icc-x-api/auth/JwtError");
|
|
21
|
-
const BasicAuthService_1 = require("../../../icc-x-api/auth/BasicAuthService");
|
|
22
|
-
const EnsembleAuthService_1 = require("../../../icc-x-api/auth/EnsembleAuthService");
|
|
23
|
-
const NoAuthService_1 = require("../../../icc-x-api/auth/NoAuthService");
|
|
24
|
-
const SmartAuthProvider_1 = require("../../../icc-x-api/auth/SmartAuthProvider");
|
|
25
|
-
describe('JWT provider resiliency test', () => {
|
|
26
|
-
function generateJwt() {
|
|
27
|
-
return `jwt.${(0, ModelHelper_1.b2a)(JSON.stringify({ exp: 1000 }))}.${Math.floor(100000 + Math.random() * 900000)}`;
|
|
28
|
-
}
|
|
29
|
-
function generateRefreshJwt() {
|
|
30
|
-
return `refreshJwt.${(0, ModelHelper_1.b2a)(JSON.stringify({ exp: new Date().getTime() * 10 }))}.${Math.floor(100000 + Math.random() * 900000)}`;
|
|
31
|
-
}
|
|
32
|
-
class FakeAuthApi extends icc_api_1.IccAuthApi {
|
|
33
|
-
constructor() {
|
|
34
|
-
super('', {});
|
|
35
|
-
this.jwt = `jwt.${(0, ModelHelper_1.b2a)(JSON.stringify({ exp: 1000 }))}.signature`;
|
|
36
|
-
this.refreshJwt = `refreshJwt.${(0, ModelHelper_1.b2a)(JSON.stringify({ exp: new Date().getTime() * 10 }))}.signature`;
|
|
37
|
-
}
|
|
38
|
-
login(body) {
|
|
39
|
-
if (!!this.loginException) {
|
|
40
|
-
throw this.loginException;
|
|
41
|
-
}
|
|
42
|
-
this.jwt = generateJwt();
|
|
43
|
-
this.refreshJwt = generateRefreshJwt();
|
|
44
|
-
return Promise.resolve(new AuthenticationResponse_1.AuthenticationResponse({
|
|
45
|
-
token: this.jwt,
|
|
46
|
-
refreshToken: this.refreshJwt,
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
refreshAuthenticationJWT(refreshJWT) {
|
|
50
|
-
var _a;
|
|
51
|
-
if (!!this.refreshException) {
|
|
52
|
-
throw this.refreshException;
|
|
53
|
-
}
|
|
54
|
-
this.jwt = generateJwt();
|
|
55
|
-
return Promise.resolve(new AuthenticationResponse_1.AuthenticationResponse({
|
|
56
|
-
token: this.jwt,
|
|
57
|
-
refreshToken: (_a = this.refreshJwt) !== null && _a !== void 0 ? _a : generateRefreshJwt(),
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function expectThrowOnGetHeaders(service) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
let caught = null;
|
|
64
|
-
try {
|
|
65
|
-
yield service.getAuthHeaders();
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
caught = e;
|
|
69
|
-
}
|
|
70
|
-
(0, chai_1.expect)(caught).not.to.be.null;
|
|
71
|
-
(0, chai_1.expect)(caught).to.be.instanceof(JwtError_1.JwtError);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
it('JwtBridgedAuthService - If the login fails for any type of error it is possible to retry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
-
const errors = [
|
|
76
|
-
new Error('A generic error'),
|
|
77
|
-
new XHRError('', '', 403, 'FORBIDDEN', new Headers()),
|
|
78
|
-
new XHRError('', '', 503, 'TIMEOUT', new Headers()),
|
|
79
|
-
];
|
|
80
|
-
for (const e of errors) {
|
|
81
|
-
const fakeAuthApi = new FakeAuthApi();
|
|
82
|
-
const authService = new JwtBridgedAuthService_1.JwtBridgedAuthService(fakeAuthApi, 'username', 'password', {}, undefined);
|
|
83
|
-
fakeAuthApi.loginException = e;
|
|
84
|
-
yield expectThrowOnGetHeaders(authService);
|
|
85
|
-
fakeAuthApi.loginException = null;
|
|
86
|
-
const firstHeader = yield authService.getAuthHeaders();
|
|
87
|
-
(0, chai_1.expect)(firstHeader[0].data).to.be.equal(`Bearer ${fakeAuthApi.jwt}`);
|
|
88
|
-
}
|
|
89
|
-
}));
|
|
90
|
-
function jwtBridgedTest(error, loginAfterError) {
|
|
91
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const fakeAuthApi = new FakeAuthApi();
|
|
93
|
-
const authService = new JwtBridgedAuthService_1.JwtBridgedAuthService(fakeAuthApi, 'username', 'password', {}, undefined);
|
|
94
|
-
fakeAuthApi.refreshException = null;
|
|
95
|
-
const firstHeader = yield authService.getAuthHeaders();
|
|
96
|
-
const initialJwt = fakeAuthApi.jwt;
|
|
97
|
-
const initialRefresh = fakeAuthApi.refreshJwt;
|
|
98
|
-
(0, chai_1.expect)(firstHeader[0].data).to.be.equal(`Bearer ${initialJwt}`);
|
|
99
|
-
fakeAuthApi.refreshException = error;
|
|
100
|
-
yield expectThrowOnGetHeaders(authService);
|
|
101
|
-
fakeAuthApi.refreshException = null;
|
|
102
|
-
const secondHeader = yield authService.getAuthHeaders();
|
|
103
|
-
const secondJwt = fakeAuthApi.jwt;
|
|
104
|
-
const secondRefresh = fakeAuthApi.refreshJwt;
|
|
105
|
-
(0, chai_1.expect)(secondHeader[0].data).to.be.equal(`Bearer ${secondJwt}`);
|
|
106
|
-
(0, chai_1.expect)(secondJwt).not.to.be.equal(initialJwt);
|
|
107
|
-
if (loginAfterError) {
|
|
108
|
-
(0, chai_1.expect)(secondRefresh).not.to.be.equal(initialRefresh);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
(0, chai_1.expect)(secondRefresh).to.be.equal(initialRefresh);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
it('JwtBridgedAuthService - If the refresh fails for a generic error, it is possible to retry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
-
const error = new Error('A generic error');
|
|
117
|
-
yield jwtBridgedTest(error, false);
|
|
118
|
-
}));
|
|
119
|
-
it('JwtBridgedAuthService - If the refresh fails for a 500 error, the login is performed again', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
|
-
const error = new XHRError('', '', 500, 'INTERNAL SERVER ERROR', new Headers());
|
|
121
|
-
yield jwtBridgedTest(error, false);
|
|
122
|
-
}));
|
|
123
|
-
it('JwtBridgedAuthService - If the refresh fails for a 400 error, the login is performed again', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
-
const error = new XHRError('', '', 403, 'FORBIDDEN', new Headers());
|
|
125
|
-
yield jwtBridgedTest(error, true);
|
|
126
|
-
}));
|
|
127
|
-
it('JwtAuthService - If the refresh fails for an error, it is possible to retry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
-
const fakeAuthApi = new FakeAuthApi();
|
|
129
|
-
const error = new Error('A generic error');
|
|
130
|
-
const initialJwt = generateJwt();
|
|
131
|
-
const initialRefresh = generateRefreshJwt();
|
|
132
|
-
const authService = new JwtAuthService_1.JwtAuthService(fakeAuthApi, { authJwt: initialJwt, refreshJwt: initialRefresh });
|
|
133
|
-
fakeAuthApi.refreshException = error;
|
|
134
|
-
yield expectThrowOnGetHeaders(authService);
|
|
135
|
-
fakeAuthApi.refreshException = null;
|
|
136
|
-
const secondHeader = yield authService.getAuthHeaders();
|
|
137
|
-
const secondJwt = fakeAuthApi.jwt;
|
|
138
|
-
(0, chai_1.expect)(secondHeader[0].data).to.be.equal(`Bearer ${secondJwt}`);
|
|
139
|
-
(0, chai_1.expect)(secondJwt).not.to.be.equal(initialJwt);
|
|
140
|
-
}));
|
|
141
|
-
it('A BasicAuthService does not have a jwtGetter property', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
-
const service = new BasicAuthService_1.BasicAuthService('username', 'password');
|
|
143
|
-
(0, chai_1.expect)(service.jwtGetter).to.be.undefined;
|
|
144
|
-
}));
|
|
145
|
-
it('A NoAuthService does not have a jwtGetter property', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
-
const service = new NoAuthService_1.NoAuthService();
|
|
147
|
-
(0, chai_1.expect)(service.jwtGetter).to.be.undefined;
|
|
148
|
-
}));
|
|
149
|
-
it('A JwtBridgedAuthService supports the jwtGetter', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
-
const fakeAuthApi = new FakeAuthApi();
|
|
151
|
-
const authService = new JwtBridgedAuthService_1.JwtBridgedAuthService(fakeAuthApi, 'username', 'password', {}, undefined);
|
|
152
|
-
(0, chai_1.expect)(authService.jwtGetter).not.to.be.undefined;
|
|
153
|
-
if (!!authService.jwtGetter) {
|
|
154
|
-
const token = yield authService.jwtGetter();
|
|
155
|
-
(0, chai_1.expect)(token === null || token === void 0 ? void 0 : token.token).to.be.equal(fakeAuthApi.jwt);
|
|
156
|
-
}
|
|
157
|
-
}));
|
|
158
|
-
it('A JwtAuthService supports the jwtGetter', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
159
|
-
const initialJwt = generateJwt();
|
|
160
|
-
const initialRefresh = generateRefreshJwt();
|
|
161
|
-
const fakeAuthApi = new FakeAuthApi();
|
|
162
|
-
const jwtService = new JwtAuthService_1.JwtAuthService(fakeAuthApi, { authJwt: initialJwt, refreshJwt: initialRefresh });
|
|
163
|
-
(0, chai_1.expect)(jwtService.jwtGetter).not.to.be.undefined;
|
|
164
|
-
if (!!jwtService.jwtGetter) {
|
|
165
|
-
const token = yield jwtService.jwtGetter();
|
|
166
|
-
(0, chai_1.expect)(token === null || token === void 0 ? void 0 : token.token).to.be.equal(initialJwt);
|
|
167
|
-
}
|
|
168
|
-
}));
|
|
169
|
-
it('An EnsembleAuthService supports the jwtGetter', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
170
|
-
const initialJwt = generateJwt();
|
|
171
|
-
const initialRefresh = generateRefreshJwt();
|
|
172
|
-
const fakeAuthApi = new FakeAuthApi();
|
|
173
|
-
const basic = new BasicAuthService_1.BasicAuthService('username', 'password');
|
|
174
|
-
const jwtService = new JwtAuthService_1.JwtAuthService(fakeAuthApi, { authJwt: initialJwt, refreshJwt: initialRefresh });
|
|
175
|
-
const service = new EnsembleAuthService_1.EnsembleAuthService(jwtService, new NoAuthService_1.NoAuthService(), basic);
|
|
176
|
-
(0, chai_1.expect)(service.jwtGetter).not.to.be.undefined;
|
|
177
|
-
if (!!service.jwtGetter) {
|
|
178
|
-
const token = yield service.jwtGetter();
|
|
179
|
-
(0, chai_1.expect)(token === null || token === void 0 ? void 0 : token.token).to.be.equal(initialJwt);
|
|
180
|
-
}
|
|
181
|
-
}));
|
|
182
|
-
it('A SmartAuthService supports the jwtGetter', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
-
const authApi = new FakeAuthApi();
|
|
184
|
-
const authProvider = yield SmartAuthProvider_1.SmartAuthProvider.initialise(authApi, 'username', {
|
|
185
|
-
getSecret: (acceptedSecrets, previousAttempts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
186
|
-
return { value: 'wrong', secretType: SmartAuthProvider_1.AuthSecretType.LONG_LIVED_TOKEN }; // pragma: allowlist secret
|
|
187
|
-
}),
|
|
188
|
-
});
|
|
189
|
-
const service = authProvider.getAuthService();
|
|
190
|
-
(0, chai_1.expect)(service.jwtGetter).not.to.be.undefined;
|
|
191
|
-
if (!!service.jwtGetter) {
|
|
192
|
-
const token = yield service.jwtGetter();
|
|
193
|
-
(0, chai_1.expect)(token === null || token === void 0 ? void 0 : token.token).to.be.equal(authApi.jwt);
|
|
194
|
-
}
|
|
195
|
-
}));
|
|
196
|
-
});
|
|
197
|
-
//# sourceMappingURL=jwt-provider-test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-provider-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/auth/jwt-provider-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,8CAA6C;AAE7C,0FAAsF;AACtF,oEAAwD;AACxD,+BAA6B;AAC7B,yFAAqF;AAErF,2EAAuE;AACvE,kDAA8C;AAC9C,IAAO,QAAQ,GAAG,SAAG,CAAC,QAAQ,CAAA;AAC9B,+DAA2D;AAC3D,+EAA2E;AAC3E,qFAAiF;AACjF,yEAAqE;AACrE,iFAAgH;AAEhH,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,SAAS,WAAW;QAClB,OAAO,OAAO,IAAA,iBAAG,EAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;IACnG,CAAC;I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,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,kCAAc,CAAC,gBAAgB,EAAE,CAAA,CAAC,2BAA2B;YACpG,CAAC,CAAA;SACF,CAAC,CAAA;QACF,MAAM,OAAO,GAAG,YAAY,CAAC,cAAc,EAAE,CAAA;QAE7C,IAAA,aAAM,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAA;QAE7C,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE,CAAA;YAEvC,IAAA,aAAM,EAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { IccAuthApi } from '../../../icc-api'\nimport { LoginCredentials } from '../../../icc-api/model/LoginCredentials'\nimport { AuthenticationResponse } from '../../../icc-api/model/AuthenticationResponse'\nimport { b2a } from '../../../icc-api/model/ModelHelper'\nimport { expect } from 'chai'\nimport { JwtBridgedAuthService } from '../../../icc-x-api/auth/JwtBridgedAuthService'\nimport { AuthService } from '../../../icc-x-api/auth/AuthService'\nimport { JwtAuthService } from '../../../icc-x-api/auth/JwtAuthService'\nimport { XHR } from '../../../icc-api/api/XHR'\nimport XHRError = XHR.XHRError\nimport { JwtError } from '../../../icc-x-api/auth/JwtError'\nimport { BasicAuthService } from '../../../icc-x-api/auth/BasicAuthService'\nimport { EnsembleAuthService } from '../../../icc-x-api/auth/EnsembleAuthService'\nimport { NoAuthService } from '../../../icc-x-api/auth/NoAuthService'\nimport { AuthSecretDetails, AuthSecretType, SmartAuthProvider } from '../../../icc-x-api/auth/SmartAuthProvider'\n\ndescribe('JWT provider resiliency test', () => {\n function generateJwt() {\n return `jwt.${b2a(JSON.stringify({ exp: 1000 }))}.${Math.floor(100000 + Math.random() * 900000)}`\n }\n\n function generateRefreshJwt() {\n return `refreshJwt.${b2a(JSON.stringify({ exp: new Date().getTime() * 10 }))}.${Math.floor(100000 + Math.random() * 900000)}`\n }\n\n class FakeAuthApi extends IccAuthApi {\n refreshException: Error | undefined | null\n loginException: Error | undefined | null\n jwt = `jwt.${b2a(JSON.stringify({ exp: 1000 }))}.signature`\n refreshJwt = `refreshJwt.${b2a(JSON.stringify({ exp: new Date().getTime() * 10 }))}.signature`\n\n constructor() {\n super('', {})\n }\n\n login(body?: LoginCredentials): Promise<AuthenticationResponse> {\n if (!!this.loginException) {\n throw this.loginException\n }\n\n this.jwt = generateJwt()\n this.refreshJwt = generateRefreshJwt()\n return Promise.resolve(\n new AuthenticationResponse({\n token: this.jwt,\n refreshToken: this.refreshJwt,\n })\n )\n }\n\n refreshAuthenticationJWT(refreshJWT: string): Promise<AuthenticationResponse> {\n if (!!this.refreshException) {\n throw this.refreshException\n }\n\n this.jwt = generateJwt()\n return Promise.resolve(\n new AuthenticationResponse({\n token: this.jwt,\n refreshToken: this.refreshJwt ?? generateRefreshJwt(),\n })\n )\n }\n }\n\n async function expectThrowOnGetHeaders(service: AuthService): Promise<void> {\n let caught: Error | null = null\n try {\n await service.getAuthHeaders()\n } catch (e) {\n caught = e as Error\n }\n expect(caught).not.to.be.null\n expect(caught).to.be.instanceof(JwtError)\n }\n\n it('JwtBridgedAuthService - If the login fails for any type of error it is possible to retry', async () => {\n const errors: Error[] = [\n new Error('A generic error'),\n new XHRError('', '', 403, 'FORBIDDEN', new Headers()),\n new XHRError('', '', 503, 'TIMEOUT', new Headers()),\n ]\n for (const e of errors) {\n const fakeAuthApi = new FakeAuthApi()\n const authService = new JwtBridgedAuthService(fakeAuthApi, 'username', 'password', {}, undefined)\n\n fakeAuthApi.loginException = e\n await expectThrowOnGetHeaders(authService)\n\n fakeAuthApi.loginException = null\n const firstHeader = await authService.getAuthHeaders()\n expect(firstHeader[0].data).to.be.equal(`Bearer ${fakeAuthApi.jwt}`)\n }\n })\n\n async function jwtBridgedTest(error: Error, loginAfterError: boolean) {\n const fakeAuthApi = new FakeAuthApi()\n const authService = new JwtBridgedAuthService(fakeAuthApi, 'username', 'password', {}, undefined)\n\n fakeAuthApi.refreshException = null\n const firstHeader = await authService.getAuthHeaders()\n const initialJwt = fakeAuthApi.jwt\n const initialRefresh = fakeAuthApi.refreshJwt\n expect(firstHeader[0].data).to.be.equal(`Bearer ${initialJwt}`)\n\n fakeAuthApi.refreshException = error\n await expectThrowOnGetHeaders(authService)\n\n fakeAuthApi.refreshException = null\n const secondHeader = await authService.getAuthHeaders()\n const secondJwt = fakeAuthApi.jwt\n const secondRefresh = fakeAuthApi.refreshJwt\n expect(secondHeader[0].data).to.be.equal(`Bearer ${secondJwt}`)\n expect(secondJwt).not.to.be.equal(initialJwt)\n if (loginAfterError) {\n expect(secondRefresh).not.to.be.equal(initialRefresh)\n } else {\n expect(secondRefresh).to.be.equal(initialRefresh)\n }\n }\n\n it('JwtBridgedAuthService - If the refresh fails for a generic error, it is possible to retry', async () => {\n const error = new Error('A generic error')\n await jwtBridgedTest(error, false)\n })\n\n it('JwtBridgedAuthService - If the refresh fails for a 500 error, the login is performed again', async () => {\n const error = new XHRError('', '', 500, 'INTERNAL SERVER ERROR', new Headers())\n await jwtBridgedTest(error, false)\n })\n\n it('JwtBridgedAuthService - If the refresh fails for a 400 error, the login is performed again', async () => {\n const error = new XHRError('', '', 403, 'FORBIDDEN', new Headers())\n await jwtBridgedTest(error, true)\n })\n\n it('JwtAuthService - If the refresh fails for an error, it is possible to retry', async () => {\n const fakeAuthApi = new FakeAuthApi()\n const error = new Error('A generic error')\n const initialJwt = generateJwt()\n const initialRefresh = generateRefreshJwt()\n const authService = new JwtAuthService(fakeAuthApi, { authJwt: initialJwt, refreshJwt: initialRefresh })\n\n fakeAuthApi.refreshException = error\n await expectThrowOnGetHeaders(authService)\n\n fakeAuthApi.refreshException = null\n const secondHeader = await authService.getAuthHeaders()\n const secondJwt = fakeAuthApi.jwt\n expect(secondHeader[0].data).to.be.equal(`Bearer ${secondJwt}`)\n expect(secondJwt).not.to.be.equal(initialJwt)\n })\n\n it('A BasicAuthService does not have a jwtGetter property', async () => {\n const service = new BasicAuthService('username', 'password') as AuthService\n expect(service.jwtGetter).to.be.undefined\n })\n\n it('A NoAuthService does not have a jwtGetter property', async () => {\n const service = new NoAuthService() as AuthService\n expect(service.jwtGetter).to.be.undefined\n })\n\n it('A JwtBridgedAuthService supports the jwtGetter', async () => {\n const fakeAuthApi = new FakeAuthApi()\n const authService = new JwtBridgedAuthService(fakeAuthApi, 'username', 'password', {}, undefined) as AuthService\n expect(authService.jwtGetter).not.to.be.undefined\n\n if (!!authService.jwtGetter) {\n const token = await authService.jwtGetter()\n\n expect(token?.token).to.be.equal(fakeAuthApi.jwt)\n }\n })\n\n it('A JwtAuthService supports the jwtGetter', async () => {\n const initialJwt = generateJwt()\n const initialRefresh = generateRefreshJwt()\n const fakeAuthApi = new FakeAuthApi()\n const jwtService = new JwtAuthService(fakeAuthApi, { authJwt: initialJwt, refreshJwt: initialRefresh }) as AuthService\n expect(jwtService.jwtGetter).not.to.be.undefined\n\n if (!!jwtService.jwtGetter) {\n const token = await jwtService.jwtGetter()\n\n expect(token?.token).to.be.equal(initialJwt)\n }\n })\n\n it('An EnsembleAuthService supports the jwtGetter', async () => {\n const initialJwt = generateJwt()\n const initialRefresh = generateRefreshJwt()\n const fakeAuthApi = new FakeAuthApi()\n const basic = new BasicAuthService('username', 'password')\n const jwtService = new JwtAuthService(fakeAuthApi, { authJwt: initialJwt, refreshJwt: initialRefresh })\n const service = new EnsembleAuthService(jwtService, new NoAuthService(), basic) as AuthService\n expect(service.jwtGetter).not.to.be.undefined\n\n if (!!service.jwtGetter) {\n const token = await service.jwtGetter()\n\n expect(token?.token).to.be.equal(initialJwt)\n }\n })\n\n it('A SmartAuthService supports the jwtGetter', async () => {\n const authApi = new FakeAuthApi()\n const authProvider = await SmartAuthProvider.initialise(authApi, 'username', {\n getSecret: async (acceptedSecrets: AuthSecretType[], previousAttempts: AuthSecretDetails[]) => {\n return { value: 'wrong', secretType: AuthSecretType.LONG_LIVED_TOKEN } // pragma: allowlist secret\n },\n })\n const service = authProvider.getAuthService()\n\n expect(service.jwtGetter).not.to.be.undefined\n\n if (!!service.jwtGetter) {\n const token = await service.jwtGetter()\n\n expect(token?.token).to.be.equal(authApi.jwt)\n }\n })\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import 'isomorphic-fetch';
|