pleno-dlp 0.0.0-stage → 0.71.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,20 @@
1
- # Temporary Holding Version
1
+ # @plenoai/pleno-dlp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Node.js bindings for [pleno-dlp](https://github.com/plenoai/pleno-dlp), a
4
+ secret and PII scanner. Scan buffers and files, verify a secret with its
5
+ provider, and revoke leaked credentials.
6
+
7
+ ```js
8
+ import { scanPaths } from '@plenoai/pleno-dlp';
9
+
10
+ for (const f of scanPaths('src')) {
11
+ console.log(f.detector, f.path, f.line, f.redacted);
12
+ }
13
+ ```
14
+
15
+ Scans are offline and findings are redacted unless you pass
16
+ `{ verify: true }` or `{ includeRaw: true }`. `revoke()` requires
17
+ `{ confirm: true }` or `{ dryRun: true }`.
18
+
19
+ See the [library documentation](https://github.com/plenoai/pleno-dlp/blob/main/docs/library.md)
20
+ for the full API, supported platforms, and stability policy.
package/index.cjs ADDED
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+ // Node.js bindings for pleno-dlp's stable embeddable API (docs/library.md).
3
+ // The bundled libpleno_dlp shared library is loaded through koffi; set
4
+ // PLENO_DLP_LIBRARY to load a library from another path.
5
+ const path = require('node:path');
6
+ const fs = require('node:fs');
7
+ const koffi = require('koffi');
8
+
9
+ class PlenoDLPError extends Error {
10
+ constructor(code, message) {
11
+ super(`${code}: ${message}`);
12
+ this.name = 'PlenoDLPError';
13
+ this.code = code;
14
+ }
15
+ }
16
+
17
+ function libraryPath() {
18
+ if (process.env.PLENO_DLP_LIBRARY) return process.env.PLENO_DLP_LIBRARY;
19
+ const file = { darwin: 'libpleno_dlp.dylib', win32: 'pleno_dlp.dll' }[process.platform] || 'libpleno_dlp.so';
20
+ return path.join(__dirname, 'lib', `${process.platform}-${process.arch}`, file);
21
+ }
22
+
23
+ let native;
24
+ function load() {
25
+ if (native) return native;
26
+ const p = libraryPath();
27
+ if (!fs.existsSync(p)) {
28
+ throw new Error(`pleno-dlp native library not found at ${p} (${process.platform}-${process.arch} may be unsupported)`);
29
+ }
30
+ const lib = koffi.load(p);
31
+ // Return void* so the Go-allocated string can be released with pleno_dlp_free.
32
+ native = {
33
+ version: lib.func('void *pleno_dlp_version()'),
34
+ detectors: lib.func('void *pleno_dlp_detectors()'),
35
+ scanBytes: lib.func('void *pleno_dlp_scan_bytes(const uint8_t *data, int64_t n, const char *opts)'),
36
+ scanPaths: lib.func('void *pleno_dlp_scan_paths(const char *paths, const char *opts)'),
37
+ verify: lib.func('void *pleno_dlp_verify(const char *detector, const char *secret)'),
38
+ revoke: lib.func('void *pleno_dlp_revoke(const char *detector, const char *secret, const char *opts)'),
39
+ free: lib.func('void pleno_dlp_free(void *p)'),
40
+ };
41
+ return native;
42
+ }
43
+
44
+ function call(fn, ...args) {
45
+ const n = load();
46
+ const ptr = n[fn](...args);
47
+ let raw;
48
+ try {
49
+ raw = koffi.decode(ptr, 'char', -1);
50
+ } finally {
51
+ n.free(ptr);
52
+ }
53
+ const env = JSON.parse(raw);
54
+ if (env.error) throw new PlenoDLPError(env.error.code, env.error.message);
55
+ return env.ok;
56
+ }
57
+
58
+ function scanOpts(o = {}) {
59
+ const out = { verify: !!o.verify, include_raw: !!o.includeRaw };
60
+ if (o.detectors && o.detectors.length) out.detectors = [...o.detectors];
61
+ if (o.concurrency) out.concurrency = o.concurrency;
62
+ if (o.maxFileSize) out.max_file_size = o.maxFileSize;
63
+ return JSON.stringify(out);
64
+ }
65
+
66
+ function apiVersion() {
67
+ return call('version');
68
+ }
69
+
70
+ function detectors() {
71
+ return call('detectors');
72
+ }
73
+
74
+ function scanBytes(data, options) {
75
+ const buf = typeof data === 'string' ? Buffer.from(data, 'utf8') : Buffer.from(data);
76
+ return call('scanBytes', buf, buf.length, scanOpts(options));
77
+ }
78
+
79
+ function scanPaths(paths, options) {
80
+ const list = Array.isArray(paths) ? paths.map(String) : [String(paths)];
81
+ return call('scanPaths', JSON.stringify(list), scanOpts(options));
82
+ }
83
+
84
+ function verify(detector, secret) {
85
+ return call('verify', detector, secret);
86
+ }
87
+
88
+ function revoke(detector, secret, options = {}) {
89
+ return call('revoke', detector, secret, JSON.stringify({ confirm: !!options.confirm, dry_run: !!options.dryRun }));
90
+ }
91
+
92
+ module.exports = { PlenoDLPError, apiVersion, detectors, scanBytes, scanPaths, verify, revoke };
package/index.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ export interface ScanOptions {
2
+ /** Send candidates to providers for verification. Default false (offline). */
3
+ verify?: boolean;
4
+ /** Populate Finding.raw / raw_v2 with the plaintext secret. Default false. */
5
+ includeRaw?: boolean;
6
+ /** Restrict to these detector names (see detectors()). */
7
+ detectors?: string[];
8
+ concurrency?: number;
9
+ /** scanPaths only: skip files larger than this many bytes. */
10
+ maxFileSize?: number;
11
+ }
12
+
13
+ export interface Finding {
14
+ detector: string;
15
+ verified: boolean;
16
+ verdict: 'verified' | 'unverified' | 'indeterminate' | string;
17
+ assurance?: string;
18
+ severity: string;
19
+ redacted: string;
20
+ raw?: string;
21
+ raw_v2?: string;
22
+ path?: string;
23
+ line?: number;
24
+ verify_error?: string;
25
+ extra_data?: Record<string, string>;
26
+ }
27
+
28
+ export interface VerifyResult { detector: string; verified: boolean; error?: string }
29
+ export interface RevokeResult { detector: string; revoked: boolean; dry_run?: boolean; revoked_at?: string; provider_id?: string; note?: string }
30
+ export interface Detector { name: string; keywords: string[]; can_verify: boolean; can_revoke: boolean }
31
+
32
+ export type ErrorCode = 'unknown_detector' | 'not_supported' | 'not_confirmed' | 'invalid_argument' | 'internal';
33
+ export class PlenoDLPError extends Error {
34
+ readonly code: ErrorCode;
35
+ }
36
+
37
+ export function apiVersion(): string;
38
+ export function detectors(): Detector[];
39
+ export function scanBytes(data: string | Uint8Array, options?: ScanOptions): Finding[];
40
+ export function scanPaths(paths: string | string[], options?: ScanOptions): Finding[];
41
+ export function verify(detector: string, secret: string): VerifyResult;
42
+ /** Irreversible. Exactly one of confirm / dryRun must be true. */
43
+ export function revoke(detector: string, secret: string, options: { confirm?: boolean; dryRun?: boolean }): RevokeResult;
package/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import m from './index.cjs';
2
+ export const { PlenoDLPError, apiVersion, detectors, scanBytes, scanPaths, verify, revoke } = m;
3
+ export default m;
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "pleno-dlp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.71.2",
4
+ "description": "Embeddable pleno-dlp secret scanner: scan, verify and revoke secrets from Node.js",
5
+ "license": "AGPL-3.0-only",
6
+ "homepage": "https://github.com/plenoai/pleno-dlp/blob/main/docs/library.md",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/plenoai/pleno-dlp.git",
10
+ "directory": "bindings/node"
11
+ },
12
+ "keywords": [
13
+ "secrets",
14
+ "dlp",
15
+ "secret-scanner",
16
+ "security"
17
+ ],
18
+ "engines": {
19
+ "node": ">=20"
20
+ },
21
+ "os": [
22
+ "linux",
23
+ "darwin",
24
+ "win32"
25
+ ],
26
+ "cpu": [
27
+ "x64",
28
+ "arm64"
29
+ ],
30
+ "main": "index.cjs",
31
+ "types": "index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./index.d.ts",
35
+ "import": "./index.mjs",
36
+ "require": "./index.cjs"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "index.cjs",
42
+ "index.mjs",
43
+ "index.d.ts",
44
+ "lib/",
45
+ "README.md"
46
+ ],
47
+ "scripts": {
48
+ "test": "node --test test/*.test.cjs"
49
+ },
50
+ "dependencies": {
51
+ "koffi": "2.14.1"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ }
56
+ }