@oxidezap/baileyrs 0.3.2 → 0.3.4

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
@@ -88,6 +88,37 @@ That writes the alias to your `package.json` (with the latest version at install
88
88
  Every `import { makeWASocket } from '@whiskeysockets/baileys'` in your codebase
89
89
  now resolves to baileyrs.
90
90
 
91
+ ### What gets installed
92
+
93
+ `npm install @oxidezap/baileyrs` always brings two runtime dependencies.
94
+
95
+ - `@oxidezap/whatsapp-rust-bridge` is the Rust engine doing the protocol
96
+ work. It is the library, not an add-on, so it stays a hard dependency.
97
+ - `long` stays too. Fields like `messageTimestamp` and `fileLength` are
98
+ `Long` objects in the types, and the package builds real ones at runtime.
99
+ A consumer without it fails compilation in four declaration files and
100
+ fails at import, so there is nothing to save by dropping it. I checked.
101
+
102
+ Everything else is an optional peer. It is used when present and skipped
103
+ when not.
104
+
105
+ | Peer | What it does | Without it |
106
+ | --- | --- | --- |
107
+ | `@hapi/boom` (`^9` or `^10`) | Backs the exported `Boom` errors | A built-in implementation with the same shape |
108
+ | `pino` (`^9` or `^10`) | Backs the default logger | JSON lines on stdout, same redaction |
109
+ | `sharp`, `jimp`, `audio-decode`, `link-preview-js`, `music-metadata` | Media work | Same behavior as before this change |
110
+
111
+ Two setups both work.
112
+
113
+ - Migrating a Baileys project. Your tree already has `@hapi/boom` and
114
+ `pino`, and baileyrs reuses those copies. Error identity is shared, so
115
+ `instanceof` and `isBoom` checks against your own copy keep passing.
116
+ Install nothing, remove nothing.
117
+ - Fresh project. Install only what you touch. The defaults work with zero
118
+ extra dependencies. Add `@hapi/boom` if you compare errors against
119
+ another library's copy, and `pino` if you want transports and
120
+ pretty-printing instead of stdout JSON.
121
+
91
122
  ### Preview builds
92
123
 
93
124
  Every commit on `main` and every pull request publishes an installable build
@@ -237,6 +268,18 @@ preserved. No QR re-scan, no logged-out events.
237
268
 
238
269
  A few behaviors that differ from upstream — almost always to your advantage:
239
270
 
271
+ - **An undecryptable message tells you what it was.** The CIPHERTEXT stub
272
+ emitted on `messages.upsert` for a message that failed to decrypt carries
273
+ `stanzaType`: the envelope's `type` attribute as the server stamped it on the
274
+ sending stanza — `"text"`, `"media"`, `"pay"`, `"poll"`, `"reaction"`,
275
+ `"event"`. It describes the stanza rather than the ciphertext, so it survives
276
+ the failure, and it is stamped on the sender's own outgoing stanza, so it
277
+ cannot be pointed at anyone else. Upstream has no equivalent: there the
278
+ placeholder is unclassifiable. `messageStubParameters` is untouched and still
279
+ holds only the unavailability reason, when the server named one — the two are
280
+ independently optional, which is exactly what a positional array cannot
281
+ express.
282
+
240
283
  - **Auto-reconnect is built in, but `close` still means `close`.** The Rust
241
284
  engine retries transient drops on a fibonacci backoff and reports them as
242
285
  `connection: 'connecting'`, so the canonical upstream handler never fires
@@ -292,11 +335,17 @@ A few behaviors that differ from upstream — almost always to your advantage:
292
335
  of one group can pick the same one, and a handler that keys on it would drop
293
336
  the second person's message rather than a duplicate. That is why the engine's
294
337
  own check carries the sender too.
295
- - **`Boom` ships in the box.** baileyrs exports its own
338
+ - **`Boom` works with or without `@hapi/boom`.** baileyrs exports a
296
339
  `@hapi/boom`-compatible `Boom`, so the existing
297
- `(err as Boom).output.statusCode` pattern works unchanged. If your
298
- `package.json` was pulling `@hapi/boom` only for baileys, you can drop
299
- the dependency.
340
+ `(err as Boom).output.statusCode` pattern works unchanged. The package is
341
+ an optional peer. With it installed your copy backs the export, without
342
+ it a built-in implementation with the same shape does. See
343
+ [What gets installed](#what-gets-installed).
344
+ - **Audio duration needs the optional `music-metadata` peer.** Upstream
345
+ Baileys bundles it as a hard dependency; here it is optional like the
346
+ other media peers (`sharp`, `jimp`, `audio-decode`, `link-preview-js`).
347
+ Without it, audio messages still send — they just carry no `seconds`
348
+ value. Install `music-metadata` if you want durations computed.
300
349
  - **Your key store also holds bridge state, so "empty" is not "unpaired".**
301
350
  See [Bridge state in your key store](#bridge-state-in-your-key-store) — this
302
351
  one can break a boot path, so it has its own section.
@@ -190,6 +190,7 @@ const ADAPTERS = {
190
190
  remoteJidAlt: resolveRemoteJidAlt(senderAlt, recipientAlt, isGroup, isFromMe),
191
191
  isUnavailable: asBoolOr(data?.is_unavailable, false),
192
192
  unavailableType: asString(data?.unavailable_type),
193
+ stanzaType: asString(info.type),
193
194
  decryptFailMode: asString(data?.decrypt_fail_mode),
194
195
  raw: data
195
196
  };
@@ -566,6 +566,13 @@ export interface CanonicalUndecryptableMessage {
566
566
  isUnavailable: boolean;
567
567
  /** Bridge `unavailable_type`: "view_once" | "unknown". */
568
568
  unavailableType?: string;
569
+ /**
570
+ * The envelope's `type` attribute, as the server stamped it: "text",
571
+ * "media", "pay", "poll", "reaction", "event"… It describes the stanza,
572
+ * not the ciphertext, so it survives a decryption failure — the one thing
573
+ * a consumer can still learn about a message it cannot read.
574
+ */
575
+ stanzaType?: string;
569
576
  /** Bridge `decrypt_fail_mode`: "show" | "hide". */
570
577
  decryptFailMode?: string;
571
578
  /** Original raw payload, preserved for debug logging. */
@@ -532,9 +532,9 @@ class ProtoCompatibilityRuntime {
532
532
  return appendBytes(writer, finish());
533
533
  // The codec's own writer is what comes back, with `finish` shadowed on
534
534
  // the instance rather than replaced by a bare `{ finish }`. The published
535
- // declaration types this return as a protobufjs `Writer`, and a caller
536
- // that chains anything on it — `fork`, `join`, another field — has to
537
- // find the rest of the surface still there. The writer is freshly made
535
+ // declaration types this return as the facade's structural `Writer`,
536
+ // which mirrors the `protobufjs` 7.6.6 instance surface Baileys
537
+ // consumers hold, so a caller chaining on it keeps typechecking. The writer is freshly made
538
538
  // by this call, so shadowing one method on it touches nothing else.
539
539
  encoded.finish = finish;
540
540
  return encoded;
@@ -479,6 +479,15 @@ const DISPATCHERS = {
479
479
  stubMsg.key.participantAlt = evt.participantAlt;
480
480
  if (evt.remoteJidAlt)
481
481
  stubMsg.key.remoteJidAlt = evt.remoteJidAlt;
482
+ // A field of its own, not a second slot in `messageStubParameters`:
483
+ // that array is positional, and two independently optional values in it
484
+ // cannot be told apart — a lone `"pay"` would sit where an
485
+ // unavailability reason used to. This is the one thing that survives a
486
+ // decryption failure to say what the message was (the server stamps it
487
+ // on the sender's own outgoing stanza, in the clear), so it is named
488
+ // rather than placed.
489
+ if (evt.stanzaType)
490
+ stubMsg.stanzaType = evt.stanzaType;
482
491
  ctx.ev.emit('messages.upsert', { messages: [stubMsg], type: 'notify' });
483
492
  },
484
493
  // ── Contacts ──
@@ -29,6 +29,15 @@ export type WAMessage = Omit<proto.IWebMessageInfo, 'messageStubParameters' | 'm
29
29
  category?: string;
30
30
  retryCount?: number;
31
31
  messageStubParameters?: any;
32
+ /**
33
+ * The envelope's `type` attribute, as the server stamped it on the sending
34
+ * stanza: `"text"`, `"media"`, `"pay"`, `"poll"`, `"reaction"`, `"event"`.
35
+ *
36
+ * Set only on the CIPHERTEXT stub emitted for a message that failed to
37
+ * decrypt, where it is the one fact about the message that survives — it
38
+ * describes the stanza, not the ciphertext. Absent everywhere else.
39
+ */
40
+ stanzaType?: string;
32
41
  };
33
42
  export type WAMessageContent = proto.IMessage;
34
43
  export type WAContactMessage = proto.Message.IContactMessage;
@@ -3,7 +3,85 @@
3
3
  * making `lastDisconnect.error` and `messages.media-update.error` exactly
4
4
  * assignable, this preserves the full Boom runtime contract (`reformat`,
5
5
  * `typeof`, mutable output headers and standard payload handling).
6
+ *
7
+ * `@hapi/boom` is an optional peer: when the consumer has it installed the
8
+ * real implementation backs the export, so `instanceof` identity is shared
9
+ * with the rest of their tree. Otherwise a local implementation with the
10
+ * same observable behavior backs it, so a fresh install works without
11
+ * adding the dependency.
6
12
  */
7
- export { Boom, boomify, isBoom } from '@hapi/boom';
8
- export type { Options as BoomOptions, Output as BoomOutput, Payload as BoomPayload } from '@hapi/boom';
13
+ /** Extra error data carried beside the formatted response. */
14
+ export interface BoomOptions<Data = any> {
15
+ /** The HTTP status code. Must be 400 or above. @default 500 */
16
+ statusCode?: number;
17
+ /** Additional error information. @default null */
18
+ data?: Data;
19
+ /** Constructor reference used to crop the exception call stack output. */
20
+ ctor?: Function;
21
+ /** Replacement message applied on top of an existing error. */
22
+ message?: string;
23
+ /**
24
+ * When the input is already a Boom error and a statusCode or message is
25
+ * provided, apply them. Pass false to leave the error untouched.
26
+ * @default true
27
+ */
28
+ override?: boolean;
29
+ /** Extra properties assigned onto the error object. */
30
+ decorate?: Record<string, unknown>;
31
+ }
32
+ /** The formatted object used as the response payload. */
33
+ export interface BoomPayload {
34
+ /** The HTTP status code derived from error.output.statusCode. */
35
+ statusCode: number;
36
+ /** The HTTP status message derived from statusCode. */
37
+ error: string;
38
+ /** The error message derived from error.message. */
39
+ message: string;
40
+ /** Custom properties. */
41
+ [key: string]: unknown;
42
+ }
43
+ /** The formatted response carried on every Boom error. */
44
+ export interface BoomOutput {
45
+ /** The HTTP status code. */
46
+ statusCode: number;
47
+ /** HTTP headers, each key a header name. Mutable by design. */
48
+ headers: {
49
+ [header: string]: string | string[] | number | undefined;
50
+ };
51
+ /** The formatted object used as the response payload. */
52
+ payload: BoomPayload;
53
+ }
54
+ /** A Boom error instance. */
55
+ export interface Boom<Data = any> extends Error {
56
+ /** Custom error data. Null unless the caller passed `data`. */
57
+ data?: Data | null;
58
+ /** Always true on a Boom error. Checked by {@link isBoom}. */
59
+ isBoom: boolean;
60
+ /** True when the status code is 500 or above. */
61
+ isServer: boolean;
62
+ /** The formatted response. */
63
+ output: BoomOutput;
64
+ /** The constructor used to create the error. */
65
+ typeof: Function;
66
+ /**
67
+ * Rebuild the payload from the current status code and message.
68
+ * Returns the formatted message, matching the peer's declaration.
69
+ */
70
+ reformat(debug?: boolean): string;
71
+ }
72
+ /** The shared constructor behind the {@link Boom} export. */
73
+ export interface BoomConstructor {
74
+ new <Data = any>(message?: string | Error, options?: BoomOptions<Data>): Boom<Data>;
75
+ readonly prototype: Boom<unknown>;
76
+ }
77
+ /**
78
+ * The shared error implementation. The peer's copy when installed, so error
79
+ * identity is shared with the rest of the consumer's tree, else the local
80
+ * implementation above.
81
+ */
82
+ export declare const Boom: BoomConstructor;
83
+ /** Decorate an existing error with the Boom response shape. */
84
+ export declare const boomify: (error: Error, options?: BoomOptions) => Boom;
85
+ /** Whether a value is a Boom error, optionally with an exact status code. */
86
+ export declare const isBoom: (obj: unknown, statusCode?: number) => obj is Boom;
9
87
  //# sourceMappingURL=boom.d.ts.map
package/lib/Utils/boom.js CHANGED
@@ -3,6 +3,170 @@
3
3
  * making `lastDisconnect.error` and `messages.media-update.error` exactly
4
4
  * assignable, this preserves the full Boom runtime contract (`reformat`,
5
5
  * `typeof`, mutable output headers and standard payload handling).
6
+ *
7
+ * `@hapi/boom` is an optional peer: when the consumer has it installed the
8
+ * real implementation backs the export, so `instanceof` identity is shared
9
+ * with the rest of their tree. Otherwise a local implementation with the
10
+ * same observable behavior backs it, so a fresh install works without
11
+ * adding the dependency.
6
12
  */
7
- export { Boom, boomify, isBoom } from '@hapi/boom';
13
+ import { loadOptionalPeer } from './optional-peer.js';
14
+ /** Reason phrases per status code, matching the peer's table. */
15
+ const STATUS_MESSAGES = new Map([
16
+ [100, 'Continue'],
17
+ [101, 'Switching Protocols'],
18
+ [102, 'Processing'],
19
+ [200, 'OK'],
20
+ [201, 'Created'],
21
+ [202, 'Accepted'],
22
+ [203, 'Non-Authoritative Information'],
23
+ [204, 'No Content'],
24
+ [205, 'Reset Content'],
25
+ [206, 'Partial Content'],
26
+ [207, 'Multi-Status'],
27
+ [300, 'Multiple Choices'],
28
+ [301, 'Moved Permanently'],
29
+ [302, 'Moved Temporarily'],
30
+ [303, 'See Other'],
31
+ [304, 'Not Modified'],
32
+ [305, 'Use Proxy'],
33
+ [307, 'Temporary Redirect'],
34
+ [400, 'Bad Request'],
35
+ [401, 'Unauthorized'],
36
+ [402, 'Payment Required'],
37
+ [403, 'Forbidden'],
38
+ [404, 'Not Found'],
39
+ [405, 'Method Not Allowed'],
40
+ [406, 'Not Acceptable'],
41
+ [407, 'Proxy Authentication Required'],
42
+ [408, 'Request Time-out'],
43
+ [409, 'Conflict'],
44
+ [410, 'Gone'],
45
+ [411, 'Length Required'],
46
+ [412, 'Precondition Failed'],
47
+ [413, 'Request Entity Too Large'],
48
+ [414, 'Request-URI Too Large'],
49
+ [415, 'Unsupported Media Type'],
50
+ [416, 'Requested Range Not Satisfiable'],
51
+ [417, 'Expectation Failed'],
52
+ [418, "I'm a teapot"],
53
+ [422, 'Unprocessable Entity'],
54
+ [423, 'Locked'],
55
+ [424, 'Failed Dependency'],
56
+ [425, 'Too Early'],
57
+ [426, 'Upgrade Required'],
58
+ [428, 'Precondition Required'],
59
+ [429, 'Too Many Requests'],
60
+ [431, 'Request Header Fields Too Large'],
61
+ [451, 'Unavailable For Legal Reasons'],
62
+ [500, 'Internal Server Error'],
63
+ [501, 'Not Implemented'],
64
+ [502, 'Bad Gateway'],
65
+ [503, 'Service Unavailable'],
66
+ [504, 'Gateway Time-out'],
67
+ [505, 'HTTP Version Not Supported'],
68
+ [506, 'Variant Also Negotiates'],
69
+ [507, 'Insufficient Storage'],
70
+ [509, 'Bandwidth Limit Exceeded'],
71
+ [510, 'Not Extended'],
72
+ [511, 'Network Authentication Required']
73
+ ]);
74
+ const reformatBoom = function (debug = false) {
75
+ this.output.payload.statusCode = this.output.statusCode;
76
+ this.output.payload.error = STATUS_MESSAGES.get(this.output.statusCode) || 'Unknown';
77
+ if (this.output.statusCode === 500 && debug !== true) {
78
+ this.output.payload.message = 'An internal server error occurred';
79
+ }
80
+ else if (this.message) {
81
+ this.output.payload.message = this.message;
82
+ }
83
+ return this.output.payload.message;
84
+ };
85
+ const initializeBoom = (error, statusCode, message) => {
86
+ const code = Number.parseInt(String(statusCode), 10);
87
+ if (Number.isNaN(code) || code < 400) {
88
+ throw new Error(`First argument must be a number (400+): ${String(statusCode)}`);
89
+ }
90
+ error.isBoom = true;
91
+ error.isServer = code >= 500;
92
+ if (!Object.hasOwn(error, 'data'))
93
+ error.data = null;
94
+ error.output = { statusCode: code, payload: {}, headers: {} };
95
+ Object.defineProperty(error, 'reformat', { value: reformatBoom, configurable: true });
96
+ if (!message && !error.message) {
97
+ error.reformat();
98
+ message = error.output.payload.error;
99
+ }
100
+ if (message) {
101
+ error.message = message + (error.message ? `: ${error.message}` : '');
102
+ error.output.payload.message = error.message;
103
+ }
104
+ error.reformat();
105
+ return error;
106
+ };
107
+ /**
108
+ * Local stand-in used only when `@hapi/boom` is not installed. Reproduces
109
+ * the observable contract the rest of the package relies on: `output` with
110
+ * status code, payload and mutable headers, `data`, `isServer`, `reformat`,
111
+ * `typeof`, sanitized 500 messages, and `instanceof` recognition through
112
+ * `Symbol.hasInstance`.
113
+ */
114
+ class FallbackBoom extends Error {
115
+ constructor(messageOrError, options = {}) {
116
+ if (messageOrError instanceof Error) {
117
+ // Own properties are copied, the prototype is kept: a custom
118
+ // Error subclass still answers `instanceof` after wrapping,
119
+ // exactly like the peer's clone. Boom recognition does not need
120
+ // the fallback prototype, it goes through `isBoom`.
121
+ const copy = Object.create(Object.getPrototypeOf(messageOrError), Object.getOwnPropertyDescriptors(messageOrError));
122
+ return boomifyFallback(copy, options);
123
+ }
124
+ const { statusCode = 500, data = null, ctor = FallbackBoom } = options;
125
+ super(messageOrError ?? undefined);
126
+ this.isBoom = true;
127
+ this.isServer = true;
128
+ if (typeof Error.captureStackTrace === 'function')
129
+ Error.captureStackTrace(this, ctor);
130
+ this.data = (data ?? null);
131
+ const initialized = initializeBoom(this, statusCode);
132
+ Object.defineProperty(initialized, 'typeof', { value: ctor });
133
+ if (options.decorate)
134
+ Object.assign(initialized, options.decorate);
135
+ return initialized;
136
+ }
137
+ static [Symbol.hasInstance](instance) {
138
+ return isBoomFallback(instance);
139
+ }
140
+ }
141
+ /** Local `isBoom`: an Error carrying the Boom marker, nothing looser. */
142
+ const isBoomFallback = (obj, statusCode) => obj instanceof Error &&
143
+ obj.isBoom === true &&
144
+ (statusCode === undefined || obj.output?.statusCode === statusCode);
145
+ /** Local `boomify`: decorate an existing error in place. */
146
+ const boomifyFallback = (error, options = {}) => {
147
+ if (!(error instanceof Error))
148
+ throw new Error('Cannot wrap non-Error object');
149
+ const boom = error;
150
+ if (options.data !== undefined)
151
+ boom.data = options.data;
152
+ if (options.decorate)
153
+ Object.assign(boom, options.decorate);
154
+ if (!boom.isBoom)
155
+ return initializeBoom(boom, options.statusCode ?? 500, options.message);
156
+ if (options.override === false || (!options.statusCode && !options.message))
157
+ return boom;
158
+ return initializeBoom(boom, options.statusCode ?? boom.output.statusCode, options.message);
159
+ };
160
+ const loadBoomPeer = () => loadOptionalPeer('@hapi/boom');
161
+ const peer = loadBoomPeer();
162
+ /**
163
+ * The shared error implementation. The peer's copy when installed, so error
164
+ * identity is shared with the rest of the consumer's tree, else the local
165
+ * implementation above.
166
+ */
167
+ export const Boom = (peer?.Boom ?? FallbackBoom);
168
+ /** Decorate an existing error with the Boom response shape. */
169
+ export const boomify = peer?.boomify ?? boomifyFallback;
170
+ /** Whether a value is a Boom error, optionally with an exact status code. */
171
+ export const isBoom = peer?.isBoom ?? isBoomFallback;
8
172
  //# sourceMappingURL=boom.js.map
@@ -1,4 +1,3 @@
1
- import type { Logger } from 'pino';
2
1
  export interface ILogger {
3
2
  level: string;
4
3
  child(obj: Record<string, unknown>): ILogger;
@@ -8,6 +7,63 @@ export interface ILogger {
8
7
  warn(obj: unknown, msg?: string): void;
9
8
  error(obj: unknown, msg?: string): void;
10
9
  }
10
+ /** Options accepted by `child()`. The fallback honors `level` and `msgPrefix`;
11
+ * anything else is accepted for signature compatibility and ignored there. */
12
+ export interface ChildLoggerOptions {
13
+ level?: string;
14
+ msgPrefix?: string;
15
+ [option: string]: unknown;
16
+ }
17
+ /**
18
+ * The full logger surface behind the default export. Structural so both the
19
+ * peer logger and the local fallback satisfy it; deliberately free of any
20
+ * `pino` import so consumers typecheck with or without the peer installed.
21
+ */
22
+ export interface Logger {
23
+ level: string;
24
+ child(bindings: Record<string, unknown>, options?: ChildLoggerOptions): Logger;
25
+ trace(...args: unknown[]): void;
26
+ debug(...args: unknown[]): void;
27
+ info(...args: unknown[]): void;
28
+ warn(...args: unknown[]): void;
29
+ error(...args: unknown[]): void;
30
+ fatal(...args: unknown[]): void;
31
+ silent(...args: unknown[]): void;
32
+ flush(callback?: () => void): void;
33
+ bindings(): Record<string, unknown>;
34
+ /** Replace the bindings carried on every line from here on. */
35
+ setBindings(bindings: Record<string, unknown>): void;
36
+ /** Numeric value of the current level. Mirrors the peer. */
37
+ readonly levelVal: number;
38
+ /** Prefix prepended to every message. Mirrors the peer. */
39
+ readonly msgPrefix: string | undefined;
40
+ /** Callback run on creation of a child. Assignable, like the peer. */
41
+ onChild: (child: Logger) => void;
42
+ levels: {
43
+ values: Record<string, number>;
44
+ labels: Record<number, string>;
45
+ };
46
+ isLevelEnabled(level: string): boolean;
47
+ }
48
+ /**
49
+ * Whether a log call at `method` emits under `currentLevel`. Unknown
50
+ * requested levels are disabled, matching the peer: without the check a
51
+ * misspelled level maps to Infinity and wrongly enables guarded work.
52
+ */
53
+ export declare const isFallbackLevelEnabled: (method: string, currentLevel: string) => boolean;
54
+ export interface FallbackLineInput {
55
+ method: string;
56
+ currentLevel: string;
57
+ bindings: Record<string, unknown>;
58
+ msgPrefix?: string;
59
+ args: unknown[];
60
+ }
61
+ /**
62
+ * Render one fallback log line, or `undefined` when the level disables it.
63
+ * Pure so tests can exercise redaction, Error handling and formatting
64
+ * without hiding the `pino` peer. Never throws.
65
+ */
66
+ export declare const formatFallbackLine: ({ method, currentLevel, bindings, msgPrefix, args }: FallbackLineInput) => string | undefined;
11
67
  declare const _default: Logger;
12
68
  export default _default;
13
69
  //# sourceMappingURL=logger.d.ts.map
@@ -1,4 +1,4 @@
1
- import { createRequire } from 'node:module';
1
+ import { loadOptionalPeer } from './optional-peer.js';
2
2
  const DEFAULT_LEVEL = 'info';
3
3
  const REDACTED_PATHS = [
4
4
  'creds',
@@ -17,6 +17,301 @@ const REDACTED_PATHS = [
17
17
  '*.privateKey',
18
18
  '*.secretKey'
19
19
  ];
20
+ const FALLBACK_LEVEL_VALUES = {
21
+ trace: 10,
22
+ debug: 20,
23
+ info: 30,
24
+ warn: 40,
25
+ error: 50,
26
+ fatal: 60,
27
+ silent: Infinity
28
+ };
29
+ const FALLBACK_LEVEL_LABELS = Object.fromEntries(Object.entries(FALLBACK_LEVEL_VALUES).map(([name, value]) => [value, name]));
30
+ const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
31
+ const CIRCULAR_SENTINEL = '[Circular]';
32
+ const UNSERIALIZABLE_SENTINEL = '[Unserializable]';
33
+ const readProperty = (holder, key) => {
34
+ try {
35
+ return holder[key];
36
+ }
37
+ catch {
38
+ return UNSERIALIZABLE_SENTINEL;
39
+ }
40
+ };
41
+ /** An Error as plain data: type, message and stack survive serialization. */
42
+ const errorToRecord = (error) => {
43
+ const record = { type: error.name, message: error.message };
44
+ if (typeof error.stack === 'string')
45
+ record.stack = error.stack;
46
+ const fields = error;
47
+ for (const key of Object.keys(error))
48
+ record[key] = readProperty(fields, key);
49
+ if ('cause' in error)
50
+ record.cause = readProperty(fields, 'cause');
51
+ return record;
52
+ };
53
+ /**
54
+ * Deep-clone a logged value into JSON-safe data. Circular references become
55
+ * `[Circular]`, `BigInt` its string form, `Error` a record carrying message
56
+ * and stack. Never throws: logging must not crash the process it observes.
57
+ */
58
+ const cloneForLog = (value, seen = new Set()) => {
59
+ try {
60
+ if (typeof value === 'bigint')
61
+ return String(value);
62
+ if (value instanceof Error)
63
+ return cloneForLog(errorToRecord(value), seen);
64
+ if (Array.isArray(value)) {
65
+ if (seen.has(value))
66
+ return CIRCULAR_SENTINEL;
67
+ seen.add(value);
68
+ const copy = value.map(entry => cloneForLog(entry, seen));
69
+ seen.delete(value);
70
+ return copy;
71
+ }
72
+ if (isPlainObject(value)) {
73
+ if (seen.has(value))
74
+ return CIRCULAR_SENTINEL;
75
+ seen.add(value);
76
+ const copy = {};
77
+ for (const key of Object.keys(value))
78
+ copy[key] = cloneForLog(readProperty(value, key), seen);
79
+ seen.delete(value);
80
+ return copy;
81
+ }
82
+ return value;
83
+ }
84
+ catch {
85
+ return UNSERIALIZABLE_SENTINEL;
86
+ }
87
+ };
88
+ const safeStringify = (value) => JSON.stringify(cloneForLog(value)) ?? UNSERIALIZABLE_SENTINEL;
89
+ const censorPath = (root, path) => {
90
+ if (path.startsWith('*.')) {
91
+ const key = path.slice(2);
92
+ for (const value of Object.values(root)) {
93
+ if (isPlainObject(value) && key in value)
94
+ value[key] = '[REDACTED]';
95
+ }
96
+ if (key in root)
97
+ root[key] = '[REDACTED]';
98
+ return;
99
+ }
100
+ const segments = path.split('.');
101
+ let current = root;
102
+ for (let index = 0; index < segments.length - 1; index++) {
103
+ if (!isPlainObject(current))
104
+ return;
105
+ current = current[segments[index]];
106
+ }
107
+ if (isPlainObject(current)) {
108
+ const leaf = segments[segments.length - 1];
109
+ if (leaf in current)
110
+ current[leaf] = '[REDACTED]';
111
+ }
112
+ };
113
+ const redactForFallback = (value) => {
114
+ const copy = cloneForLog(value);
115
+ if (isPlainObject(copy)) {
116
+ for (const path of REDACTED_PATHS)
117
+ censorPath(copy, path);
118
+ }
119
+ else if (Array.isArray(copy)) {
120
+ // Arrays skip the per-call object branch downstream and land under
121
+ // `data`, so redact each element the same way. Without this a
122
+ // `[{ privateKey }]` payload leaks while `{ privateKey }` does not.
123
+ for (const entry of copy) {
124
+ if (isPlainObject(entry))
125
+ for (const path of REDACTED_PATHS)
126
+ censorPath(entry, path);
127
+ }
128
+ }
129
+ return copy;
130
+ };
131
+ /**
132
+ * Minimal `%s`/`%d`/`%i`/`%f`/`%j`/`%o`/`%O` interpolation for the fallback,
133
+ * mirroring the peer's printf-style messages without adding a dependency.
134
+ * Leftover arguments are appended rather than dropped so no detail is lost.
135
+ */
136
+ const formatFallbackMessage = (message, args) => {
137
+ let index = 0;
138
+ const formatted = message.replace(/%[sdifjoO%]/g, match => {
139
+ if (match === '%%')
140
+ return '%';
141
+ if (index >= args.length)
142
+ return match;
143
+ const arg = args[index++];
144
+ switch (match) {
145
+ case '%s':
146
+ return String(arg);
147
+ case '%d':
148
+ case '%i':
149
+ case '%f':
150
+ return String(Number(arg));
151
+ default:
152
+ return safeStringify(arg);
153
+ }
154
+ });
155
+ const rest = args.slice(index).map(entry => (typeof entry === 'string' ? entry : safeStringify(entry)));
156
+ return rest.length > 0 ? `${formatted} ${rest.join(' ')}` : formatted;
157
+ };
158
+ const levelValue = (level, fallback) => FALLBACK_LEVEL_VALUES[level] ?? fallback;
159
+ /**
160
+ * Whether a log call at `method` emits under `currentLevel`. Unknown
161
+ * requested levels are disabled, matching the peer: without the check a
162
+ * misspelled level maps to Infinity and wrongly enables guarded work.
163
+ */
164
+ export const isFallbackLevelEnabled = (method, currentLevel) => {
165
+ if (currentLevel === 'silent')
166
+ return false;
167
+ const want = FALLBACK_LEVEL_VALUES[method];
168
+ if (want === undefined)
169
+ return false;
170
+ return want >= levelValue(currentLevel, 30);
171
+ };
172
+ /**
173
+ * Render one fallback log line, or `undefined` when the level disables it.
174
+ * Pure so tests can exercise redaction, Error handling and formatting
175
+ * without hiding the `pino` peer. Never throws.
176
+ */
177
+ export const formatFallbackLine = ({ method, currentLevel, bindings, msgPrefix, args }) => {
178
+ if (!isFallbackLevelEnabled(method, currentLevel))
179
+ return undefined;
180
+ let logged;
181
+ let message;
182
+ const [first, second, ...rest] = args;
183
+ if (typeof first === 'string') {
184
+ message = formatFallbackMessage(first, second === undefined ? rest : [second, ...rest]);
185
+ }
186
+ else if (args.length > 0) {
187
+ logged = redactForFallback(first);
188
+ if (typeof second === 'string')
189
+ message = formatFallbackMessage(second, rest);
190
+ else if (second !== undefined)
191
+ logged = [logged, cloneForLog(second), ...rest.map(entry => cloneForLog(entry))];
192
+ }
193
+ if (msgPrefix)
194
+ message = `${msgPrefix}${message ?? ''}`;
195
+ const entry = {
196
+ level: levelValue(method, 30),
197
+ time: new Date().toJSON(),
198
+ ...redactForFallback(bindings)
199
+ };
200
+ if (isPlainObject(logged))
201
+ Object.assign(entry, logged);
202
+ else if (logged !== undefined)
203
+ entry.data = logged;
204
+ if (message !== undefined)
205
+ entry.msg = message;
206
+ try {
207
+ return JSON.stringify(entry);
208
+ }
209
+ catch {
210
+ return JSON.stringify({ level: entry.level, time: entry.time, msg: UNSERIALIZABLE_SENTINEL });
211
+ }
212
+ };
213
+ /** Stdout is process-global, so pending-write tracking is too. */
214
+ let fallbackPendingWrites = 0;
215
+ const fallbackFlushWaiters = [];
216
+ const noteFallbackDelivered = () => {
217
+ fallbackPendingWrites--;
218
+ if (fallbackPendingWrites === 0) {
219
+ for (const resume of fallbackFlushWaiters.splice(0, fallbackFlushWaiters.length))
220
+ resume();
221
+ }
222
+ };
223
+ const writeFallbackLine = (line) => {
224
+ fallbackPendingWrites++;
225
+ let settled = false;
226
+ const delivered = () => {
227
+ if (settled)
228
+ return;
229
+ settled = true;
230
+ noteFallbackDelivered();
231
+ };
232
+ try {
233
+ process.stdout.write(`${line}\n`, delivered);
234
+ }
235
+ catch {
236
+ delivered();
237
+ }
238
+ };
239
+ /**
240
+ * Console-backed logger used only when `pino` is not installed. Emits one
241
+ * JSON line per call with the same `level`/`time`/`msg` shape operators
242
+ * already parse, redacts the same credential paths from both per-call
243
+ * objects and child bindings, serializes `Error` values with their message
244
+ * and stack, and honors `level` and `child` bindings so level-gated code
245
+ * keeps working. A documented step down from the peer, never a crash.
246
+ */
247
+ const createFallbackLogger = (state) => {
248
+ const write = (method, args) => {
249
+ const line = formatFallbackLine({
250
+ method,
251
+ currentLevel: state.level,
252
+ bindings: state.bindings,
253
+ msgPrefix: state.msgPrefix,
254
+ args
255
+ });
256
+ if (line !== undefined)
257
+ writeFallbackLine(line);
258
+ };
259
+ const logger = {
260
+ get level() {
261
+ return state.level;
262
+ },
263
+ set level(next) {
264
+ state.level = next;
265
+ },
266
+ get levelVal() {
267
+ return levelValue(state.level, 30);
268
+ },
269
+ get msgPrefix() {
270
+ return state.msgPrefix;
271
+ },
272
+ get onChild() {
273
+ return state.onChild;
274
+ },
275
+ set onChild(callback) {
276
+ state.onChild = callback;
277
+ },
278
+ child: (extra, options) => {
279
+ const created = createFallbackLogger({
280
+ level: options?.level ?? state.level,
281
+ msgPrefix: `${state.msgPrefix ?? ''}${typeof options?.msgPrefix === 'string' ? options.msgPrefix : ''}` || undefined,
282
+ onChild: state.onChild,
283
+ bindings: { ...state.bindings, ...extra }
284
+ });
285
+ state.onChild(created);
286
+ return created;
287
+ },
288
+ trace: (...args) => write('trace', args),
289
+ debug: (...args) => write('debug', args),
290
+ info: (...args) => write('info', args),
291
+ warn: (...args) => write('warn', args),
292
+ error: (...args) => write('error', args),
293
+ fatal: (...args) => write('fatal', args),
294
+ silent: () => { },
295
+ flush: (callback) => {
296
+ // Drain-aware: when stdout is a pipe, earlier lines may still be
297
+ // queued, and exiting from the callback would lose them.
298
+ if (!callback)
299
+ return;
300
+ if (fallbackPendingWrites === 0)
301
+ callback();
302
+ else
303
+ fallbackFlushWaiters.push(callback);
304
+ },
305
+ bindings: () => ({ ...state.bindings }),
306
+ setBindings: (extra) => {
307
+ Object.assign(state.bindings, extra);
308
+ },
309
+ levels: { values: { ...FALLBACK_LEVEL_VALUES }, labels: { ...FALLBACK_LEVEL_LABELS } },
310
+ isLevelEnabled: (level) => isFallbackLevelEnabled(level, state.level)
311
+ };
312
+ return logger;
313
+ };
314
+ const loadPinoPeer = () => loadOptionalPeer('pino');
20
315
  /**
21
316
  * Deferred because building pino at module evaluation cost ~10 MB of RSS in every
22
317
  * importing process: ~4.5 MB for pino's module graph, the rest for the Date/ICU
@@ -30,20 +325,23 @@ const REDACTED_PATHS = [
30
325
  let rootLogger;
31
326
  const resolveRootLogger = () => {
32
327
  if (!rootLogger) {
33
- const requireFrom = createRequire(import.meta.url);
34
- const pino = requireFrom('pino');
35
- rootLogger = pino({
36
- name: 'baileyrs',
37
- level: process.env.BAILEYRS_LOG_LEVEL || DEFAULT_LEVEL,
38
- timestamp: () => `,"time":"${new Date().toJSON()}"`,
39
- redact: { paths: REDACTED_PATHS, censor: '[REDACTED]' }
40
- });
328
+ const configuredLevel = process.env.BAILEYRS_LOG_LEVEL || DEFAULT_LEVEL;
329
+ const peer = loadPinoPeer();
330
+ rootLogger = peer
331
+ ? peer({
332
+ name: 'baileyrs',
333
+ level: configuredLevel,
334
+ timestamp: () => `,"time":"${new Date().toJSON()}"`,
335
+ redact: { paths: REDACTED_PATHS, censor: '[REDACTED]' }
336
+ })
337
+ : createFallbackLogger({ level: configuredLevel, onChild: () => { }, bindings: { name: 'baileyrs' } });
41
338
  }
42
339
  return rootLogger;
43
340
  };
44
341
  const createDeferredLogger = (bindings, parent, childOptions) => {
45
342
  let resolved;
46
343
  let pendingLevel;
344
+ let pendingOnChild;
47
345
  const members = new Map();
48
346
  const resolve = () => {
49
347
  if (!resolved) {
@@ -51,6 +349,8 @@ const createDeferredLogger = (bindings, parent, childOptions) => {
51
349
  resolved = bindings ? source.child(bindings, childOptions) : source;
52
350
  if (pendingLevel !== undefined)
53
351
  resolved.level = pendingLevel;
352
+ if (pendingOnChild !== undefined)
353
+ resolved.onChild = pendingOnChild;
54
354
  }
55
355
  return resolved;
56
356
  };
@@ -63,8 +363,8 @@ const createDeferredLogger = (bindings, parent, childOptions) => {
63
363
  const self = { level: peekLevel, resolve };
64
364
  // Hoisted so `logger.child` keeps the stable identity a plain property has.
65
365
  const child = (extra, options) => createDeferredLogger(extra, self, options);
66
- // Typed as pino's Logger, not ILogger: narrowing would reject `logger.fatal(...)`
67
- // at compile time even though the proxy forwards it.
366
+ // Typed as the full Logger, not ILogger: narrowing would reject
367
+ // `logger.fatal(...)` at compile time even though the proxy forwards it.
68
368
  const target = {};
69
369
  return new Proxy(target, {
70
370
  get(_target, property) {
@@ -72,6 +372,8 @@ const createDeferredLogger = (bindings, parent, childOptions) => {
72
372
  return child;
73
373
  if (property === 'level' && !resolved)
74
374
  return peekLevel();
375
+ if (property === 'onChild' && !resolved && pendingOnChild !== undefined)
376
+ return pendingOnChild;
75
377
  const cached = members.get(property);
76
378
  if (cached !== undefined)
77
379
  return cached;
@@ -88,9 +390,15 @@ const createDeferredLogger = (bindings, parent, childOptions) => {
88
390
  pendingLevel = value;
89
391
  return true;
90
392
  }
393
+ if (property === 'onChild' && !resolved) {
394
+ // Stored like `level`: assigning a hook must not build the
395
+ // logger the hook observes.
396
+ pendingOnChild = value;
397
+ return true;
398
+ }
91
399
  ;
92
400
  resolve()[property] = value;
93
- // Whole cache, not just this key: pino swaps its log methods for noops
401
+ // Whole cache, not just this key: the peer swaps its log methods for noops
94
402
  // when `level` changes, so a cached `info` would stay silent forever.
95
403
  members.clear();
96
404
  return true;
@@ -1,3 +1,11 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
1
9
  import { Buffer } from 'node:buffer';
2
10
  import { execFile } from 'node:child_process';
3
11
  import { randomBytes } from 'node:crypto';
@@ -113,7 +121,19 @@ export const mediaMessageSHA256B64 = (message) => {
113
121
  };
114
122
  /** Returns audio duration in seconds, parsed via `music-metadata`. */
115
123
  export async function getAudioDuration(buffer) {
116
- const musicMetadata = await import('music-metadata');
124
+ // `music-metadata` is an optional peer: without it the duration is simply
125
+ // unknown and the caller sends without `seconds`. The specifier cast keeps
126
+ // bundlers from failing the build when the peer is absent, the same trick
127
+ // `link-preview.ts` uses for `link-preview-js`. Only the import is
128
+ // guarded: parser failures still throw so the caller's warning reports
129
+ // corrupt audio instead of silently dropping the duration.
130
+ let musicMetadata;
131
+ try {
132
+ musicMetadata = await import(__rewriteRelativeImportExtension('music-metadata'));
133
+ }
134
+ catch {
135
+ return undefined;
136
+ }
117
137
  let metadata;
118
138
  const options = {
119
139
  duration: true
@@ -0,0 +1,20 @@
1
+ /** Resolution and loading behind {@link loadOptionalPeer}. Injected in tests. */
2
+ export interface PeerLoader {
3
+ resolveSpecifier(specifier: string): string;
4
+ requireSpecifier(specifier: string): unknown;
5
+ }
6
+ /** Filesystem-backed loader, rooted at the importing module. */
7
+ export declare const nodePeerLoader: (baseUrl: string) => PeerLoader;
8
+ /**
9
+ * Load an optional peer, distinguishing "not installed" from
10
+ * "installed but broken".
11
+ *
12
+ * Presence is probed through the package manifest, which resolves whenever
13
+ * the package is installed regardless of the state of its entry point. Only
14
+ * a missing manifest falls back. Anything else — a broken entry point, a
15
+ * missing nested dependency — surfaces as an explicit error naming the
16
+ * peer, so a damaged installation is never silently hidden behind the
17
+ * fallback.
18
+ */
19
+ export declare const loadOptionalPeer: <Module>(specifier: string, loader?: PeerLoader) => Module | undefined;
20
+ //# sourceMappingURL=optional-peer.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { createRequire } from 'node:module';
2
+ /** Filesystem-backed loader, rooted at the importing module. */
3
+ export const nodePeerLoader = (baseUrl) => {
4
+ const requireFrom = createRequire(baseUrl);
5
+ return {
6
+ resolveSpecifier: specifier => requireFrom.resolve(specifier),
7
+ requireSpecifier: specifier => requireFrom(specifier)
8
+ };
9
+ };
10
+ const isAbsent = (error) => error?.code === 'MODULE_NOT_FOUND';
11
+ /**
12
+ * Load an optional peer, distinguishing "not installed" from
13
+ * "installed but broken".
14
+ *
15
+ * Presence is probed through the package manifest, which resolves whenever
16
+ * the package is installed regardless of the state of its entry point. Only
17
+ * a missing manifest falls back. Anything else — a broken entry point, a
18
+ * missing nested dependency — surfaces as an explicit error naming the
19
+ * peer, so a damaged installation is never silently hidden behind the
20
+ * fallback.
21
+ */
22
+ export const loadOptionalPeer = (specifier, loader = nodePeerLoader(import.meta.url)) => {
23
+ try {
24
+ loader.resolveSpecifier(`${specifier}/package.json`);
25
+ }
26
+ catch (error) {
27
+ if (isAbsent(error))
28
+ return undefined;
29
+ throw error;
30
+ }
31
+ try {
32
+ return loader.requireSpecifier(specifier);
33
+ }
34
+ catch (error) {
35
+ throw new Error(`Failed to load optional peer '${specifier}': it is installed but broken. ` +
36
+ `Reinstall it, or remove it to use the built-in fallback.`, { cause: error });
37
+ }
38
+ };
39
+ //# sourceMappingURL=optional-peer.js.map
@@ -1,6 +1,69 @@
1
1
  // Generated by scripts/compatibility/waproto-facade.ts. Do not edit.
2
2
  // Type-only Baileys compatibility facade; runtime codecs remain whatsapp-rust-bridge.
3
- import * as $protobuf from "protobufjs";
3
+ declare namespace $protobuf {
4
+ interface Long {
5
+ low: number;
6
+ high: number;
7
+ unsigned: boolean;
8
+ }
9
+ interface Writer {
10
+ len: number;
11
+ head: object;
12
+ tail: object;
13
+ states: (object|null);
14
+ uint32(value: number): Writer;
15
+ int32(value: number): Writer;
16
+ sint32(value: number): Writer;
17
+ uint64(value: (Long|number|string)): Writer;
18
+ int64(value: (Long|number|string)): Writer;
19
+ sint64(value: (Long|number|string)): Writer;
20
+ bool(value: boolean): Writer;
21
+ fixed32(value: number): Writer;
22
+ sfixed32(value: number): Writer;
23
+ fixed64(value: (Long|number|string)): Writer;
24
+ sfixed64(value: (Long|number|string)): Writer;
25
+ float(value: number): Writer;
26
+ double(value: number): Writer;
27
+ bytes(value: (Uint8Array|string)): Writer;
28
+ string(value: string): Writer;
29
+ fork(): Writer;
30
+ reset(): Writer;
31
+ ldelim(): Writer;
32
+ finish(): Uint8Array;
33
+ }
34
+ interface Reader {
35
+ buf: Uint8Array;
36
+ pos: number;
37
+ len: number;
38
+ uint32(): number;
39
+ int32(): number;
40
+ sint32(): number;
41
+ int64(): Long;
42
+ uint64(): Long;
43
+ sint64(): Long;
44
+ bool(): boolean;
45
+ fixed32(): number;
46
+ sfixed32(): number;
47
+ fixed64(): Long;
48
+ sfixed64(): Long;
49
+ float(): number;
50
+ double(): number;
51
+ bytes(): Uint8Array;
52
+ string(): string;
53
+ skip(length?: number): Reader;
54
+ skipType(wireType: number, depth?: number): Reader;
55
+ }
56
+ interface IConversionOptions {
57
+ longs?: Function;
58
+ enums?: Function;
59
+ bytes?: Function;
60
+ defaults?: boolean;
61
+ arrays?: boolean;
62
+ objects?: boolean;
63
+ oneofs?: boolean;
64
+ json?: boolean;
65
+ }
66
+ }
4
67
  import Long = require("long");
5
68
  export namespace proto {
6
69
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oxidezap/baileyrs",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.3.4",
5
5
  "description": "A Rust-powered WhatsApp Web library for JavaScript, with a Baileys-compatible API",
6
6
  "keywords": [
7
7
  "whatsapp",
@@ -82,14 +82,12 @@
82
82
  "test:e2e": "NODE_TLS_REJECT_UNAUTHORIZED=0 ADV_SECRET_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= node --expose-gc --test --test-concurrency=1 ./src/__tests__/e2e/*.test-e2e.ts ./scripts/compatibility/__tests__/*.test-e2e.ts"
83
83
  },
84
84
  "dependencies": {
85
- "@hapi/boom": "^10.0.1",
86
- "@oxidezap/whatsapp-rust-bridge": "0.21.3",
87
- "long": "^5.3.2",
88
- "pino": "^10.3.1",
89
- "protobufjs": "^8.8.0"
85
+ "@oxidezap/whatsapp-rust-bridge": "0.21.4",
86
+ "long": "^5.3.2"
90
87
  },
91
88
  "devDependencies": {
92
89
  "@bufbuild/protobuf": "^2.13.0",
90
+ "@hapi/boom": "^10.0.1",
93
91
  "@types/node": "^26.1.1",
94
92
  "baileys": "7.0.0-rc14",
95
93
  "jimp": "^1.6.0",
@@ -97,19 +95,27 @@
97
95
  "music-metadata": "^11.14.0",
98
96
  "oxfmt": "^0.66.0",
99
97
  "oxlint": "1.81.0",
98
+ "pino": "^10.3.1",
100
99
  "pino-pretty": "^13.1.3",
101
100
  "pkg-pr-new": "^0.0.88",
101
+ "protobufjs": "^8.8.0",
102
102
  "tsc-esm-fix": "^3.1.2",
103
103
  "typescript": "^7.0.2",
104
104
  "typescript-compat-auditor": "npm:typescript@6.0.3"
105
105
  },
106
106
  "peerDependencies": {
107
+ "@hapi/boom": "^9.1.0 || ^10.0.0",
107
108
  "audio-decode": "^2.1.3",
108
109
  "jimp": "^1.6.0",
109
110
  "link-preview-js": "^3.0.0",
111
+ "music-metadata": "^11.14.0",
112
+ "pino": "^9.0.0 || ^10.0.0",
110
113
  "sharp": "*"
111
114
  },
112
115
  "peerDependenciesMeta": {
116
+ "@hapi/boom": {
117
+ "optional": true
118
+ },
113
119
  "audio-decode": {
114
120
  "optional": true
115
121
  },
@@ -119,13 +125,16 @@
119
125
  "link-preview-js": {
120
126
  "optional": true
121
127
  },
128
+ "music-metadata": {
129
+ "optional": true
130
+ },
131
+ "pino": {
132
+ "optional": true
133
+ },
122
134
  "sharp": {
123
135
  "optional": true
124
136
  }
125
137
  },
126
- "overrides": {
127
- "protobufjs": "^8.8.0"
128
- },
129
138
  "publishConfig": {
130
139
  "access": "public"
131
140
  },