@partium/js-sdk 15.10.0 → 15.11.1

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/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from './integration-defaults/http/file-transfer/fetch-api-file-transfer
13
13
  export * from './integration-defaults/session/js-oauth-keycloak-session.service';
14
14
  export * from './integration-defaults/session/js-oauth-keycloak-auth-config';
15
15
  export * from './integration-defaults/session/js-oauth-api-key-session.service';
16
+ export * from './integration-defaults/session/js-oauth-web-cookie-session.service';
16
17
  export * from './models/i18n-string';
17
18
  export * from './models/partium-config';
18
19
  export * from './models/auth-config';
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("./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/organization"),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/organization.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);
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/organization"),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/organization.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);
@@ -1,6 +1,7 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
2
  import { Observable } from 'rxjs';
3
3
  import { OauthSessionService, OauthStatus, OauthLoginConfig } from '../../services/session/oauth-session.service';
4
+ import { LogoutConfig } from '../../services/session/session.service.interface';
4
5
  import { ServiceProvider } from '../../services/service-provider';
5
6
  export interface JsOauthPublicApiResponse {
6
7
  token: string;
@@ -42,7 +43,7 @@ export declare class JSOauthPublicApiSessionService extends OauthSessionService
42
43
  /**
43
44
  * Logout the current user-session
44
45
  */
45
- logout(): Observable<void>;
46
+ logout(_config?: LogoutConfig): Observable<void>;
46
47
  /**
47
48
  * Instead of logging in with an api-key, the user already logged in to keycloak via another channel (eg direct)
48
49
  * -> reuse this existing session instead of creating a new one.
@@ -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(){var e=this;if(this._status&&this._status.refreshToken){var t=this.authenticationConfig;return this.httpsClientService.post("".concat(t.partiumApiBaseUrl,"/auth/revoke"),{access_token:this._status.accessToken,refresh_token:this._status.refreshToken},null).pipe((0,operators_1.catchError)((function(t){return e.handleError(t)})),(0,operators_1.map)((function(){e.resetToken(),e.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.User.createFromToken(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;
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.User.createFromToken(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,6 +1,7 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
2
  import { Observable } from 'rxjs';
3
3
  import { OauthSessionService, OauthStatus, OauthLoginConfig } from '../../services/session/oauth-session.service';
4
+ import { LogoutConfig } from '../../services/session/session.service.interface';
4
5
  import { ServiceProvider } from '../../services/service-provider';
5
6
  export interface JSOauthKeycloakResponse {
6
7
  access_token: string;
@@ -47,7 +48,7 @@ export declare class JSOauthKeycloakSessionService extends OauthSessionService {
47
48
  /**
48
49
  * Logout the current user-session
49
50
  */
50
- logout(): Observable<void>;
51
+ logout(_config?: LogoutConfig): Observable<void>;
51
52
  /**
52
53
  * Instead of logging in with an api-key, the user already logged in to keycloak via another channel (eg direct)
53
54
  * -> reuse this existing session instead of creating a new one.
@@ -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(){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/logout"),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(){e.resetToken(),e.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.User.createFromToken(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;
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.User.createFromToken(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;
@@ -0,0 +1,171 @@
1
+ // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
+ import { Observable } from 'rxjs';
3
+ import { OauthAuthenticationConfig } from '../../models/auth-config';
4
+ import { User } from '../../models/user';
5
+ import { BaseServiceClass } from '../../services/base.service';
6
+ import { OauthLoginConfig, OauthSessionService, OauthStatus } from '../../services/session/oauth-session.service';
7
+ import { LogoutConfig, SessionEventContext } from '../../services/session/session.service.interface';
8
+ import { ServiceProvider } from '../../services/service-provider';
9
+ /**
10
+ * Oauth status for the web-cookie session implementation.
11
+ * Extends the default oauth status with the authenticated user and feature flags
12
+ * extracted from the access token.
13
+ */
14
+ export declare class JSOauthWebCookieStatus extends OauthStatus {
15
+ user?: User;
16
+ featureFlags?: string[];
17
+ }
18
+ /**
19
+ * Authentication configuration for the web-cookie oauth session service.
20
+ * Extends the default oauth configuration with the Authentication API base URL
21
+ * and an optional authorization code for completing a redirect callback.
22
+ */
23
+ export declare class JSOauthWebCookieAuthenticationConfig extends OauthAuthenticationConfig {
24
+ partiumApiBaseUrl?: string;
25
+ authorizationCode?: string;
26
+ oauthSessionService: BaseServiceClass<OauthSessionService>;
27
+ constructor(init?: Partial<JSOauthWebCookieAuthenticationConfig>);
28
+ }
29
+ /**
30
+ * Login configuration for the web-cookie oauth session service.
31
+ * Allows overriding the redirect URL and passing additional event context for
32
+ * session setup.
33
+ */
34
+ export declare class JSOauthWebCookieLoginConfig extends OauthLoginConfig {
35
+ redirectUrl?: string;
36
+ loginEventContext?: SessionEventContext;
37
+ constructor(init?: Partial<JSOauthWebCookieLoginConfig>);
38
+ }
39
+ /**
40
+ * Web-cookie based implementation of the OauthSessionService for web
41
+ * applications.
42
+ * It uses the Authentication API to manage the refresh token in an HTTP-only
43
+ * cookie while exposing the current oauth session state through the SDK.
44
+ */
45
+ export declare class JSOauthWebCookieSessionService extends OauthSessionService {
46
+ private status;
47
+ private status$;
48
+ private httpsClientService;
49
+ constructor(serviceProvider: ServiceProvider);
50
+ /**
51
+ * Called when the service is initialized.
52
+ */
53
+ onCreate(): void;
54
+ /**
55
+ * Returns an observable that always emits the current web-cookie oauth status
56
+ * every time it changes.
57
+ *
58
+ * @returns Observable<JSOauthWebCookieStatus> observable that resolves with the current oauth status whenever it changes
59
+ */
60
+ getStatus(): Observable<JSOauthWebCookieStatus>;
61
+ /**
62
+ * Login user and resolves on success.
63
+ * Depending on the provided configuration, the login flow can reuse an api key,
64
+ * complete an authorization-code callback, bootstrap from an existing cookie-backed session, or redirect to the oauth login page.
65
+ *
66
+ * @param config the oauth login configuration
67
+ * @returns Observable<void> observable that resolves when login and session setup are finished successfully
68
+ */
69
+ login(config: OauthLoginConfig): Observable<void>;
70
+ /**
71
+ * Refresh session and access token with the cookie-backed refresh flow.
72
+ *
73
+ * @returns Observable<void> observable that resolves when the access token was refreshed successfully
74
+ */
75
+ refresh(): Observable<void>;
76
+ /**
77
+ * Logout the current user-session.
78
+ *
79
+ * @returns Observable<void> observable that resolves when the current session has ended
80
+ */
81
+ logout(config?: LogoutConfig): Observable<void>;
82
+ /**
83
+ * End the local session and hand browser logout over to the Authentication API.
84
+ */
85
+ private logoutThroughBrowser;
86
+ /**
87
+ * Revoke the current cookie-backed session, falling back to the access token if needed.
88
+ */
89
+ private revokeSession;
90
+ /**
91
+ * Exchange an OAuth authorization code through the backend so it can manage the refresh cookie.
92
+ */
93
+ private exchangeCodeForToken;
94
+ /**
95
+ * Bootstrap the same auth endpoint with an API key instead of a browser redirect.
96
+ */
97
+ private loginWithApiKey;
98
+ /**
99
+ * Ask the Authentication API to refresh the access token using the HTTP-only cookie.
100
+ */
101
+ private refreshWithCookie;
102
+ /**
103
+ * Redirect the browser into the OAuth login flow and stop the current observable chain.
104
+ */
105
+ private redirectToLoginPage;
106
+ /**
107
+ * Build the upstream authorization URL from SDK config and the current browser context.
108
+ */
109
+ private buildOauthAuthorizationUrl;
110
+ /**
111
+ * Resolve the redirect target from the per-call login config or the static auth config.
112
+ */
113
+ private getRedirectUrl;
114
+ /**
115
+ * Read the Authentication API base URL and fail fast when the SDK is misconfigured.
116
+ */
117
+ private getPartiumApiBaseUrl;
118
+ /**
119
+ * Safely read a query parameter from the current browser URL.
120
+ */
121
+ private getUrlQueryParam;
122
+ /**
123
+ * Collapse OAuth callback errors into a single message for public SDK error handling.
124
+ */
125
+ private getOauthErrorFromUrl;
126
+ /**
127
+ * Remove only consumed OAuth callback parameters without reloading the page,
128
+ * preserving unrelated query params such as IdP routing hints.
129
+ */
130
+ private clearAuthCallbackParamsFromUrl;
131
+ /**
132
+ * Forward Authentication API responses into the shared access-token update path.
133
+ */
134
+ private updateTokenFromResponse;
135
+ /**
136
+ * Decode the latest access token and mirror its state into the SDK session status.
137
+ */
138
+ private updateToken;
139
+ /**
140
+ * Clear all in-memory auth state after logout, refresh expiry, or invalid token data.
141
+ */
142
+ private resetToken;
143
+ /**
144
+ * Normalize unrecoverable refresh failures into the session-expired error contract.
145
+ */
146
+ private handleRefreshError;
147
+ /**
148
+ * Classify refresh failures that should end the local session immediately.
149
+ * We treat both refresh 401s and the backend's explicit "missing refresh token"
150
+ * validation message as unrecoverable refresh expiry.
151
+ */
152
+ private isExpiredOrMissingRefreshError;
153
+ /**
154
+ * Extract validation messages from the different error detail shapes emitted by
155
+ * the SDK HTTP clients so refresh error classification can stay transport-agnostic.
156
+ */
157
+ private getRefreshValidationMessages;
158
+ /**
159
+ * Preserve typed SDK errors and wrap unknown failures into a public OAuth error shape.
160
+ */
161
+ private handleError;
162
+ /**
163
+ * Create a fallback OAuth error when an upstream failure does not already use SdkError.
164
+ */
165
+ private createSdkError;
166
+ private getNumericClaim;
167
+ private getStringArrayClaim;
168
+ private asRefreshValidationErrorDetail;
169
+ private getRefreshValidationMessage;
170
+ private isObjectRecord;
171
+ }
@@ -0,0 +1,2 @@
1
+ // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
+ "use strict";var __extends=this&&this.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])},r(e,t)};return function(e,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=e}r(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}(),__awaiter=this&&this.__awaiter||function(r,e,t,o){return new(t||(t=Promise))((function(n,i){function s(r){try{u(o.next(r))}catch(r){i(r)}}function a(r){try{u(o.throw(r))}catch(r){i(r)}}function u(r){var e;r.done?n(r.value):(e=r.value,e instanceof t?e:new t((function(r){r(e)}))).then(s,a)}u((o=o.apply(r,e||[])).next())}))},__generator=this&&this.__generator||function(r,e){var t,o,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(t=1,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=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(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(r,s)}catch(r){a=[6,r],o=0}finally{t=n=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.",JSOauthWebCookieStatus=function(r){function e(){return null!==r&&r.apply(this,arguments)||this}return __extends(e,r),e}(oauth_session_service_1.OauthStatus);exports.JSOauthWebCookieStatus=JSOauthWebCookieStatus;var JSOauthWebCookieAuthenticationConfig=function(r){function e(e){var t=r.call(this,e)||this;return t.partiumApiBaseUrl="https://api.partium.io",t.oauthSessionService=JSOauthWebCookieSessionService,Object.assign(t,e),t}return __extends(e,r),e}(auth_config_1.OauthAuthenticationConfig);exports.JSOauthWebCookieAuthenticationConfig=JSOauthWebCookieAuthenticationConfig;var JSOauthWebCookieLoginConfig=function(r){function e(e){var t=r.call(this)||this;return Object.assign(t,e),t}return __extends(e,r),e}(oauth_session_service_1.OauthLoginConfig);exports.JSOauthWebCookieLoginConfig=JSOauthWebCookieLoginConfig;var JSOauthWebCookieSessionService=function(r){function e(e){var t=r.call(this,e)||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(e,r),e.prototype.onCreate=function(){r.prototype.onCreate.call(this),this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},e.prototype.getStatus=function(){return this.status$.asObservable()},e.prototype.login=function(r){var e=this,t=r,o=this.authenticationConfig,n=t.apiKey||o.apiKey,i=this.getUrlQueryParam("code"),s=this.getOauthErrorFromUrl();if(n)return this.loginWithApiKey(n).pipe((0,operators_1.mergeMap)((function(){return e.sessionSetup(t.loginEventContext)})));if(s)return(0,rxjs_1.throwError)((function(){return e.createSdkError(null,s)}));var a=o.authorizationCode||i;if(a){var u=void 0;try{u=this.getRedirectUrl(t)}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.exchangeCodeForToken(a,u).pipe((0,operators_1.tap)((function(){return e.clearAuthCallbackParamsFromUrl()})),(0,operators_1.mergeMap)((function(){return e.sessionSetup(t.loginEventContext)})))}return this.refreshWithCookie().pipe((0,operators_1.mergeMap)((function(){return e.sessionSetup(t.loginEventContext)})),(0,operators_1.catchError)((function(){return e.redirectToLoginPage(t)})))},e.prototype.refresh=function(){var r=this;return this.refreshWithCookie().pipe((0,operators_1.map)((function(e){return r.updateTokenFromResponse(e)})),(0,operators_1.catchError)((function(e){return r.handleRefreshError(e)})))},e.prototype.logout=function(r){return void 0!==(null==r?void 0:r.postLogoutRedirectUri)?this.logoutThroughBrowser(r.postLogoutRedirectUri):this.revokeSession()},e.prototype.logoutThroughBrowser=function(r){if("string"!=typeof r||!r.trim())return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,{postLogoutRedirectUri:r},"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:r},"Cannot redirect to the logout page outside of a browser context.")}));var e;try{e=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}var t=new URL("".concat(e,"/auth/logout"));return t.searchParams.set("post_logout_redirect_uri",r),this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0).pipe((0,operators_1.tap)((function(){return window.location.assign(t.toString())})))},e.prototype.revokeSession=function(){var r,e=this;try{r=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.httpsClientService.post("".concat(r,"/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(){e.resetToken(),e.sessionEnded()})),(0,operators_1.catchError)((function(r){return e.resetToken(),e.sessionEnded(),e.handleError(r)})))},e.prototype.exchangeCodeForToken=function(r,e){var t,o=this;try{t=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.httpsClientService.post("".concat(t,"/auth"),{grant_type:"authorization_code",code:r,redirect_uri:e},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(r){return o.updateTokenFromResponse(r)})),(0,operators_1.catchError)((function(r){return o.handleError(r)})))},e.prototype.loginWithApiKey=function(r){var e,t=this;try{e=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.httpsClientService.post("".concat(e,"/auth"),{},void 0,{Authorization:"Bearer ".concat(r)},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(r){return t.updateTokenFromResponse(r)})),(0,operators_1.catchError)((function(r){return t.handleError(r)})))},e.prototype.refreshWithCookie=function(){var r;try{r=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.httpsClientService.post("".concat(r,"/auth/refresh"),{refresh_token:null},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS)},e.prototype.redirectToLoginPage=function(r){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 e;try{e=this.getRedirectUrl(r)}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return(0,rxjs_1.from)(this.buildOauthAuthorizationUrl(e)).pipe((0,operators_1.tap)((function(r){window.location.href=r})),(0,operators_1.mergeMap)((function(){return rxjs_1.NEVER})))},e.prototype.buildOauthAuthorizationUrl=function(r){return __awaiter(this,void 0,void 0,(function(){var e,t,o,n,i,s,a;return __generator(this,(function(u){if(e=this.authenticationConfig,t=e.baseUrl,o=e.realm,n=e.clientId,!t||!o||!n)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,e,"OAuth auth configuration is incomplete. Required: baseUrl, realm, clientId.");return i="".concat(t,"/auth/realms/").concat(o,"/protocol/openid-connect/auth"),s=new URLSearchParams({client_id:n,redirect_uri:r,response_type:"code",response_mode:"query",scope:"openid"}),(a=this.getUrlQueryParam("kc_idp_hint"))&&s.set("kc_idp_hint",a),[2,"".concat(i,"?").concat(s.toString())]}))}))},e.prototype.getRedirectUrl=function(r){var e=r.redirectUrl||this.authenticationConfig.redirectUrl;if(!e)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing redirectUrl in OAuth authentication configuration.");return e},e.prototype.getPartiumApiBaseUrl=function(){var r=this.authenticationConfig.partiumApiBaseUrl;if(!r)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing partiumApiBaseUrl in OAuth authentication configuration.");return r},e.prototype.getUrlQueryParam=function(r){var e;return"undefined"!=typeof window&&(null===(e=window.location)||void 0===e?void 0:e.search)?new URLSearchParams(window.location.search).get(r):null},e.prototype.getOauthErrorFromUrl=function(){var r=this.getUrlQueryParam("error"),e=this.getUrlQueryParam("error_description");if(r||e)return[r,e].filter((function(r){return!!r})).join(" - ")},e.prototype.clearAuthCallbackParamsFromUrl=function(){if("undefined"!=typeof window){var r=new URL(window.location.href);r.searchParams.delete("code"),r.searchParams.delete("session_state"),r.searchParams.delete("iss"),r.searchParams.delete("error"),r.searchParams.delete("error_description");var e="".concat(r.pathname).concat(r.search).concat(r.hash);window.history.replaceState(window.history.state,"",e)}},e.prototype.updateTokenFromResponse=function(r){this.updateToken(r.token)},e.prototype.updateToken=function(r){if(r){var e=(0,user_token_1.createUserToken)(r),t=this.getNumericClaim(e.exp),o=this.getNumericClaim(e.iat),n=void 0!==t?new Date(1e3*t):new Date,i=void 0!==o?new Date(1e3*o):new Date,s=user_1.User.createFromToken(e),a=this.getStringArrayClaim(e.features);this.tokenUpdated(r,n),this.setUser(s),this.status={accessToken:r,accessTokenCreateDate:i,accessTokenExpiration:n,refreshToken:void 0,authenticated:!0,user:s,featureFlags:a},this.status$.next(this.status)}else this.resetToken()},e.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,user:void 0,featureFlags:void 0},this.status$.next(this.status)},e.prototype.handleRefreshError=function(r){return r instanceof error_1.SdkError&&this.isExpiredOrMissingRefreshError(r)?(this.resetToken(),this.sessionEnded(),(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED,r.detail,"Refresh token expired or missing.")}))):this.handleError(r)},e.prototype.isExpiredOrMissingRefreshError=function(r){return r.code===error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED||r.code===error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY&&this.getRefreshValidationMessages(r.detail).includes(MISSING_REFRESH_TOKEN_ERROR_MESSAGE)},e.prototype.getRefreshValidationMessages=function(r){var e,t,o=this,n=this.asRefreshValidationErrorDetail(r);if(!n)return[];if("string"==typeof n.message)return[n.message];var i=null===(t=null===(e=n.response)||void 0===e?void 0:e.data)||void 0===t?void 0:t.detail;return"string"==typeof i?[i]:Array.isArray(i)?i.map((function(r){return o.getRefreshValidationMessage(r)})).filter((function(r){return void 0!==r})):[]},e.prototype.handleError=function(r){var e=this;return r instanceof error_1.SdkError?(0,rxjs_1.throwError)((function(){return r})):(0,rxjs_1.throwError)((function(){return e.createSdkError(r)}))},e.prototype.createSdkError=function(r,e){return new error_1.SdkError(error_1.SDK_ERROR_CODES.OAUTH_ERROR,r,e)},e.prototype.getNumericClaim=function(r){return"number"==typeof r?r:void 0},e.prototype.getStringArrayClaim=function(r){return Array.isArray(r)&&r.every((function(r){return"string"==typeof r}))?r:void 0},e.prototype.asRefreshValidationErrorDetail=function(r){return this.isObjectRecord(r)?r:void 0},e.prototype.getRefreshValidationMessage=function(r){if(this.isObjectRecord(r))return"string"==typeof r.msg?r.msg:void 0},e.prototype.isObjectRecord=function(r){return"object"==typeof r&&null!==r},e}(oauth_session_service_1.OauthSessionService);exports.JSOauthWebCookieSessionService=JSOauthWebCookieSessionService;
@@ -45,6 +45,7 @@ export declare class HttpsClientService extends BaseService {
45
45
  * @param data the data to be sent with the post request
46
46
  * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
47
47
  * @param headers object with the request headers
48
+ * @param requestOptions options for the request
48
49
  * @returns Observable that resolves with the request result
49
50
  */
50
51
  post(url: string, data: Object, urlParams?: Array<Object>, headers?: Object, requestOptions?: RequestOptions): Observable<any>;
@@ -65,6 +66,7 @@ export declare class HttpsClientService extends BaseService {
65
66
  * @param data the data to be sent with the patch request
66
67
  * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
67
68
  * @param headers object with the request headers
69
+ * @param requestOptions options for the request
68
70
  * @returns Observable that resolves with the request result
69
71
  */
70
72
  patch(url: string, data: Object, urlParams?: Array<Object>, headers?: Object, requestOptions?: RequestOptions): Observable<any>;
@@ -74,6 +76,7 @@ export declare class HttpsClientService extends BaseService {
74
76
  * @param url the full server url
75
77
  * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
76
78
  * @param headers object with the request headers
79
+ * @param requestOptions options for the request
77
80
  * @returns Observable that resolves with the request result
78
81
  */
79
82
  delete(url: string, data?: Object, urlParams?: Array<Object>, headers?: Object, requestOptions?: RequestOptions): Observable<any>;
@@ -1,5 +1,5 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- import { SessionService, LoginConfig } from './session.service.interface';
2
+ import { SessionService, LoginConfig, LogoutConfig } from './session.service.interface';
3
3
  import { Observable } from 'rxjs';
4
4
  import { ServiceProvider } from '../service-provider';
5
5
  /**
@@ -68,7 +68,7 @@ export declare abstract class OauthSessionService extends SessionService {
68
68
  *
69
69
  * @returns {Observable<void>}
70
70
  */
71
- logout(): Observable<void>;
71
+ logout(config?: LogoutConfig): Observable<void>;
72
72
  /**
73
73
  * Update the oauth token in the oauth https service whenever it changes.
74
74
  */
@@ -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 o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.OauthSessionService=exports.OauthStatus=exports.OauthLoginConfig=void 0;var session_service_interface_1=require("./session.service.interface"),https_service_interface_1=require("../http/https.service.interface"),OauthLoginConfig=function(e){function t(t){var r=e.call(this)||this;return Object.assign(r,t),r}return __extends(t,e),t}(session_service_interface_1.LoginConfig);exports.OauthLoginConfig=OauthLoginConfig;var OauthStatus=function(e){Object.assign(this,e)};exports.OauthStatus=OauthStatus;var OauthSessionService=function(e){function t(t){return e.call(this,t)||this}return __extends(t,e),t.prototype.onCreate=function(){this.httpsServiceOauth=this.serviceProvider.getService(https_service_interface_1.HttpsService)},t.prototype.login=function(e){throw new Error("In order to use the OauthSessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.refresh=function(){throw new Error("In order to use the OauthSessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.logout=function(){throw new Error("In order to use the OauthSessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.tokenUpdated=function(e,t){this.httpsServiceOauth.setToken(e,t)},t}(session_service_interface_1.SessionService);exports.OauthSessionService=OauthSessionService;
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 o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.OauthSessionService=exports.OauthStatus=exports.OauthLoginConfig=void 0;var session_service_interface_1=require("./session.service.interface"),https_service_interface_1=require("../http/https.service.interface"),OauthLoginConfig=function(e){function t(t){var r=e.call(this)||this;return Object.assign(r,t),r}return __extends(t,e),t}(session_service_interface_1.LoginConfig);exports.OauthLoginConfig=OauthLoginConfig;var OauthStatus=function(e){Object.assign(this,e)};exports.OauthStatus=OauthStatus;var OauthSessionService=function(e){function t(t){return e.call(this,t)||this}return __extends(t,e),t.prototype.onCreate=function(){this.httpsServiceOauth=this.serviceProvider.getService(https_service_interface_1.HttpsService)},t.prototype.login=function(e){throw new Error("In order to use the OauthSessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.refresh=function(){throw new Error("In order to use the OauthSessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.logout=function(e){throw new Error("In order to use the OauthSessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.tokenUpdated=function(e,t){this.httpsServiceOauth.setToken(e,t)},t}(session_service_interface_1.SessionService);exports.OauthSessionService=OauthSessionService;
@@ -17,6 +17,10 @@ export declare enum SESSION_STATUS_EVENT {
17
17
  */
18
18
  export declare class LoginConfig {
19
19
  }
20
+ export declare class LogoutConfig {
21
+ postLogoutRedirectUri?: string;
22
+ constructor(init?: Partial<LogoutConfig>);
23
+ }
20
24
  export interface SessionEventContext extends EventContext {
21
25
  languageUi?: string;
22
26
  }
@@ -62,7 +66,7 @@ export declare class SessionService extends BaseService {
62
66
  *
63
67
  * Method should be overridden by child-class
64
68
  */
65
- logout(): Observable<void>;
69
+ logout(config?: LogoutConfig): Observable<void>;
66
70
  /**
67
71
  * Returns an Observable that always emits an event when a session has just
68
72
  * started or ended.
@@ -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 i(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}}(),__decorate=this&&this.__decorate||function(e,r,t,i){var n,o=arguments.length,s=o<3?r:null===i?i=Object.getOwnPropertyDescriptor(r,t):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,r,t,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(r,t,s):n(r,t))||s);return o>3&&s&&Object.defineProperty(r,t,s),s},__awaiter=this&&this.__awaiter||function(e,r,t,i){return new(t||(t=Promise))((function(n,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,a)}c((i=i.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var t,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(t=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],i=0}finally{t=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var i,n=0,o=r.length;n<o;n++)!i&&n in r||(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return e.concat(i||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SessionService=exports.LoginConfig=exports.SESSION_STATUS_EVENT=void 0;var SESSION_STATUS_EVENT,rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),injection_identifier_1=require("../../decorators/injection-identifier"),base_service_1=require("../base.service"),organization_service_1=require("../organization.service"),log_1=require("../../models/log"),log_service_1=require("../log.service"),device_status_service_interface_1=require("../device-status.service.interface"),sdk_version_1=require("../../../gen/sdk-version"),error_1=require("../../models/error"),local_storage_service_interface_1=require("../local-storage.service.interface");!function(e){e[e.SESSION_STARTED=0]="SESSION_STARTED",e[e.SESSION_ENDED=1]="SESSION_ENDED"}(SESSION_STATUS_EVENT||(exports.SESSION_STATUS_EVENT=SESSION_STATUS_EVENT={}));var LoginConfig=function(){};exports.LoginConfig=LoginConfig;var SessionService=function(e){function r(r){var t=e.call(this,r)||this;return t.currentOrganization$=new rxjs_1.BehaviorSubject(void 0),t.servicesToInitDuringLogin=[],t.sessionStatus$=new rxjs_1.BehaviorSubject(null),t}return __extends(r,e),r.prototype.init=function(e){var r=this;return new rxjs_1.Observable((function(t){r.authenticationConfig=e.authenticationConfig,r.partiumConfig=e,t.next(),t.complete()}))},r.prototype.login=function(e){throw new Error("In order to use the SessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},r.prototype.logout=function(){throw new Error("In order to use the SessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},r.prototype.getSessionStatusEvents=function(){return this.sessionStatus$.asObservable()},r.prototype.getAuthConfig=function(){return this.authenticationConfig},r.prototype.setUser=function(e){this.user=e},r.prototype.getUser=function(){return this.user},r.prototype.useOrganization=function(e){return __awaiter(this,void 0,void 0,(function(){var r,t,i,n,o;return __generator(this,(function(s){switch(s.label){case 0:return[4,this.organizationService.getOrganizations()];case 1:for(r=s.sent(),t=this.getFlattenedOrganizations(r),i=0,n=t;i<n.length;i++)if((o=n[i]).partiumId===e||o.name===e)return this.currentOrganization$.next(o),this.localStorageService.setItem("lastUsedOrganizationId",o.partiumId,{organizationName:!1,userEmail:!1}),[2];throw new error_1.SdkError(error_1.SDK_ERROR_CODES.ORGANIZATION_NOT_FOUND,{organizationIdentifier:e},"Could not find organization with id/name ".concat(e))}}))}))},r.prototype.getCurrentOrganization$=function(){return this.currentOrganization$.asObservable()},r.prototype.registerLoginInitService=function(e,r){void 0===r&&(r=100),this.servicesToInitDuringLogin.push({service:e,priority:r})},r.prototype.sessionSetup=function(e){var r=this;this.organizationService=this.serviceProvider.getService(organization_service_1.OrganizationService),this.localStorageService=this.serviceProvider.getService(local_storage_service_interface_1.LocalStorageService);var t=this.serviceProvider.getService(log_service_1.LogServiceImpl),i=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService);return(0,rxjs_1.from)(Promise.all([this.localStorageService.getItem("lastUsedOrganizationId",{organizationName:!1,userEmail:!1}),this.organizationService.init().then((function(){return r.organizationService.getOrganizations()}))])).pipe((0,operators_1.mergeMap)((function(e){var t=e[0],i=e[1];if(t){var n=r.getFlattenedOrganizations(i).find((function(e){return e.partiumId===t}));if(n&&!n.requiresAdditionalAuthentication)return(0,rxjs_1.of)(n)}return(0,rxjs_1.from)(r.organizationService.getFirstOrganization())})),(0,operators_1.map)((function(e){return r.currentOrganization$.next(e),e})),(0,operators_1.mergeMap)((function(n){return r.initializeRegisteredServices().pipe((0,operators_1.mergeMap)((function(){return(0,rxjs_1.from)(i.getDeviceInfo()).pipe((0,operators_1.tap)((function(i){r.logUserSessionInfoEvent(i,t,n,e)})))})))})),(0,operators_1.map)((function(){r.sessionStatus$.next(SESSION_STATUS_EVENT.SESSION_STARTED)})),(0,operators_1.catchError)((function(e){return r.logout().subscribe(),(0,rxjs_1.throwError)(e)})))},r.prototype.logUserSessionInfoEvent=function(e,r,t,i){var n=this.getValidLanguageUiForEvent(t,null==i?void 0:i.languageUi),o={deviceId:e.deviceId,manufacturer:e.manufacturer,model:e.model,os:e.os,osVersion:e.osVersion,deviceType:e.deviceType,deviceLanguage:e.deviceLanguage,appVersionCode:e.appVersionCode,appVersionName:e.appVersionName,partiumSdkVersion:sdk_version_1.SDK_VERSION_NUMBER,languageUi:n,browserName:e.browserName,browserVersion:e.browserVersion,cpuArchitecture:e.cpuArchitecture,engineName:e.engineName,engineVersion:e.engineVersion};r.logEvent(new log_1.EventLog({organizationId:t.partiumId,version:log_1.EVENTLOG_VERSIONS.V_2_0_0,interface:(null==i?void 0:i.eventInterface)||log_1.INTERFACE.API_ACCESS,event:log_1.EVENT.USER_SESSION_INFO,data:o})).subscribe({next:function(){},error:function(e){console.error("Error while sending log event ".concat(log_1.EVENT.USER_SESSION_INFO,": "),e)}})},r.prototype.getValidLanguageUiForEvent=function(e,r){var t;if(r&&((null===(t=e.config)||void 0===t?void 0:t.availableUiLanguages)||["en"]).includes(r))return r;return null},r.prototype.sessionEnded=function(){this.sessionStatus$.next(SESSION_STATUS_EVENT.SESSION_ENDED)},r.prototype.initializeRegisteredServices=function(){for(var e=this,r=this.servicesToInitDuringLogin.sort((function(e,r){return e.priority-r.priority})),t=[],i=-1,n=0;n<r.length;n++){var o=r[n];o.priority===i?t[t.length-1].push(o.service):(i=o.priority,t.push([o.service]))}return rxjs_1.concat.apply(void 0,t.map((function(r){return(0,rxjs_1.forkJoin)(r.map((function(r){return r.init(e.partiumConfig,e.user.email,e.getCurrentOrganization$())})))}))).pipe((0,operators_1.last)())},r.prototype.getFlattenedOrganizations=function(e){return e.reduce((function(e,r){return __spreadArray(__spreadArray(__spreadArray([],e,!0),[r],!1),r.subOrgs||[],!0)}),[])},r=__decorate([(0,injection_identifier_1.InjectionIdentifier)("SessionService")],r)}(base_service_1.BaseService);exports.SessionService=SessionService;
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 i(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}}(),__decorate=this&&this.__decorate||function(e,r,t,i){var n,o=arguments.length,s=o<3?r:null===i?i=Object.getOwnPropertyDescriptor(r,t):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,r,t,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(r,t,s):n(r,t))||s);return o>3&&s&&Object.defineProperty(r,t,s),s},__awaiter=this&&this.__awaiter||function(e,r,t,i){return new(t||(t=Promise))((function(n,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,a)}c((i=i.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var t,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(t=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],i=0}finally{t=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var i,n=0,o=r.length;n<o;n++)!i&&n in r||(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return e.concat(i||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SessionService=exports.LogoutConfig=exports.LoginConfig=exports.SESSION_STATUS_EVENT=void 0;var SESSION_STATUS_EVENT,rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),injection_identifier_1=require("../../decorators/injection-identifier"),base_service_1=require("../base.service"),organization_service_1=require("../organization.service"),log_1=require("../../models/log"),log_service_1=require("../log.service"),device_status_service_interface_1=require("../device-status.service.interface"),sdk_version_1=require("../../../gen/sdk-version"),error_1=require("../../models/error"),local_storage_service_interface_1=require("../local-storage.service.interface");!function(e){e[e.SESSION_STARTED=0]="SESSION_STARTED",e[e.SESSION_ENDED=1]="SESSION_ENDED"}(SESSION_STATUS_EVENT||(exports.SESSION_STATUS_EVENT=SESSION_STATUS_EVENT={}));var LoginConfig=function(){};exports.LoginConfig=LoginConfig;var LogoutConfig=function(e){Object.assign(this,e)};exports.LogoutConfig=LogoutConfig;var SessionService=function(e){function r(r){var t=e.call(this,r)||this;return t.currentOrganization$=new rxjs_1.BehaviorSubject(void 0),t.servicesToInitDuringLogin=[],t.sessionStatus$=new rxjs_1.BehaviorSubject(null),t}return __extends(r,e),r.prototype.init=function(e){var r=this;return new rxjs_1.Observable((function(t){r.authenticationConfig=e.authenticationConfig,r.partiumConfig=e,t.next(),t.complete()}))},r.prototype.login=function(e){throw new Error("In order to use the SessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},r.prototype.logout=function(e){throw new Error("In order to use the SessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},r.prototype.getSessionStatusEvents=function(){return this.sessionStatus$.asObservable()},r.prototype.getAuthConfig=function(){return this.authenticationConfig},r.prototype.setUser=function(e){this.user=e},r.prototype.getUser=function(){return this.user},r.prototype.useOrganization=function(e){return __awaiter(this,void 0,void 0,(function(){var r,t,i,n,o;return __generator(this,(function(s){switch(s.label){case 0:return[4,this.organizationService.getOrganizations()];case 1:for(r=s.sent(),t=this.getFlattenedOrganizations(r),i=0,n=t;i<n.length;i++)if((o=n[i]).partiumId===e||o.name===e)return this.currentOrganization$.next(o),this.localStorageService.setItem("lastUsedOrganizationId",o.partiumId,{organizationName:!1,userEmail:!1}),[2];throw new error_1.SdkError(error_1.SDK_ERROR_CODES.ORGANIZATION_NOT_FOUND,{organizationIdentifier:e},"Could not find organization with id/name ".concat(e))}}))}))},r.prototype.getCurrentOrganization$=function(){return this.currentOrganization$.asObservable()},r.prototype.registerLoginInitService=function(e,r){void 0===r&&(r=100),this.servicesToInitDuringLogin.push({service:e,priority:r})},r.prototype.sessionSetup=function(e){var r=this;this.organizationService=this.serviceProvider.getService(organization_service_1.OrganizationService),this.localStorageService=this.serviceProvider.getService(local_storage_service_interface_1.LocalStorageService);var t=this.serviceProvider.getService(log_service_1.LogServiceImpl),i=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService);return(0,rxjs_1.from)(Promise.all([this.localStorageService.getItem("lastUsedOrganizationId",{organizationName:!1,userEmail:!1}),this.organizationService.init().then((function(){return r.organizationService.getOrganizations()}))])).pipe((0,operators_1.mergeMap)((function(e){var t=e[0],i=e[1];if(t){var n=r.getFlattenedOrganizations(i).find((function(e){return e.partiumId===t}));if(n&&!n.requiresAdditionalAuthentication)return(0,rxjs_1.of)(n)}return(0,rxjs_1.from)(r.organizationService.getFirstOrganization())})),(0,operators_1.map)((function(e){return r.currentOrganization$.next(e),e})),(0,operators_1.mergeMap)((function(n){return r.initializeRegisteredServices().pipe((0,operators_1.mergeMap)((function(){return(0,rxjs_1.from)(i.getDeviceInfo()).pipe((0,operators_1.tap)((function(i){r.logUserSessionInfoEvent(i,t,n,e)})))})))})),(0,operators_1.map)((function(){r.sessionStatus$.next(SESSION_STATUS_EVENT.SESSION_STARTED)})),(0,operators_1.catchError)((function(e){return r.logout().subscribe(),(0,rxjs_1.throwError)(e)})))},r.prototype.logUserSessionInfoEvent=function(e,r,t,i){var n=this.getValidLanguageUiForEvent(t,null==i?void 0:i.languageUi),o={deviceId:e.deviceId,manufacturer:e.manufacturer,model:e.model,os:e.os,osVersion:e.osVersion,deviceType:e.deviceType,deviceLanguage:e.deviceLanguage,appVersionCode:e.appVersionCode,appVersionName:e.appVersionName,partiumSdkVersion:sdk_version_1.SDK_VERSION_NUMBER,languageUi:n,browserName:e.browserName,browserVersion:e.browserVersion,cpuArchitecture:e.cpuArchitecture,engineName:e.engineName,engineVersion:e.engineVersion};r.logEvent(new log_1.EventLog({organizationId:t.partiumId,version:log_1.EVENTLOG_VERSIONS.V_2_0_0,interface:(null==i?void 0:i.eventInterface)||log_1.INTERFACE.API_ACCESS,event:log_1.EVENT.USER_SESSION_INFO,data:o})).subscribe({next:function(){},error:function(e){console.error("Error while sending log event ".concat(log_1.EVENT.USER_SESSION_INFO,": "),e)}})},r.prototype.getValidLanguageUiForEvent=function(e,r){var t;if(r&&((null===(t=e.config)||void 0===t?void 0:t.availableUiLanguages)||["en"]).includes(r))return r;return null},r.prototype.sessionEnded=function(){this.sessionStatus$.next(SESSION_STATUS_EVENT.SESSION_ENDED)},r.prototype.initializeRegisteredServices=function(){for(var e=this,r=this.servicesToInitDuringLogin.sort((function(e,r){return e.priority-r.priority})),t=[],i=-1,n=0;n<r.length;n++){var o=r[n];o.priority===i?t[t.length-1].push(o.service):(i=o.priority,t.push([o.service]))}return rxjs_1.concat.apply(void 0,t.map((function(r){return(0,rxjs_1.forkJoin)(r.map((function(r){return r.init(e.partiumConfig,e.user.email,e.getCurrentOrganization$())})))}))).pipe((0,operators_1.last)())},r.prototype.getFlattenedOrganizations=function(e){return e.reduce((function(e,r){return __spreadArray(__spreadArray(__spreadArray([],e,!0),[r],!1),r.subOrgs||[],!0)}),[])},r=__decorate([(0,injection_identifier_1.InjectionIdentifier)("SessionService")],r)}(base_service_1.BaseService);exports.SessionService=SessionService;
@@ -1,2 +1,2 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- export declare const SDK_VERSION_NUMBER = "15.10.0";
2
+ export declare const SDK_VERSION_NUMBER = "15.11.1";
@@ -1,2 +1,2 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.10.0";
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.11.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@partium/js-sdk",
3
- "version": "15.10.0",
3
+ "version": "15.11.1",
4
4
  "author": "Partium Inc.",
5
5
  "license": "See LICENSE.txt",
6
6
  "description": "The Partium Find SDK enables integration of Partium’s parts and materials search capabilities into JavaScript-based applications.",
@@ -5,6 +5,7 @@
5
5
  "outDir": "../.local-build/js-sdk",
6
6
  "rootDir": ".",
7
7
  "target": "es2020",
8
+ "inlineSources": true,
8
9
  // The long-running local SDK watcher relies on incremental project state in `.local-build`.
9
10
  "composite": true,
10
11
  "incremental": true,