
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
@xss-shared-library/https
Advanced tools
This library provides reusable HTTP services and utilities for Angular applications. It includes features like token-based authentication, URL configuration, and HTTP interceptors to streamline API communication.
This library provides reusable HTTP services and utilities for Angular applications. It includes features like token-based authentication, URL configuration, and HTTP interceptors to streamline API communication.
@xss-shared-library/uicomponent
and @xss-shared-library/translations
.To install the library, run the following command:
npm install @xss-shared-library/https
Add the XSSHttpServiceModule
to your Angular application's module:
import { XSSHttpServiceModule } from '@xss-shared-library/https';
@NgModule({
imports: [
XSSHttpServiceModule
]
})
export class AppModule { }
appsettings.json
To use this library, ensure you have an appsettings.json
file in the assets
folder of your Angular project. This file should include the necessary configuration for API URLs and token validation.
appsettings.json
:{
"App": {
"Api": "https://api.example.com",
"EnableTokenValidation": true
}
}
Api
: The base URL for your API.EnableTokenValidation
: Set to true
to enable token validation using the AuthService
.AuthService
The AuthService
provides methods for managing user authentication, such as checking tokens and logging out.
If EnableTokenValidation
is set to true
in appsettings.json
, you can use the AuthService
to validate the token. If the token is invalid, the system will automatically redirect to the /login
path.
import { AuthService } from '@xss-shared-library/https';
constructor(private authService: AuthService) {
this.authService.checkToken();
}
this.authService.logout();
BaseHttpClients
The BaseHttpClients
class provides reusable methods for making HTTP requests.
import { BaseHttpClients } from '@xss-shared-library/https';
constructor(private httpClient: BaseHttpClients) {
this.httpClient.getCheckToken().subscribe(response => {
console.log('Token is valid:', response);
});
}
this.httpClient.postLogOut().subscribe(response => {
console.log('Logged out successfully:', response);
});
Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.
This library is licensed under the MIT License. See the LICENSE
file for more details.
For more help with the Angular CLI, use ng help
or check out the Angular CLI Overview and Command Reference page.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.