New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@proffix/restapi-angular-library

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@proffix/restapi-angular-library

Programmbibliothek für die einfache Verwendung der PROFFIX REST API in Angular Applikationen

latest
Source
npmnpm
Version
3.0.2
Version published
Maintainers
1
Created
Source

PROFFIX REST API Library für Angular

Die PROFFIX REST API Library für Angular ermöglicht die einfache Kommunikation mit der PROFFIX REST API in Angular- Anwendungen. Die Library ist unabhängig von der grafischen Oberfläche und kann mit Ionic oder anderen Frameworks verwendet werden.

Erste Schritte

Ein lauffähiges Angular-Projekt muss vorhanden sein. Über die Angular CLI lässt sich das einfach erstellen.

1. Library im Projekt installieren

Die Library ist über npm verfügbar: npm install @proffix/restapi-angular-library --save

2. Konfiguration und Bootstrapping

Es muss eine von Configuration vererbte Klasse erstellt werden, in der die beiden abstrakten Methoden requiredWebserviceVersion und requiredLicencedModules überschrieben werden müssen.

import { Injectable } from '@angular/core';
import { PxConfiguration, PxModule, PxVersion } from '@proffix/restapi-angular-library';

@Injectable()
export class AppConfiguration extends PxConfiguration {
  public get requiredWebserviceVersion(): PxVersion {
    return { Major: 2, Minor: 7, Patch: 1 };
  }
  public get requiredLicencedModules(): string[] {
    return [ "ZEI", "ADR" ];
  }
}

Die AppConfiguration muss Injectable sein, da sie dem dem Dependency Injector als Configuration für die Library mitgegeben werden muss. Zusätzliche wird das PxRestApiModule geladen und über PxRestApiModule.forRoot() importiert.

// Root Module (src/app.module.ts)

import { PxRestApiModule, PxConfiguration } from '@proffix/restapi-angular-library';

// ...
imports: [ PxRestApiModule.forRoot() ],
providers: [
  AppConfiguration,
  { provide: PxConfiguration, useExisting: AppConfiguration }
],
// ...

3. Verbindungseinstellungen hinterlegen

Die Verbindungseinstellungen (Klasse ConnectionSettings) werden durch den ConnectionSettingsService im LocalStorage abgelegt.

// Angular Component

import { PxConnectionSettings, PxConnectionSettingsService } from '@proffix/restapi-angular-library';

// ...
constructor(private connectionSettingsService: PxConnectionSettingsService) {
  let connectionSettings: PxConnectionSettings =  {
    WebserviceUrl: "https://restapi.company.invalid",
    WebservicePasswortHash: "d3612ab62..."
  };
  connectionSettingsService.save(connectionSettings);
}

Hinweis: Der SHA256 kann über die statische Methode Hash.sha256 erstellt werden, nachdem die Klasse Hash importiert wurde.

4. Login durchführen

Der Login kann durchgeführt werden, wenn gültige Verbindungseinstellungen hinterlegt wurden.

// Angular Component

import { PxLogin, PxLoginService, PxConfiguration } from '@proffix/restapi-angular-library';

// ...
constructor(private loginService: PxLoginService, private configuration: PxConfiguration) {
  let login: PxLogin =  {
    Benutzer: "pxuser",
    Passwort: "d3612ab62...",
    Datenbank: { Name: "PXDB" },
    Module: this.configuration.getRequiredLicencedModulesAsStringArray() // Die Module können aus der AppConfiguration gelesen werden
  };
  this.loginService.doLogin(login).subscribe( // nur zu Anschauungszwecken, nie HTTP-Requests in einem Konstruktor absetzen
      login => console.log("Login successful: " + login.Benutzer),
      error => console.log("Login failed")
    );
}

FAQs

Package last updated on 25 Apr 2019

Did you know?

Socket

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.

Install

Related posts