npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@peyushx/campaign

v1.0.15

Published

A campaign module for enterprise

Downloads

1,087

Readme

@peyushx/campaign

The @peyushx/campaign library provides a campaign management module for enterprise applications. It includes support for encrypted data handling using AES encryption, allowing secure transmission and storage of sensitive campaign information.

Features

  • Campaign Management: Core services and components for managing campaigns.
  • AES Encryption: Securely encrypt and decrypt data using AES, with customizable encryption keys.
  • Interceptor Support: Automatically decrypt responses for specified URLs.

Installation

To install this library, you need to install the required peer dependencies: moment and crypto-js.

Run the following command:

npm install @peyushx/campaign moment crypto-js

Usage

1. Import the CampaignModule

To use the CampaignModule in your application, import it into your app’s module.

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CampaignModule } from '@peyushx/campaign';  // Import the CampaignModule
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, CampaignModule],  // Add CampaignModule here
  bootstrap: [AppComponent]
})
export class AppModule {}

2. Configure EncryptionService

The EncryptionService requires an encryption key that you can provide via dependency injection. This allows flexible configuration for different environments.

Example (app.module.ts):

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CampaignModule, EncryptionConfig } from '@peyushx/campaign';

@NgModule({
  imports: [BrowserModule, CampaignModule],
  providers: [
    {
      provide: 'ENCRYPTION_CONFIG',
      useValue: { secretKey: 'yourSecretKey' } as EncryptionConfig  // Provide your encryption key
    }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

3. Use EncryptionService in Your Components/Services

You can inject the EncryptionService and use its encryptData and decryptData methods.

import { Component } from '@angular/core';
import { EncryptionService } from '@peyushx/campaign';

@Component({
  selector: 'app-example',
  templateUrl: './example.component.html'
})
export class ExampleComponent {
  constructor(private encryptionService: EncryptionService) {}

  encryptExample() {
    const data = { message: 'Hello, World!' };
    const encryptedData = this.encryptionService.encryptData(data);
    console.log('Encrypted Data:', encryptedData);
  }

  decryptExample(encryptedData: string) {
    const decryptedData = this.encryptionService.decryptData(encryptedData);
    console.log('Decrypted Data:', decryptedData);
  }
}

4. Interceptor for Encrypted Responses

The module includes an HTTP interceptor (AuthInterceptor) that automatically decrypts responses from specific URLs. You can configure it by adding it to your app’s providers.

Example:

import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { AuthInterceptor } from '@peyushx/campaign';

@NgModule({
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
  ]
})
export class AppModule {}

The interceptor will automatically decrypt responses from the configured URLs (http://localhost:8080 and https://evolix-core.moglilabs.com by default).

API Documentation

EncryptionService

  • encryptData(data: Object): string

    • Encrypts the given object using AES.
    • Parameters: data (Object) – the data to be encrypted.
    • Returns: AES encrypted string.
  • decryptData(data: string): any

    • Decrypts the given AES encrypted string.
    • Parameters: data (string) – the encrypted data to decrypt.
    • Returns: Decrypted data.

Configuration Options

  • EncryptionConfig
    • secretKey: string – The secret key used for AES encryption/decryption. You must provide this in your module configuration.

Peer Dependencies

Ensure that the following peer dependencies are installed in your project:

  • moment: ^2.29.1
  • crypto-js: ^4.0.0

You can install them along with the library:

npm install @peyushx/campaign moment crypto-js

Development

To contribute or modify the module:

  1. Clone the repository.
  2. Run npm install to install the dependencies.
  3. Run ng build to build the library.
  4. To test the library locally, run npm link and use it in another Angular project.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Updates in package.json

Make sure that your package.json reflects moment and crypto-js as peer dependencies:

{
  "peerDependencies": {
    "@angular/common": "^14.2.0",
    "@angular/core": "^14.2.0",
    "moment": "^2.29.1",
    "crypto-js": "^4.0.0"
  },
  "dependencies": {
    "tslib": "^2.3.0"
  }
}

Feel free to open issues or submit pull requests on GitHub if you would like to contribute to this module.