Socket
Socket
Sign inDemoInstall

syshub-rest-module

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syshub-rest-module - npm Package Compare versions

Comparing version 5.0.2 to 5.1.0

6

lib/session.d.ts

@@ -10,2 +10,3 @@ import { Observable } from "rxjs";

refreshIsDue: Observable<boolean>;
private storageLocation;
private token$;

@@ -41,4 +42,5 @@ token: Observable<string>;

* @param token A Token object.
* @param keepLoggedin A boolean which defines storage location and persistence of the session (true = localStorage = permanent, false = sessionStorag = until browser window closed)
*/
setToken(token: Token): void;
setToken(token: Token, keepLoggedin?: boolean): void;
/**

@@ -52,3 +54,3 @@ * Checks the token and if valid call the refresh Methods.

clearToken(): void;
setToken(token: Token): void;
setToken(token: Token, keepLoggedin: boolean): void;
};

@@ -55,0 +57,0 @@ export type Token = {

@@ -132,3 +132,3 @@ export declare class Settings {

* **options.useEtags**: If true, the Rest service uses the etag-based cache mechanism from sysHUB server. If entities have not been changed, response will be HTTP status 304/Not modified with content = `null`.
* As the `Etag` header is not announced correct prior to 2024 it may or may not work. Statring with 2024 it will work.
* As the `Etag` header is not announced correct prior to 2024 it may or may not work.
* Default: *true*

@@ -135,0 +135,0 @@ */

@@ -13,2 +13,8 @@ import { HttpClient, HttpErrorResponse, HttpStatusCode } from '@angular/common/http';

isLoggedIn: Observable<boolean>;
/**
* track the current refreshing state. While the module is renewing the OAuth token
* this will be true and all request will be postponed.
*/
private isRefreshing$;
private isRefreshing;
private token$;

@@ -461,4 +467,3 @@ token: Observable<string>;

* In case of an arror in get(), post(), patch(), etc... this method creates the
* subject error status that is returned to the caller. In case of a 401/Unauthorized
* error, it forces a token refresh. If this failes, the user will be logged out.
* subject error status that is returned to the caller.
* @param subject The subject to be set with the error.

@@ -505,6 +510,7 @@ * @param e The error response from the call to the server.

* @param password A string containing the users password.
* @param [keepLoggedin=true] A boolean indicating whether the session is permanent.
* @returns A subscribable subject that contains the status of the login process. It starts with null, and changes to
* true on success or an HttpErrorResponse in case of any error.
*/
login(username: string, password: string): BehaviorSubject<boolean | null | HttpErrorResponse>;
login(username: string, password: string, keepLoggedin?: boolean): BehaviorSubject<boolean | null | HttpErrorResponse>;
/**

@@ -598,3 +604,2 @@ * Method to clear the users login session.

putc(endpoint: string, payload: any, acceptHeader?: string[]): Observable<Response>;
private isRefreshing;
/**

@@ -601,0 +606,0 @@ * Private method which handles the automatic refresh of a session.

{
"name": "syshub-rest-module",
"version": "5.0.2",
"version": "5.1.0",
"description": "This package provides a generic library for the communication from an Angular SPA with a NT-Ware uniFLOW sysHUB backend server based on HTTPS Rest API with OAuth2 flow.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -90,3 +90,3 @@ [![Node.js CI](https://github.com/surcoufx83/syshub-rest-module/actions/workflows/node.js.yml/badge.svg)](https://github.com/surcoufx83/syshub-rest-module/actions/workflows/node.js.yml)

Below is a code example demonstrating how to configure the REST module for a sysHUB server version 2021:
Below is a code example demonstrating how to configure the REST module for a sysHUB server version 2023:

@@ -103,3 +103,3 @@ ```ts

host: "/",
version: SyshubVersion.sysHUB_2021,
version: SyshubVersion.sysHUB_2023,
basic: {

@@ -187,2 +187,14 @@ enabled: true,

#### Temporary sessions
In this example, temporary sessions are utilized to store user login data. By setting the third parameter of the `login()` method to `false`, the user credentials are stored in the sessionStorage instead of the localStorage of the browser.
```typescript
this.restService.login(this.username, this.password, false).subscribe((response) => {
// your code goes here
});
```
Sessions stored in the sessionStorage are automatically cleared when the browser is closed, providing a secure and temporary means of storing user authentication data.
### Check login state before sending request

@@ -234,2 +246,8 @@

#### Renewal of OAuth2 tokens
There may be a short period of half a second or less where requests are deferred to the Rest API to refresh the token and store it in the browser cache. The calling function will not notice this as the subscription will not be updated while waiting for the renewal method to complete. This happens automatically and is not configurable.
If the module did not defer the requests, it can happen that a request uses an old access token that has already been changed in the backend but has not yet been updated in the browser. This then leads to a 403/Forbidden status.
### Calling Rest API endpoints

@@ -236,0 +254,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc