{"id":16010,"library":"easycodef-node","title":"CODEF easyCodef-node Client","description":"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.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/codef-io/easycodef-node","tags":["javascript","CODEF","easyCodef","easyCodef-node","typescript"],"install":[{"cmd":"npm install easycodef-node","lang":"bash","label":"npm"},{"cmd":"yarn add easycodef-node","lang":"bash","label":"yarn"},{"cmd":"pnpm add easycodef-node","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primary class for interacting with the CODEF API. CommonJS `require` is a common anti-pattern in modern Node.js ESM projects.","wrong":"const EasyCodef = require('easycodef-node').EasyCodef;","symbol":"EasyCodef","correct":"import { EasyCodef } from 'easycodef-node';"},{"note":"Provides constants like `SERVICE_TYPE_SANDBOX`, `SERVICE_TYPE_DEMO`, `SERVICE_TYPE_API` for specifying the target environment.","wrong":"const EasyCodefConstant = require('easycodef-node').EasyCodefConstant;","symbol":"EasyCodefConstant","correct":"import { EasyCodefConstant } from 'easycodef-node';"},{"note":"Includes utility functions such as `encodeToFileString` for handling file data (e.g., certificates) and `encryptRSA` for manual RSA encryption.","wrong":"const EasyCodefUtil = require('easycodef-node').EasyCodefUtil;","symbol":"EasyCodefUtil","correct":"import { EasyCodefUtil } from 'easycodef-node';"}],"quickstart":{"code":"import { EasyCodef, EasyCodefConstant, EasyCodefUtil } from 'easycodef-node';\nimport path from 'path'; // Needed for EasyCodefUtil.encodeToFileString example if used\n\n// Placeholder for CODEF client credentials (replace with your actual keys).\n// Obtain these from the CODEF website after signing up for demo/official service.\nconst DEMO_CLIENT_ID: string = process.env.CODEF_DEMO_CLIENT_ID ?? 'YOUR_DEMO_CLIENT_ID';\nconst DEMO_CLIENT_SECRET: string = process.env.CODEF_DEMO_CLIENT_SECRET ?? 'YOUR_DEMO_CLIENT_SECRET';\nconst CLIENT_ID: string = process.env.CODEF_CLIENT_ID ?? 'YOUR_CLIENT_ID';\nconst CLIENT_SECRET: string = process.env.CODEF_CLIENT_SECRET ?? 'YOUR_CLIENT_SECRET';\n\n// Placeholder for CODEF RSA Public Key (required for encryption).\n// Obtain this from the CODEF website (e.g., https://codef.io/#/account/keys).\nconst PUBLIC_KEY: string = process.env.CODEF_PUBLIC_KEY ?? 'YOUR_PUBLIC_KEY';\n\n// 1. Create an EasyCodef instance.\nconst codef = new EasyCodef();\n\n// 2. Set the RSA Public Key for encryption.\n//    This is crucial for encrypting sensitive data sent to the CODEF API.\ncodef.setPublicKey(PUBLIC_KEY);\n\n// 3. Set demo client information (for sandbox/demo environments).\ncodef.setClientInfoForDemo(DEMO_CLIENT_ID, DEMO_CLIENT_SECRET);\n\n// 4. Set official client information (for production environment).\ncodef.setClientInfo(CLIENT_ID, CLIENT_SECRET);\n\n// 5. Request an access token for the Sandbox environment.\n//    Note: easycodef-node automatically handles token issuance and reuse for API calls,\n//    so explicit token requests are usually only for specific scenarios or testing.\nconsole.log('Requesting token for Sandbox...');\ncodef\n  .requestToken(EasyCodefConstant.SERVICE_TYPE_SANDBOX)\n  .then(function (response) {\n    console.log('Token 발급 결과 (Sandbox):');\n    console.log(response);\n    // Expected response for Sandbox token request:\n    // { data: { accessToken: \"sandbox-access-token\", ... } }\n  })\n  .catch(function (error) {\n    console.error('Error requesting token:', error);\n  });","lang":"typescript","description":"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."},"warnings":[{"fix":"Ensure `setClientInfoForDemo` and/or `setClientInfo` are called with valid credentials obtained from your CODEF account page. Use environment variables for sensitive data in production.","message":"Failing to set correct client credentials (Client ID, Client Secret) for the target environment (demo, official) will result in authentication failures when making API requests.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Obtain your RSA Public Key from the CODEF website and set it using `codef.setPublicKey(PUBLIC_KEY)`. Verify which API endpoints require encrypted parameters.","message":"The RSA Public Key must be set via `setPublicKey` if any API requests involve encrypting sensitive user data (e.g., account details, certificates). Failure to do so will lead to encryption errors or rejected requests for sensitive operations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Refer to the CODEF developer guide to determine if a specific API product requires a Connected ID. Only implement Connected ID management where explicitly necessary.","message":"Connected IDs are specific to end-user account management and are not required for all CODEF API products. Attempting to use or manage Connected IDs unnecessarily can add complexity to your integration.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Run `npm install easycodef-node` in your project directory. For TypeScript, ensure `moduleResolution` in `tsconfig.json` is set appropriately (e.g., `NodeNext` or `Bundler`).","cause":"The package has not been installed or there's a module resolution issue in your environment.","error":"Cannot find module 'easycodef-node' or its corresponding type declarations."},{"fix":"Double-check your client credentials against your CODEF account page. Ensure you are using the correct set of keys for the `SERVICE_TYPE` you are requesting (e.g., `DEMO_CLIENT_ID` for `SERVICE_TYPE_SANDBOX` or `SERVICE_TYPE_DEMO`).","cause":"The provided `CLIENT_ID` or `CLIENT_SECRET` for the requested service type (demo/official) is incorrect or not registered with CODEF.","error":"Error: Invalid client information."},{"fix":"Ensure you are creating an instance using `const codef = new EasyCodef();` and that `EasyCodef` is correctly imported from `easycodef-node`.","cause":"The `codef` object is not an instance of `EasyCodef` or the `EasyCodef` class was imported incorrectly.","error":"TypeError: codef.setPublicKey is not a function"},{"fix":"Provide a valid RSA public key string to `codef.setPublicKey(PUBLIC_KEY)` before making API calls that involve encryption.","cause":"You are attempting to perform an operation or send data that requires RSA encryption, but `codef.setPublicKey()` has not been called or was called with an invalid key.","error":"Error: Required public key not set for encryption."}],"ecosystem":"npm"}