@moxxy/plugin-channel-whatsapp 0.41.3 → 0.42.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/dist/pair-flow.d.ts.map +1 -1
- package/dist/pair-flow.js +8 -21
- package/dist/pair-flow.js.map +1 -1
- package/package.json +9 -9
- package/src/auth-state.test.ts +4 -2
- package/src/channel.test.ts +2 -1
- package/src/pair-flow.ts +8 -21
- package/src/subcommands.test.ts +2 -1
package/dist/pair-flow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pair-flow.d.ts","sourceRoot":"","sources":["../src/pair-flow.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"pair-flow.d.ts","sourceRoot":"","sources":["../src/pair-flow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAU1E;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqFxF"}
|
package/dist/pair-flow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { log, outro, spinner } from '@clack/prompts';
|
|
2
2
|
import QRCode from 'qrcode';
|
|
3
|
-
import {
|
|
3
|
+
import { finishPairing } from '@moxxy/sdk';
|
|
4
4
|
import { WhatsAppChannel } from './channel.js';
|
|
5
5
|
import { CONSENT_REQUIRED_MESSAGE } from './consent.js';
|
|
6
6
|
import { ensureConsentInteractive } from './consent-prompt.js';
|
|
@@ -83,26 +83,13 @@ export async function runWhatsAppPairFlow(ctx) {
|
|
|
83
83
|
spin.start('Waiting for the scan (the QR refreshes periodically)...');
|
|
84
84
|
const ownerJid = await paired;
|
|
85
85
|
spin.stop(`Linked as ${ownerJid}. Your Note-to-Self chat now talks to moxxy.`);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
await stopChannel();
|
|
94
|
-
return 0;
|
|
95
|
-
}
|
|
96
|
-
log.info('Channel is running. Press Ctrl+C to stop.');
|
|
97
|
-
try {
|
|
98
|
-
await handle.running;
|
|
99
|
-
return 0;
|
|
100
|
-
}
|
|
101
|
-
finally {
|
|
102
|
-
unsubscribeConnect();
|
|
103
|
-
process.removeListener('SIGINT', onSignal);
|
|
104
|
-
process.removeListener('SIGTERM', onSignal);
|
|
105
|
-
}
|
|
86
|
+
// Drop the pairing-only handlers first: their `process.exit` would otherwise
|
|
87
|
+
// cut the real channel (or an orchestrator) short. The linked credentials are
|
|
88
|
+
// persisted, so the restarted channel reconnects without a new QR.
|
|
89
|
+
unsubscribeConnect();
|
|
90
|
+
process.removeListener('SIGINT', onSignal);
|
|
91
|
+
process.removeListener('SIGTERM', onSignal);
|
|
92
|
+
return finishPairing(ctx, stopChannel);
|
|
106
93
|
}
|
|
107
94
|
/** Render the rotating pairing payload as a scannable terminal QR. */
|
|
108
95
|
async function printPairQr(payload) {
|
package/dist/pair-flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pair-flow.js","sourceRoot":"","sources":["../src/pair-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pair-flow.js","sourceRoot":"","sources":["../src/pair-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAiC,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAA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O,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxxy/plugin-channel-whatsapp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"description": "WhatsApp channel for moxxy via Baileys (UNOFFICIAL WhatsApp Web protocol — violates WhatsApp's Terms of Service; the linked number can be banned, use a secondary number). QR device-link pairing, JID allow-list, voice-note transcription, dedicated isolated runner.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"moxxy",
|
|
@@ -75,18 +75,18 @@
|
|
|
75
75
|
"@whiskeysockets/baileys": "^6.7.21",
|
|
76
76
|
"qrcode": "^1.5.4",
|
|
77
77
|
"zod": "^3.25.76",
|
|
78
|
-
"@moxxy/
|
|
79
|
-
"@moxxy/
|
|
80
|
-
"@moxxy/
|
|
81
|
-
"@moxxy/
|
|
78
|
+
"@moxxy/channel-kit": "0.42.1",
|
|
79
|
+
"@moxxy/core": "0.42.1",
|
|
80
|
+
"@moxxy/plugin-vault": "0.42.1",
|
|
81
|
+
"@moxxy/sdk": "0.42.1"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@types/node": "^22.
|
|
84
|
+
"@types/node": "^22.20.5",
|
|
85
85
|
"@types/qrcode": "^1.5.5",
|
|
86
86
|
"typescript": "^6.0.3",
|
|
87
|
-
"vitest": "^
|
|
88
|
-
"@moxxy/mode-default": "0.
|
|
89
|
-
"@moxxy/testing": "0.0.
|
|
87
|
+
"vitest": "^5.0.3",
|
|
88
|
+
"@moxxy/mode-default": "0.42.1",
|
|
89
|
+
"@moxxy/testing": "0.0.72",
|
|
90
90
|
"@moxxy/tsconfig": "0.0.0",
|
|
91
91
|
"@moxxy/vitest-preset": "0.0.0"
|
|
92
92
|
},
|
package/src/auth-state.test.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { promises as fs } from 'node:fs';
|
|
|
2
2
|
import * as os from 'node:os';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { posixFileModes } from '@moxxy/vitest-preset/platform';
|
|
5
6
|
import {
|
|
6
7
|
createFileAuthStorage,
|
|
7
8
|
createWhatsAppAuthState,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
type BaileysAuthBridge,
|
|
11
12
|
type WhatsAppAuthStorage,
|
|
12
13
|
} from './auth-state.js';
|
|
14
|
+
import { removeDir } from '@moxxy/vitest-preset/fs';
|
|
13
15
|
|
|
14
16
|
// A trivial bridge: identity JSON (no Buffer categories), fresh creds counter.
|
|
15
17
|
function fakeBridge(): BaileysAuthBridge {
|
|
@@ -83,7 +85,7 @@ describe('createFileAuthStorage', () => {
|
|
|
83
85
|
dir = await fs.mkdtemp(path.join(os.tmpdir(), 'wa-auth-'));
|
|
84
86
|
});
|
|
85
87
|
afterEach(async () => {
|
|
86
|
-
await
|
|
88
|
+
await removeDir(dir);
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
it('writes 0600 files and clears the whole dir', async () => {
|
|
@@ -94,7 +96,7 @@ describe('createFileAuthStorage', () => {
|
|
|
94
96
|
|
|
95
97
|
const file = path.join(dir, 'auth', 'creds.json');
|
|
96
98
|
const mode = (await fs.stat(file)).mode & 0o777;
|
|
97
|
-
expect(mode).toBe(0o600);
|
|
99
|
+
if (posixFileModes) expect(mode).toBe(0o600);
|
|
98
100
|
|
|
99
101
|
await storage.clear();
|
|
100
102
|
expect(await storage.read('creds')).toBeNull();
|
package/src/channel.test.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
} from './socket.js';
|
|
19
19
|
import { createFileAuthStorage } from './auth-state.js';
|
|
20
20
|
import { WHATSAPP_CONSENT_ENV } from './keys.js';
|
|
21
|
+
import { removeDir } from '@moxxy/vitest-preset/fs';
|
|
21
22
|
|
|
22
23
|
const OWNER = '15550000000@s.whatsapp.net';
|
|
23
24
|
const FRIEND = '15551111111@s.whatsapp.net';
|
|
@@ -115,7 +116,7 @@ afterEach(async () => {
|
|
|
115
116
|
// a single rm can race it (ENOTEMPTY). Retry briefly, then give up.
|
|
116
117
|
for (let i = 0; i < 5; i++) {
|
|
117
118
|
try {
|
|
118
|
-
await
|
|
119
|
+
await removeDir(tmp);
|
|
119
120
|
break;
|
|
120
121
|
} catch {
|
|
121
122
|
await new Promise((r) => setTimeout(r, 20));
|
package/src/pair-flow.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { log, outro, spinner } from '@clack/prompts';
|
|
2
2
|
import QRCode from 'qrcode';
|
|
3
|
-
import {
|
|
3
|
+
import { finishPairing, type ChannelSubcommandContext } from '@moxxy/sdk';
|
|
4
4
|
import type { VaultStore } from '@moxxy/plugin-vault';
|
|
5
5
|
import { WhatsAppChannel } from './channel.js';
|
|
6
6
|
import { CONSENT_REQUIRED_MESSAGE } from './consent.js';
|
|
@@ -97,26 +97,13 @@ export async function runWhatsAppPairFlow(ctx: ChannelSubcommandContext): Promis
|
|
|
97
97
|
const ownerJid = await paired;
|
|
98
98
|
spin.stop(`Linked as ${ownerJid}. Your Note-to-Self chat now talks to moxxy.`);
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
await stopChannel();
|
|
108
|
-
return 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
log.info('Channel is running. Press Ctrl+C to stop.');
|
|
112
|
-
try {
|
|
113
|
-
await handle.running;
|
|
114
|
-
return 0;
|
|
115
|
-
} finally {
|
|
116
|
-
unsubscribeConnect();
|
|
117
|
-
process.removeListener('SIGINT', onSignal);
|
|
118
|
-
process.removeListener('SIGTERM', onSignal);
|
|
119
|
-
}
|
|
100
|
+
// Drop the pairing-only handlers first: their `process.exit` would otherwise
|
|
101
|
+
// cut the real channel (or an orchestrator) short. The linked credentials are
|
|
102
|
+
// persisted, so the restarted channel reconnects without a new QR.
|
|
103
|
+
unsubscribeConnect();
|
|
104
|
+
process.removeListener('SIGINT', onSignal);
|
|
105
|
+
process.removeListener('SIGTERM', onSignal);
|
|
106
|
+
return finishPairing(ctx, stopChannel);
|
|
120
107
|
}
|
|
121
108
|
|
|
122
109
|
/** Render the rotating pairing payload as a scannable terminal QR. */
|
package/src/subcommands.test.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
WHATSAPP_CONSENT_KEY,
|
|
12
12
|
WHATSAPP_OWNER_JID_KEY,
|
|
13
13
|
} from './keys.js';
|
|
14
|
+
import { removeDir } from '@moxxy/vitest-preset/fs';
|
|
14
15
|
|
|
15
16
|
let tmp: string;
|
|
16
17
|
let vault: VaultStore;
|
|
@@ -46,7 +47,7 @@ beforeEach(async () => {
|
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
afterEach(async () => {
|
|
49
|
-
await
|
|
50
|
+
await removeDir(tmp);
|
|
50
51
|
process.stdout.write = origOut;
|
|
51
52
|
process.stderr.write = origErr;
|
|
52
53
|
if (origHome === undefined) delete process.env.MOXXY_HOME;
|