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

@affinidi/affinidi-uaf-service-lib

v1.6.0

Published

UAF Banner integration package for third party vendors [Backend integration]

Downloads

11

Readme

Affinidi UAF Service Lib [ Backend Integration ]

Affinidi UAF Service library helps to validate and sent the data to affinidi UAF application.

Installation

npm i @affinidi/affinidi-uaf-service-lib  --save

import the file into the application where the data sent to affinidi applcation.

Example for typescript for importing the library.

import { UafServiceIntegration } from '@affinidi/affinidi-uaf-service-lib/dist'
// SDK initialization
const uafService = new UafServiceIntegration()

You should have 2 environemnt variables before proceeding further. it has to be added in the env file

AFFINIDI_UAF_BASEURL=<base url given by affinidi>
AFFINIDI_UAF_PREFILL_ENDPOINT=<API end point given by affinidi>

Example for javascript for importing the library.

var uafLib = require('@affinidi/affinidi-uaf-service-lib/dist')
// SDK initialization
const uafService = new uafLib.UafServiceIntegration()

There is 3 functionalites/steps to helps to sent the data to UAF applcation.

1. validateLoanDataSchemaFormat  -> validate the data schema provided by vendor.
2. validatePublicKeyExistOnPath  -> validate the public key exist on the abosolute path provided by developer.
3. prefillUserData               -> It will sent the data to the affinidi.

UserData Object format should be like below.

{
  uuid?: string // should have the value, we will be checking the value is there or not.
  // UUID can be unique indetifier for the third party.
  affinidiPartnerId?: string
  userContactInformation?: {
    name?: string
    personalEmailAddress?: string
    mobile?: string
  }
  userProfileInformation: {
    dob?: string
    gender?: string
    panNumber?: string
    nameAsInPan?: string
    pfUAN?: string
    aadharNumber?: string
    nameAsInAadhar?: string
    mothersName?: string
    fatherOrSpouseName?: string
    relationshipStatus?: string
    education?: { fileInput?: string; qualification?: string; filePassword?: string }
    currentAddress?: {
      addressLine1?: string
      addressLine2?: string
      pincode?: string
      city?: string
      state?: string
      country?: string
      permanentAddress?: boolean
      fileInput?: string
      filePassword?: string
    }
    permanentAddress?: {
      addressLine1?: string
      addressLine2?: string
      pincode?: string
      city?: string
      state?: string
      country?: string
      fileInput?: string
      filePassword?: string
    }
    bankAccounts?: {
      ifsc?: string
      accountNumber?: string
    }

    cibilScore?: number
  }
  employment: {
    employmentType?: string
    workStatus?: string
    employerName?: string
    employerType?: string
    employeeId?: string
    currentExperience?: string
    noticePeriod?: string
    totalEmiAmount?: string
    currentlyWorking?: string
    designation?: string
    joiningDate?: string
    industry?: string
    jobSector?: string
    supervisorDetails?: {
      name?: string
      phoneNumber?: string
      emailId?: string
    }
    epfo?: string
    monthlySalary?: string
    salaryDocuments?: { files?: SalaryFiles[] }
    salaryMode?: string
    salarySlipDocumentUri?: string
    servingNoticePeriod?: string
    lastWorkingDate?: string
    tenureInMonths?: number
    totalWorkExperienceInMonths?: string
    workEmailAddress?: string
    workAddress?: {
      addressLine1?: string
      addressLine2?: string
      pincode?: string
      city?: string
      state?: string
      country?: string
    }
  }
}

Salary File Object Format

SalaryFiles {
  fileType?: string
  fileInput?: string
  filePassword?: string
}

Success and Error Response for the each functionality.

  1. validateLoanDataSchemaFormat

    // Success
    { success: true, DataValidationErros: [] }
    // Error
    [
      { key: 'Joining Date', error: 'please enter date in DD/MM/YYYY format' },
      { key: 'Pincode', error: 'please give valid 6 digit pincode' },
      { key: 'Salary mode', error: 'salary mode should be cash or bank' },
      { key: 'Monthly salary', error: 'please give valid salary in integer' },
    ]
  2. validatePublicKeyExistOnPath

    // In case the file exists at the given path
    Response: {
      success: true
    }
    // or, else
    Error: {
      error: 'File not found / Directory does not exists'
    }
  3. prefillUserData

    // in case we get success
    { success: true, DataValidationErros: [] }
    
    // in case of error
    {
     success: false,
     DataValidationErros: [
       { key: 'Joining Date', error: 'please enter date in DD/MM/YYYY format' },
       { key: 'Pincode', error: 'please give valid 6 digit pincode' },
       { key: 'Salary mode', error: 'salary mode should be cash or bank' },
       { key: 'Monthly salary', error: 'please give valid salary in integer' },
     ]
    }

Example [typescript]

/*
 * usersData -> user data from thrid party vendor and it must be the format which is given by affinidi.
 * sessiontoken -> session token would be the end user token which is generated by UAF while end user joureny.
 * apiKey -> issuer API key which is given by affinidi.
 * store the affinidi public key in any of the folder and get the absolute path.
 */

// SDK initialization
const uafService = new UafServiceIntegration()

// step 1:  needed to check the user date schema format by using SDK
const validateUserData = await uafService.validateLoanDataSchemaFormat(usersData)
if (validateUserData && validateUserData.success === false) {
  throw new OperationError('UBSB-2', { message: 'user data validation error' })
}

// step 2: needed to check the public key path exist by using SDK
const pathArray = __dirname.split('/')
pathArray.splice(-2)
const currentPath = pathArray.join('/')
const publicKeyAbsolutePath = `${currentPath}/secrets/affinidi.public.txt`
await uafService.validatePublicKeyExistOnPath(publicKeyAbsolutePath)

// step 3: sent the data to affinidi by using SDK
const prefillData = await uafService.prefillUserData({
  endUserSessionToken: sessiontoken,
  issuerApiKey: apiKey,
  usersData: usersData,
  publicKeyPath: publicKeyAbsolutePath,
})

Frameworks and tools

  1. Typescript
  2. Express for REST APIs
  3. tsoa for OpenAPI spec generation
  4. dotenv for .env file configuration
  5. pino for logging
  6. ESLint for code analysis
  7. husky for git hooks
  8. jest for testing