@partium/js-sdk 15.19.0 → 16.0.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/core/constants/constants.d.ts +1 -2
- package/core/constants/constants.js +1 -1
- package/core/index.d.ts +2 -2
- package/core/index.js +1 -1
- package/core/integration-defaults/http/https-client/axios-https-client.service.d.ts +5 -0
- package/core/integration-defaults/http/https-client/axios-https-client.service.js +1 -1
- package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +1 -1
- package/core/integration-defaults/session/js-oauth-api-key-session.service.js +1 -1
- package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +1 -1
- package/core/integration-defaults/session/js-oauth-web-cookie-session.service.js +1 -1
- package/core/models/user.d.ts +7 -43
- package/core/models/user.js +1 -1
- package/core/services/http/https.service.interface.d.ts +18 -20
- package/core/services/http/https.service.interface.js +1 -1
- package/core/services/http/oauth-https.service.d.ts +3 -3
- package/core/services/local-storage.service.interface.d.ts +1 -1
- package/core/services/log.service.d.ts +1 -1
- package/core/services/organization/index.d.ts +6 -0
- package/core/services/organization/index.js +2 -0
- package/core/services/organization/models/get-organization-by-id-request.d.ts +10 -0
- package/core/services/organization/models/get-organization-by-name-request.d.ts +10 -0
- package/core/services/organization/models/get-organizations-request.d.ts +33 -0
- package/core/services/organization/models/get-organizations-request.js +2 -0
- package/core/services/organization/models/organization.d.ts +77 -0
- package/core/services/organization/models/organization.js +2 -0
- package/core/services/organization/organization.service.d.ts +81 -0
- package/core/services/organization/organization.service.js +2 -0
- package/core/services/recent-parts.service.d.ts +1 -1
- package/core/services/session/session.service.interface.d.ts +17 -5
- package/core/services/session/session.service.interface.js +1 -1
- package/core/utils/general-helper.d.ts +2 -1
- package/core/utils/general-helper.js +1 -1
- package/core/utils/multipart-upload.helper.d.ts +20 -0
- package/core/utils/multipart-upload.helper.js +2 -0
- package/data/models/attribute.d.ts +5 -5
- package/data/models/attribute.js +1 -1
- package/data/models/csa-request.d.ts +2 -3
- package/data/models/csa-request.js +1 -1
- package/data/models/image.d.ts +10 -13
- package/data/models/image.js +1 -1
- package/data/models/part-data.d.ts +20 -1
- package/data/models/part-data.js +1 -1
- package/data/models/part.d.ts +13 -9
- package/data/models/part.js +1 -1
- package/data/services/customer-service-assistance.service.d.ts +3 -22
- package/data/services/customer-service-assistance.service.js +1 -1
- package/data/services/data.service.js +1 -1
- package/data/services/filter.service.d.ts +0 -21
- package/data/services/filter.service.js +1 -1
- package/enrichment/models/enrichment-job-part.d.ts +2 -2
- package/enrichment/models/enrichment-job-part.js +1 -1
- package/enrichment/models/enrichment-job.d.ts +2 -2
- package/enrichment/models/enrichment-job.js +1 -1
- package/find/index.d.ts +1 -28
- package/find/index.js +1 -1
- package/find/models/image-crop-area.d.ts +7 -0
- package/find/models/search-input.d.ts +11 -3
- package/find/models/search-input.js +1 -1
- package/find/services/asset.service.d.ts +41 -102
- package/find/services/asset.service.js +1 -1
- package/find/services/search/search.service.d.ts +5 -218
- package/find/services/search/search.service.js +1 -1
- package/gen/sdk-version.d.ts +1 -1
- package/gen/sdk-version.js +1 -1
- package/index.d.ts +14 -8
- package/index.js +1 -1
- package/ocr/index.d.ts +1 -2
- package/ocr/index.js +1 -1
- package/ocr/models/ocr-response.d.ts +5 -0
- package/ocr/models/ocr-response.js +2 -0
- package/ocr/services/ocr.service.d.ts +9 -15
- package/ocr/services/ocr.service.js +1 -1
- package/package.json +1 -1
- package/core/models/organization.d.ts +0 -127
- package/core/models/organization.js +0 -2
- package/core/services/organization.service.d.ts +0 -48
- package/core/services/organization.service.js +0 -2
- package/data/services/csa-helper.service.d.ts +0 -32
- package/data/services/csa-helper.service.js +0 -2
- package/find/models/assets/asset.d.ts +0 -24
- package/find/models/assets/asset.js +0 -2
- package/find/models/search-filter.d.ts +0 -87
- package/find/models/search-filter.js +0 -2
- package/find/models/search-result-status.d.ts +0 -33
- package/find/models/search-result-status.js +0 -2
- package/find/models/search-session-log-object.d.ts +0 -16
- package/find/models/search-session-log-object.js +0 -2
- package/find/models/search-status/cv-search-status.d.ts +0 -20
- package/find/models/search-status/cv-search-status.js +0 -2
- package/find/models/search-status/search-filter-status.d.ts +0 -33
- package/find/models/search-status/search-filter-status.js +0 -2
- package/find/models/search-status/search-status.d.ts +0 -34
- package/find/models/search-status/search-status.js +0 -2
- package/find/models/search-status/tag-search-status.d.ts +0 -16
- package/find/models/search-status/tag-search-status.js +0 -2
- package/find/models/search-status/text-search-status.d.ts +0 -15
- package/find/models/search-status/text-search-status.js +0 -2
- package/find/models/search-tag.d.ts +0 -12
- package/find/models/search-tag.js +0 -2
- package/find/models/tagable/i18n-tagable.d.ts +0 -10
- package/find/models/tagable/i18n-tagable.js +0 -2
- package/find/models/tagable/tagable-base.d.ts +0 -11
- package/find/models/tagable/tagable-base.js +0 -2
- package/find/models/tagable/tagable.d.ts +0 -10
- package/find/models/tagable/tagable.js +0 -2
- package/find/models/text-search-config.d.ts +0 -57
- package/find/models/text-search-config.js +0 -2
- package/find/models/text-search-manipulator.d.ts +0 -46
- package/find/models/text-search-manipulator.js +0 -2
- package/find/models/text-search-result-item/text-search-error.d.ts +0 -7
- package/find/models/text-search-result-item/text-search-error.js +0 -2
- package/find/models/text-search-result-item/text-search-result-item-document.d.ts +0 -10
- package/find/models/text-search-result-item/text-search-result-item-document.js +0 -2
- package/find/models/text-search-result-item/text-search-result-item-part.d.ts +0 -12
- package/find/models/text-search-result-item/text-search-result-item-part.js +0 -2
- package/find/models/text-search-result-item/text-search-result-item-recent-query.d.ts +0 -10
- package/find/models/text-search-result-item/text-search-result-item-recent-query.js +0 -2
- package/find/models/text-search-result-item/text-search-result-item-unknown.d.ts +0 -12
- package/find/models/text-search-result-item/text-search-result-item-unknown.js +0 -2
- package/find/models/text-search-result-item/text-search-result-item.d.ts +0 -16
- package/find/models/text-search-result-item/text-search-result-item.js +0 -2
- package/find/services/filter-uploaders/filter-uploader.d.ts +0 -13
- package/find/services/filter-uploaders/update-filters-uploader.d.ts +0 -17
- package/find/services/filter-uploaders/update-filters-uploader.js +0 -2
- package/find/services/filter-uploaders/update-filters.model.d.ts +0 -19
- package/find/services/filter-uploaders/update-filters.model.js +0 -2
- package/find/services/search/cv-search.service.d.ts +0 -103
- package/find/services/search/cv-search.service.js +0 -2
- package/find/services/search/search-result.service.d.ts +0 -142
- package/find/services/search/search-result.service.js +0 -2
- package/find/services/search/tag-search.service.d.ts +0 -66
- package/find/services/search/tag-search.service.js +0 -2
- package/find/services/search/text-search.service.d.ts +0 -116
- package/find/services/search/text-search.service.js +0 -2
- package/find/services/search-filter.service.d.ts +0 -223
- package/find/services/search-filter.service.js +0 -2
- package/find/utils/search-helper.d.ts +0 -14
- package/find/utils/search-helper.js +0 -2
- package/ocr/models/detect-response.d.ts +0 -5
- package/ocr/models/detected-text-entry.d.ts +0 -5
- /package/{find/services/filter-uploaders/filter-uploader.js → core/services/organization/models/get-organization-by-id-request.js} +0 -0
- /package/{ocr/models/detect-response.js → core/services/organization/models/get-organization-by-name-request.js} +0 -0
- /package/{ocr/models/detected-text-entry.js → find/models/image-crop-area.js} +0 -0
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
2
|
export declare const PARTIUM_API_VERSION = 1;
|
|
3
|
-
export declare const REL_FIND_API_URL = "_find";
|
|
4
3
|
export declare const REL_DATA_API_URL = "_data";
|
|
5
4
|
export declare const REL_CSA_API_URL = "_csa";
|
|
6
5
|
export declare const REL_LOGS_API_URL = "_logs";
|
|
7
6
|
export declare const REL_USER_DATA_API_URL = "_ud";
|
|
8
|
-
export declare const REL_OCR_API_URL = "_ocr";
|
|
9
7
|
export declare const REL_AUTH_API_URL = "_auth";
|
|
10
8
|
export declare const REL_STATUS_API_URL = "_status";
|
|
11
9
|
export declare const REL_MANAGEMENT_API_URL = "management";
|
|
@@ -13,4 +11,5 @@ export declare const REL_CATALOG_API_URL = "catalog";
|
|
|
13
11
|
export declare const REL_DATACURATION_API_URL = "datacuration";
|
|
14
12
|
export declare const REL_DATA_V2_API_URL = "data";
|
|
15
13
|
export declare const REL_DATA_ENRICHMENT_API_URL = "enrichment";
|
|
14
|
+
export declare const REL_BACKOFFICE_API_URL = "backoffice";
|
|
16
15
|
export declare const BACKEND_STATUS_FALLBACK_URL = "https://example.com";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BACKEND_STATUS_FALLBACK_URL=exports.REL_DATA_ENRICHMENT_API_URL=exports.REL_DATA_V2_API_URL=exports.REL_DATACURATION_API_URL=exports.REL_CATALOG_API_URL=exports.REL_MANAGEMENT_API_URL=exports.REL_STATUS_API_URL=exports.REL_AUTH_API_URL=exports.
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BACKEND_STATUS_FALLBACK_URL=exports.REL_BACKOFFICE_API_URL=exports.REL_DATA_ENRICHMENT_API_URL=exports.REL_DATA_V2_API_URL=exports.REL_DATACURATION_API_URL=exports.REL_CATALOG_API_URL=exports.REL_MANAGEMENT_API_URL=exports.REL_STATUS_API_URL=exports.REL_AUTH_API_URL=exports.REL_USER_DATA_API_URL=exports.REL_LOGS_API_URL=exports.REL_CSA_API_URL=exports.REL_DATA_API_URL=exports.PARTIUM_API_VERSION=void 0,exports.PARTIUM_API_VERSION=1,exports.REL_DATA_API_URL="_data",exports.REL_CSA_API_URL="_csa",exports.REL_LOGS_API_URL="_logs",exports.REL_USER_DATA_API_URL="_ud",exports.REL_AUTH_API_URL="_auth",exports.REL_STATUS_API_URL="_status",exports.REL_MANAGEMENT_API_URL="management",exports.REL_CATALOG_API_URL="catalog",exports.REL_DATACURATION_API_URL="datacuration",exports.REL_DATA_V2_API_URL="data",exports.REL_DATA_ENRICHMENT_API_URL="enrichment",exports.REL_BACKOFFICE_API_URL="backoffice",exports.BACKEND_STATUS_FALLBACK_URL="https://example.com";
|
package/core/index.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export * from './models/p-file';
|
|
|
21
21
|
export * from './models/formatted-string';
|
|
22
22
|
export * from './models/i18n-map';
|
|
23
23
|
export * from './models/error';
|
|
24
|
-
export * from './models/organization';
|
|
25
24
|
export * from './models/api-object';
|
|
26
25
|
export * from './models/paginated-list';
|
|
27
26
|
export * from './models/log';
|
|
@@ -41,7 +40,6 @@ export * from './services/base-login-init.service';
|
|
|
41
40
|
export * from './services/device-status.service.interface';
|
|
42
41
|
export * from './services/session/session.service.interface';
|
|
43
42
|
export * from './services/session/oauth-session.service';
|
|
44
|
-
export * from './services/organization.service';
|
|
45
43
|
export * from './services/paginated-request.service';
|
|
46
44
|
export * from './services/log.service';
|
|
47
45
|
export * from './factories/paginated-request-service.factory';
|
|
@@ -51,3 +49,5 @@ export * from './models/base-paginated-request';
|
|
|
51
49
|
export * from './models/base-paginated-response';
|
|
52
50
|
export * from './models/default-get-paginated-request-pagination-context';
|
|
53
51
|
export * from './utils/general-helper';
|
|
52
|
+
export * from './utils/multipart-upload.helper';
|
|
53
|
+
export * from './services/organization';
|
package/core/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,s){void 0===s&&(s=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,s,i)}:function(e,r,t,s){void 0===s&&(s=t),e[s]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./decorators/injection-identifier"),exports),__exportStar(require("./integration-defaults/js-p-file"),exports),__exportStar(require("./integration-defaults/web-local-storage.service"),exports),__exportStar(require("./integration-defaults/web-device-status.service"),exports),__exportStar(require("./integration-defaults/web-indexeddb.service"),exports),__exportStar(require("./integration-defaults/web-file.service"),exports),__exportStar(require("./integration-defaults/http/js-oauth-keycloak-https.service"),exports),__exportStar(require("./integration-defaults/http/https-client/axios-https-client.service"),exports),__exportStar(require("./integration-defaults/http/https-client/fetch-api-https-client.service"),exports),__exportStar(require("./integration-defaults/http/file-transfer/axios-file-transfer.service"),exports),__exportStar(require("./integration-defaults/http/file-transfer/fetch-api-file-transfer.service"),exports),__exportStar(require("./integration-defaults/session/js-oauth-keycloak-session.service"),exports),__exportStar(require("./integration-defaults/session/js-oauth-keycloak-auth-config"),exports),__exportStar(require("./integration-defaults/session/js-oauth-api-key-session.service"),exports),__exportStar(require("./integration-defaults/session/js-oauth-web-cookie-session.service"),exports),__exportStar(require("./models/i18n-string"),exports),__exportStar(require("./models/partium-config"),exports),__exportStar(require("./models/auth-config"),exports),__exportStar(require("./models/p-file"),exports),__exportStar(require("./models/formatted-string"),exports),__exportStar(require("./models/i18n-map"),exports),__exportStar(require("./models/error"),exports),__exportStar(require("./models/
|
|
2
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,s){void 0===s&&(s=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,s,i)}:function(e,r,t,s){void 0===s&&(s=t),e[s]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./decorators/injection-identifier"),exports),__exportStar(require("./integration-defaults/js-p-file"),exports),__exportStar(require("./integration-defaults/web-local-storage.service"),exports),__exportStar(require("./integration-defaults/web-device-status.service"),exports),__exportStar(require("./integration-defaults/web-indexeddb.service"),exports),__exportStar(require("./integration-defaults/web-file.service"),exports),__exportStar(require("./integration-defaults/http/js-oauth-keycloak-https.service"),exports),__exportStar(require("./integration-defaults/http/https-client/axios-https-client.service"),exports),__exportStar(require("./integration-defaults/http/https-client/fetch-api-https-client.service"),exports),__exportStar(require("./integration-defaults/http/file-transfer/axios-file-transfer.service"),exports),__exportStar(require("./integration-defaults/http/file-transfer/fetch-api-file-transfer.service"),exports),__exportStar(require("./integration-defaults/session/js-oauth-keycloak-session.service"),exports),__exportStar(require("./integration-defaults/session/js-oauth-keycloak-auth-config"),exports),__exportStar(require("./integration-defaults/session/js-oauth-api-key-session.service"),exports),__exportStar(require("./integration-defaults/session/js-oauth-web-cookie-session.service"),exports),__exportStar(require("./models/i18n-string"),exports),__exportStar(require("./models/partium-config"),exports),__exportStar(require("./models/auth-config"),exports),__exportStar(require("./models/p-file"),exports),__exportStar(require("./models/formatted-string"),exports),__exportStar(require("./models/i18n-map"),exports),__exportStar(require("./models/error"),exports),__exportStar(require("./models/api-object"),exports),__exportStar(require("./models/paginated-list"),exports),__exportStar(require("./models/log"),exports),__exportStar(require("./models/device-info"),exports),__exportStar(require("./models/user-token"),exports),__exportStar(require("./models/user"),exports),__exportStar(require("./models/base-response"),exports),__exportStar(require("./services/service-provider"),exports),__exportStar(require("./services/local-storage.service.interface"),exports),__exportStar(require("./services/backend-status.service"),exports),__exportStar(require("./services/http/https.service.interface"),exports),__exportStar(require("./services/http/https-client/https-client.service.interface"),exports),__exportStar(require("./services/http/file-transfer/file-transfer.service.interface"),exports),__exportStar(require("./services/http/oauth-https.service"),exports),__exportStar(require("./services/base.service"),exports),__exportStar(require("./services/base-login-init.service"),exports),__exportStar(require("./services/device-status.service.interface"),exports),__exportStar(require("./services/session/session.service.interface"),exports),__exportStar(require("./services/session/oauth-session.service"),exports),__exportStar(require("./services/paginated-request.service"),exports),__exportStar(require("./services/log.service"),exports),__exportStar(require("./factories/paginated-request-service.factory"),exports),__exportStar(require("./services/file.service.interface"),exports),__exportStar(require("./services/recent-parts.service"),exports),__exportStar(require("./models/base-paginated-request"),exports),__exportStar(require("./models/base-paginated-response"),exports),__exportStar(require("./models/default-get-paginated-request-pagination-context"),exports),__exportStar(require("./utils/general-helper"),exports),__exportStar(require("./utils/multipart-upload.helper"),exports),__exportStar(require("./services/organization"),exports);
|
|
@@ -64,6 +64,11 @@ export declare class AxiosHttpsClientService extends HttpsClientService {
|
|
|
64
64
|
* @returns Observable that resolves with the request result
|
|
65
65
|
*/
|
|
66
66
|
put(url: string, data: any, urlParams?: Array<Object>, headers?: Object, requestOptions?: RequestOptions): Observable<any>;
|
|
67
|
+
/**
|
|
68
|
+
* React Native FormData uploads fail when Content-Type is set without a boundary,
|
|
69
|
+
* and axios may stringify FormData unless transformRequest passes it through unchanged.
|
|
70
|
+
*/
|
|
71
|
+
private applyFormDataRequestOptions;
|
|
67
72
|
/**
|
|
68
73
|
* Wraps the requests with necessary rxjs operators for processing response
|
|
69
74
|
* and errors.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var e=function(r
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},__assign.apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AxiosHttpsClientService=void 0;var rxjs_1=require("rxjs"),axios_observable_1=require("axios-observable"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("../../../services/http/https-client/https-client.service.interface"),handle_axios_error_helper_1=require("../handle-axios-error-helper"),device_status_service_interface_1=require("../../../services/device-status.service.interface"),error_1=require("../../../models/error"),AxiosHttpsClientService=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.deviceStatusService=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService)},t.prototype.get=function(e,t,r,s){var i;return this.requestAsObservable({method:"GET",url:this.addUrlParameters(e,t),headers:r,withCredentials:null!==(i=null==s?void 0:s.withCredentials)&&void 0!==i&&i})},t.prototype.post=function(e,t,r,s,i){var o;return this.requestAsObservable(this.applyFormDataRequestOptions({method:"POST",url:this.addUrlParameters(e,r),data:t,headers:s,withCredentials:null!==(o=null==i?void 0:i.withCredentials)&&void 0!==o&&o}))},t.prototype.patch=function(e,t,r,s,i){var o;return this.requestAsObservable(this.applyFormDataRequestOptions({method:"PATCH",url:this.addUrlParameters(e,r),data:t,headers:s,withCredentials:null!==(o=null==i?void 0:i.withCredentials)&&void 0!==o&&o}))},t.prototype.delete=function(e,t,r,s,i){var o;return this.requestAsObservable({method:"DELETE",url:this.addUrlParameters(e,r),data:t,headers:s,withCredentials:null!==(o=null==i?void 0:i.withCredentials)&&void 0!==o&&o})},t.prototype.put=function(e,t,r,s,i){var o;return this.requestAsObservable(this.applyFormDataRequestOptions({method:"PUT",url:this.addUrlParameters(e,r),data:t,headers:s,withCredentials:null!==(o=null==i?void 0:i.withCredentials)&&void 0!==o&&o}))},t.prototype.applyFormDataRequestOptions=function(e){if(!(e.data instanceof FormData))return e;var t=__assign({},e.headers);return delete t["Content-Type"],delete t["content-type"],__assign(__assign({},e),{headers:t,transformRequest:[function(e){return e}]})},t.prototype.requestAsObservable=function(e){var t=this;return(0,rxjs_1.defer)((function(){return t.validateIsKnownUrlOrCry(e.url),axios_observable_1.default.request(e)})).pipe((0,operators_1.map)((function(e){return t.processResponse(e)})),(0,operators_1.catchError)((function(e){return t.checkInternetConnectivity(e)})),(0,operators_1.catchError)(handle_axios_error_helper_1.HandleAxiosErrorHelper.processError))},t.prototype.processResponse=function(e){if(e.status){if(e.status>=400&&e.status<500)throw console.log("HttpsService - Client Error"),e;if(e.status>=500&&e.status<600)throw console.log("HttpsService - Server Error"),e;return e.data}throw e},t.prototype.checkInternetConnectivity=function(e){return(0,rxjs_1.from)(this.deviceStatusService.isConnectionAvailable()).pipe((0,operators_1.map)((function(t){throw t?e:new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_INTERNET,e)})))},t}(https_client_service_interface_1.HttpsClientService);exports.AxiosHttpsClientService=AxiosHttpsClientService;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},__assign.apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FetchAPIHttpsClientService=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),fetch_api_http_error_helper_1=require("../fetch-api-http-error-helper"),https_client_service_interface_1=require("../../../services/http/https-client/https-client.service.interface"),device_status_service_interface_1=require("../../../services/device-status.service.interface"),error_1=require("../../../models/error"),FetchAPIHttpsClientService=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.deviceStatusService=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService)},t.prototype.get=function(e,t,r,s){return this.requestAsObservable(this.addUrlParameters(e,t),__assign({method:"GET",credentials:(null==s?void 0:s.withCredentials)?"include":"same-origin"},r&&{headers:Object.entries(r)}))},t.prototype.post=function(e,t,r,s,i){return t instanceof FormData&&delete s["Content-Type"],this.requestAsObservable(this.addUrlParameters(e,r),__assign(__assign({method:"POST",credentials:(null==i?void 0:i.withCredentials)?"include":"same-origin"},t&&{body:this.createBody(t)}),s&&{headers:Object.entries(s)}))},t.prototype.patch=function(e,t,r,s,i){return this.requestAsObservable(this.addUrlParameters(e,r),__assign(__assign({method:"PATCH",credentials:(null==i?void 0:i.withCredentials)?"include":"same-origin"},t&&{body:this.createBody(t)}),s&&{headers:Object.entries(s)}))},t.prototype.delete=function(e,t,r,s,i){return this.requestAsObservable(this.addUrlParameters(e,r),__assign(__assign({method:"DELETE",credentials:(null==i?void 0:i.withCredentials)?"include":"same-origin"},t&&{body:this.createBody(t)}),s&&{headers:Object.entries(s)}))},t.prototype.put=function(e,t,r,s,i){return this.requestAsObservable(this.addUrlParameters(e,r),__assign(__assign({method:"PUT",credentials:(null==i?void 0:i.withCredentials)?"include":"same-origin"},t&&{body:this.createBody(t)}),s&&{headers:Object.entries(s)}))},t.prototype.requestAsObservable=function(e,t){var r=this;return new rxjs_1.Observable((function(s){r.validateIsKnownUrlOrCry(e),fetch(e,t).then((function(e){s.next(e),s.complete()})).catch((function(e){s.error(e)}))})).pipe((0,operators_1.mergeMap)((function(e){return r.processResponse(e)})),(0,operators_1.catchError)((function(e){return r.checkInternetConnectivity(e)})),(0,operators_1.catchError)(fetch_api_http_error_helper_1.FetchAPIHttpErrorHelper.processError))},t.prototype.processResponse=function(e){if(e.status){if(e.status>=400&&e.status<500)throw console.log("HttpsService - Client Error"),e;if(e.status>=500&&e.status<600)throw console.log("HttpsService - Server Error"),e;return 204===e.status?(0,rxjs_1.of)({}):(0,rxjs_1.from)(e.clone().json())}throw e},t.prototype.checkInternetConnectivity=function(e){return(0,rxjs_1.from)(this.deviceStatusService.isConnectionAvailable()).pipe((0,operators_1.map)((function(t){throw t?e:new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_INTERNET,e)})))},t.prototype.createBody=function(e){return"string"==typeof e||e instanceof FormData?e:JSON.stringify(e)},t}(https_client_service_interface_1.HttpsClientService);exports.FetchAPIHttpsClientService=FetchAPIHttpsClientService;
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},__assign.apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FetchAPIHttpsClientService=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),fetch_api_http_error_helper_1=require("../fetch-api-http-error-helper"),https_client_service_interface_1=require("../../../services/http/https-client/https-client.service.interface"),device_status_service_interface_1=require("../../../services/device-status.service.interface"),error_1=require("../../../models/error"),FetchAPIHttpsClientService=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.deviceStatusService=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService)},t.prototype.get=function(e,t,r,s){return this.requestAsObservable(this.addUrlParameters(e,t),__assign({method:"GET",credentials:(null==s?void 0:s.withCredentials)?"include":"same-origin"},r&&{headers:Object.entries(r)}))},t.prototype.post=function(e,t,r,s,i){return t instanceof FormData&&s&&delete s["Content-Type"],this.requestAsObservable(this.addUrlParameters(e,r),__assign(__assign({method:"POST",credentials:(null==i?void 0:i.withCredentials)?"include":"same-origin"},t&&{body:this.createBody(t)}),s&&{headers:Object.entries(s)}))},t.prototype.patch=function(e,t,r,s,i){return this.requestAsObservable(this.addUrlParameters(e,r),__assign(__assign({method:"PATCH",credentials:(null==i?void 0:i.withCredentials)?"include":"same-origin"},t&&{body:this.createBody(t)}),s&&{headers:Object.entries(s)}))},t.prototype.delete=function(e,t,r,s,i){return this.requestAsObservable(this.addUrlParameters(e,r),__assign(__assign({method:"DELETE",credentials:(null==i?void 0:i.withCredentials)?"include":"same-origin"},t&&{body:this.createBody(t)}),s&&{headers:Object.entries(s)}))},t.prototype.put=function(e,t,r,s,i){return this.requestAsObservable(this.addUrlParameters(e,r),__assign(__assign({method:"PUT",credentials:(null==i?void 0:i.withCredentials)?"include":"same-origin"},t&&{body:this.createBody(t)}),s&&{headers:Object.entries(s)}))},t.prototype.requestAsObservable=function(e,t){var r=this;return new rxjs_1.Observable((function(s){r.validateIsKnownUrlOrCry(e),fetch(e,t).then((function(e){s.next(e),s.complete()})).catch((function(e){s.error(e)}))})).pipe((0,operators_1.mergeMap)((function(e){return r.processResponse(e)})),(0,operators_1.catchError)((function(e){return r.checkInternetConnectivity(e)})),(0,operators_1.catchError)(fetch_api_http_error_helper_1.FetchAPIHttpErrorHelper.processError))},t.prototype.processResponse=function(e){if(e.status){if(e.status>=400&&e.status<500)throw console.log("HttpsService - Client Error"),e;if(e.status>=500&&e.status<600)throw console.log("HttpsService - Server Error"),e;return 204===e.status?(0,rxjs_1.of)({}):(0,rxjs_1.from)(e.clone().json())}throw e},t.prototype.checkInternetConnectivity=function(e){return(0,rxjs_1.from)(this.deviceStatusService.isConnectionAvailable()).pipe((0,operators_1.map)((function(t){throw t?e:new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_INTERNET,e)})))},t.prototype.createBody=function(e){return"string"==typeof e||e instanceof FormData?e:JSON.stringify(e)},t}(https_client_service_interface_1.HttpsClientService);exports.FetchAPIHttpsClientService=FetchAPIHttpsClientService;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSOauthPublicApiSessionService=void 0;var rxjs_1=require("rxjs"),oauth_session_service_1=require("../../services/session/oauth-session.service"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("../../services/http/https-client/https-client.service.interface"),user_1=require("../../models/user"),error_1=require("../../models/error"),user_token_1=require("../../models/user-token"),JSOauthPublicApiSessionService=function(e){function t(t){var r=e.call(this,t)||this;return r._status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0},r.status$=new rxjs_1.BehaviorSubject(r._status),r}return __extends(t,e),t.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},t.prototype.getStatus=function(){return this.status$.asObservable()},t.prototype.login=function(e){var t=this;if(e.activeSession)return this.reuseActiveSession(e.activeSession),this.sessionSetup();if(e.apiKey){var r=this.authenticationConfig;return this.httpsClientService.post("".concat(r.partiumApiBaseUrl,"/auth/"),null,null,{Authorization:"Bearer ".concat(r.apiKey)}).pipe((0,operators_1.catchError)((function(e){return t.handleError(e)})),(0,operators_1.tap)((function(e){t.updateTokenFromResponse(e)})),(0,operators_1.mergeMap)((function(){return t.sessionSetup()})))}return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_LOGIN_CONFIG,null,"Neither an api key nor an active session was provided"))},t.prototype.refresh=function(){var e=this;if(this._status&&this._status.refreshToken){var t=this.authenticationConfig;return this.httpsClientService.post("".concat(t.partiumApiBaseUrl,"/auth/refresh"),{refresh_token:this._status.refreshToken},null).pipe((0,operators_1.catchError)((function(t){return e.handleError(t)})),(0,operators_1.map)((function(t){e.updateTokenFromResponse(t)})))}return this.resetToken(),this.sessionEnded(),(0,rxjs_1.throwError)(this.createSdkError(null,"Could not refresh because there was no refresh token"))},t.prototype.logout=function(e){var t=this;if(this._status&&this._status.refreshToken){var r=this.authenticationConfig;return this.httpsClientService.post("".concat(r.partiumApiBaseUrl,"/auth/revoke"),{access_token:this._status.accessToken,refresh_token:this._status.refreshToken},null).pipe((0,operators_1.catchError)((function(e){return t.handleError(e)})),(0,operators_1.map)((function(){t.resetToken(),t.sessionEnded()})))}return this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0)},t.prototype.reuseActiveSession=function(e){this.updateToken(e)},t.prototype.updateTokenFromResponse=function(e){var t=new Date(Date.now()+1e3*e.expires_in_secs);this.updateToken({accessToken:e.token,accessTokenExpiration:t,accessTokenCreateDate:new Date,authenticated:!0,refreshToken:e.refresh_token})},t.prototype.updateToken=function(e){this.tokenUpdated(e.accessToken,e.accessTokenExpiration);var t=(0,user_token_1.createUserToken)(e.accessToken),r=user_1.
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSOauthPublicApiSessionService=void 0;var rxjs_1=require("rxjs"),oauth_session_service_1=require("../../services/session/oauth-session.service"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("../../services/http/https-client/https-client.service.interface"),user_1=require("../../models/user"),error_1=require("../../models/error"),user_token_1=require("../../models/user-token"),JSOauthPublicApiSessionService=function(e){function t(t){var r=e.call(this,t)||this;return r._status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0},r.status$=new rxjs_1.BehaviorSubject(r._status),r}return __extends(t,e),t.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},t.prototype.getStatus=function(){return this.status$.asObservable()},t.prototype.login=function(e){var t=this;if(e.activeSession)return this.reuseActiveSession(e.activeSession),this.sessionSetup();if(e.apiKey){var r=this.authenticationConfig;return this.httpsClientService.post("".concat(r.partiumApiBaseUrl,"/auth/"),null,null,{Authorization:"Bearer ".concat(r.apiKey)}).pipe((0,operators_1.catchError)((function(e){return t.handleError(e)})),(0,operators_1.tap)((function(e){t.updateTokenFromResponse(e)})),(0,operators_1.mergeMap)((function(){return t.sessionSetup()})))}return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_LOGIN_CONFIG,null,"Neither an api key nor an active session was provided"))},t.prototype.refresh=function(){var e=this;if(this._status&&this._status.refreshToken){var t=this.authenticationConfig;return this.httpsClientService.post("".concat(t.partiumApiBaseUrl,"/auth/refresh"),{refresh_token:this._status.refreshToken},null).pipe((0,operators_1.catchError)((function(t){return e.handleError(t)})),(0,operators_1.map)((function(t){e.updateTokenFromResponse(t)})))}return this.resetToken(),this.sessionEnded(),(0,rxjs_1.throwError)(this.createSdkError(null,"Could not refresh because there was no refresh token"))},t.prototype.logout=function(e){var t=this;if(this._status&&this._status.refreshToken){var r=this.authenticationConfig;return this.httpsClientService.post("".concat(r.partiumApiBaseUrl,"/auth/revoke"),{access_token:this._status.accessToken,refresh_token:this._status.refreshToken},null).pipe((0,operators_1.catchError)((function(e){return t.handleError(e)})),(0,operators_1.map)((function(){t.resetToken(),t.sessionEnded()})))}return this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0)},t.prototype.reuseActiveSession=function(e){this.updateToken(e)},t.prototype.updateTokenFromResponse=function(e){var t=new Date(Date.now()+1e3*e.expires_in_secs);this.updateToken({accessToken:e.token,accessTokenExpiration:t,accessTokenCreateDate:new Date,authenticated:!0,refreshToken:e.refresh_token})},t.prototype.updateToken=function(e){this.tokenUpdated(e.accessToken,e.accessTokenExpiration);var t=(0,user_token_1.createUserToken)(e.accessToken),r=(0,user_1.createUserFromToken)(t);this.setUser(r),this._status=e,this.status$.next(this._status)},t.prototype.resetToken=function(){this.tokenUpdated(null,null),this.setUser(null),this._status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0},this.status$.next(this._status)},t.prototype.handleError=function(e){return e instanceof error_1.SdkError?e.code===error_1.SDK_ERROR_CODES.BAD_REQUEST&&e.detail&&e.detail.response&&e.detail.response.data&&"unauthorized_client"===e.detail.response.data.error?(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,e.detail,"Unauthorized Keycloak client.")):(0,rxjs_1.throwError)(e):(0,rxjs_1.throwError)(this.createSdkError(e))},t.prototype.createSdkError=function(e,t){return new error_1.SdkError(error_1.SDK_ERROR_CODES.OAUTH_ERROR,e,t)},t}(oauth_session_service_1.OauthSessionService);exports.JSOauthPublicApiSessionService=JSOauthPublicApiSessionService;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSOauthKeycloakSessionService=void 0;var rxjs_1=require("rxjs"),querystring=require("query-string"),oauth_session_service_1=require("../../services/session/oauth-session.service"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("../../services/http/https-client/https-client.service.interface"),user_1=require("../../models/user"),error_1=require("../../models/error"),base64=require("base-64"),user_token_1=require("../../models/user-token"),JSOauthKeycloakSessionService=function(e){function r(r){var t=e.call(this,r)||this;return t._status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0},t.status$=new rxjs_1.BehaviorSubject(t._status),t}return __extends(r,e),r.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},r.prototype.getStatus=function(){return this.status$.asObservable()},r.prototype.login=function(e){var r=this;if(e.activeSession)return this.reuseActiveSession(e.activeSession),this.sessionSetup();if(e.apiKey){var t=this.authenticationConfig,o=this.parseApiKey(e.apiKey),s=o.email,n=o.password,i=t.realm,a=t.clientId,c="".concat(t.baseUrl,"/auth/realms/").concat(i,"/protocol/openid-connect/token"),u=querystring.stringify({client_id:a,grant_type:"password",scope:"openid",username:s,password:n});return this.httpsClientService.post(c,u,null,{"Content-type":"application/x-www-form-urlencoded"}).pipe((0,operators_1.catchError)((function(e){return r.handleError(e)})),(0,operators_1.tap)((function(e){if(e.error)throw console.error(e.error,e.error_description),r.resetToken(),r.sessionEnded(),r.createSdkError(e);r.updateTokenFromResponse(e)})),(0,operators_1.mergeMap)((function(){return r.sessionSetup()})))}return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_LOGIN_CONFIG,null,"Neither an api key nor an active session was provided"))},r.prototype.refresh=function(){var e=this;if(this._status&&this._status.refreshToken){var r=this.authenticationConfig,t=this.authenticationConfig,o=t.realm,s=t.clientId,n="".concat(r.baseUrl,"/auth/realms/").concat(o,"/protocol/openid-connect/token"),i=querystring.stringify({client_id:s,grant_type:"refresh_token",refresh_token:this._status.refreshToken});return this.httpsClientService.post(n,i,null,{"Content-type":"application/x-www-form-urlencoded"}).pipe((0,operators_1.catchError)((function(r){return e.handleError(r)})),(0,operators_1.map)((function(r){if(r.error)throw console.error(r.error,r.error_description),e.resetToken(),e.sessionEnded(),e.createSdkError(r);e.updateTokenFromResponse(r)})))}return this.resetToken(),this.sessionEnded(),(0,rxjs_1.throwError)(this.createSdkError(null,"Could not refresh because there was no refresh token"))},r.prototype.logout=function(e){var r=this;if(this._status&&this._status.refreshToken){var t=this.authenticationConfig,o=this.authenticationConfig,s=o.realm,n=o.clientId,i="".concat(t.baseUrl,"/auth/realms/").concat(s,"/protocol/openid-connect/logout"),a=querystring.stringify({client_id:n,grant_type:"refresh_token",refresh_token:this._status.refreshToken});return this.httpsClientService.post(i,a,null,{"Content-type":"application/x-www-form-urlencoded"}).pipe((0,operators_1.catchError)((function(e){return r.handleError(e)})),(0,operators_1.map)((function(){r.resetToken(),r.sessionEnded()})))}return this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0)},r.prototype.reuseActiveSession=function(e){this.updateToken(e)},r.prototype.updateTokenFromResponse=function(e){var r=new Date(Date.now()+1e3*e.expires_in);this.updateToken({accessToken:e.access_token,accessTokenExpiration:r,accessTokenCreateDate:new Date,authenticated:!0,refreshToken:e.refresh_token})},r.prototype.updateToken=function(e){this.tokenUpdated(e.accessToken,e.accessTokenExpiration);var r=(0,user_token_1.createUserToken)(e.accessToken),t=user_1.
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSOauthKeycloakSessionService=void 0;var rxjs_1=require("rxjs"),querystring=require("query-string"),oauth_session_service_1=require("../../services/session/oauth-session.service"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("../../services/http/https-client/https-client.service.interface"),user_1=require("../../models/user"),error_1=require("../../models/error"),base64=require("base-64"),user_token_1=require("../../models/user-token"),JSOauthKeycloakSessionService=function(e){function r(r){var t=e.call(this,r)||this;return t._status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0},t.status$=new rxjs_1.BehaviorSubject(t._status),t}return __extends(r,e),r.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},r.prototype.getStatus=function(){return this.status$.asObservable()},r.prototype.login=function(e){var r=this;if(e.activeSession)return this.reuseActiveSession(e.activeSession),this.sessionSetup();if(e.apiKey){var t=this.authenticationConfig,o=this.parseApiKey(e.apiKey),s=o.email,n=o.password,i=t.realm,a=t.clientId,c="".concat(t.baseUrl,"/auth/realms/").concat(i,"/protocol/openid-connect/token"),u=querystring.stringify({client_id:a,grant_type:"password",scope:"openid",username:s,password:n});return this.httpsClientService.post(c,u,null,{"Content-type":"application/x-www-form-urlencoded"}).pipe((0,operators_1.catchError)((function(e){return r.handleError(e)})),(0,operators_1.tap)((function(e){if(e.error)throw console.error(e.error,e.error_description),r.resetToken(),r.sessionEnded(),r.createSdkError(e);r.updateTokenFromResponse(e)})),(0,operators_1.mergeMap)((function(){return r.sessionSetup()})))}return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_LOGIN_CONFIG,null,"Neither an api key nor an active session was provided"))},r.prototype.refresh=function(){var e=this;if(this._status&&this._status.refreshToken){var r=this.authenticationConfig,t=this.authenticationConfig,o=t.realm,s=t.clientId,n="".concat(r.baseUrl,"/auth/realms/").concat(o,"/protocol/openid-connect/token"),i=querystring.stringify({client_id:s,grant_type:"refresh_token",refresh_token:this._status.refreshToken});return this.httpsClientService.post(n,i,null,{"Content-type":"application/x-www-form-urlencoded"}).pipe((0,operators_1.catchError)((function(r){return e.handleError(r)})),(0,operators_1.map)((function(r){if(r.error)throw console.error(r.error,r.error_description),e.resetToken(),e.sessionEnded(),e.createSdkError(r);e.updateTokenFromResponse(r)})))}return this.resetToken(),this.sessionEnded(),(0,rxjs_1.throwError)(this.createSdkError(null,"Could not refresh because there was no refresh token"))},r.prototype.logout=function(e){var r=this;if(this._status&&this._status.refreshToken){var t=this.authenticationConfig,o=this.authenticationConfig,s=o.realm,n=o.clientId,i="".concat(t.baseUrl,"/auth/realms/").concat(s,"/protocol/openid-connect/logout"),a=querystring.stringify({client_id:n,grant_type:"refresh_token",refresh_token:this._status.refreshToken});return this.httpsClientService.post(i,a,null,{"Content-type":"application/x-www-form-urlencoded"}).pipe((0,operators_1.catchError)((function(e){return r.handleError(e)})),(0,operators_1.map)((function(){r.resetToken(),r.sessionEnded()})))}return this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0)},r.prototype.reuseActiveSession=function(e){this.updateToken(e)},r.prototype.updateTokenFromResponse=function(e){var r=new Date(Date.now()+1e3*e.expires_in);this.updateToken({accessToken:e.access_token,accessTokenExpiration:r,accessTokenCreateDate:new Date,authenticated:!0,refreshToken:e.refresh_token})},r.prototype.updateToken=function(e){this.tokenUpdated(e.accessToken,e.accessTokenExpiration);var r=(0,user_token_1.createUserToken)(e.accessToken),t=(0,user_1.createUserFromToken)(r);this.setUser(t),this._status=e,this.status$.next(this._status)},r.prototype.resetToken=function(){this.tokenUpdated(null,null),this.setUser(null),this._status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0},this.status$.next(this._status)},r.prototype.handleError=function(e){return e instanceof error_1.SdkError?e.code===error_1.SDK_ERROR_CODES.BAD_REQUEST&&e.detail&&e.detail.response&&e.detail.response.data&&"unauthorized_client"===e.detail.response.data.error?(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,e.detail,"Unauthorized Keycloak client.")):(0,rxjs_1.throwError)(e):(0,rxjs_1.throwError)(this.createSdkError(e))},r.prototype.createSdkError=function(e,r){return new error_1.SdkError(error_1.SDK_ERROR_CODES.OAUTH_ERROR,e,r)},r.prototype.parseApiKey=function(e){try{var r=JSON.parse(base64.decode(e));if(!r.email||!r.password)throw"Invalid API Key";return r}catch(e){throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_API_KEY_FORMAT,null,"The provided api-key has an invalid format.")}},r}(oauth_session_service_1.OauthSessionService);exports.JSOauthKeycloakSessionService=JSOauthKeycloakSessionService;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}(),__awaiter=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))((function(i,n){function s(e){try{u(o.next(e))}catch(e){n(e)}}function a(e){try{u(o.throw(e))}catch(e){n(e)}}function u(e){var r;e.done?i(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,a)}u((o=o.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var t,o,i,n,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(a){return function(u){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;n&&(n=0,a[0]&&(s=0)),s;)try{if(t=1,o&&(i=2&a[0]?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],o=0}finally{t=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSOauthWebCookieSessionService=exports.JSOauthWebCookieLoginConfig=exports.JSOauthWebCookieAuthenticationConfig=exports.JSOauthWebCookieStatus=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),auth_config_1=require("../../models/auth-config"),error_1=require("../../models/error"),user_token_1=require("../../models/user-token"),user_1=require("../../models/user"),https_client_service_interface_1=require("../../services/http/https-client/https-client.service.interface"),oauth_session_service_1=require("../../services/session/oauth-session.service"),COOKIE_REQUEST_OPTIONS={withCredentials:!0},MISSING_REFRESH_TOKEN_ERROR_MESSAGE="Refresh token not provided in cookie or request body.",PKCE_CODE_VERIFIER_STORAGE_KEY="partium.oauth.web_cookie.pkce_code_verifier",COOKIE_SESSION_STORAGE_KEY="partium.oauth.web_cookie.has_active_session",COOKIE_SESSION_STORAGE_VALUE="true",PKCE_CODE_CHALLENGE_METHOD="S256",JSOauthWebCookieStatus=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return __extends(r,e),r}(oauth_session_service_1.OauthStatus);exports.JSOauthWebCookieStatus=JSOauthWebCookieStatus;var JSOauthWebCookieAuthenticationConfig=function(e){function r(r){var t=e.call(this,r)||this;return t.partiumApiBaseUrl="https://api.partium.io",t.oauthSessionService=JSOauthWebCookieSessionService,Object.assign(t,r),t}return __extends(r,e),r}(auth_config_1.OauthAuthenticationConfig);exports.JSOauthWebCookieAuthenticationConfig=JSOauthWebCookieAuthenticationConfig;var JSOauthWebCookieLoginConfig=function(e){function r(r){var t=e.call(this)||this;return Object.assign(t,r),t}return __extends(r,e),r}(oauth_session_service_1.OauthLoginConfig);exports.JSOauthWebCookieLoginConfig=JSOauthWebCookieLoginConfig;var JSOauthWebCookieSessionService=function(e){function r(r){var t=e.call(this,r)||this;return t.status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0,user:void 0,featureFlags:void 0},t.status$=new rxjs_1.BehaviorSubject(t.status),t}return __extends(r,e),r.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},r.prototype.getStatus=function(){return this.status$.asObservable()},r.prototype.login=function(e){var r=this,t=e,o=this.authenticationConfig,i=t.apiKey||o.apiKey,n=this.getUrlQueryParam("code"),s=this.getOauthErrorFromUrl();if(i)return this.loginWithApiKey(i).pipe((0,operators_1.mergeMap)((function(){return r.sessionSetup(t.loginEventContext)})));if(s)return this.clearPkceCodeVerifier(),(0,rxjs_1.throwError)((function(){return r.createSdkError(null,s)}));var a=o.authorizationCode||n;if(a){var u=void 0;try{u=this.stripIdentityProviderHintsFromRedirectUrl(this.getRedirectUrl(t))}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.exchangeCodeForToken(a,u).pipe((0,operators_1.tap)((function(){return r.clearAuthCallbackParamsFromUrl()})),(0,operators_1.mergeMap)((function(){return r.sessionSetup(t.loginEventContext)})))}return this.refreshWithCookie().pipe((0,operators_1.map)((function(e){return r.updateTokenFromResponse(e)})),(0,operators_1.mergeMap)((function(){return r.sessionSetup(t.loginEventContext)})),(0,operators_1.catchError)((function(){return r.redirectToLoginPage(t)})))},r.prototype.refresh=function(){var e=this;return this.refreshWithCookie().pipe((0,operators_1.map)((function(r){return e.updateTokenFromResponse(r)})),(0,operators_1.catchError)((function(r){return e.handleRefreshError(r)})))},r.prototype.logout=function(e){return void 0!==(null==e?void 0:e.postLogoutRedirectUri)?this.logoutThroughBrowser(e.postLogoutRedirectUri):this.revokeSession()},r.prototype.logoutThroughBrowser=function(e){if("string"!=typeof e||!e.trim())return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,{postLogoutRedirectUri:e},"Missing postLogoutRedirectUri for browser logout.")}));if("undefined"==typeof window)return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,{postLogoutRedirectUri:e},"Cannot redirect to the logout page outside of a browser context.")}));var r;try{r=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}var t=new URL("".concat(r,"/auth/logout"));t.searchParams.set("post_logout_redirect_uri",e),this.resetToken(),this.sessionEnded();var o=t.toString();return(0,rxjs_1.of)(void 0).pipe((0,operators_1.tap)((function(){window.setTimeout((function(){window.location.assign(o)}),0)})))},r.prototype.revokeSession=function(){var e,r=this;if(!this.hasSessionToRevoke())return this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0);try{e=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(e,"/auth/revoke"),{access_token:this.status.accessToken||null,refresh_token:null},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(){r.resetToken(),r.sessionEnded()})),(0,operators_1.catchError)((function(e){return r.resetToken(),r.sessionEnded(),r.handleError(e)})))},r.prototype.exchangeCodeForToken=function(e,r){var t,o,i=this;try{t=this.getPartiumApiBaseUrl(),o=this.getPkceCodeVerifier()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(t,"/auth"),{grant_type:"authorization_code",code:e,redirect_uri:r,code_verifier:o},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(e){i.clearPkceCodeVerifier(),i.updateTokenFromResponse(e)})),(0,operators_1.catchError)((function(e){return i.handleError(e)})))},r.prototype.loginWithApiKey=function(e){var r,t=this;try{r=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(r,"/auth"),{},void 0,{Authorization:"Bearer ".concat(e)},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(e){return t.updateTokenFromResponse(e)})),(0,operators_1.catchError)((function(e){return t.handleError(e)})))},r.prototype.refreshWithCookie=function(){var e;try{e=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(e,"/auth/refresh"),{refresh_token:null},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS)},r.prototype.redirectToLoginPage=function(e){if("undefined"==typeof window)return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Cannot redirect to OAuth login page outside of a browser context.")}));var r;try{r=this.getRedirectUrl(e)}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return(0,rxjs_1.from)(this.buildOauthAuthorizationUrl(r)).pipe((0,operators_1.tap)((function(e){window.location.href=e})),(0,operators_1.mergeMap)((function(){return rxjs_1.NEVER})))},r.prototype.buildOauthAuthorizationUrl=function(e){return __awaiter(this,void 0,void 0,(function(){var r,t,o,i,n,s,a,u,c,h,p;return __generator(this,(function(_){switch(_.label){case 0:if(r=this.authenticationConfig,t=r.baseUrl,o=r.realm,i=r.clientId,!t||!o||!i)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,r,"OAuth auth configuration is incomplete. Required: baseUrl, realm, clientId.");return n=this.stripIdentityProviderHintsFromRedirectUrl(e),s="".concat(t,"/auth/realms/").concat(o,"/protocol/openid-connect/auth"),a=new URLSearchParams({client_id:i,redirect_uri:n,response_type:"code",response_mode:"query",scope:"openid"}),u=this.createPkceCodeVerifier(),[4,this.createPkceCodeChallenge(u)];case 1:return c=_.sent(),this.storePkceCodeVerifier(u),a.set("code_challenge",c),a.set("code_challenge_method",PKCE_CODE_CHALLENGE_METHOD),(h=this.getKcIdpHintForAuthorizationRequest(e))&&a.set("kc_idp_hint",h),(p=this.getUseOrganizationIdpForAuthorizationRequest(e))&&a.set("use_organization_idp",p),[2,"".concat(s,"?").concat(a.toString())]}}))}))},r.prototype.getRedirectUrl=function(e){var r=e.redirectUrl||this.authenticationConfig.redirectUrl;if(!r)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing redirectUrl in OAuth authentication configuration.");return r},r.prototype.getPartiumApiBaseUrl=function(){var e=this.authenticationConfig.partiumApiBaseUrl;if(!e)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing partiumApiBaseUrl in OAuth authentication configuration.");return e},r.prototype.getUrlQueryParam=function(e){var r;return"undefined"!=typeof window&&(null===(r=window.location)||void 0===r?void 0:r.search)?new URLSearchParams(window.location.search).get(e):null},r.prototype.getHintFromUrlString=function(e,r){try{return new URL(e).searchParams.get(r)}catch(e){return null}},r.prototype.stripIdentityProviderHintsFromRedirectUrl=function(e){var r=new URL(e);return r.searchParams.delete("kc_idp_hint"),r.searchParams.delete("use_organization_idp"),r.toString()},r.prototype.resolveAuthorizationHintParam=function(e,r){var t=this.getUrlQueryParam(e);return t||this.getHintFromUrlString(r,e)},r.prototype.getKcIdpHintForAuthorizationRequest=function(e){return this.resolveAuthorizationHintParam("kc_idp_hint",e)},r.prototype.getUseOrganizationIdpForAuthorizationRequest=function(e){return this.resolveAuthorizationHintParam("use_organization_idp",e)},r.prototype.getOauthErrorFromUrl=function(){var e=this.getUrlQueryParam("error"),r=this.getUrlQueryParam("error_description");if(e||r)return[e,r].filter((function(e){return!!e})).join(" - ")},r.prototype.clearAuthCallbackParamsFromUrl=function(){if("undefined"!=typeof window){var e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("session_state"),e.searchParams.delete("iss"),e.searchParams.delete("error"),e.searchParams.delete("error_description"),e.searchParams.delete("kc_idp_hint"),e.searchParams.delete("use_organization_idp"),e.searchParams.delete("apiKey"),e.searchParams.delete("apikey");var r="".concat(e.pathname).concat(e.search).concat(e.hash);window.history.replaceState(window.history.state,"",r)}},r.prototype.updateTokenFromResponse=function(e){this.updateToken(e.token),e.token&&this.markActiveCookieSession()},r.prototype.updateToken=function(e){if(e){var r=(0,user_token_1.createUserToken)(e),t=this.getNumericClaim(r.exp),o=this.getNumericClaim(r.iat),i=void 0!==t?new Date(1e3*t):new Date,n=void 0!==o?new Date(1e3*o):new Date,s=user_1.User.createFromToken(r),a=this.getStringArrayClaim(r.features);this.tokenUpdated(e,i),this.setUser(s),this.status={accessToken:e,accessTokenCreateDate:n,accessTokenExpiration:i,refreshToken:void 0,authenticated:!0,user:s,featureFlags:a},this.status$.next(this.status)}else this.resetToken()},r.prototype.resetToken=function(){this.tokenUpdated(null,null),this.setUser(null),this.clearActiveCookieSession(),this.status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0,user:void 0,featureFlags:void 0},this.status$.next(this.status)},r.prototype.handleRefreshError=function(e){return e instanceof error_1.SdkError&&this.isExpiredOrMissingRefreshError(e)?(this.resetToken(),this.sessionEnded(),(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED,e.detail,"Refresh token expired or missing.")}))):this.handleError(e)},r.prototype.isExpiredOrMissingRefreshError=function(e){return e.code===error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED||e.code===error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY&&this.getRefreshValidationMessages(e.detail).includes(MISSING_REFRESH_TOKEN_ERROR_MESSAGE)},r.prototype.getRefreshValidationMessages=function(e){var r,t,o=this,i=this.asRefreshValidationErrorDetail(e);if(!i)return[];if("string"==typeof i.message)return[i.message];var n=null===(t=null===(r=i.response)||void 0===r?void 0:r.data)||void 0===t?void 0:t.detail;return"string"==typeof n?[n]:Array.isArray(n)?n.map((function(e){return o.getRefreshValidationMessage(e)})).filter((function(e){return void 0!==e})):[]},r.prototype.handleError=function(e){var r=this;return e instanceof error_1.SdkError?(0,rxjs_1.throwError)((function(){return e})):(0,rxjs_1.throwError)((function(){return r.createSdkError(e)}))},r.prototype.createSdkError=function(e,r){return new error_1.SdkError(error_1.SDK_ERROR_CODES.OAUTH_ERROR,e,r)},r.prototype.hasSessionToRevoke=function(){return Boolean(this.status.accessToken)||this.hasActiveCookieSession()},r.prototype.createPkceCodeVerifier=function(){var e=new Uint8Array(32);return this.getBrowserCrypto().getRandomValues(e),this.base64UrlEncode(e)},r.prototype.createPkceCodeChallenge=function(e){return __awaiter(this,void 0,void 0,(function(){var r,t;return __generator(this,(function(o){switch(o.label){case 0:if("undefined"==typeof TextEncoder)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"TextEncoder is required for PKCE OAuth login.");return r=(new TextEncoder).encode(e),[4,this.getBrowserCrypto().subtle.digest("SHA-256",r)];case 1:return t=o.sent(),[2,this.base64UrlEncode(new Uint8Array(t))]}}))}))},r.prototype.getBrowserCrypto=function(){var e;if("function"!=typeof(null===(e=globalThis.crypto)||void 0===e?void 0:e.getRandomValues)||!globalThis.crypto.subtle)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Web Crypto API is required for PKCE OAuth login.");return globalThis.crypto},r.prototype.storePkceCodeVerifier=function(e){this.getBrowserSessionStorage().setItem(PKCE_CODE_VERIFIER_STORAGE_KEY,e)},r.prototype.getPkceCodeVerifier=function(){var e=this.getBrowserSessionStorage().getItem(PKCE_CODE_VERIFIER_STORAGE_KEY);if(!e)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Missing PKCE code verifier for OAuth callback.");return e},r.prototype.clearPkceCodeVerifier=function(){"undefined"!=typeof window&&window.sessionStorage.removeItem(PKCE_CODE_VERIFIER_STORAGE_KEY)},r.prototype.markActiveCookieSession=function(){this.getBrowserSessionStorage().setItem(COOKIE_SESSION_STORAGE_KEY,COOKIE_SESSION_STORAGE_VALUE)},r.prototype.hasActiveCookieSession=function(){return"undefined"!=typeof window&&window.sessionStorage.getItem(COOKIE_SESSION_STORAGE_KEY)===COOKIE_SESSION_STORAGE_VALUE},r.prototype.clearActiveCookieSession=function(){"undefined"!=typeof window&&window.sessionStorage.removeItem(COOKIE_SESSION_STORAGE_KEY)},r.prototype.getBrowserSessionStorage=function(){if("undefined"==typeof window)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Browser sessionStorage is required for the web-cookie OAuth flow.");return window.sessionStorage},r.prototype.base64UrlEncode=function(e){var r=Array.from(e,(function(e){return String.fromCharCode(e)})).join("");return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},r.prototype.getNumericClaim=function(e){return"number"==typeof e?e:void 0},r.prototype.getStringArrayClaim=function(e){return Array.isArray(e)&&e.every((function(e){return"string"==typeof e}))?e:void 0},r.prototype.asRefreshValidationErrorDetail=function(e){return this.isObjectRecord(e)?e:void 0},r.prototype.getRefreshValidationMessage=function(e){if(this.isObjectRecord(e))return"string"==typeof e.msg?e.msg:void 0},r.prototype.isObjectRecord=function(e){return"object"==typeof e&&null!==e},r}(oauth_session_service_1.OauthSessionService);exports.JSOauthWebCookieSessionService=JSOauthWebCookieSessionService;
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}(),__awaiter=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))((function(i,n){function s(e){try{u(o.next(e))}catch(e){n(e)}}function a(e){try{u(o.throw(e))}catch(e){n(e)}}function u(e){var r;e.done?i(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,a)}u((o=o.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var t,o,i,n,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(a){return function(u){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;n&&(n=0,a[0]&&(s=0)),s;)try{if(t=1,o&&(i=2&a[0]?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],o=0}finally{t=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSOauthWebCookieSessionService=exports.JSOauthWebCookieLoginConfig=exports.JSOauthWebCookieAuthenticationConfig=exports.JSOauthWebCookieStatus=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),auth_config_1=require("../../models/auth-config"),error_1=require("../../models/error"),user_token_1=require("../../models/user-token"),user_1=require("../../models/user"),https_client_service_interface_1=require("../../services/http/https-client/https-client.service.interface"),oauth_session_service_1=require("../../services/session/oauth-session.service"),COOKIE_REQUEST_OPTIONS={withCredentials:!0},MISSING_REFRESH_TOKEN_ERROR_MESSAGE="Refresh token not provided in cookie or request body.",PKCE_CODE_VERIFIER_STORAGE_KEY="partium.oauth.web_cookie.pkce_code_verifier",COOKIE_SESSION_STORAGE_KEY="partium.oauth.web_cookie.has_active_session",COOKIE_SESSION_STORAGE_VALUE="true",PKCE_CODE_CHALLENGE_METHOD="S256",JSOauthWebCookieStatus=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return __extends(r,e),r}(oauth_session_service_1.OauthStatus);exports.JSOauthWebCookieStatus=JSOauthWebCookieStatus;var JSOauthWebCookieAuthenticationConfig=function(e){function r(r){var t=e.call(this,r)||this;return t.partiumApiBaseUrl="https://api.partium.io",t.oauthSessionService=JSOauthWebCookieSessionService,Object.assign(t,r),t}return __extends(r,e),r}(auth_config_1.OauthAuthenticationConfig);exports.JSOauthWebCookieAuthenticationConfig=JSOauthWebCookieAuthenticationConfig;var JSOauthWebCookieLoginConfig=function(e){function r(r){var t=e.call(this)||this;return Object.assign(t,r),t}return __extends(r,e),r}(oauth_session_service_1.OauthLoginConfig);exports.JSOauthWebCookieLoginConfig=JSOauthWebCookieLoginConfig;var JSOauthWebCookieSessionService=function(e){function r(r){var t=e.call(this,r)||this;return t.status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0,user:void 0,featureFlags:void 0},t.status$=new rxjs_1.BehaviorSubject(t.status),t}return __extends(r,e),r.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},r.prototype.getStatus=function(){return this.status$.asObservable()},r.prototype.login=function(e){var r=this,t=e,o=this.authenticationConfig,i=t.apiKey||o.apiKey,n=this.getUrlQueryParam("code"),s=this.getOauthErrorFromUrl();if(i)return this.loginWithApiKey(i).pipe((0,operators_1.mergeMap)((function(){return r.sessionSetup(t.loginEventContext)})));if(s)return this.clearPkceCodeVerifier(),(0,rxjs_1.throwError)((function(){return r.createSdkError(null,s)}));var a=o.authorizationCode||n;if(a){var u=void 0;try{u=this.stripIdentityProviderHintsFromRedirectUrl(this.getRedirectUrl(t))}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.exchangeCodeForToken(a,u).pipe((0,operators_1.tap)((function(){return r.clearAuthCallbackParamsFromUrl()})),(0,operators_1.mergeMap)((function(){return r.sessionSetup(t.loginEventContext)})))}return this.refreshWithCookie().pipe((0,operators_1.map)((function(e){return r.updateTokenFromResponse(e)})),(0,operators_1.mergeMap)((function(){return r.sessionSetup(t.loginEventContext)})),(0,operators_1.catchError)((function(){return r.redirectToLoginPage(t)})))},r.prototype.refresh=function(){var e=this;return this.refreshWithCookie().pipe((0,operators_1.map)((function(r){return e.updateTokenFromResponse(r)})),(0,operators_1.catchError)((function(r){return e.handleRefreshError(r)})))},r.prototype.logout=function(e){return void 0!==(null==e?void 0:e.postLogoutRedirectUri)?this.logoutThroughBrowser(e.postLogoutRedirectUri):this.revokeSession()},r.prototype.logoutThroughBrowser=function(e){if("string"!=typeof e||!e.trim())return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,{postLogoutRedirectUri:e},"Missing postLogoutRedirectUri for browser logout.")}));if("undefined"==typeof window)return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,{postLogoutRedirectUri:e},"Cannot redirect to the logout page outside of a browser context.")}));var r;try{r=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}var t=new URL("".concat(r,"/auth/logout"));t.searchParams.set("post_logout_redirect_uri",e),this.resetToken(),this.sessionEnded();var o=t.toString();return(0,rxjs_1.of)(void 0).pipe((0,operators_1.tap)((function(){window.setTimeout((function(){window.location.assign(o)}),0)})))},r.prototype.revokeSession=function(){var e,r=this;if(!this.hasSessionToRevoke())return this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0);try{e=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(e,"/auth/revoke"),{access_token:this.status.accessToken||null,refresh_token:null},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(){r.resetToken(),r.sessionEnded()})),(0,operators_1.catchError)((function(e){return r.resetToken(),r.sessionEnded(),r.handleError(e)})))},r.prototype.exchangeCodeForToken=function(e,r){var t,o,i=this;try{t=this.getPartiumApiBaseUrl(),o=this.getPkceCodeVerifier()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(t,"/auth"),{grant_type:"authorization_code",code:e,redirect_uri:r,code_verifier:o},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(e){i.clearPkceCodeVerifier(),i.updateTokenFromResponse(e)})),(0,operators_1.catchError)((function(e){return i.handleError(e)})))},r.prototype.loginWithApiKey=function(e){var r,t=this;try{r=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(r,"/auth"),{},void 0,{Authorization:"Bearer ".concat(e)},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(e){return t.updateTokenFromResponse(e)})),(0,operators_1.catchError)((function(e){return t.handleError(e)})))},r.prototype.refreshWithCookie=function(){var e;try{e=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(e,"/auth/refresh"),{refresh_token:null},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS)},r.prototype.redirectToLoginPage=function(e){if("undefined"==typeof window)return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Cannot redirect to OAuth login page outside of a browser context.")}));var r;try{r=this.getRedirectUrl(e)}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return(0,rxjs_1.from)(this.buildOauthAuthorizationUrl(r)).pipe((0,operators_1.tap)((function(e){window.location.href=e})),(0,operators_1.mergeMap)((function(){return rxjs_1.NEVER})))},r.prototype.buildOauthAuthorizationUrl=function(e){return __awaiter(this,void 0,void 0,(function(){var r,t,o,i,n,s,a,u,c,h,p;return __generator(this,(function(_){switch(_.label){case 0:if(r=this.authenticationConfig,t=r.baseUrl,o=r.realm,i=r.clientId,!t||!o||!i)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,r,"OAuth auth configuration is incomplete. Required: baseUrl, realm, clientId.");return n=this.stripIdentityProviderHintsFromRedirectUrl(e),s="".concat(t,"/auth/realms/").concat(o,"/protocol/openid-connect/auth"),a=new URLSearchParams({client_id:i,redirect_uri:n,response_type:"code",response_mode:"query",scope:"openid"}),u=this.createPkceCodeVerifier(),[4,this.createPkceCodeChallenge(u)];case 1:return c=_.sent(),this.storePkceCodeVerifier(u),a.set("code_challenge",c),a.set("code_challenge_method",PKCE_CODE_CHALLENGE_METHOD),(h=this.getKcIdpHintForAuthorizationRequest(e))&&a.set("kc_idp_hint",h),(p=this.getUseOrganizationIdpForAuthorizationRequest(e))&&a.set("use_organization_idp",p),[2,"".concat(s,"?").concat(a.toString())]}}))}))},r.prototype.getRedirectUrl=function(e){var r=e.redirectUrl||this.authenticationConfig.redirectUrl;if(!r)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing redirectUrl in OAuth authentication configuration.");return r},r.prototype.getPartiumApiBaseUrl=function(){var e=this.authenticationConfig.partiumApiBaseUrl;if(!e)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing partiumApiBaseUrl in OAuth authentication configuration.");return e},r.prototype.getUrlQueryParam=function(e){var r;return"undefined"!=typeof window&&(null===(r=window.location)||void 0===r?void 0:r.search)?new URLSearchParams(window.location.search).get(e):null},r.prototype.getHintFromUrlString=function(e,r){try{return new URL(e).searchParams.get(r)}catch(e){return null}},r.prototype.stripIdentityProviderHintsFromRedirectUrl=function(e){var r=new URL(e);return r.searchParams.delete("kc_idp_hint"),r.searchParams.delete("use_organization_idp"),r.toString()},r.prototype.resolveAuthorizationHintParam=function(e,r){var t=this.getUrlQueryParam(e);return t||this.getHintFromUrlString(r,e)},r.prototype.getKcIdpHintForAuthorizationRequest=function(e){return this.resolveAuthorizationHintParam("kc_idp_hint",e)},r.prototype.getUseOrganizationIdpForAuthorizationRequest=function(e){return this.resolveAuthorizationHintParam("use_organization_idp",e)},r.prototype.getOauthErrorFromUrl=function(){var e=this.getUrlQueryParam("error"),r=this.getUrlQueryParam("error_description");if(e||r)return[e,r].filter((function(e){return!!e})).join(" - ")},r.prototype.clearAuthCallbackParamsFromUrl=function(){if("undefined"!=typeof window){var e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("session_state"),e.searchParams.delete("iss"),e.searchParams.delete("error"),e.searchParams.delete("error_description"),e.searchParams.delete("kc_idp_hint"),e.searchParams.delete("use_organization_idp"),e.searchParams.delete("apiKey"),e.searchParams.delete("apikey");var r="".concat(e.pathname).concat(e.search).concat(e.hash);window.history.replaceState(window.history.state,"",r)}},r.prototype.updateTokenFromResponse=function(e){this.updateToken(e.token),e.token&&this.markActiveCookieSession()},r.prototype.updateToken=function(e){if(e){var r=(0,user_token_1.createUserToken)(e),t=this.getNumericClaim(r.exp),o=this.getNumericClaim(r.iat),i=void 0!==t?new Date(1e3*t):new Date,n=void 0!==o?new Date(1e3*o):new Date,s=(0,user_1.createUserFromToken)(r),a=this.getStringArrayClaim(r.features);this.tokenUpdated(e,i),this.setUser(s),this.status={accessToken:e,accessTokenCreateDate:n,accessTokenExpiration:i,refreshToken:void 0,authenticated:!0,user:s,featureFlags:a},this.status$.next(this.status)}else this.resetToken()},r.prototype.resetToken=function(){this.tokenUpdated(null,null),this.setUser(null),this.clearActiveCookieSession(),this.status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0,user:void 0,featureFlags:void 0},this.status$.next(this.status)},r.prototype.handleRefreshError=function(e){return e instanceof error_1.SdkError&&this.isExpiredOrMissingRefreshError(e)?(this.resetToken(),this.sessionEnded(),(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED,e.detail,"Refresh token expired or missing.")}))):this.handleError(e)},r.prototype.isExpiredOrMissingRefreshError=function(e){return e.code===error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED||e.code===error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY&&this.getRefreshValidationMessages(e.detail).includes(MISSING_REFRESH_TOKEN_ERROR_MESSAGE)},r.prototype.getRefreshValidationMessages=function(e){var r,t,o=this,i=this.asRefreshValidationErrorDetail(e);if(!i)return[];if("string"==typeof i.message)return[i.message];var n=null===(t=null===(r=i.response)||void 0===r?void 0:r.data)||void 0===t?void 0:t.detail;return"string"==typeof n?[n]:Array.isArray(n)?n.map((function(e){return o.getRefreshValidationMessage(e)})).filter((function(e){return void 0!==e})):[]},r.prototype.handleError=function(e){var r=this;return e instanceof error_1.SdkError?(0,rxjs_1.throwError)((function(){return e})):(0,rxjs_1.throwError)((function(){return r.createSdkError(e)}))},r.prototype.createSdkError=function(e,r){return new error_1.SdkError(error_1.SDK_ERROR_CODES.OAUTH_ERROR,e,r)},r.prototype.hasSessionToRevoke=function(){return Boolean(this.status.accessToken)||this.hasActiveCookieSession()},r.prototype.createPkceCodeVerifier=function(){var e=new Uint8Array(32);return this.getBrowserCrypto().getRandomValues(e),this.base64UrlEncode(e)},r.prototype.createPkceCodeChallenge=function(e){return __awaiter(this,void 0,void 0,(function(){var r,t;return __generator(this,(function(o){switch(o.label){case 0:if("undefined"==typeof TextEncoder)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"TextEncoder is required for PKCE OAuth login.");return r=(new TextEncoder).encode(e),[4,this.getBrowserCrypto().subtle.digest("SHA-256",r)];case 1:return t=o.sent(),[2,this.base64UrlEncode(new Uint8Array(t))]}}))}))},r.prototype.getBrowserCrypto=function(){var e;if("function"!=typeof(null===(e=globalThis.crypto)||void 0===e?void 0:e.getRandomValues)||!globalThis.crypto.subtle)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Web Crypto API is required for PKCE OAuth login.");return globalThis.crypto},r.prototype.storePkceCodeVerifier=function(e){this.getBrowserSessionStorage().setItem(PKCE_CODE_VERIFIER_STORAGE_KEY,e)},r.prototype.getPkceCodeVerifier=function(){var e=this.getBrowserSessionStorage().getItem(PKCE_CODE_VERIFIER_STORAGE_KEY);if(!e)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Missing PKCE code verifier for OAuth callback.");return e},r.prototype.clearPkceCodeVerifier=function(){"undefined"!=typeof window&&window.sessionStorage.removeItem(PKCE_CODE_VERIFIER_STORAGE_KEY)},r.prototype.markActiveCookieSession=function(){this.getBrowserSessionStorage().setItem(COOKIE_SESSION_STORAGE_KEY,COOKIE_SESSION_STORAGE_VALUE)},r.prototype.hasActiveCookieSession=function(){return"undefined"!=typeof window&&window.sessionStorage.getItem(COOKIE_SESSION_STORAGE_KEY)===COOKIE_SESSION_STORAGE_VALUE},r.prototype.clearActiveCookieSession=function(){"undefined"!=typeof window&&window.sessionStorage.removeItem(COOKIE_SESSION_STORAGE_KEY)},r.prototype.getBrowserSessionStorage=function(){if("undefined"==typeof window)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Browser sessionStorage is required for the web-cookie OAuth flow.");return window.sessionStorage},r.prototype.base64UrlEncode=function(e){var r=Array.from(e,(function(e){return String.fromCharCode(e)})).join("");return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},r.prototype.getNumericClaim=function(e){return"number"==typeof e?e:void 0},r.prototype.getStringArrayClaim=function(e){return Array.isArray(e)&&e.every((function(e){return"string"==typeof e}))?e:void 0},r.prototype.asRefreshValidationErrorDetail=function(e){return this.isObjectRecord(e)?e:void 0},r.prototype.getRefreshValidationMessage=function(e){if(this.isObjectRecord(e))return"string"==typeof e.msg?e.msg:void 0},r.prototype.isObjectRecord=function(e){return"object"==typeof e&&null!==e},r}(oauth_session_service_1.OauthSessionService);exports.JSOauthWebCookieSessionService=JSOauthWebCookieSessionService;
|
package/core/models/user.d.ts
CHANGED
|
@@ -1,51 +1,15 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
2
|
import { UserToken } from './user-token';
|
|
3
|
-
export declare enum Role {
|
|
4
|
-
admin = "admin",
|
|
5
|
-
announcementsEditor = "announcementsEditor",//partium/org/announcementsEditor
|
|
6
|
-
partiumAnnouncementsEditor = "partiumAnnouncementsEditor",// partium/announcementsEditor
|
|
7
|
-
/** @deprecated role does not exist in Partium */
|
|
8
|
-
user = "user",
|
|
9
|
-
/** Partium Analytics user role */
|
|
10
|
-
analyst = "dataAnalyst",
|
|
11
|
-
/** Partium Data Insights user role */
|
|
12
|
-
dataInsightAnalyst = "dataInsightAnalyst",
|
|
13
|
-
csa = "csa",
|
|
14
|
-
factoryWorker = "factoryWorker",
|
|
15
|
-
developer = "developer",
|
|
16
|
-
catalogAdmin = "catalogAdmin",
|
|
17
|
-
dataManipulator = "dataManipulator",
|
|
18
|
-
dataContributor = "dataContributor",
|
|
19
|
-
dataValidator = "dataValidator",
|
|
20
|
-
enrichmentRequester = "enrichmentRequester"
|
|
21
|
-
}
|
|
22
3
|
/**
|
|
23
4
|
* The user-object of the user that is logged in into the SDK.
|
|
24
5
|
*/
|
|
25
|
-
export
|
|
6
|
+
export interface User {
|
|
26
7
|
/** Can be either an email or the `preferred_username` of the user (can be any string) */
|
|
27
8
|
email: string;
|
|
28
|
-
/** @deprecated first role of the set of roles the user has. Use `roles` property instead. */
|
|
29
|
-
role: Role;
|
|
30
|
-
/**
|
|
31
|
-
* Set of roles the user has.
|
|
32
|
-
* Does not distinguish the organizations in which the user has certain roles.
|
|
33
|
-
*/
|
|
34
|
-
roles: Set<Role>;
|
|
35
|
-
/**
|
|
36
|
-
* List of groups of the user.
|
|
37
|
-
* This can be used in cases where roles can not be parsed from them directly.
|
|
38
|
-
*/
|
|
39
|
-
groups: string[];
|
|
40
|
-
constructor(email: string, role: Role, roles?: Set<Role>, groups?: string[]);
|
|
41
|
-
/**
|
|
42
|
-
* Creates a User object from a UserToken object (parsed jwt token)
|
|
43
|
-
* @param token - jwt token in UserToken format
|
|
44
|
-
* @returns created User with values populated from token
|
|
45
|
-
*/
|
|
46
|
-
static createFromToken(token: UserToken): User;
|
|
47
|
-
private static createRoles;
|
|
48
|
-
private static getRoleFromGroup;
|
|
49
|
-
private static checkPartiumRoles;
|
|
50
|
-
private static getRoleByString;
|
|
51
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a User object from a UserToken object (parsed jwt token)
|
|
12
|
+
* @param token - jwt token in UserToken format
|
|
13
|
+
* @returns created User with values populated from token
|
|
14
|
+
*/
|
|
15
|
+
export declare const createUserFromToken: (token: UserToken) => User;
|
package/core/models/user.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createUserFromToken=void 0;var createUserFromToken=function(e){return{email:e.email||e.preferred_username}};exports.createUserFromToken=createUserFromToken;
|
|
@@ -3,34 +3,32 @@ import { BaseService } from '../base.service';
|
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import { AuthenticationConfig } from '../../models/auth-config';
|
|
5
5
|
import { ServiceProvider } from '../service-provider';
|
|
6
|
-
import { Organization } from '
|
|
6
|
+
import { Organization } from '../organization/models/organization';
|
|
7
7
|
export declare enum BACKEND_SERVICE {
|
|
8
8
|
PARTIUM = 0,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
DATA_ENRICHMENT = 11
|
|
9
|
+
DATA = 1,
|
|
10
|
+
CSA = 2,
|
|
11
|
+
LOG = 3,
|
|
12
|
+
USER_DATA = 4,
|
|
13
|
+
MANAGEMENT = 5,
|
|
14
|
+
CATALOG = 6,
|
|
15
|
+
DATACURATION = 7,
|
|
16
|
+
DATA_V2 = 8,
|
|
17
|
+
DATA_ENRICHMENT = 9,
|
|
18
|
+
BACKOFFICE = 10
|
|
20
19
|
}
|
|
21
20
|
export interface BaseUrls {
|
|
22
21
|
partiumApiBaseUrl: string;
|
|
23
|
-
findBeBaseUrl: string;
|
|
24
22
|
dataBeBaseUrl: string;
|
|
25
23
|
csaBeBaseUrl: string;
|
|
26
24
|
logBeBaseUrl: string;
|
|
27
25
|
userDataBeBaseUrl: string;
|
|
28
|
-
ocrBeBaseUrl: string;
|
|
29
26
|
managementBeBaseUrl: string;
|
|
30
27
|
catalogBeBaseUrl: string;
|
|
31
28
|
datacurationBeBaseUrl: string;
|
|
32
29
|
dataV2BeBaseUrl: string;
|
|
33
30
|
dataEnrichmentBeBaseUrl: string;
|
|
31
|
+
backofficeBeBaseUrl: string;
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
36
34
|
* Defines the structure of a https-service implementation, which
|
|
@@ -66,7 +64,7 @@ export declare class HttpsService extends BaseService {
|
|
|
66
64
|
*
|
|
67
65
|
* @param url the relative url
|
|
68
66
|
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
69
|
-
* @param beService to which backend-service should the request be sent (default
|
|
67
|
+
* @param beService to which backend-service should the request be sent (default PARTIUM)
|
|
70
68
|
* @returns Observable that resolves with the request result
|
|
71
69
|
*/
|
|
72
70
|
get(url: string, urlParams?: Array<Object>, beService?: BACKEND_SERVICE): Observable<any>;
|
|
@@ -76,7 +74,7 @@ export declare class HttpsService extends BaseService {
|
|
|
76
74
|
* @param url the relative url
|
|
77
75
|
* @param data the data to be sent with the post request
|
|
78
76
|
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
79
|
-
* @param beService to which backend-service should the request be sent (default
|
|
77
|
+
* @param beService to which backend-service should the request be sent (default PARTIUM)
|
|
80
78
|
* @param headers object with custom headers to send with the request
|
|
81
79
|
* @returns Observable that resolves with the request result
|
|
82
80
|
*/
|
|
@@ -87,7 +85,7 @@ export declare class HttpsService extends BaseService {
|
|
|
87
85
|
* @param url the relative url
|
|
88
86
|
* @param data the data to be sent with the post request
|
|
89
87
|
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
90
|
-
* @param beService to which backend-service should the request be sent (default
|
|
88
|
+
* @param beService to which backend-service should the request be sent (default PARTIUM)
|
|
91
89
|
* @param headers object with custom headers to send with the request
|
|
92
90
|
* @returns Observable that resolves with the request result
|
|
93
91
|
*/
|
|
@@ -98,7 +96,7 @@ export declare class HttpsService extends BaseService {
|
|
|
98
96
|
* @param url the relative url
|
|
99
97
|
* @param data the data to be sent with the patch request
|
|
100
98
|
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
101
|
-
* @param beService to which backend-service should the request be sent (default
|
|
99
|
+
* @param beService to which backend-service should the request be sent (default PARTIUM)
|
|
102
100
|
* @param headers object with custom headers to send with the request
|
|
103
101
|
* @returns Observable that resolves with the request result
|
|
104
102
|
*/
|
|
@@ -109,7 +107,7 @@ export declare class HttpsService extends BaseService {
|
|
|
109
107
|
* @param url the relative url
|
|
110
108
|
* @param data the data to be sent with the delete request
|
|
111
109
|
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
112
|
-
* @param beService to which backend-service should the request be sent (default
|
|
110
|
+
* @param beService to which backend-service should the request be sent (default PARTIUM)
|
|
113
111
|
* @returns Observable that resolves with the request result
|
|
114
112
|
*/
|
|
115
113
|
delete(url: string, data?: Object, urlParams?: Array<Object>, beService?: BACKEND_SERVICE): Observable<any>;
|
|
@@ -150,7 +148,7 @@ export declare class HttpsService extends BaseService {
|
|
|
150
148
|
* Combine the given relative url with the Backends Base-url.
|
|
151
149
|
*
|
|
152
150
|
* @param relUrl the relative url
|
|
153
|
-
* @param beService to which backend-service should the request be sent (default
|
|
151
|
+
* @param beService to which backend-service should the request be sent (default PARTIUM)
|
|
154
152
|
*/
|
|
155
153
|
private createUrl;
|
|
156
154
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}(),__decorate=this&&this.__decorate||function(e,r,t,n){var o,s=arguments.length,i=s<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,r,t,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(s<3?o(i):s>3?o(r,t,i):o(r,t))||i);return s>3&&i&&Object.defineProperty(r,t,i),i};Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpsService=exports.BACKEND_SERVICE=void 0;var BACKEND_SERVICE,base_service_1=require("../base.service"),rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("./https-client/https-client.service.interface"),injection_identifier_1=require("../../decorators/injection-identifier");!function(e){e[e.PARTIUM=0]="PARTIUM",e[e.
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}(),__decorate=this&&this.__decorate||function(e,r,t,n){var o,s=arguments.length,i=s<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,r,t,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(s<3?o(i):s>3?o(r,t,i):o(r,t))||i);return s>3&&i&&Object.defineProperty(r,t,i),i};Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpsService=exports.BACKEND_SERVICE=void 0;var BACKEND_SERVICE,base_service_1=require("../base.service"),rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("./https-client/https-client.service.interface"),injection_identifier_1=require("../../decorators/injection-identifier");!function(e){e[e.PARTIUM=0]="PARTIUM",e[e.DATA=1]="DATA",e[e.CSA=2]="CSA",e[e.LOG=3]="LOG",e[e.USER_DATA=4]="USER_DATA",e[e.MANAGEMENT=5]="MANAGEMENT",e[e.CATALOG=6]="CATALOG",e[e.DATACURATION=7]="DATACURATION",e[e.DATA_V2=8]="DATA_V2",e[e.DATA_ENRICHMENT=9]="DATA_ENRICHMENT",e[e.BACKOFFICE=10]="BACKOFFICE"}(BACKEND_SERVICE||(exports.BACKEND_SERVICE=BACKEND_SERVICE={}));var HttpsService=function(e){function r(r){return e.call(this,r)||this}return __extends(r,e),r.prototype.onCreate=function(){this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},r.prototype.init=function(e,r){return this.baseUrls=e,this.config=r,(0,rxjs_1.of)(void 0)},r.prototype.get=function(e,r,t){var n=this;return(0,rxjs_1.defer)((function(){return n.configureHeaders({},t)})).pipe((0,operators_1.mergeMap)((function(o){return n.httpsClientService.get(n.createUrl(e,t),r,o)})),(0,operators_1.retryWhen)((function(e){return n.retryWhen(e)})),(0,operators_1.catchError)((function(e){return n.processError(e)})))},r.prototype.post=function(e,r,t,n,o){var s=this;return(0,rxjs_1.defer)((function(){return s.configureHeaders(o,n)})).pipe((0,operators_1.mergeMap)((function(o){return s.httpsClientService.post(s.createUrl(e,n),r,t,o)})),(0,operators_1.retryWhen)((function(e){return s.retryWhen(e)})),(0,operators_1.catchError)((function(e){return s.processError(e)})))},r.prototype.put=function(e,r,t,n,o){var s=this;return(0,rxjs_1.defer)((function(){return s.configureHeaders(o,n)})).pipe((0,operators_1.mergeMap)((function(o){return s.httpsClientService.put(s.createUrl(e,n),r,t,o)})),(0,operators_1.retryWhen)((function(e){return s.retryWhen(e)})),(0,operators_1.catchError)((function(e){return s.processError(e)})))},r.prototype.patch=function(e,r,t,n,o){var s=this;return(0,rxjs_1.defer)((function(){return s.configureHeaders(o,n)})).pipe((0,operators_1.mergeMap)((function(o){return s.httpsClientService.patch(s.createUrl(e,n),r,t,o)})),(0,operators_1.retryWhen)((function(e){return s.retryWhen(e)})),(0,operators_1.catchError)((function(e){return s.processError(e)})))},r.prototype.delete=function(e,r,t,n){var o=this;return(0,rxjs_1.defer)((function(){return o.configureHeaders({},n)})).pipe((0,operators_1.mergeMap)((function(s){return o.httpsClientService.delete(o.createUrl(e,n),r,t,s)})),(0,operators_1.retryWhen)((function(e){return o.retryWhen(e)})),(0,operators_1.catchError)((function(e){return o.processError(e)})))},r.prototype.setCurrentOrganization=function(e){this.currentOrganization$=e},r.prototype.retryWhen=function(e){return e.pipe((0,operators_1.mergeMap)((function(e){return(0,rxjs_1.throwError)(e)})))},r.prototype.processError=function(e){return(0,rxjs_1.throwError)(e)},r.prototype.createHeaders=function(e){throw new Error("In order to use the HttpsService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},r.prototype.createUrl=function(e,r){for(void 0===r&&(r=BACKEND_SERVICE.PARTIUM);e.startsWith("/");)e=e.substring(1);var t;switch(r){case BACKEND_SERVICE.DATA:t=this.baseUrls.dataBeBaseUrl;break;case BACKEND_SERVICE.CSA:t=this.baseUrls.csaBeBaseUrl;break;case BACKEND_SERVICE.LOG:t=this.baseUrls.logBeBaseUrl;break;case BACKEND_SERVICE.USER_DATA:t=this.baseUrls.userDataBeBaseUrl;break;case BACKEND_SERVICE.MANAGEMENT:t=this.baseUrls.managementBeBaseUrl;break;case BACKEND_SERVICE.CATALOG:t=this.baseUrls.catalogBeBaseUrl;break;case BACKEND_SERVICE.DATACURATION:t=this.baseUrls.datacurationBeBaseUrl;break;case BACKEND_SERVICE.DATA_V2:t=this.baseUrls.dataV2BeBaseUrl;break;case BACKEND_SERVICE.DATA_ENRICHMENT:t=this.baseUrls.dataEnrichmentBeBaseUrl;break;case BACKEND_SERVICE.BACKOFFICE:t=this.baseUrls.backofficeBeBaseUrl;break;case BACKEND_SERVICE.PARTIUM:default:t=this.baseUrls.partiumApiBaseUrl}return[t,e].join("/")},r.prototype.configureHeaders=function(e,r){var t=this.createHeaders(e);return this.config.externalUserId&&r!==BACKEND_SERVICE.LOG&&(t["X-Partium-ExternalUserId"]=this.config.externalUserId),this.currentOrganization$?this.currentOrganization$.pipe((0,operators_1.first)(),(0,operators_1.map)((function(e){return(null==e?void 0:e.name)&&(t["X-Partium-Data-Organization"]=e.name),t}))):(0,rxjs_1.of)(t)},r=__decorate([(0,injection_identifier_1.InjectionIdentifier)("HttpsService")],r)}(base_service_1.BaseService);exports.HttpsService=HttpsService;
|
|
@@ -40,7 +40,7 @@ export declare class OauthHttpsService extends HttpsService {
|
|
|
40
40
|
*
|
|
41
41
|
* @param url the relative server url
|
|
42
42
|
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
43
|
-
* @param beService to which backend-service should the request be sent (default
|
|
43
|
+
* @param beService to which backend-service should the request be sent (default PARTIUM)
|
|
44
44
|
* @returns Observable that resolves with the request result
|
|
45
45
|
*/
|
|
46
46
|
get(url: string, urlParams?: Array<Object>, beService?: BACKEND_SERVICE): Observable<any>;
|
|
@@ -56,7 +56,7 @@ export declare class OauthHttpsService extends HttpsService {
|
|
|
56
56
|
* @param url the relative server url
|
|
57
57
|
* @param data the data to be sent with the post request
|
|
58
58
|
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
59
|
-
* @param beService to which backend-service should the request be sent (default
|
|
59
|
+
* @param beService to which backend-service should the request be sent (default PARTIUM)
|
|
60
60
|
* @param headers object with custom headers to send with the request
|
|
61
61
|
* @returns Observable that resolves with the request result
|
|
62
62
|
*/
|
|
@@ -73,7 +73,7 @@ export declare class OauthHttpsService extends HttpsService {
|
|
|
73
73
|
* @param url the relative server url
|
|
74
74
|
* @param data the data to be sent with the patch request
|
|
75
75
|
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
76
|
-
* @param beService to which backend-service should the request be sent (default
|
|
76
|
+
* @param beService to which backend-service should the request be sent (default PARTIUM)
|
|
77
77
|
* @param headers object with custom headers to send with the request
|
|
78
78
|
* @returns Observable that resolves with the request result
|
|
79
79
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
3
|
import { PartiumConfig } from "../models/partium-config";
|
|
4
|
-
import { Organization } from
|
|
4
|
+
import { Organization } from './organization/models/organization';
|
|
5
5
|
import { BaseLoginInitService } from "./base-login-init.service";
|
|
6
6
|
export type KeyPrefixParams = {
|
|
7
7
|
userEmail: boolean;
|
|
@@ -4,7 +4,7 @@ import { HttpsService } from './http/https.service.interface';
|
|
|
4
4
|
import { EventLog, EventLogRequestBody } from '../models/log';
|
|
5
5
|
import { BaseLoginInitService } from './base-login-init.service';
|
|
6
6
|
import { PartiumConfig } from '../models/partium-config';
|
|
7
|
-
import { Organization } from '
|
|
7
|
+
import { Organization } from './organization/models/organization';
|
|
8
8
|
/**
|
|
9
9
|
* Service to create search logs (also known as search events)
|
|
10
10
|
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
+
export * from './organization.service';
|
|
3
|
+
export * from './models/get-organizations-request';
|
|
4
|
+
export * from './models/get-organization-by-id-request';
|
|
5
|
+
export * from './models/get-organization-by-name-request';
|
|
6
|
+
export * from './models/organization';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,i)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./organization.service"),exports),__exportStar(require("./models/get-organizations-request"),exports),__exportStar(require("./models/get-organization-by-id-request"),exports),__exportStar(require("./models/get-organization-by-name-request"),exports),__exportStar(require("./models/organization"),exports);
|