
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
TypeScript SDK for the ADP Workforce API - mTLS OAuth authentication, async worker fetching, and employee data retrieval
TypeScript SDK for the ADP Workforce API. Handles mTLS OAuth authentication, async worker polling, and employee data retrieval.
Requires Node.js >= 18.
npm install adp-api
You need ADP API credentials before using this SDK:
.pem files and store them securely.Note: The
AdpClientconstructor reads the certificate and key files synchronously. Ensure the paths point to real files before constructing the client — placeholder paths will throw aCONFIG_ERROR.
import { AdpClient } from 'adp-api';
const client = new AdpClient({
certPath: './certs/adp-cert.pem',
keyPath: './certs/adp-key.pem',
clientId: process.env.ADP_CLIENT_ID!,
clientSecret: process.env.ADP_CLIENT_SECRET!,
});
// Fetch all workers (async polling)
const workers = await client.fetchAllWorkersAsync();
// Fetch a single worker
const worker = await client.fetchWorker('associate-oid');
// Fetch talent/competency data
const competencies = await client.fetchTalent('associate-oid');
// Fetch vacation balances
const balances = await client.fetchVacationBalances('associate-oid');
// Clean up credentials when done
client.destroy();
Pass config directly or use environment variables:
| Config Field | Env Var | Default |
|---|---|---|
certPath | ADP_CERT_PATH | required |
keyPath | ADP_KEY_PATH | required |
clientId | ADP_CLIENT_ID | required |
clientSecret | ADP_CLIENT_SECRET | required |
baseUrl | ADP_BASE_URL | https://api.adp.com |
tokenUrl | ADP_TOKEN_URL | https://accounts.adp.com/auth/oauth/v2/token?grant_type=client_credentials |
timeoutMs | — | 30000 |
rejectUnauthorized | — | true |
logger | — | null |
Constructor args take precedence over env vars.
const client = new AdpClient({
certPath: '/path/to/cert.pem',
keyPath: '/path/to/key.pem',
clientId: 'id',
clientSecret: 'secret',
rejectUnauthorized: false, // for self-signed CAs
logger: (msg) => console.log(msg),
});
AdpClientfetchAllWorkersAsync(options?) — Fetches all workers using ADP's async polling pattern (Prefer: respond-async). Options: { maxAttempts?: number } (default: 30). Returns Promise<AdpWorker[]>.fetchWorker(oid) — Fetches a single worker by associate OID with unmasked data. Returns Promise<AdpWorker | undefined>.fetchTalent(oid) — Fetches talent/competency data. Returns Promise<AdpCompetency[]>.fetchVacationBalances(oid) — Fetches vacation/time-off balances. Returns Promise<AdpVacationBalance[]>.refreshAuth() — Forces a token refresh. Useful after credential rotation or to proactively refresh before a burst of requests.getAuthStatus() — Returns { hasToken, consecutiveFailures, circuitBreakerOpen } for observability. Use in health checks to monitor auth state without triggering requests.destroy() — Zeros all cached credentials and tokens in memory. Call when shutting down to prevent sensitive data lingering in process memory.import { AdpAPIError } from 'adp-api';
try {
await client.fetchWorker('oid');
} catch (err) {
if (err instanceof AdpAPIError) {
console.log(err.code); // 'AUTH_FAILED', 'TIMEOUT', etc.
console.log(err.httpStatus); // 401, 500, etc.
console.log(err.endpoint); // '/hr/v2/workers/oid'
console.log(err.responseHeaders); // headers from the failed response
console.log(err.isRetryable()); // true for 5xx, timeout, network
console.log(err.isAuthError()); // true for 401/403
}
}
| Code | Meaning |
|---|---|
AUTH_FAILED | OAuth authentication or authorization failure (401/403) |
TOKEN_EXPIRED | Cached token expired and needs refresh |
CONFIG_ERROR | Configuration error — missing/unreadable cert, key, or invalid settings |
REQUEST_FAILED | Generic request failure (non-auth, non-timeout) |
TIMEOUT | Request timed out (ECONNABORTED) |
NETWORK_ERROR | Network-level failure (ECONNREFUSED, ENOTFOUND) |
SERVICE_UNAVAILABLE | Server error (5xx response) |
ASYNC_TIMEOUT | Async worker poll exceeded max attempts — try again or increase maxAttempts |
Both AdpClient and AdpAPIError are re-exported from the main 'adp-api' entry point for convenience. The subpath imports below are equivalent and useful for tree-shaking or importing only what you need:
import { AdpClient } from 'adp-api';
import type { AdpWorker, AdpCompetency, AdpVacationBalance, AdpClientConfig } from 'adp-api/types';
import { AdpAPIError } from 'adp-api/errors'; // same as: import { AdpAPIError } from 'adp-api'
import { findPrimaryWorkAssignment } from 'adp-api/utils';
import { API_PATHS, ERROR_CODES } from 'adp-api/config';
import { findPrimaryWorkAssignment } from 'adp-api/utils';
const worker = await client.fetchWorker('associate-oid');
if (worker) {
const primary = findPrimaryWorkAssignment(worker.workAssignments);
console.log(primary?.jobTitle);
}
respond-async pattern: initial request triggers processing, then polls the Link header URL until results are ready (up to 30 attempts)AdpClient instance — The client manages a single token lifecycle with built-in deduplication and caching. Creating multiple instances against the same credentials wastes token requests and bypasses the circuit breaker. Share one instance across your application.FAQs
TypeScript SDK for the ADP Workforce API - mTLS OAuth authentication, async worker fetching, and employee data retrieval
We found that adp-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.