Options
All
  • Public
  • Public/Protected
  • All
Menu

CX Cloud Core Services

A collection of tools to work with 3rd Party and Partner services & networks. This module is meant to be used in creating commerce services.

An example of implementation can be found in CX API Accelerator.

Installation and Usage

npm install @cxcloud/core
import { Commerce, Content } from '@cxcloud/core';
import { Cart } from '@cxcloud/core/dist/commerce';

Included Bundles

  • Commerce (Powered by CommerceTools)
    • Products
    • Categories
    • Shipping
    • Carts
    • Orders
    • Customers
    • Authentication
  • Content (Powered by Contentful)
    • Entry
    • Entries
    • Space Info
  • Search (Powered by Algolia)
  • Authentication (Powered by AWS Cognito)
    • Login (Normal, MFA)
    • Registration
    • Edit Profile and Phone Number
    • Session Update
    • Password Forgot, Reset, Change
    • Get Profile

Documentation

An automatically generated documentation can be found here.

Config Schema

Using this module requires configuration. You can do so by installing node-config in your project and setting up the following keys one of your json files:

{
  "commerceTools": {
    "projectKey": "PROJECT_KEY",
    "admin": {
      "clientId": "ADMIN_CLIENT_ID",
      "clientSecret": "ADMIN_CLIENT_ID"
    },
    "user": {
      "clientId": "USER_FACING_CLIENT_ID",
      "clientSecret": "USER_FACING_CLIENT_SECRET"
    }
  },
  "contentful": {
    "sdkConfig": {
      "space": "SPACE_ID",
      "accessToken": "ACCESS_TOKEN"
    }
  },
  "algolia": {
    "applicationId": "APP_ID",
    "apiKey": "API_KEY"
  },
  "cognito": {
    "userPoolId": "USER_POOL_ID",
    "clientId": "CLIENT_ID"
  }
}

License

This project is licensed under The GPL v2 and is released merely for educational and internal purposes. The modules are not useful independently and require paid licenses from the vendors mentioned above.

Index

Type aliases

IntrospectionResponse

IntrospectionResponse: object

Type declaration

  • expiresIn: number
  • tokenScopes: string

Status

Status: "SUCCESS"

Task

Task: object

Type declaration

  • isFetching: boolean
  • tasks: any[]

TaskQueue

TaskQueue: object

Type declaration

  • [id: string]: Task

Variables

Const CognitoUserPoolWrapper

CognitoUserPoolWrapper: any = require('cognito-user-pool')

Const Commerce

Commerce: "/Users/sallar/Projects/cxcloud/cxcloud-facade/src/commerce/index" = commerceServices

Const ENCRYPTION_KEY

ENCRYPTION_KEY: "wY[Ax)FC0AlQjruD$9J_tO3U+YiMZyL1" = "wY[Ax)FC0AlQjruD$9J_tO3U+YiMZyL1"

Const IV_LENGTH

IV_LENGTH: 16 = 16

Const TEXT_SEPARATOR

TEXT_SEPARATOR: ":" = ":"

Let __client

__client: any

Let __services

__services: any

createAuthMiddlewareForClientCredentialsFlow

createAuthMiddlewareForClientCredentialsFlow: any

createClient

createClient: any

createHttpMiddleware

createHttpMiddleware: any

createLoggerMiddleware

createLoggerMiddleware: any

createQueueMiddleware

createQueueMiddleware: any

createRequestBuilder

createRequestBuilder: any

createUserAgentMiddleware

createUserAgentMiddleware: any

Const customerCache

customerCache: NodeCache = new Cache({stdTTL: 60 * 15 // 15 mins})

features

features: any

Const packageInfo

packageInfo: any = require('../../../package.json')

Const userScopes

userScopes: string[] = ['manage_my_orders','manage_my_profile','manage_my_shopping_lists','view_products','manage_my_profile','manage_my_payments']

Functions

authenticatedFormRequest

  • authenticatedFormRequest<T>(requestOptions: any, user?: boolean): Promise<T>
  • Type parameters

    • T

    Parameters

    • requestOptions: any
    • Default value user: boolean = false

    Returns Promise<T>

Const calculateExpirationTime

  • calculateExpirationTime(expiresIn: number): number

clientExecute

  • clientExecute<T>(request: ClientRequest): Promise<T>

clientProcess

  • clientProcess<T>(request: ClientRequest): Promise<T>

cognitoAttrsToHash

Const createAuthMiddlewareForIntrospectionFlow

  • createAuthMiddlewareForIntrospectionFlow(options: SdkConfig): (Anonymous function)

createClientRequest

  • createClientRequest(request: ClientRequest): ClientRequest

decrypt

  • decrypt(text: string): string

encrypt

  • encrypt(text: string): string

encryptTokenResponse

  • encryptTokenResponse(token: OAuthToken, customerId: string, isAnonymous?: boolean): OAuthToken
  • Parameters

    • token: OAuthToken
    • customerId: string
    • Default value isAnonymous: boolean = false

    Returns OAuthToken

findCustomerById

  • findCustomerById(customerId: string): Promise<Customer>

getAnonymousIdFromToken

  • getAnonymousIdFromToken(token?: undefined | string): string | null
  • Parameters

    • Optional token: undefined | string

    Returns string | null

getClient

  • getClient(): any

getConfig

  • getConfig(): object
  • Returns object

    • admin: ClientCredentials
    • apiHost: string
    • authHost: string
    • projectKey: string
    • user: ClientCredentials
    • verbose: boolean

getCustomerBillingAddress

  • getCustomerBillingAddress(customer: Customer): Address | undefined

getCustomerCurrency

  • getCustomerCurrency(customer: Customer): string

getCustomerShippingAddress

  • getCustomerShippingAddress(customer: Customer): Address | undefined

getDefaults

  • getDefaults(options: QueryOptions): QueryOptions
  • Parameters

    • options: QueryOptions

    Returns QueryOptions

getServices

  • getServices(): any

getTokenData

  • getTokenData(encryptedToken: string): EncryptedTokenData
  • Parameters

    • encryptedToken: string

    Returns EncryptedTokenData

hashToCognitoAttrs

Const mergeAuthHeader

  • mergeAuthHeader(token: string, req: any): any

nestify

  • nestify(categories: Category[]): Category[]

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc