@proveanything/smartlinks 1.13.11 → 1.13.13
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/api/authKit.d.ts +3 -1
- package/dist/api/authKit.js +5 -0
- package/dist/docs/API_SUMMARY.md +36 -2
- package/dist/docs/auth-kit.md +50 -1
- package/dist/openapi.yaml +73 -2
- package/dist/types/authKit.d.ts +23 -1
- package/docs/API_SUMMARY.md +36 -2
- package/docs/auth-kit.md +50 -1
- package/openapi.yaml +73 -2
- package/package.json +1 -1
package/dist/api/authKit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthLoginResponse, PhoneSendCodeResponse, PhoneVerifyResponse, PasswordResetRequestResponse, VerifyResetTokenResponse, PasswordResetCompleteResponse, EmailVerificationActionResponse, EmailVerifyTokenResponse, AuthKitConfig, MagicLinkSendResponse, MagicLinkVerifyResponse, UserProfile, ProfileUpdateData, SuccessResponse, SendWhatsAppRequest, SendWhatsAppResponse, VerifyWhatsAppResponse, WhatsAppStatusResponse, SendSmsVerifyRequest, SendSmsVerifyResponse, VerifySmsResponse, UpsertContactRequest, UpsertContactResponse } from "../types/authKit";
|
|
1
|
+
import type { AuthLoginResponse, PhoneSendCodeResponse, PhoneVerifyResponse, PasswordResetRequestResponse, VerifyResetTokenResponse, PasswordResetCompleteResponse, EmailVerificationActionResponse, EmailVerifyTokenResponse, AuthKitConfig, MagicLinkSendResponse, MagicLinkVerifyResponse, UserProfile, ProfileUpdateData, SuccessResponse, SendWhatsAppRequest, SendWhatsAppResponse, ExchangeWhatsAppSessionResponse, VerifyWhatsAppResponse, WhatsAppStatusResponse, SendSmsVerifyRequest, SendSmsVerifyResponse, VerifySmsResponse, UpsertContactRequest, UpsertContactResponse } from "../types/authKit";
|
|
2
2
|
/**
|
|
3
3
|
* Namespace containing helper functions for the new AuthKit API.
|
|
4
4
|
* Legacy collection-based authKit helpers retained (marked as *Legacy*).
|
|
@@ -33,6 +33,8 @@ export declare namespace authKit {
|
|
|
33
33
|
function verifyWhatsApp(clientId: string, token: string, phoneNumber: string): Promise<VerifyWhatsAppResponse>;
|
|
34
34
|
/** Poll WhatsApp verification status for a token (public). */
|
|
35
35
|
function getWhatsAppStatus(clientId: string, token: string): Promise<WhatsAppStatusResponse>;
|
|
36
|
+
/** Exchange a verified WhatsApp token for an Auth Kit session (public). */
|
|
37
|
+
function exchangeWhatsAppSession(clientId: string, token: string, sessionKey: string): Promise<ExchangeWhatsAppSessionResponse>;
|
|
36
38
|
/** Send an SMS click-to-verify link (public). */
|
|
37
39
|
function sendSmsVerify(clientId: string, body: SendSmsVerifyRequest): Promise<SendSmsVerifyResponse>;
|
|
38
40
|
/** Verify an SMS click-to-verify token via API (public). */
|
package/dist/api/authKit.js
CHANGED
|
@@ -62,6 +62,11 @@ export var authKit;
|
|
|
62
62
|
return request(`/authkit/${encodeURIComponent(clientId)}/auth/whatsapp/status?token=${encodedToken}`);
|
|
63
63
|
}
|
|
64
64
|
authKit.getWhatsAppStatus = getWhatsAppStatus;
|
|
65
|
+
/** Exchange a verified WhatsApp token for an Auth Kit session (public). */
|
|
66
|
+
async function exchangeWhatsAppSession(clientId, token, sessionKey) {
|
|
67
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/whatsapp/exchange-session`, { token, sessionKey });
|
|
68
|
+
}
|
|
69
|
+
authKit.exchangeWhatsAppSession = exchangeWhatsAppSession;
|
|
65
70
|
/** Send an SMS click-to-verify link (public). */
|
|
66
71
|
async function sendSmsVerify(clientId, body) {
|
|
67
72
|
return post(`/authkit/${encodeURIComponent(clientId)}/auth/sms/send`, body);
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.13.
|
|
3
|
+
Version: 1.13.13 | Generated: 2026-05-15T11:06:27.909Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -3024,11 +3024,31 @@ interface EmailVerifyTokenResponse {
|
|
|
3024
3024
|
}
|
|
3025
3025
|
```
|
|
3026
3026
|
|
|
3027
|
+
**WhatsAppReplyCta** (interface)
|
|
3028
|
+
```typescript
|
|
3029
|
+
interface WhatsAppReplyCta {
|
|
3030
|
+
body: string
|
|
3031
|
+
buttonLabel: string
|
|
3032
|
+
buttonUrl: string
|
|
3033
|
+
}
|
|
3034
|
+
```
|
|
3035
|
+
|
|
3036
|
+
**WhatsAppReplyOptions** (interface)
|
|
3037
|
+
```typescript
|
|
3038
|
+
interface WhatsAppReplyOptions {
|
|
3039
|
+
contentSid?: string
|
|
3040
|
+
contentVariables?: Record<string, unknown>
|
|
3041
|
+
cta?: WhatsAppReplyCta
|
|
3042
|
+
text?: string
|
|
3043
|
+
}
|
|
3044
|
+
```
|
|
3045
|
+
|
|
3027
3046
|
**SendWhatsAppRequest** (interface)
|
|
3028
3047
|
```typescript
|
|
3029
3048
|
interface SendWhatsAppRequest {
|
|
3030
|
-
phoneNumber?: string
|
|
3031
3049
|
redirectUrl?: string
|
|
3050
|
+
prefillMessage?: string
|
|
3051
|
+
reply?: WhatsAppReplyOptions
|
|
3032
3052
|
}
|
|
3033
3053
|
```
|
|
3034
3054
|
|
|
@@ -3038,10 +3058,21 @@ interface SendWhatsAppResponse {
|
|
|
3038
3058
|
waLink: string
|
|
3039
3059
|
code: string
|
|
3040
3060
|
token: string
|
|
3061
|
+
sessionKey?: string
|
|
3041
3062
|
expiresAt: string
|
|
3042
3063
|
}
|
|
3043
3064
|
```
|
|
3044
3065
|
|
|
3066
|
+
**ExchangeWhatsAppSessionResponse** (interface)
|
|
3067
|
+
```typescript
|
|
3068
|
+
interface ExchangeWhatsAppSessionResponse {
|
|
3069
|
+
success: boolean
|
|
3070
|
+
token: string
|
|
3071
|
+
user: AuthKitUser
|
|
3072
|
+
accountData?: Record<string, any>
|
|
3073
|
+
}
|
|
3074
|
+
```
|
|
3075
|
+
|
|
3045
3076
|
**VerifyWhatsAppResponse** (interface)
|
|
3046
3077
|
```typescript
|
|
3047
3078
|
interface VerifyWhatsAppResponse {
|
|
@@ -8201,6 +8232,9 @@ Manually verify WhatsApp token if inbound webhook path is unavailable (public).
|
|
|
8201
8232
|
**getWhatsAppStatus**(clientId: string, token: string) → `Promise<WhatsAppStatusResponse>`
|
|
8202
8233
|
Poll WhatsApp verification status for a token (public).
|
|
8203
8234
|
|
|
8235
|
+
**exchangeWhatsAppSession**(clientId: string, token: string, sessionKey: string) → `Promise<ExchangeWhatsAppSessionResponse>`
|
|
8236
|
+
Exchange a verified WhatsApp token for an Auth Kit session (public).
|
|
8237
|
+
|
|
8204
8238
|
**sendSmsVerify**(clientId: string, body: SendSmsVerifyRequest) → `Promise<SendSmsVerifyResponse>`
|
|
8205
8239
|
Send an SMS click-to-verify link (public).
|
|
8206
8240
|
|
package/dist/docs/auth-kit.md
CHANGED
|
@@ -88,15 +88,30 @@ import { authKit } from '@proveanything/smartlinks';
|
|
|
88
88
|
// 1) Send WhatsApp verification deep link
|
|
89
89
|
const wa = await authKit.sendWhatsApp(clientId);
|
|
90
90
|
|
|
91
|
-
// Optional: pass redirect context
|
|
91
|
+
// Optional: pass redirect context and/or a post-verification reply
|
|
92
92
|
// const wa = await authKit.sendWhatsApp(clientId, {
|
|
93
93
|
// redirectUrl: 'https://app.example.com/checkout/continue',
|
|
94
|
+
// prefillMessage: 'Please let me bid in this auction. Code: {{token}}',
|
|
95
|
+
// reply: {
|
|
96
|
+
// cta: {
|
|
97
|
+
// body: "You're verified and ready to bid.",
|
|
98
|
+
// buttonLabel: 'Back to Auction',
|
|
99
|
+
// buttonUrl: '{{returnUrl}}',
|
|
100
|
+
// },
|
|
101
|
+
// text: "You're verified. Return to the app to continue.",
|
|
102
|
+
// },
|
|
94
103
|
// });
|
|
95
104
|
|
|
96
105
|
// wa.waLink can be opened directly by the app/browser
|
|
97
106
|
// Poll status while user switches to WhatsApp and back
|
|
98
107
|
const status = await authKit.getWhatsAppStatus(clientId, wa.token);
|
|
99
108
|
|
|
109
|
+
// Optional: exchange verified WhatsApp proof for an Auth Kit session
|
|
110
|
+
if (status.status === 'verified' && wa.sessionKey) {
|
|
111
|
+
const session = await authKit.exchangeWhatsAppSession(clientId, wa.token, wa.sessionKey);
|
|
112
|
+
// session.token can be used as the authenticated bearer token
|
|
113
|
+
}
|
|
114
|
+
|
|
100
115
|
// Optional fallback path if webhook confirmation is unavailable
|
|
101
116
|
await authKit.verifyWhatsApp(clientId, wa.token, '+447911123456');
|
|
102
117
|
|
|
@@ -135,6 +150,40 @@ Verification status values returned by `authKit.getWhatsAppStatus` are:
|
|
|
135
150
|
- `expired`
|
|
136
151
|
- `unknown`
|
|
137
152
|
|
|
153
|
+
#### Post-verification reply
|
|
154
|
+
|
|
155
|
+
Pass a `reply` object in `sendWhatsApp` to send a message back to the user after they confirm `CONFIRM <token>`. Reply resolution order:
|
|
156
|
+
|
|
157
|
+
1. `reply.contentSid` — explicit Twilio Content SID
|
|
158
|
+
2. `reply.cta` — CTA shorthand using the shared generic Twilio Content template SID (`TWILIO_WHATSAPP_GENERIC_CTA_SID`)
|
|
159
|
+
3. `reply.text` — plain-text fallback
|
|
160
|
+
4. Per-client default (`authKit/{clientId}.whatsapp` config)
|
|
161
|
+
5. Built-in default text
|
|
162
|
+
|
|
163
|
+
The following template placeholders are available in `reply.text`, `reply.cta` fields, and `reply.contentVariables` values:
|
|
164
|
+
|
|
165
|
+
| Placeholder | Description |
|
|
166
|
+
|---|---|
|
|
167
|
+
| `{{returnUrl}}` | The resolved redirect URL |
|
|
168
|
+
| `{{phoneNumber}}` | The verified phone number |
|
|
169
|
+
| `{{clientId}}` | The Auth Kit client ID |
|
|
170
|
+
| `{{token}}` | The verification token |
|
|
171
|
+
|
|
172
|
+
You can also set `prefillMessage` on `sendWhatsApp` to customize the text pre-filled in the `wa.me` deep link. If `{{token}}` is not present, the token is appended to the message.
|
|
173
|
+
|
|
174
|
+
#### Session exchange after verification
|
|
175
|
+
|
|
176
|
+
After polling returns `status === 'verified'`, exchange the verification proof for an Auth Kit login session:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
const session = await authKit.exchangeWhatsAppSession(clientId, wa.token, wa.sessionKey!);
|
|
180
|
+
// session: { success, token, user, accountData? }
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`sessionKey` is returned by `sendWhatsApp` and is used to mitigate token replay from contexts that did not initiate the browser flow.
|
|
184
|
+
|
|
185
|
+
> **Note:** `redirectUrl` is optional. WhatsApp tokens are short hex strings (16 chars) for better UX.
|
|
186
|
+
|
|
138
187
|
### Google OAuth
|
|
139
188
|
|
|
140
189
|
```ts
|
package/dist/openapi.yaml
CHANGED
|
@@ -8501,6 +8501,32 @@ paths:
|
|
|
8501
8501
|
description: Unauthorized
|
|
8502
8502
|
404:
|
|
8503
8503
|
description: Not found
|
|
8504
|
+
/authkit/{clientId}/auth/whatsapp/exchange-session:
|
|
8505
|
+
post:
|
|
8506
|
+
tags:
|
|
8507
|
+
- authKit
|
|
8508
|
+
summary: Exchange a verified WhatsApp token for an Auth Kit session (public).
|
|
8509
|
+
operationId: authKit_exchangeWhatsAppSession
|
|
8510
|
+
security: []
|
|
8511
|
+
parameters:
|
|
8512
|
+
- name: clientId
|
|
8513
|
+
in: path
|
|
8514
|
+
required: true
|
|
8515
|
+
schema:
|
|
8516
|
+
type: string
|
|
8517
|
+
responses:
|
|
8518
|
+
200:
|
|
8519
|
+
description: Success
|
|
8520
|
+
content:
|
|
8521
|
+
application/json:
|
|
8522
|
+
schema:
|
|
8523
|
+
$ref: "#/components/schemas/ExchangeWhatsAppSessionResponse"
|
|
8524
|
+
400:
|
|
8525
|
+
description: Bad request
|
|
8526
|
+
401:
|
|
8527
|
+
description: Unauthorized
|
|
8528
|
+
404:
|
|
8529
|
+
description: Not found
|
|
8504
8530
|
/authkit/{clientId}/auth/whatsapp/send:
|
|
8505
8531
|
post:
|
|
8506
8532
|
tags:
|
|
@@ -17864,13 +17890,40 @@ components:
|
|
|
17864
17890
|
required:
|
|
17865
17891
|
- success
|
|
17866
17892
|
- message
|
|
17867
|
-
|
|
17893
|
+
WhatsAppReplyCta:
|
|
17868
17894
|
type: object
|
|
17869
17895
|
properties:
|
|
17870
|
-
|
|
17896
|
+
body:
|
|
17897
|
+
type: string
|
|
17898
|
+
buttonLabel:
|
|
17899
|
+
type: string
|
|
17900
|
+
buttonUrl:
|
|
17901
|
+
type: string
|
|
17902
|
+
required:
|
|
17903
|
+
- body
|
|
17904
|
+
- buttonLabel
|
|
17905
|
+
- buttonUrl
|
|
17906
|
+
WhatsAppReplyOptions:
|
|
17907
|
+
type: object
|
|
17908
|
+
properties:
|
|
17909
|
+
contentSid:
|
|
17910
|
+
type: string
|
|
17911
|
+
contentVariables:
|
|
17912
|
+
type: object
|
|
17913
|
+
additionalProperties: true
|
|
17914
|
+
cta:
|
|
17915
|
+
$ref: "#/components/schemas/WhatsAppReplyCta"
|
|
17916
|
+
text:
|
|
17871
17917
|
type: string
|
|
17918
|
+
SendWhatsAppRequest:
|
|
17919
|
+
type: object
|
|
17920
|
+
properties:
|
|
17872
17921
|
redirectUrl:
|
|
17873
17922
|
type: string
|
|
17923
|
+
prefillMessage:
|
|
17924
|
+
type: string
|
|
17925
|
+
reply:
|
|
17926
|
+
$ref: "#/components/schemas/WhatsAppReplyOptions"
|
|
17874
17927
|
SendWhatsAppResponse:
|
|
17875
17928
|
type: object
|
|
17876
17929
|
properties:
|
|
@@ -17880,6 +17933,8 @@ components:
|
|
|
17880
17933
|
type: string
|
|
17881
17934
|
token:
|
|
17882
17935
|
type: string
|
|
17936
|
+
sessionKey:
|
|
17937
|
+
type: string
|
|
17883
17938
|
expiresAt:
|
|
17884
17939
|
type: string
|
|
17885
17940
|
required:
|
|
@@ -17887,6 +17942,22 @@ components:
|
|
|
17887
17942
|
- code
|
|
17888
17943
|
- token
|
|
17889
17944
|
- expiresAt
|
|
17945
|
+
ExchangeWhatsAppSessionResponse:
|
|
17946
|
+
type: object
|
|
17947
|
+
properties:
|
|
17948
|
+
success:
|
|
17949
|
+
type: boolean
|
|
17950
|
+
token:
|
|
17951
|
+
type: string
|
|
17952
|
+
user:
|
|
17953
|
+
$ref: "#/components/schemas/AuthKitUser"
|
|
17954
|
+
accountData:
|
|
17955
|
+
type: object
|
|
17956
|
+
additionalProperties: true
|
|
17957
|
+
required:
|
|
17958
|
+
- success
|
|
17959
|
+
- token
|
|
17960
|
+
- user
|
|
17890
17961
|
VerifyWhatsAppResponse:
|
|
17891
17962
|
type: object
|
|
17892
17963
|
properties:
|
package/dist/types/authKit.d.ts
CHANGED
|
@@ -76,16 +76,38 @@ export interface EmailVerifyTokenResponse {
|
|
|
76
76
|
emailVerificationMode?: 'immediate' | 'verify-auto-login' | 'verify-manual-login';
|
|
77
77
|
}
|
|
78
78
|
export type VerifyStatus = 'pending' | 'verified' | 'failed' | 'expired' | 'unknown';
|
|
79
|
+
export interface WhatsAppReplyCta {
|
|
80
|
+
body: string;
|
|
81
|
+
buttonLabel: string;
|
|
82
|
+
buttonUrl: string;
|
|
83
|
+
}
|
|
84
|
+
export interface WhatsAppReplyOptions {
|
|
85
|
+
/** Option A: explicit Twilio Content SID */
|
|
86
|
+
contentSid?: string;
|
|
87
|
+
contentVariables?: Record<string, unknown>;
|
|
88
|
+
/** Option B: CTA shorthand (uses shared generic CTA content SID) */
|
|
89
|
+
cta?: WhatsAppReplyCta;
|
|
90
|
+
/** Option C: plain-text fallback */
|
|
91
|
+
text?: string;
|
|
92
|
+
}
|
|
79
93
|
export interface SendWhatsAppRequest {
|
|
80
|
-
phoneNumber?: string;
|
|
81
94
|
redirectUrl?: string;
|
|
95
|
+
prefillMessage?: string;
|
|
96
|
+
reply?: WhatsAppReplyOptions;
|
|
82
97
|
}
|
|
83
98
|
export interface SendWhatsAppResponse {
|
|
84
99
|
waLink: string;
|
|
85
100
|
code: string;
|
|
86
101
|
token: string;
|
|
102
|
+
sessionKey?: string;
|
|
87
103
|
expiresAt: string;
|
|
88
104
|
}
|
|
105
|
+
export interface ExchangeWhatsAppSessionResponse {
|
|
106
|
+
success: boolean;
|
|
107
|
+
token: string;
|
|
108
|
+
user: AuthKitUser;
|
|
109
|
+
accountData?: Record<string, any>;
|
|
110
|
+
}
|
|
89
111
|
export interface VerifyWhatsAppResponse {
|
|
90
112
|
success: boolean;
|
|
91
113
|
verified: boolean;
|
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.13.
|
|
3
|
+
Version: 1.13.13 | Generated: 2026-05-15T11:06:27.909Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -3024,11 +3024,31 @@ interface EmailVerifyTokenResponse {
|
|
|
3024
3024
|
}
|
|
3025
3025
|
```
|
|
3026
3026
|
|
|
3027
|
+
**WhatsAppReplyCta** (interface)
|
|
3028
|
+
```typescript
|
|
3029
|
+
interface WhatsAppReplyCta {
|
|
3030
|
+
body: string
|
|
3031
|
+
buttonLabel: string
|
|
3032
|
+
buttonUrl: string
|
|
3033
|
+
}
|
|
3034
|
+
```
|
|
3035
|
+
|
|
3036
|
+
**WhatsAppReplyOptions** (interface)
|
|
3037
|
+
```typescript
|
|
3038
|
+
interface WhatsAppReplyOptions {
|
|
3039
|
+
contentSid?: string
|
|
3040
|
+
contentVariables?: Record<string, unknown>
|
|
3041
|
+
cta?: WhatsAppReplyCta
|
|
3042
|
+
text?: string
|
|
3043
|
+
}
|
|
3044
|
+
```
|
|
3045
|
+
|
|
3027
3046
|
**SendWhatsAppRequest** (interface)
|
|
3028
3047
|
```typescript
|
|
3029
3048
|
interface SendWhatsAppRequest {
|
|
3030
|
-
phoneNumber?: string
|
|
3031
3049
|
redirectUrl?: string
|
|
3050
|
+
prefillMessage?: string
|
|
3051
|
+
reply?: WhatsAppReplyOptions
|
|
3032
3052
|
}
|
|
3033
3053
|
```
|
|
3034
3054
|
|
|
@@ -3038,10 +3058,21 @@ interface SendWhatsAppResponse {
|
|
|
3038
3058
|
waLink: string
|
|
3039
3059
|
code: string
|
|
3040
3060
|
token: string
|
|
3061
|
+
sessionKey?: string
|
|
3041
3062
|
expiresAt: string
|
|
3042
3063
|
}
|
|
3043
3064
|
```
|
|
3044
3065
|
|
|
3066
|
+
**ExchangeWhatsAppSessionResponse** (interface)
|
|
3067
|
+
```typescript
|
|
3068
|
+
interface ExchangeWhatsAppSessionResponse {
|
|
3069
|
+
success: boolean
|
|
3070
|
+
token: string
|
|
3071
|
+
user: AuthKitUser
|
|
3072
|
+
accountData?: Record<string, any>
|
|
3073
|
+
}
|
|
3074
|
+
```
|
|
3075
|
+
|
|
3045
3076
|
**VerifyWhatsAppResponse** (interface)
|
|
3046
3077
|
```typescript
|
|
3047
3078
|
interface VerifyWhatsAppResponse {
|
|
@@ -8201,6 +8232,9 @@ Manually verify WhatsApp token if inbound webhook path is unavailable (public).
|
|
|
8201
8232
|
**getWhatsAppStatus**(clientId: string, token: string) → `Promise<WhatsAppStatusResponse>`
|
|
8202
8233
|
Poll WhatsApp verification status for a token (public).
|
|
8203
8234
|
|
|
8235
|
+
**exchangeWhatsAppSession**(clientId: string, token: string, sessionKey: string) → `Promise<ExchangeWhatsAppSessionResponse>`
|
|
8236
|
+
Exchange a verified WhatsApp token for an Auth Kit session (public).
|
|
8237
|
+
|
|
8204
8238
|
**sendSmsVerify**(clientId: string, body: SendSmsVerifyRequest) → `Promise<SendSmsVerifyResponse>`
|
|
8205
8239
|
Send an SMS click-to-verify link (public).
|
|
8206
8240
|
|
package/docs/auth-kit.md
CHANGED
|
@@ -88,15 +88,30 @@ import { authKit } from '@proveanything/smartlinks';
|
|
|
88
88
|
// 1) Send WhatsApp verification deep link
|
|
89
89
|
const wa = await authKit.sendWhatsApp(clientId);
|
|
90
90
|
|
|
91
|
-
// Optional: pass redirect context
|
|
91
|
+
// Optional: pass redirect context and/or a post-verification reply
|
|
92
92
|
// const wa = await authKit.sendWhatsApp(clientId, {
|
|
93
93
|
// redirectUrl: 'https://app.example.com/checkout/continue',
|
|
94
|
+
// prefillMessage: 'Please let me bid in this auction. Code: {{token}}',
|
|
95
|
+
// reply: {
|
|
96
|
+
// cta: {
|
|
97
|
+
// body: "You're verified and ready to bid.",
|
|
98
|
+
// buttonLabel: 'Back to Auction',
|
|
99
|
+
// buttonUrl: '{{returnUrl}}',
|
|
100
|
+
// },
|
|
101
|
+
// text: "You're verified. Return to the app to continue.",
|
|
102
|
+
// },
|
|
94
103
|
// });
|
|
95
104
|
|
|
96
105
|
// wa.waLink can be opened directly by the app/browser
|
|
97
106
|
// Poll status while user switches to WhatsApp and back
|
|
98
107
|
const status = await authKit.getWhatsAppStatus(clientId, wa.token);
|
|
99
108
|
|
|
109
|
+
// Optional: exchange verified WhatsApp proof for an Auth Kit session
|
|
110
|
+
if (status.status === 'verified' && wa.sessionKey) {
|
|
111
|
+
const session = await authKit.exchangeWhatsAppSession(clientId, wa.token, wa.sessionKey);
|
|
112
|
+
// session.token can be used as the authenticated bearer token
|
|
113
|
+
}
|
|
114
|
+
|
|
100
115
|
// Optional fallback path if webhook confirmation is unavailable
|
|
101
116
|
await authKit.verifyWhatsApp(clientId, wa.token, '+447911123456');
|
|
102
117
|
|
|
@@ -135,6 +150,40 @@ Verification status values returned by `authKit.getWhatsAppStatus` are:
|
|
|
135
150
|
- `expired`
|
|
136
151
|
- `unknown`
|
|
137
152
|
|
|
153
|
+
#### Post-verification reply
|
|
154
|
+
|
|
155
|
+
Pass a `reply` object in `sendWhatsApp` to send a message back to the user after they confirm `CONFIRM <token>`. Reply resolution order:
|
|
156
|
+
|
|
157
|
+
1. `reply.contentSid` — explicit Twilio Content SID
|
|
158
|
+
2. `reply.cta` — CTA shorthand using the shared generic Twilio Content template SID (`TWILIO_WHATSAPP_GENERIC_CTA_SID`)
|
|
159
|
+
3. `reply.text` — plain-text fallback
|
|
160
|
+
4. Per-client default (`authKit/{clientId}.whatsapp` config)
|
|
161
|
+
5. Built-in default text
|
|
162
|
+
|
|
163
|
+
The following template placeholders are available in `reply.text`, `reply.cta` fields, and `reply.contentVariables` values:
|
|
164
|
+
|
|
165
|
+
| Placeholder | Description |
|
|
166
|
+
|---|---|
|
|
167
|
+
| `{{returnUrl}}` | The resolved redirect URL |
|
|
168
|
+
| `{{phoneNumber}}` | The verified phone number |
|
|
169
|
+
| `{{clientId}}` | The Auth Kit client ID |
|
|
170
|
+
| `{{token}}` | The verification token |
|
|
171
|
+
|
|
172
|
+
You can also set `prefillMessage` on `sendWhatsApp` to customize the text pre-filled in the `wa.me` deep link. If `{{token}}` is not present, the token is appended to the message.
|
|
173
|
+
|
|
174
|
+
#### Session exchange after verification
|
|
175
|
+
|
|
176
|
+
After polling returns `status === 'verified'`, exchange the verification proof for an Auth Kit login session:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
const session = await authKit.exchangeWhatsAppSession(clientId, wa.token, wa.sessionKey!);
|
|
180
|
+
// session: { success, token, user, accountData? }
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`sessionKey` is returned by `sendWhatsApp` and is used to mitigate token replay from contexts that did not initiate the browser flow.
|
|
184
|
+
|
|
185
|
+
> **Note:** `redirectUrl` is optional. WhatsApp tokens are short hex strings (16 chars) for better UX.
|
|
186
|
+
|
|
138
187
|
### Google OAuth
|
|
139
188
|
|
|
140
189
|
```ts
|
package/openapi.yaml
CHANGED
|
@@ -8501,6 +8501,32 @@ paths:
|
|
|
8501
8501
|
description: Unauthorized
|
|
8502
8502
|
404:
|
|
8503
8503
|
description: Not found
|
|
8504
|
+
/authkit/{clientId}/auth/whatsapp/exchange-session:
|
|
8505
|
+
post:
|
|
8506
|
+
tags:
|
|
8507
|
+
- authKit
|
|
8508
|
+
summary: Exchange a verified WhatsApp token for an Auth Kit session (public).
|
|
8509
|
+
operationId: authKit_exchangeWhatsAppSession
|
|
8510
|
+
security: []
|
|
8511
|
+
parameters:
|
|
8512
|
+
- name: clientId
|
|
8513
|
+
in: path
|
|
8514
|
+
required: true
|
|
8515
|
+
schema:
|
|
8516
|
+
type: string
|
|
8517
|
+
responses:
|
|
8518
|
+
200:
|
|
8519
|
+
description: Success
|
|
8520
|
+
content:
|
|
8521
|
+
application/json:
|
|
8522
|
+
schema:
|
|
8523
|
+
$ref: "#/components/schemas/ExchangeWhatsAppSessionResponse"
|
|
8524
|
+
400:
|
|
8525
|
+
description: Bad request
|
|
8526
|
+
401:
|
|
8527
|
+
description: Unauthorized
|
|
8528
|
+
404:
|
|
8529
|
+
description: Not found
|
|
8504
8530
|
/authkit/{clientId}/auth/whatsapp/send:
|
|
8505
8531
|
post:
|
|
8506
8532
|
tags:
|
|
@@ -17864,13 +17890,40 @@ components:
|
|
|
17864
17890
|
required:
|
|
17865
17891
|
- success
|
|
17866
17892
|
- message
|
|
17867
|
-
|
|
17893
|
+
WhatsAppReplyCta:
|
|
17868
17894
|
type: object
|
|
17869
17895
|
properties:
|
|
17870
|
-
|
|
17896
|
+
body:
|
|
17897
|
+
type: string
|
|
17898
|
+
buttonLabel:
|
|
17899
|
+
type: string
|
|
17900
|
+
buttonUrl:
|
|
17901
|
+
type: string
|
|
17902
|
+
required:
|
|
17903
|
+
- body
|
|
17904
|
+
- buttonLabel
|
|
17905
|
+
- buttonUrl
|
|
17906
|
+
WhatsAppReplyOptions:
|
|
17907
|
+
type: object
|
|
17908
|
+
properties:
|
|
17909
|
+
contentSid:
|
|
17910
|
+
type: string
|
|
17911
|
+
contentVariables:
|
|
17912
|
+
type: object
|
|
17913
|
+
additionalProperties: true
|
|
17914
|
+
cta:
|
|
17915
|
+
$ref: "#/components/schemas/WhatsAppReplyCta"
|
|
17916
|
+
text:
|
|
17871
17917
|
type: string
|
|
17918
|
+
SendWhatsAppRequest:
|
|
17919
|
+
type: object
|
|
17920
|
+
properties:
|
|
17872
17921
|
redirectUrl:
|
|
17873
17922
|
type: string
|
|
17923
|
+
prefillMessage:
|
|
17924
|
+
type: string
|
|
17925
|
+
reply:
|
|
17926
|
+
$ref: "#/components/schemas/WhatsAppReplyOptions"
|
|
17874
17927
|
SendWhatsAppResponse:
|
|
17875
17928
|
type: object
|
|
17876
17929
|
properties:
|
|
@@ -17880,6 +17933,8 @@ components:
|
|
|
17880
17933
|
type: string
|
|
17881
17934
|
token:
|
|
17882
17935
|
type: string
|
|
17936
|
+
sessionKey:
|
|
17937
|
+
type: string
|
|
17883
17938
|
expiresAt:
|
|
17884
17939
|
type: string
|
|
17885
17940
|
required:
|
|
@@ -17887,6 +17942,22 @@ components:
|
|
|
17887
17942
|
- code
|
|
17888
17943
|
- token
|
|
17889
17944
|
- expiresAt
|
|
17945
|
+
ExchangeWhatsAppSessionResponse:
|
|
17946
|
+
type: object
|
|
17947
|
+
properties:
|
|
17948
|
+
success:
|
|
17949
|
+
type: boolean
|
|
17950
|
+
token:
|
|
17951
|
+
type: string
|
|
17952
|
+
user:
|
|
17953
|
+
$ref: "#/components/schemas/AuthKitUser"
|
|
17954
|
+
accountData:
|
|
17955
|
+
type: object
|
|
17956
|
+
additionalProperties: true
|
|
17957
|
+
required:
|
|
17958
|
+
- success
|
|
17959
|
+
- token
|
|
17960
|
+
- user
|
|
17890
17961
|
VerifyWhatsAppResponse:
|
|
17891
17962
|
type: object
|
|
17892
17963
|
properties:
|