@wsapichat/mcp-server 3.1.0 → 3.2.0

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.
@@ -13,6 +13,11 @@ export interface paths {
13
13
  /**
14
14
  * Get QR code for pairing
15
15
  * @description Returns a PNG image of the QR code to scan with WhatsApp.
16
+ *
17
+ * Returns 409 while a passkey verification step is pending (see `GET /session/passkey`):
18
+ * generating a new QR would disconnect the client and discard the in-progress pairing.
19
+ * Stop polling this endpoint while `passkeyStatus` on `GET /session/status` is
20
+ * `required`, `submitted` or `confirmation_required`.
16
21
  */
17
22
  get: operations["getQR"];
18
23
  put?: never;
@@ -33,6 +38,9 @@ export interface paths {
33
38
  /**
34
39
  * Get QR code as text
35
40
  * @description Returns the raw QR code string for clients that want to render the QR code themselves.
41
+ *
42
+ * Returns 409 while a passkey verification step is pending (see `GET /session/passkey`).
43
+ * Stop polling this endpoint until the step completes, fails or expires.
36
44
  */
37
45
  get: operations["getQRText"];
38
46
  put?: never;
@@ -50,7 +58,13 @@ export interface paths {
50
58
  path?: never;
51
59
  cookie?: never;
52
60
  };
53
- /** Get pair code for phone number */
61
+ /**
62
+ * Get pair code for phone number
63
+ * @description Generates a pair code to enter on the phone (Linked devices → Link with phone number).
64
+ *
65
+ * Returns 409 while a passkey verification step is pending (see `GET /session/passkey`).
66
+ * Stop requesting new pair codes until the step completes, fails or expires.
67
+ */
54
68
  get: operations["getPairCode"];
55
69
  put?: never;
56
70
  post?: never;
@@ -77,6 +91,145 @@ export interface paths {
77
91
  patch?: never;
78
92
  trace?: never;
79
93
  };
94
+ "/session/passkey": {
95
+ parameters: {
96
+ query?: never;
97
+ header?: never;
98
+ path?: never;
99
+ cookie?: never;
100
+ };
101
+ /**
102
+ * Get passkey verification state
103
+ * @description Returns the state of the passkey verification step, if any.
104
+ *
105
+ * On some accounts WhatsApp does not finish linking after the QR scan or pair code is
106
+ * accepted. Instead it asks the account owner to verify with their passkey, sending a
107
+ * standard WebAuthn challenge. While `status` is `required`, this endpoint returns that
108
+ * challenge in `challenge` (a `PublicKeyCredentialRequestOptionsJSON` object with
109
+ * base64url-encoded binary fields).
110
+ *
111
+ * The challenge must be signed with `navigator.credentials.get()` in a browser on the
112
+ * `https://web.whatsapp.com` origin (WebAuthn binds the origin into `clientDataJSON`, so
113
+ * a server cannot sign it on its own) — typically via a browser extension or a snippet
114
+ * pasted into the DevTools console on web.whatsapp.com. Submit the resulting assertion
115
+ * with `POST /session/passkey`.
116
+ *
117
+ * The step expires 5 minutes after it is requested (`expiresAt`); after that the status
118
+ * becomes `error` and a new QR or pair code must be generated. While the step is pending,
119
+ * `GET /session/qr`, `GET /session/qr/text` and `GET /session/pair-code/{phone}` return
120
+ * 409 — stop polling them. `GET /session/status` also reports the state as `passkeyStatus`,
121
+ * so a single poll is enough to notice the step.
122
+ *
123
+ * Statuses:
124
+ * - `none` — no passkey step in progress
125
+ * - `required` — WhatsApp is waiting for the passkey assertion; `challenge` and `origin` are set
126
+ * - `submitted` — the assertion was sent; waiting for WhatsApp to complete the link
127
+ * - `confirmation_required` — show `confirmationCode` to the user so they can check it
128
+ * matches the code on their phone and approve there. wsapi-app sends the confirmation
129
+ * automatically (`confirmationSent` becomes `true`); the link then completes by itself
130
+ * (`isLoggedIn` becomes `true`). No confirm call is needed.
131
+ * - `error` — the step failed or expired; see `error`
132
+ */
133
+ get: operations["getPasskeyState"];
134
+ put?: never;
135
+ /**
136
+ * Submit passkey assertion
137
+ * @description Forwards the WebAuthn assertion produced by the account owner's passkey to WhatsApp.
138
+ *
139
+ * The request body is the JSON from `PublicKeyCredential.toJSON()` (binary fields
140
+ * base64url-encoded) after calling `navigator.credentials.get()` on
141
+ * `https://web.whatsapp.com` with the `challenge` from `GET /session/passkey`, e.g.:
142
+ *
143
+ * ```js
144
+ * const options = PublicKeyCredential.parseRequestOptionsFromJSON(challenge);
145
+ * const credential = await navigator.credentials.get({ publicKey: options });
146
+ * const body = JSON.stringify(credential.toJSON());
147
+ * ```
148
+ *
149
+ * Only valid while the status is `required` and the step has not expired (5 minutes
150
+ * after it was requested); otherwise returns 409. On success the returned state is
151
+ * usually `submitted`, or `confirmation_required` if WhatsApp wants the user to confirm
152
+ * a code.
153
+ *
154
+ * Before forwarding, the assertion's `clientDataJSON` is checked locally: its `type` must
155
+ * be `webauthn.get`, its `origin` must be `https://web.whatsapp.com`, and its `challenge`
156
+ * must match the pending one. If any check fails the request returns 400 with a message
157
+ * explaining the mismatch, nothing is sent to WhatsApp, and the step stays `required` so
158
+ * the user can try again.
159
+ */
160
+ post: operations["submitPasskey"];
161
+ delete?: never;
162
+ options?: never;
163
+ head?: never;
164
+ patch?: never;
165
+ trace?: never;
166
+ };
167
+ "/session/passkey/request": {
168
+ parameters: {
169
+ query?: never;
170
+ header?: never;
171
+ path?: never;
172
+ cookie?: never;
173
+ };
174
+ get?: never;
175
+ put?: never;
176
+ /**
177
+ * Request passkey challenge
178
+ * @description Asks WhatsApp for a passkey challenge for an unpaired device. Use it when the account is
179
+ * known to use a passkey but WhatsApp's own notification (which normally sets the status to
180
+ * `required` after the QR scan or pair code) does not arrive, or to start a passkey-only
181
+ * link with no QR or pair code at all.
182
+ *
183
+ * No existing QR or pair-code connection is required: if the device is not connected, the
184
+ * call opens a connection itself (without a QR channel), waits a few seconds, then requests
185
+ * the challenge. Without a prior QR scan, WhatsApp returns a challenge for a discoverable
186
+ * credential (empty `allowCredentials`, `rpId` `whatsapp.com`, `timeout` 600000), and the
187
+ * passkey the user picks identifies the account. Returns 409 if that connection does not
188
+ * come up. If a challenge is already pending (status `required`, not expired), it is
189
+ * returned unchanged, so the call is idempotent. While a passkey step is active (from
190
+ * either source), QR code rotation is stopped so the QR timeout no longer disconnects
191
+ * the device mid-passkey.
192
+ * On success the state is `required` with `source: requested`; sign the `challenge` and
193
+ * submit it with `POST /session/passkey`.
194
+ *
195
+ * Without the QR handoff proof that a notification-driven challenge carries, WhatsApp asks
196
+ * the owner to approve the new device on their phone, so expect `confirmation_required`
197
+ * after submitting the assertion. The confirmation is sent automatically; show
198
+ * `confirmationCode` so the owner can compare it and approve on their phone.
199
+ */
200
+ post: operations["requestPasskey"];
201
+ delete?: never;
202
+ options?: never;
203
+ head?: never;
204
+ patch?: never;
205
+ trace?: never;
206
+ };
207
+ "/session/passkey/confirm": {
208
+ parameters: {
209
+ query?: never;
210
+ header?: never;
211
+ path?: never;
212
+ cookie?: never;
213
+ };
214
+ get?: never;
215
+ put?: never;
216
+ /**
217
+ * Confirm passkey pairing code
218
+ * @description Fallback / compatibility endpoint. wsapi-app now sends the confirmation automatically as
219
+ * soon as the status becomes `confirmation_required` (`confirmationSent` is `true` in
220
+ * `GET /session/passkey`); the user only compares `confirmationCode` and approves on their
221
+ * phone, and the link completes by itself. Clients do not need to call this.
222
+ *
223
+ * If the confirmation was already sent, returns 204 without doing anything. Otherwise
224
+ * sends it. Returns 409 if no step is in `confirmation_required` or the step has expired.
225
+ */
226
+ post: operations["confirmPasskey"];
227
+ delete?: never;
228
+ options?: never;
229
+ head?: never;
230
+ patch?: never;
231
+ trace?: never;
232
+ };
80
233
  "/session/logout": {
81
234
  parameters: {
82
235
  query?: never;
@@ -475,7 +628,7 @@ export interface paths {
475
628
  put?: never;
476
629
  /**
477
630
  * Create a new group
478
- * @description Create a new WhatsApp group with the specified name and initial participants.
631
+ * @description Create a new WhatsApp group with the specified name and optional initial participants.
479
632
  */
480
633
  post: operations["createGroup"];
481
634
  delete?: never;
@@ -1816,6 +1969,100 @@ export interface components {
1816
1969
  isConnected?: boolean;
1817
1970
  isLoggedIn?: boolean;
1818
1971
  deviceId?: string;
1972
+ /**
1973
+ * @description Passkey verification state (same as `status` from `GET /session/passkey`). While it is
1974
+ * `required`, `submitted` or `confirmation_required`, stop polling QR / pair-code endpoints.
1975
+ * @enum {string}
1976
+ */
1977
+ passkeyStatus?: "none" | "required" | "submitted" | "confirmation_required" | "error";
1978
+ };
1979
+ PasskeyState: {
1980
+ /**
1981
+ * @description Current passkey verification state
1982
+ * @enum {string}
1983
+ */
1984
+ status: "none" | "required" | "submitted" | "confirmation_required" | "error";
1985
+ /**
1986
+ * @description Where the challenge came from: `notification` (WhatsApp pushed it after the QR scan
1987
+ * or pair code) or `requested` (fetched via `POST /session/passkey/request`, which
1988
+ * usually leads to `confirmation_required`). Omitted when no step is in progress.
1989
+ * @enum {string}
1990
+ */
1991
+ source?: "notification" | "requested";
1992
+ /**
1993
+ * @description WebAuthn `PublicKeyCredentialRequestOptionsJSON` sent by WhatsApp, with binary fields
1994
+ * base64url-encoded (accepted by `PublicKeyCredential.parseRequestOptionsFromJSON`).
1995
+ * Pass it to `navigator.credentials.get()` on `origin`. Only set while `status` is `required`.
1996
+ */
1997
+ challenge?: {
1998
+ /** @description Challenge bytes (base64url, unpadded) */
1999
+ challenge?: string;
2000
+ /** @description Timeout in milliseconds */
2001
+ timeout?: number;
2002
+ /** @description Relying party ID */
2003
+ rpId?: string;
2004
+ allowCredentials?: {
2005
+ /** @description Credential ID (base64url, unpadded) */
2006
+ id?: string;
2007
+ /** @example public-key */
2008
+ type?: string;
2009
+ transports?: string[];
2010
+ }[];
2011
+ /** @example required */
2012
+ userVerification?: string;
2013
+ extensions?: {
2014
+ [key: string]: unknown;
2015
+ };
2016
+ };
2017
+ /**
2018
+ * @description Origin the challenge must be signed on. Only set while `status` is `required`.
2019
+ * @example https://web.whatsapp.com
2020
+ */
2021
+ origin?: string;
2022
+ /**
2023
+ * @description Code to show the user while `status` is `confirmation_required`. They must check it
2024
+ * matches the code on their phone and approve the link there.
2025
+ */
2026
+ confirmationCode?: string;
2027
+ /**
2028
+ * @description `true` once the confirmation has been sent to WhatsApp (sent automatically when
2029
+ * `status` becomes `confirmation_required`). Omitted until then.
2030
+ */
2031
+ confirmationSent?: boolean;
2032
+ /** @description Failure reason when `status` is `error` */
2033
+ error?: string;
2034
+ /**
2035
+ * Format: date-time
2036
+ * @description When WhatsApp requested the passkey verification
2037
+ */
2038
+ requestedAt?: string;
2039
+ /**
2040
+ * Format: date-time
2041
+ * @description When the step expires (5 minutes after `requestedAt`)
2042
+ */
2043
+ expiresAt?: string;
2044
+ };
2045
+ /**
2046
+ * @description WebAuthn assertion as produced by `PublicKeyCredential.toJSON()` in the browser.
2047
+ * Binary fields are base64url-encoded.
2048
+ */
2049
+ PasskeyAssertion: {
2050
+ /** @description Credential ID */
2051
+ id?: string;
2052
+ /** @description Raw credential ID (base64url) */
2053
+ rawId: string;
2054
+ /** @example public-key */
2055
+ type?: string;
2056
+ response: {
2057
+ /** @description Client data JSON (base64url) */
2058
+ clientDataJSON: string;
2059
+ /** @description Authenticator data (base64url) */
2060
+ authenticatorData?: string;
2061
+ /** @description Assertion signature (base64url) */
2062
+ signature: string;
2063
+ /** @description User handle (base64url), if returned by the authenticator */
2064
+ userHandle?: string | null;
2065
+ };
1819
2066
  };
1820
2067
  SendTextRequest: {
1821
2068
  /** @description Recipient JID (user or group) */
@@ -1984,8 +2231,8 @@ export interface components {
1984
2231
  };
1985
2232
  CreateGroupRequest: {
1986
2233
  name: string;
1987
- /** @description List of participant JIDs */
1988
- participants: string[];
2234
+ /** @description Initial participant JIDs. Omit or pass an empty array to create a group with only the paired account. */
2235
+ participants?: string[];
1989
2236
  };
1990
2237
  UpdateParticipantsRequest: {
1991
2238
  participants: string[];
@@ -2253,7 +2500,10 @@ export interface components {
2253
2500
  pictureId?: string;
2254
2501
  /** @description Profile picture URL (omitted if unavailable) */
2255
2502
  pictureUrl?: string;
2503
+ /** @description Whether the account is a verified WhatsApp Business account */
2256
2504
  isVerified?: boolean;
2505
+ /** @description Verified business name (omitted unless the account is a verified business) */
2506
+ verifiedName?: string;
2257
2507
  };
2258
2508
  UserMeInfo: components["schemas"]["Identity"] & {
2259
2509
  deviceId?: number;
@@ -2482,13 +2732,47 @@ export interface components {
2482
2732
  content: {
2483
2733
  /**
2484
2734
  * @example {
2485
- * "status": 403,
2735
+ * "status": 409,
2486
2736
  * "detail": "device not paired"
2487
2737
  * }
2488
2738
  */
2489
2739
  "application/json": components["schemas"]["Error"];
2490
2740
  };
2491
2741
  };
2742
+ /**
2743
+ * @description A passkey verification step is pending. Generating a new QR or pair code would discard
2744
+ * the in-progress pairing. Complete it via `/session/passkey` or wait for it to expire
2745
+ * (5 minutes after it was requested).
2746
+ */
2747
+ PasskeyPending: {
2748
+ headers: {
2749
+ [name: string]: unknown;
2750
+ };
2751
+ content: {
2752
+ /**
2753
+ * @example {
2754
+ * "status": 409,
2755
+ * "detail": "passkey verification pending: complete it via /session/passkey or wait for it to expire"
2756
+ * }
2757
+ */
2758
+ "application/json": components["schemas"]["Error"];
2759
+ };
2760
+ };
2761
+ /** @description No matching passkey verification step is pending (or it has expired). */
2762
+ NoPasskeyPending: {
2763
+ headers: {
2764
+ [name: string]: unknown;
2765
+ };
2766
+ content: {
2767
+ /**
2768
+ * @example {
2769
+ * "status": 409,
2770
+ * "detail": "no passkey verification pending"
2771
+ * }
2772
+ */
2773
+ "application/json": components["schemas"]["Error"];
2774
+ };
2775
+ };
2492
2776
  };
2493
2777
  parameters: {
2494
2778
  /** @description The ID of the WhatsApp instance to use */
@@ -2535,6 +2819,7 @@ export interface operations {
2535
2819
  };
2536
2820
  400: components["responses"]["BadRequest"];
2537
2821
  401: components["responses"]["Unauthorized"];
2822
+ 409: components["responses"]["PasskeyPending"];
2538
2823
  503: components["responses"]["ServiceUnavailable"];
2539
2824
  };
2540
2825
  };
@@ -2564,6 +2849,7 @@ export interface operations {
2564
2849
  };
2565
2850
  400: components["responses"]["BadRequest"];
2566
2851
  401: components["responses"]["Unauthorized"];
2852
+ 409: components["responses"]["PasskeyPending"];
2567
2853
  503: components["responses"]["ServiceUnavailable"];
2568
2854
  };
2569
2855
  };
@@ -2596,6 +2882,7 @@ export interface operations {
2596
2882
  };
2597
2883
  400: components["responses"]["BadRequest"];
2598
2884
  401: components["responses"]["Unauthorized"];
2885
+ 409: components["responses"]["PasskeyPending"];
2599
2886
  503: components["responses"]["ServiceUnavailable"];
2600
2887
  };
2601
2888
  };
@@ -2624,6 +2911,194 @@ export interface operations {
2624
2911
  503: components["responses"]["ServiceUnavailable"];
2625
2912
  };
2626
2913
  };
2914
+ getPasskeyState: {
2915
+ parameters: {
2916
+ query?: never;
2917
+ header: {
2918
+ /** @description The ID of the WhatsApp instance to use */
2919
+ "X-Instance-Id": components["parameters"]["XInstanceId"];
2920
+ };
2921
+ path?: never;
2922
+ cookie?: never;
2923
+ };
2924
+ requestBody?: never;
2925
+ responses: {
2926
+ /** @description Passkey verification state */
2927
+ 200: {
2928
+ headers: {
2929
+ [name: string]: unknown;
2930
+ };
2931
+ content: {
2932
+ "application/json": components["schemas"]["PasskeyState"];
2933
+ };
2934
+ };
2935
+ 401: components["responses"]["Unauthorized"];
2936
+ 503: components["responses"]["ServiceUnavailable"];
2937
+ };
2938
+ };
2939
+ submitPasskey: {
2940
+ parameters: {
2941
+ query?: never;
2942
+ header: {
2943
+ /** @description The ID of the WhatsApp instance to use */
2944
+ "X-Instance-Id": components["parameters"]["XInstanceId"];
2945
+ };
2946
+ path?: never;
2947
+ cookie?: never;
2948
+ };
2949
+ requestBody: {
2950
+ content: {
2951
+ "application/json": components["schemas"]["PasskeyAssertion"];
2952
+ };
2953
+ };
2954
+ responses: {
2955
+ /** @description Assertion forwarded to WhatsApp */
2956
+ 200: {
2957
+ headers: {
2958
+ [name: string]: unknown;
2959
+ };
2960
+ content: {
2961
+ "application/json": components["schemas"]["PasskeyState"];
2962
+ };
2963
+ };
2964
+ /**
2965
+ * @description Malformed assertion, or `clientDataJSON` failed a local check (wrong `type`, wrong
2966
+ * `origin`, or a challenge other than the pending one). The step stays `required`.
2967
+ */
2968
+ 400: {
2969
+ headers: {
2970
+ [name: string]: unknown;
2971
+ };
2972
+ content: {
2973
+ /**
2974
+ * @example {
2975
+ * "status": 400,
2976
+ * "detail": "the passkey was used on \"https://example.com\"; it must be used on https://web.whatsapp.com"
2977
+ * }
2978
+ */
2979
+ "application/json": components["schemas"]["Error"];
2980
+ };
2981
+ };
2982
+ 401: components["responses"]["Unauthorized"];
2983
+ 409: components["responses"]["NoPasskeyPending"];
2984
+ /** @description Request body too large (limit 64 KB) */
2985
+ 413: {
2986
+ headers: {
2987
+ [name: string]: unknown;
2988
+ };
2989
+ content: {
2990
+ "application/json": components["schemas"]["Error"];
2991
+ };
2992
+ };
2993
+ /** @description WhatsApp rejected the passkey response. The state becomes `error`. */
2994
+ 502: {
2995
+ headers: {
2996
+ [name: string]: unknown;
2997
+ };
2998
+ content: {
2999
+ "application/json": components["schemas"]["Error"];
3000
+ };
3001
+ };
3002
+ 503: components["responses"]["ServiceUnavailable"];
3003
+ };
3004
+ };
3005
+ requestPasskey: {
3006
+ parameters: {
3007
+ query?: never;
3008
+ header: {
3009
+ /** @description The ID of the WhatsApp instance to use */
3010
+ "X-Instance-Id": components["parameters"]["XInstanceId"];
3011
+ };
3012
+ path?: never;
3013
+ cookie?: never;
3014
+ };
3015
+ requestBody?: never;
3016
+ responses: {
3017
+ /** @description Pending passkey challenge */
3018
+ 200: {
3019
+ headers: {
3020
+ [name: string]: unknown;
3021
+ };
3022
+ content: {
3023
+ "application/json": components["schemas"]["PasskeyState"];
3024
+ };
3025
+ };
3026
+ /** @description The device is already registered (paired) */
3027
+ 400: {
3028
+ headers: {
3029
+ [name: string]: unknown;
3030
+ };
3031
+ content: {
3032
+ /**
3033
+ * @example {
3034
+ * "status": 400,
3035
+ * "detail": "device already registered"
3036
+ * }
3037
+ */
3038
+ "application/json": components["schemas"]["Error"];
3039
+ };
3040
+ };
3041
+ 401: components["responses"]["Unauthorized"];
3042
+ /** @description Could not connect to WhatsApp to request the passkey challenge. Try again. */
3043
+ 409: {
3044
+ headers: {
3045
+ [name: string]: unknown;
3046
+ };
3047
+ content: {
3048
+ /**
3049
+ * @example {
3050
+ * "status": 409,
3051
+ * "detail": "could not connect to whatsapp to request the passkey challenge; try again"
3052
+ * }
3053
+ */
3054
+ "application/json": components["schemas"]["Error"];
3055
+ };
3056
+ };
3057
+ /** @description WhatsApp did not return a passkey challenge (the account may not use a passkey). */
3058
+ 502: {
3059
+ headers: {
3060
+ [name: string]: unknown;
3061
+ };
3062
+ content: {
3063
+ "application/json": components["schemas"]["Error"];
3064
+ };
3065
+ };
3066
+ 503: components["responses"]["ServiceUnavailable"];
3067
+ };
3068
+ };
3069
+ confirmPasskey: {
3070
+ parameters: {
3071
+ query?: never;
3072
+ header: {
3073
+ /** @description The ID of the WhatsApp instance to use */
3074
+ "X-Instance-Id": components["parameters"]["XInstanceId"];
3075
+ };
3076
+ path?: never;
3077
+ cookie?: never;
3078
+ };
3079
+ requestBody?: never;
3080
+ responses: {
3081
+ /** @description Confirmation sent to WhatsApp, or it had already been sent (no-op) */
3082
+ 204: {
3083
+ headers: {
3084
+ [name: string]: unknown;
3085
+ };
3086
+ content?: never;
3087
+ };
3088
+ 401: components["responses"]["Unauthorized"];
3089
+ 409: components["responses"]["NoPasskeyPending"];
3090
+ /** @description WhatsApp rejected the confirmation. The state becomes `error`. */
3091
+ 502: {
3092
+ headers: {
3093
+ [name: string]: unknown;
3094
+ };
3095
+ content: {
3096
+ "application/json": components["schemas"]["Error"];
3097
+ };
3098
+ };
3099
+ 503: components["responses"]["ServiceUnavailable"];
3100
+ };
3101
+ };
2627
3102
  logout: {
2628
3103
  parameters: {
2629
3104
  query?: never;