CODEF easyCodef-node Client

1.0.4 · active · verified Tue Apr 21

The `easycodef-node` library, currently at version 1.0.4, serves as a utility for integrating Node.js applications with the CODEF API services. It abstracts away common complexities associated with API interactions, such as automatic handling of access token issuance and reuse (which are valid for one week), and provides functionalities for secure data exchange using RSA encryption. The library supports managing Connected IDs for end-user account authentication with various financial institutions (banks, cards, insurance, etc.), although this step is optional for APIs not requiring a Connected ID. While the release cadence appears to be low, indicating stability, the library is actively maintained with recent patch updates addressing bug fixes. Key differentiators include its comprehensive support for CODEF's authentication mechanisms and streamlined API request process, contrasting with direct API calls that would require manual token and encryption management. It ships with TypeScript types, facilitating development in typed environments.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize the EasyCodef client and explicitly request an access token from the CODEF API sandbox environment, setting necessary client information and the RSA public key for encryption.

import { EasyCodef, EasyCodefConstant, EasyCodefUtil } from 'easycodef-node';
import path from 'path'; // Needed for EasyCodefUtil.encodeToFileString example if used

// Placeholder for CODEF client credentials (replace with your actual keys).
// Obtain these from the CODEF website after signing up for demo/official service.
const DEMO_CLIENT_ID: string = process.env.CODEF_DEMO_CLIENT_ID ?? 'YOUR_DEMO_CLIENT_ID';
const DEMO_CLIENT_SECRET: string = process.env.CODEF_DEMO_CLIENT_SECRET ?? 'YOUR_DEMO_CLIENT_SECRET';
const CLIENT_ID: string = process.env.CODEF_CLIENT_ID ?? 'YOUR_CLIENT_ID';
const CLIENT_SECRET: string = process.env.CODEF_CLIENT_SECRET ?? 'YOUR_CLIENT_SECRET';

// Placeholder for CODEF RSA Public Key (required for encryption).
// Obtain this from the CODEF website (e.g., https://codef.io/#/account/keys).
const PUBLIC_KEY: string = process.env.CODEF_PUBLIC_KEY ?? 'YOUR_PUBLIC_KEY';

// 1. Create an EasyCodef instance.
const codef = new EasyCodef();

// 2. Set the RSA Public Key for encryption.
//    This is crucial for encrypting sensitive data sent to the CODEF API.
codef.setPublicKey(PUBLIC_KEY);

// 3. Set demo client information (for sandbox/demo environments).
codef.setClientInfoForDemo(DEMO_CLIENT_ID, DEMO_CLIENT_SECRET);

// 4. Set official client information (for production environment).
codef.setClientInfo(CLIENT_ID, CLIENT_SECRET);

// 5. Request an access token for the Sandbox environment.
//    Note: easycodef-node automatically handles token issuance and reuse for API calls,
//    so explicit token requests are usually only for specific scenarios or testing.
console.log('Requesting token for Sandbox...');
codef
  .requestToken(EasyCodefConstant.SERVICE_TYPE_SANDBOX)
  .then(function (response) {
    console.log('Token 발급 결과 (Sandbox):');
    console.log(response);
    // Expected response for Sandbox token request:
    // { data: { accessToken: "sandbox-access-token", ... } }
  })
  .catch(function (error) {
    console.error('Error requesting token:', error);
  });

view raw JSON →