@pulse-si/core 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +68 -2
- package/dist/config.d.ts +19 -0
- package/dist/config.js +82 -0
- package/dist/config.js.map +1 -0
- package/dist/detect.d.ts +3 -0
- package/dist/detect.js +128 -0
- package/dist/detect.js.map +1 -0
- package/dist/hpke.d.ts +25 -0
- package/dist/hpke.js +123 -0
- package/dist/hpke.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/log-shipper.d.ts +25 -0
- package/dist/log-shipper.js +100 -0
- package/dist/log-shipper.js.map +1 -0
- package/dist/logs.d.ts +21 -0
- package/dist/logs.js +147 -0
- package/dist/logs.js.map +1 -0
- package/dist/pinned-fetch.d.ts +2 -0
- package/dist/pinned-fetch.js +55 -0
- package/dist/pinned-fetch.js.map +1 -0
- package/dist/probes.d.ts +4 -0
- package/dist/probes.js +45 -0
- package/dist/probes.js.map +1 -0
- package/dist/reporter.d.ts +49 -0
- package/dist/reporter.js +200 -0
- package/dist/reporter.js.map +1 -0
- package/dist/sanitize.d.ts +2 -0
- package/dist/sanitize.js +22 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/seal.d.ts +13 -0
- package/dist/seal.js +40 -0
- package/dist/seal.js.map +1 -0
- package/dist/secure-report.d.ts +59 -0
- package/dist/secure-report.js +34 -0
- package/dist/secure-report.js.map +1 -0
- package/dist/selection.d.ts +10 -0
- package/dist/selection.js +38 -0
- package/dist/selection.js.map +1 -0
- package/dist/transport.d.ts +2 -0
- package/dist/transport.js +17 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/versions.d.ts +2 -0
- package/dist/versions.js +36 -0
- package/dist/versions.js.map +1 -0
- package/package.json +38 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Charles Désiré Bally
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pulse-si/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Le cœur commun de [`@pulse-si/nest`](https://www.npmjs.com/package/@pulse-si/nest) et [`@pulse-si/next`](https://www.npmjs.com/package/@pulse-si/next). Tu n'as normalement pas à l'installer toi-même : c'est lui qui parle à l'API [Pulse](https://pulse-app.si), et cette page sert surtout à qui veut savoir exactement ce qui sort de son app.
|
|
4
|
+
|
|
5
|
+
## Ce qu'il fait
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌──────────────────────────── pulse-core ───────────────────────────┐
|
|
9
|
+
tes clients ──▶ │ detect reconnaît Prisma, TypeORM, Mongoose, Redis, BullMQ, crons │
|
|
10
|
+
(Prisma…) │ probes SELECT 1 / PING, 5 s au plus, erreurs nettoyées │
|
|
11
|
+
│ selection PULSE_SEND, PULSE_INCLUDE, PULSE_EXCLUDE │
|
|
12
|
+
stdout/stderr ▶ │ logs recopie, niveau, contexte, secrets masqués │
|
|
13
|
+
│ seal HPKE (RFC 9180) si PULSE_PUBLIC_KEY │──▶ api.pulse-app.si
|
|
14
|
+
│ reporter rythme dicté par l'API, accéléré en direct │ (HTTPS seulement)
|
|
15
|
+
└────────────────────────────────────────────────────────────────────┘
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- **Aucune dépendance** : la bibliothèque standard de Node 18 et plus (`fetch`, `crypto`), rien d'autre à auditer.
|
|
19
|
+
- **Ne lève jamais** : une panne de Pulse ne doit pas faire tomber l'app surveillée.
|
|
20
|
+
- **Rien de métier** : l'état des dépendances, les passages des tâches, les versions, et les journaux si tu les envoies.
|
|
21
|
+
|
|
22
|
+
## Ce qui part, mot pour mot
|
|
23
|
+
|
|
24
|
+
Un rapport, toutes les 30 secondes en Pro (le rythme vient de l'API) :
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"packageName": "pulse-nest",
|
|
29
|
+
"packageVersion": "0.1.0",
|
|
30
|
+
"framework": "nestjs",
|
|
31
|
+
"frameworkVersion": "11.2.7",
|
|
32
|
+
"appVersion": "2.3.0",
|
|
33
|
+
"deployedAt": "2026-10-20T08:00:00.000Z",
|
|
34
|
+
"checks": [{ "name": "PostgreSQL", "kind": "database", "ok": true, "latencyMs": 4 }],
|
|
35
|
+
"crons": [{ "name": "relance-abonnements", "schedule": "0 * * * *", "lastRunOk": false, "error": "ETIMEDOUT" }]
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Un lot de journaux, toutes les 10 secondes (chaque seconde quand quelqu'un regarde) :
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{ "entries": [{ "at": "2026-10-20T12:12:56.000Z", "level": "ERROR", "context": "PaymentsService", "message": "Paiement refusé token=***" }] }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
En mode sécurisé, chacun devient `{ "sealed": { "v": 1, "kid", "enc", "ct" }, "clear": { … } }` où `clear` ne contient que ce que tu as choisi de laisser lisible.
|
|
46
|
+
|
|
47
|
+
## Nettoyage
|
|
48
|
+
|
|
49
|
+
Avant de partir, chaque message passe par le même filtre :
|
|
50
|
+
|
|
51
|
+
| Ce qui est trouvé | Ce qui part |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `postgres://user:motdepasse@db:5432/app` | `postgres://***@db:5432/app` |
|
|
54
|
+
| `password=…`, `secret=…`, `token=…`, `key=…` | `password=***` |
|
|
55
|
+
| `Bearer eyJhbGciOi…`, `Basic dXNlcjpw…` | `Bearer ***` |
|
|
56
|
+
| `pk_live_…`, `pk_agent_…` | `pk_live_***` |
|
|
57
|
+
| paramètres d'URL dans une erreur | retirés |
|
|
58
|
+
|
|
59
|
+
Les erreurs sont coupées à 300 caractères, les lignes de journal à 4 000.
|
|
60
|
+
|
|
61
|
+
## Chiffrement
|
|
62
|
+
|
|
63
|
+
- HPKE en mode de base (RFC 9180) : `DHKEM(X25519, HKDF-SHA256)`, `HKDF-SHA256`, `AES-256-GCM`, la suite que CryptoKit sait ouvrir sur iPhone et Mac.
|
|
64
|
+
- `info` = `pulse/v1`, données authentifiées = `pulse/<report|logs>/<empreinte>` : un rapport ne peut pas passer pour un lot de journaux.
|
|
65
|
+
- Une clé éphémère neuve par message. Vérifié contre les vecteurs officiels de la RFC (annexe A.1) et contre une implémentation indépendante.
|
|
66
|
+
|
|
67
|
+
## Licence
|
|
68
|
+
|
|
69
|
+
MIT
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Selection } from './selection';
|
|
2
|
+
import { type ClearField, type PulseLogger, type PulseOptions } from './types';
|
|
3
|
+
export declare const DEFAULT_ENDPOINT = "https://api.pulse-app.si";
|
|
4
|
+
export type PulseConfig = {
|
|
5
|
+
key: string;
|
|
6
|
+
endpoint: string;
|
|
7
|
+
appVersion?: string;
|
|
8
|
+
secure: {
|
|
9
|
+
publicKey: Buffer;
|
|
10
|
+
clear: readonly ClearField[];
|
|
11
|
+
} | null;
|
|
12
|
+
logs: boolean;
|
|
13
|
+
selection: Selection;
|
|
14
|
+
logger: PulseLogger;
|
|
15
|
+
fetch: typeof fetch;
|
|
16
|
+
};
|
|
17
|
+
export declare const defaultLogger: PulseLogger;
|
|
18
|
+
export declare function isValidKey(key: string): boolean;
|
|
19
|
+
export declare function resolveConfig(options: PulseOptions, env?: NodeJS.ProcessEnv): PulseConfig | null;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultLogger = exports.DEFAULT_ENDPOINT = void 0;
|
|
4
|
+
exports.isValidKey = isValidKey;
|
|
5
|
+
exports.resolveConfig = resolveConfig;
|
|
6
|
+
const pinned_fetch_1 = require("./pinned-fetch");
|
|
7
|
+
const seal_1 = require("./seal");
|
|
8
|
+
const selection_1 = require("./selection");
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
exports.DEFAULT_ENDPOINT = 'https://api.pulse-app.si';
|
|
11
|
+
const KEY_PATTERN = /^pk_(live|test)_[A-Za-z0-9_-]{20,}$/;
|
|
12
|
+
const LOCAL_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '[::1]']);
|
|
13
|
+
const DEFAULT_CLEAR = ['status'];
|
|
14
|
+
exports.defaultLogger = {
|
|
15
|
+
warn: (message) => process.emitWarning(message, 'Pulse'),
|
|
16
|
+
error: (message) => process.emitWarning(message, 'Pulse'),
|
|
17
|
+
};
|
|
18
|
+
function isValidKey(key) {
|
|
19
|
+
return KEY_PATTERN.test(key);
|
|
20
|
+
}
|
|
21
|
+
function safeEndpoint(raw) {
|
|
22
|
+
try {
|
|
23
|
+
const url = new URL(raw);
|
|
24
|
+
if (url.protocol === 'https:' || LOCAL_HOSTS.has(url.hostname))
|
|
25
|
+
return url.origin;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
function resolveConfig(options, env = process.env) {
|
|
33
|
+
const logger = options.logger ?? exports.defaultLogger;
|
|
34
|
+
if (options.disabled ?? env.PULSE_DISABLED === 'true')
|
|
35
|
+
return null;
|
|
36
|
+
const key = (options.key ?? env.PULSE_KEY ?? '').trim();
|
|
37
|
+
if (!key) {
|
|
38
|
+
logger.warn('PULSE_KEY absente : Pulse ne surveille pas cette app.');
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (!isValidKey(key)) {
|
|
42
|
+
logger.error('PULSE_KEY mal formée : elle commence par pk_live_ ou pk_test_.');
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const endpoint = safeEndpoint(options.endpoint ?? env.PULSE_ENDPOINT ?? exports.DEFAULT_ENDPOINT);
|
|
46
|
+
if (!endpoint) {
|
|
47
|
+
logger.error('PULSE_ENDPOINT doit être en https.');
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const rawPublicKey = options.publicKey ?? env.PULSE_PUBLIC_KEY;
|
|
51
|
+
const publicKey = rawPublicKey ? (0, seal_1.parsePublicKey)(rawPublicKey) : null;
|
|
52
|
+
if (rawPublicKey && !publicKey) {
|
|
53
|
+
logger.error('PULSE_PUBLIC_KEY mal formée : copie-la depuis l’app Pulse, elle commence par pulse_pub_.');
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const rawFingerprint = options.relayFingerprint ?? env.PULSE_RELAY_FINGERPRINT;
|
|
57
|
+
const fingerprint = rawFingerprint ? (0, pinned_fetch_1.normalizeFingerprint)(rawFingerprint) : null;
|
|
58
|
+
if (rawFingerprint && !fingerprint) {
|
|
59
|
+
logger.error('PULSE_RELAY_FINGERPRINT mal formée : copie l’empreinte SHA-256 affichée par ton relais.');
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const selection = (0, selection_1.resolveSelection)(options, env);
|
|
63
|
+
return {
|
|
64
|
+
key,
|
|
65
|
+
endpoint,
|
|
66
|
+
appVersion: options.appVersion ?? env.PULSE_APP_VERSION ?? env.npm_package_version,
|
|
67
|
+
secure: publicKey ? { publicKey, clear: clearFields(options.clear, env.PULSE_CLEAR) } : null,
|
|
68
|
+
logs: selection.send.includes('logs'),
|
|
69
|
+
selection,
|
|
70
|
+
logger,
|
|
71
|
+
fetch: options.fetch ?? (fingerprint ? (0, pinned_fetch_1.pinnedFetch)(fingerprint) : globalThis.fetch),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function clearFields(option, raw) {
|
|
75
|
+
if (option)
|
|
76
|
+
return option;
|
|
77
|
+
if (raw === undefined)
|
|
78
|
+
return DEFAULT_CLEAR;
|
|
79
|
+
const wanted = raw.split(',').map((field) => field.trim());
|
|
80
|
+
return types_1.CLEAR_FIELDS.filter((field) => wanted.includes(field));
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AA2BA,gCAEC;AAaD,sCA+CC;AAzFD,iDAAmE;AACnE,iCAAwC;AACxC,2CAA+D;AAC/D,mCAA6F;AAEhF,QAAA,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,WAAW,GAAG,qCAAqC,CAAC;AAC1D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EA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AE,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;QAC5F,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QACrC,SAAS;QACT,MAAM;QACN,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,0BAAW,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;KACpF,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,MAAyC,EAAE,GAAuB;IACrF,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,aAAa,CAAC;IAC5C,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,OAAO,oBAAY,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/detect.d.ts
ADDED
package/dist/detect.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectProbes = detectProbes;
|
|
4
|
+
exports.cronSnapshots = cronSnapshots;
|
|
5
|
+
const ENGINE_NAMES = {
|
|
6
|
+
postgresql: 'PostgreSQL',
|
|
7
|
+
postgres: 'PostgreSQL',
|
|
8
|
+
mysql: 'MySQL',
|
|
9
|
+
mariadb: 'MariaDB',
|
|
10
|
+
sqlserver: 'SQL Server',
|
|
11
|
+
mssql: 'SQL Server',
|
|
12
|
+
sqlite: 'SQLite',
|
|
13
|
+
'better-sqlite3': 'SQLite',
|
|
14
|
+
mongodb: 'MongoDB',
|
|
15
|
+
cockroachdb: 'CockroachDB',
|
|
16
|
+
};
|
|
17
|
+
const isFunction = (value) => typeof value === 'function';
|
|
18
|
+
const engineName = (raw) => typeof raw === 'string' ? (ENGINE_NAMES[raw.toLowerCase()] ?? raw) : 'Base de données';
|
|
19
|
+
const call = (instance, method, ...args) => Promise.resolve(instance[method].apply(instance, args));
|
|
20
|
+
function prismaProvider(instance) {
|
|
21
|
+
const config = (instance._engineConfig ?? {});
|
|
22
|
+
return (instance._activeProvider ?? config.activeProvider);
|
|
23
|
+
}
|
|
24
|
+
const DETECTORS = [
|
|
25
|
+
(instance) => {
|
|
26
|
+
if (!isFunction(instance.$queryRawUnsafe) || !isFunction(instance.$connect))
|
|
27
|
+
return null;
|
|
28
|
+
const provider = prismaProvider(instance);
|
|
29
|
+
const mongo = provider === 'mongodb';
|
|
30
|
+
return {
|
|
31
|
+
label: engineName(provider),
|
|
32
|
+
kind: 'database',
|
|
33
|
+
engine: provider ?? 'prisma',
|
|
34
|
+
run: () => mongo
|
|
35
|
+
? call(instance, '$runCommandRaw', { ping: 1 })
|
|
36
|
+
: call(instance, '$queryRawUnsafe', 'SELECT 1'),
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
(instance) => {
|
|
40
|
+
if (!isFunction(instance.query) || typeof instance.isInitialized !== 'boolean')
|
|
41
|
+
return null;
|
|
42
|
+
const type = instance.options?.type;
|
|
43
|
+
return {
|
|
44
|
+
label: engineName(type),
|
|
45
|
+
kind: 'database',
|
|
46
|
+
engine: typeof type === 'string' ? type : 'typeorm',
|
|
47
|
+
run: () => call(instance, 'query', 'SELECT 1'),
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
(instance) => {
|
|
51
|
+
const db = instance.db;
|
|
52
|
+
if (typeof instance.readyState !== 'number' || !db || !isFunction(db.admin))
|
|
53
|
+
return null;
|
|
54
|
+
return {
|
|
55
|
+
label: 'MongoDB',
|
|
56
|
+
kind: 'database',
|
|
57
|
+
engine: 'mongodb',
|
|
58
|
+
run: () => call(call(db, 'admin'), 'ping'),
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
(instance) => {
|
|
62
|
+
const isIoredis = typeof instance.status === 'string' && isFunction(instance.ping) && 'options' in instance;
|
|
63
|
+
const isNodeRedis = typeof instance.isOpen === 'boolean' && isFunction(instance.ping);
|
|
64
|
+
if (!isIoredis && !isNodeRedis)
|
|
65
|
+
return null;
|
|
66
|
+
return { label: 'Redis', kind: 'redis', engine: 'redis', run: () => call(instance, 'ping') };
|
|
67
|
+
},
|
|
68
|
+
(instance) => {
|
|
69
|
+
if (typeof instance.name !== 'string' ||
|
|
70
|
+
!isFunction(instance.getJobCounts) ||
|
|
71
|
+
!isFunction(instance.add))
|
|
72
|
+
return null;
|
|
73
|
+
return {
|
|
74
|
+
label: `File ${instance.name}`,
|
|
75
|
+
kind: 'queue',
|
|
76
|
+
engine: 'bullmq',
|
|
77
|
+
run: () => call(instance, 'getJobCounts', 'waiting'),
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
function detectProbes(instances) {
|
|
82
|
+
const seen = new Set();
|
|
83
|
+
const probes = [];
|
|
84
|
+
const names = new Map();
|
|
85
|
+
for (const instance of instances) {
|
|
86
|
+
if (!instance || typeof instance !== 'object' || seen.has(instance))
|
|
87
|
+
continue;
|
|
88
|
+
seen.add(instance);
|
|
89
|
+
for (const detect of DETECTORS) {
|
|
90
|
+
let found = null;
|
|
91
|
+
try {
|
|
92
|
+
found = detect(instance);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
found = null;
|
|
96
|
+
}
|
|
97
|
+
if (!found)
|
|
98
|
+
continue;
|
|
99
|
+
const count = (names.get(found.label) ?? 0) + 1;
|
|
100
|
+
names.set(found.label, count);
|
|
101
|
+
const { label, ...probe } = found;
|
|
102
|
+
probes.push({ ...probe, name: count > 1 ? `${label} (${count})` : label });
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return probes;
|
|
107
|
+
}
|
|
108
|
+
const toDate = (value) => {
|
|
109
|
+
if (value instanceof Date)
|
|
110
|
+
return value;
|
|
111
|
+
if (value && typeof value === 'object' && isFunction(value.toJSDate)) {
|
|
112
|
+
return value.toJSDate();
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
};
|
|
116
|
+
function cronSnapshots(jobs) {
|
|
117
|
+
return [...jobs].map(([name, raw]) => {
|
|
118
|
+
const job = raw;
|
|
119
|
+
const source = job.cronTime?.source;
|
|
120
|
+
return {
|
|
121
|
+
name,
|
|
122
|
+
schedule: typeof source === 'string' ? source : undefined,
|
|
123
|
+
lastRunAt: toDate(job.lastDate?.()),
|
|
124
|
+
nextRunAt: toDate(job.nextDate?.()),
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":";;AA2FA,oCAuBC;AAgBD,sCAWC;AAxID,MAAM,YAAY,GAA2B;IAC3C,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,YAAY;IACtB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,QAAQ;IAChB,gBAAgB,EAAE,QAAQ;IAC1B,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;CAC3B,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,KAAc,EAA4C,EAAE,CAC9E,OAAO,KAAK,KAAK,UAAU,CAAC;AAE9B,MAAM,UAAU,GAAG,CAAC,GAAY,EAAE,EAAE,CAClC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAA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C,CAAC,CAAC;AACL,CAAC"}
|
package/dist/hpke.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type KeyObject } from 'node:crypto';
|
|
2
|
+
export declare const AEADS: {
|
|
3
|
+
readonly 'aes-128-gcm': {
|
|
4
|
+
readonly id: 1;
|
|
5
|
+
readonly keyBytes: 16;
|
|
6
|
+
};
|
|
7
|
+
readonly 'aes-256-gcm': {
|
|
8
|
+
readonly id: 2;
|
|
9
|
+
readonly keyBytes: 32;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type Aead = keyof typeof AEADS;
|
|
13
|
+
export type Sealed = {
|
|
14
|
+
enc: Buffer;
|
|
15
|
+
ct: Buffer;
|
|
16
|
+
};
|
|
17
|
+
export declare function privateKeyFromRaw(raw: Buffer): KeyObject;
|
|
18
|
+
export declare function publicKeyFromRaw(raw: Buffer): KeyObject;
|
|
19
|
+
export declare function rawPublicKey(key: KeyObject): Buffer;
|
|
20
|
+
export declare function generateKeyPair(): {
|
|
21
|
+
privateKey: Buffer;
|
|
22
|
+
publicKey: Buffer;
|
|
23
|
+
};
|
|
24
|
+
export declare function seal(recipientPublicKey: Buffer, info: Buffer, aad: Buffer, plaintext: Buffer, aead?: Aead, ephemeral?: KeyObject): Sealed;
|
|
25
|
+
export declare function open(recipientPrivateKey: Buffer, info: Buffer, aad: Buffer, sealed: Sealed, aead?: Aead): Buffer;
|
package/dist/hpke.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AEADS = void 0;
|
|
4
|
+
exports.privateKeyFromRaw = privateKeyFromRaw;
|
|
5
|
+
exports.publicKeyFromRaw = publicKeyFromRaw;
|
|
6
|
+
exports.rawPublicKey = rawPublicKey;
|
|
7
|
+
exports.generateKeyPair = generateKeyPair;
|
|
8
|
+
exports.seal = seal;
|
|
9
|
+
exports.open = open;
|
|
10
|
+
const node_crypto_1 = require("node:crypto");
|
|
11
|
+
const HASH_BYTES = 32;
|
|
12
|
+
const NONCE_BYTES = 12;
|
|
13
|
+
const TAG_BYTES = 16;
|
|
14
|
+
const KEM_ID = 0x0020;
|
|
15
|
+
const KDF_ID = 0x0001;
|
|
16
|
+
const PKCS8_X25519_PREFIX = Buffer.from('302e020100300506032b656e04220420', 'hex');
|
|
17
|
+
const SPKI_X25519_PREFIX = Buffer.from('302a300506032b656e032100', 'hex');
|
|
18
|
+
exports.AEADS = {
|
|
19
|
+
'aes-128-gcm': { id: 0x0001, keyBytes: 16 },
|
|
20
|
+
'aes-256-gcm': { id: 0x0002, keyBytes: 32 },
|
|
21
|
+
};
|
|
22
|
+
function i2osp(value, bytes) {
|
|
23
|
+
const out = Buffer.alloc(bytes);
|
|
24
|
+
out.writeUIntBE(value, 0, bytes);
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
function extract(salt, ikm) {
|
|
28
|
+
return (0, node_crypto_1.createHmac)('sha256', salt.length ? salt : Buffer.alloc(HASH_BYTES))
|
|
29
|
+
.update(ikm)
|
|
30
|
+
.digest();
|
|
31
|
+
}
|
|
32
|
+
function expand(prk, info, length) {
|
|
33
|
+
const blocks = [];
|
|
34
|
+
let previous = Buffer.alloc(0);
|
|
35
|
+
for (let counter = 1; Buffer.concat(blocks).length < length; counter += 1) {
|
|
36
|
+
previous = (0, node_crypto_1.createHmac)('sha256', prk)
|
|
37
|
+
.update(Buffer.concat([previous, info, i2osp(counter, 1)]))
|
|
38
|
+
.digest();
|
|
39
|
+
blocks.push(previous);
|
|
40
|
+
}
|
|
41
|
+
return Buffer.concat(blocks).subarray(0, length);
|
|
42
|
+
}
|
|
43
|
+
function labeled(suiteId) {
|
|
44
|
+
const prefix = (label) => Buffer.concat([Buffer.from('HPKE-v1'), suiteId, Buffer.from(label)]);
|
|
45
|
+
return {
|
|
46
|
+
extract: (salt, label, ikm) => extract(salt, Buffer.concat([prefix(label), ikm])),
|
|
47
|
+
expand: (prk, label, info, length) => expand(prk, Buffer.concat([i2osp(length, 2), prefix(label), info]), length),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const KEM = labeled(Buffer.concat([Buffer.from('KEM'), i2osp(KEM_ID, 2)]));
|
|
51
|
+
function privateKeyFromRaw(raw) {
|
|
52
|
+
return (0, node_crypto_1.createPrivateKey)({
|
|
53
|
+
key: Buffer.concat([PKCS8_X25519_PREFIX, raw]),
|
|
54
|
+
format: 'der',
|
|
55
|
+
type: 'pkcs8',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function publicKeyFromRaw(raw) {
|
|
59
|
+
return (0, node_crypto_1.createPublicKey)({
|
|
60
|
+
key: Buffer.concat([SPKI_X25519_PREFIX, raw]),
|
|
61
|
+
format: 'der',
|
|
62
|
+
type: 'spki',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function rawPublicKey(key) {
|
|
66
|
+
return key.export({ format: 'der', type: 'spki' }).subarray(SPKI_X25519_PREFIX.length);
|
|
67
|
+
}
|
|
68
|
+
function generateKeyPair() {
|
|
69
|
+
const pair = (0, node_crypto_1.generateKeyPairSync)('x25519');
|
|
70
|
+
return {
|
|
71
|
+
privateKey: pair.privateKey
|
|
72
|
+
.export({ format: 'der', type: 'pkcs8' })
|
|
73
|
+
.subarray(PKCS8_X25519_PREFIX.length),
|
|
74
|
+
publicKey: rawPublicKey(pair.publicKey),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function sharedSecret(dh, enc, recipient) {
|
|
78
|
+
const prk = KEM.extract(Buffer.alloc(0), 'eae_prk', dh);
|
|
79
|
+
return KEM.expand(prk, 'shared_secret', Buffer.concat([enc, recipient]), HASH_BYTES);
|
|
80
|
+
}
|
|
81
|
+
function keySchedule(shared, info, aead) {
|
|
82
|
+
const suite = labeled(Buffer.concat([
|
|
83
|
+
Buffer.from('HPKE'),
|
|
84
|
+
i2osp(KEM_ID, 2),
|
|
85
|
+
i2osp(KDF_ID, 2),
|
|
86
|
+
i2osp(exports.AEADS[aead].id, 2),
|
|
87
|
+
]));
|
|
88
|
+
const empty = Buffer.alloc(0);
|
|
89
|
+
const context = Buffer.concat([
|
|
90
|
+
i2osp(0, 1),
|
|
91
|
+
suite.extract(empty, 'psk_id_hash', empty),
|
|
92
|
+
suite.extract(empty, 'info_hash', info),
|
|
93
|
+
]);
|
|
94
|
+
const secret = suite.extract(shared, 'secret', empty);
|
|
95
|
+
return {
|
|
96
|
+
key: suite.expand(secret, 'key', context, exports.AEADS[aead].keyBytes),
|
|
97
|
+
nonce: suite.expand(secret, 'base_nonce', context, NONCE_BYTES),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function seal(recipientPublicKey, info, aad, plaintext, aead = 'aes-256-gcm', ephemeral = (0, node_crypto_1.generateKeyPairSync)('x25519').privateKey) {
|
|
101
|
+
const enc = rawPublicKey((0, node_crypto_1.createPublicKey)(ephemeral));
|
|
102
|
+
const dh = (0, node_crypto_1.diffieHellman)({
|
|
103
|
+
privateKey: ephemeral,
|
|
104
|
+
publicKey: publicKeyFromRaw(recipientPublicKey),
|
|
105
|
+
});
|
|
106
|
+
const { key, nonce } = keySchedule(sharedSecret(dh, enc, recipientPublicKey), info, aead);
|
|
107
|
+
const cipher = (0, node_crypto_1.createCipheriv)(aead, key, nonce).setAAD(aad);
|
|
108
|
+
const ct = Buffer.concat([cipher.update(plaintext), cipher.final(), cipher.getAuthTag()]);
|
|
109
|
+
return { enc, ct };
|
|
110
|
+
}
|
|
111
|
+
function open(recipientPrivateKey, info, aad, sealed, aead = 'aes-256-gcm') {
|
|
112
|
+
const privateKey = privateKeyFromRaw(recipientPrivateKey);
|
|
113
|
+
const recipient = rawPublicKey((0, node_crypto_1.createPublicKey)(privateKey));
|
|
114
|
+
const dh = (0, node_crypto_1.diffieHellman)({ privateKey, publicKey: publicKeyFromRaw(sealed.enc) });
|
|
115
|
+
const { key, nonce } = keySchedule(sharedSecret(dh, sealed.enc, recipient), info, aead);
|
|
116
|
+
const decipher = (0, node_crypto_1.createDecipheriv)(aead, key, nonce).setAAD(aad);
|
|
117
|
+
decipher.setAuthTag(sealed.ct.subarray(sealed.ct.length - TAG_BYTES));
|
|
118
|
+
return Buffer.concat([
|
|
119
|
+
decipher.update(sealed.ct.subarray(0, sealed.ct.length - TAG_BYTES)),
|
|
120
|
+
decipher.final(),
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=hpke.js.map
|
package/dist/hpke.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke.js","sourceRoot":"","sources":["../src/hpke.ts"],"names":[],"mappings":";;;AAgEA,8CAMC;AAED,4CAMC;AAED,oCAEC;AAED,0CAQC;AA8BD,oBAiBC;AAED,oBAiBC;AA9JD,6CASqB;AAErB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,MAAM,GAAG,MAAM,CAAC;AACtB,MAAM,MAAM,GAAG,MAAM,CAAC;AACtB,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;AACnF,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;AAE7D,QAAA,KAAK,GAAG;IACnB,aAAa,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3C,aAAa,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;CACnC,CAAC;AAKX,SAAS,KAAK,CAAC,KAAa,EAAE,KAAa;IACzC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACjC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,EAAE,EAAE,CAAC;AACrB,CAAC;AAED,SAAgB,IAAI,CAClB,mBAA2B,EAC3B,IAAY,EACZ,GAAW,EACX,MAAc,EACd,OAAa,aAAa;IAE1B,MAAM,UAAU,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,YAAY,CAAC,IAAA,6BAAe,EAAC,UAAU,CAAC,CAAC,CAAC;IAC5D,MAAM,EAAE,GAAG,IAAA,2BAAa,EAAC,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClF,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACxF,MAAM,QAAQ,GAAG,IAAA,8BAAgB,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;QACpE,QAAQ,CAAC,KAAK,EAAE;KACjB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { DEFAULT_ENDPOINT, isValidKey, resolveConfig } from './config';
|
|
2
|
+
export { cronSnapshots, detectProbes } from './detect';
|
|
3
|
+
export { httpProbe, runProbe } from './probes';
|
|
4
|
+
export { PulseReporter } from './reporter';
|
|
5
|
+
export { sanitizeError } from './sanitize';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export { installedVersion, ownVersion } from './versions';
|
|
8
|
+
export { generateKeyPair } from './hpke';
|
|
9
|
+
export { formatPublicKey, keyId, openJson, parsePublicKey, sealJson, type SealedEnvelope, } from './seal';
|
|
10
|
+
export { LOG_LEVELS, parseLogLine, type LogEntry, type LogLevel } from './logs';
|
|
11
|
+
export { isSelected } from './selection';
|
|
12
|
+
export { normalizeFingerprint } from './pinned-fetch';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.normalizeFingerprint = exports.isSelected = exports.parseLogLine = exports.LOG_LEVELS = exports.sealJson = exports.parsePublicKey = exports.openJson = exports.keyId = exports.formatPublicKey = exports.generateKeyPair = exports.ownVersion = exports.installedVersion = exports.sanitizeError = exports.PulseReporter = exports.runProbe = exports.httpProbe = exports.detectProbes = exports.cronSnapshots = exports.resolveConfig = exports.isValidKey = exports.DEFAULT_ENDPOINT = void 0;
|
|
18
|
+
var config_1 = require("./config");
|
|
19
|
+
Object.defineProperty(exports, "DEFAULT_ENDPOINT", { enumerable: true, get: function () { return config_1.DEFAULT_ENDPOINT; } });
|
|
20
|
+
Object.defineProperty(exports, "isValidKey", { enumerable: true, get: function () { return config_1.isValidKey; } });
|
|
21
|
+
Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return config_1.resolveConfig; } });
|
|
22
|
+
var detect_1 = require("./detect");
|
|
23
|
+
Object.defineProperty(exports, "cronSnapshots", { enumerable: true, get: function () { return detect_1.cronSnapshots; } });
|
|
24
|
+
Object.defineProperty(exports, "detectProbes", { enumerable: true, get: function () { return detect_1.detectProbes; } });
|
|
25
|
+
var probes_1 = require("./probes");
|
|
26
|
+
Object.defineProperty(exports, "httpProbe", { enumerable: true, get: function () { return probes_1.httpProbe; } });
|
|
27
|
+
Object.defineProperty(exports, "runProbe", { enumerable: true, get: function () { return probes_1.runProbe; } });
|
|
28
|
+
var reporter_1 = require("./reporter");
|
|
29
|
+
Object.defineProperty(exports, "PulseReporter", { enumerable: true, get: function () { return reporter_1.PulseReporter; } });
|
|
30
|
+
var sanitize_1 = require("./sanitize");
|
|
31
|
+
Object.defineProperty(exports, "sanitizeError", { enumerable: true, get: function () { return sanitize_1.sanitizeError; } });
|
|
32
|
+
__exportStar(require("./types"), exports);
|
|
33
|
+
var versions_1 = require("./versions");
|
|
34
|
+
Object.defineProperty(exports, "installedVersion", { enumerable: true, get: function () { return versions_1.installedVersion; } });
|
|
35
|
+
Object.defineProperty(exports, "ownVersion", { enumerable: true, get: function () { return versions_1.ownVersion; } });
|
|
36
|
+
var hpke_1 = require("./hpke");
|
|
37
|
+
Object.defineProperty(exports, "generateKeyPair", { enumerable: true, get: function () { return hpke_1.generateKeyPair; } });
|
|
38
|
+
var seal_1 = require("./seal");
|
|
39
|
+
Object.defineProperty(exports, "formatPublicKey", { enumerable: true, get: function () { return seal_1.formatPublicKey; } });
|
|
40
|
+
Object.defineProperty(exports, "keyId", { enumerable: true, get: function () { return seal_1.keyId; } });
|
|
41
|
+
Object.defineProperty(exports, "openJson", { enumerable: true, get: function () { return seal_1.openJson; } });
|
|
42
|
+
Object.defineProperty(exports, "parsePublicKey", { enumerable: true, get: function () { return seal_1.parsePublicKey; } });
|
|
43
|
+
Object.defineProperty(exports, "sealJson", { enumerable: true, get: function () { return seal_1.sealJson; } });
|
|
44
|
+
var logs_1 = require("./logs");
|
|
45
|
+
Object.defineProperty(exports, "LOG_LEVELS", { enumerable: true, get: function () { return logs_1.LOG_LEVELS; } });
|
|
46
|
+
Object.defineProperty(exports, "parseLogLine", { enumerable: true, get: function () { return logs_1.parseLogLine; } });
|
|
47
|
+
var selection_1 = require("./selection");
|
|
48
|
+
Object.defineProperty(exports, "isSelected", { enumerable: true, get: function () { return selection_1.isSelected; } });
|
|
49
|
+
var pinned_fetch_1 = require("./pinned-fetch");
|
|
50
|
+
Object.defineProperty(exports, "normalizeFingerprint", { enumerable: true, get: function () { return pinned_fetch_1.normalizeFingerprint; } });
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAuE;AAA9D,0GAAA,gBAAgB,OAAA;AAAE,oGAAA,UAAU,OAAA;AAAE,uGAAA,aAAa,OAAA;AACpD,mCAAuD;AAA9C,uGAAA,aAAa,OAAA;AAAE,sGAAA,YAAY,OAAA;AACpC,mCAA+C;AAAtC,mGAAA,SAAS,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAC5B,uCAA2C;AAAlC,yGAAA,aAAa,OAAA;AACtB,uCAA2C;AAAlC,yGAAA,aAAa,OAAA;AACtB,0CAAwB;AACxB,uCAA0D;AAAjD,4GAAA,gBAAgB,OAAA;AAAE,sGAAA,UAAU,OAAA;AACrC,+BAAyC;AAAhC,uGAAA,eAAe,OAAA;AACxB,+BAOgB;AANd,uGAAA,eAAe,OAAA;AACf,6FAAA,KAAK,OAAA;AACL,gGAAA,QAAQ,OAAA;AACR,sGAAA,cAAc,OAAA;AACd,gGAAA,QAAQ,OAAA;AAGV,+BAAgF;AAAvE,kGAAA,UAAU,OAAA;AAAE,oGAAA,YAAY,OAAA;AACjC,yCAAyC;AAAhC,uGAAA,UAAU,OAAA;AACnB,+CAAsD;AAA7C,oHAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PulseConfig } from './config';
|
|
2
|
+
import { LogCollector } from './logs';
|
|
3
|
+
export type ServerState = {
|
|
4
|
+
logs: boolean;
|
|
5
|
+
live: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare class LogShipper {
|
|
8
|
+
private readonly config;
|
|
9
|
+
private readonly userAgent;
|
|
10
|
+
private readonly onState;
|
|
11
|
+
private readonly warn;
|
|
12
|
+
readonly collector: LogCollector;
|
|
13
|
+
private restore?;
|
|
14
|
+
private timer?;
|
|
15
|
+
private stopped;
|
|
16
|
+
private state;
|
|
17
|
+
private accepted;
|
|
18
|
+
constructor(config: PulseConfig, userAgent: string, onState: (state: ServerState) => void, warn: (message: string) => void);
|
|
19
|
+
start(): void;
|
|
20
|
+
stop(): void;
|
|
21
|
+
update(state: ServerState): void;
|
|
22
|
+
flush(): Promise<number>;
|
|
23
|
+
private release;
|
|
24
|
+
private schedule;
|
|
25
|
+
}
|