@proveanything/smartlinks 1.0.41 → 1.0.43
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/API_SUMMARY.md +261 -1
- package/dist/api/authKit.d.ts +48 -0
- package/dist/api/authKit.js +100 -0
- package/dist/api/comms.d.ts +47 -0
- package/dist/api/comms.js +54 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/types/authKit.d.ts +67 -0
- package/dist/types/authKit.js +2 -0
- package/dist/types/comms.d.ts +107 -0
- package/dist/types/comms.js +3 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +1 -1
package/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.43 | Generated: 2025-11-22T12:58:28.713Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -14,9 +14,11 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
14
14
|
- **asset** - File upload and asset management for collections, products, and proofs
|
|
15
15
|
- **attestation** - Digital attestations and verification for products
|
|
16
16
|
- **auth** - Authentication, login, and user account management
|
|
17
|
+
- **authKit** - Functions for authKit operations
|
|
17
18
|
- **batch** - Product batch management and tracking
|
|
18
19
|
- **claimSet** - Claim creation, management, and verification
|
|
19
20
|
- **collection** - Collection CRUD operations and management
|
|
21
|
+
- **comms** - Functions for comms operations
|
|
20
22
|
- **crate** - Container/crate management for organizing products
|
|
21
23
|
- **form** - Dynamic form creation and submission
|
|
22
24
|
- **product** - Product CRUD operations and management within collections
|
|
@@ -136,6 +138,119 @@ type UserAccountRegistrationRequest = {
|
|
|
136
138
|
}
|
|
137
139
|
```
|
|
138
140
|
|
|
141
|
+
### authKit
|
|
142
|
+
|
|
143
|
+
**AuthKitUser** (interface)
|
|
144
|
+
```typescript
|
|
145
|
+
interface AuthKitUser {
|
|
146
|
+
uid: string
|
|
147
|
+
email?: string
|
|
148
|
+
displayName?: string | null
|
|
149
|
+
photoURL?: string | null
|
|
150
|
+
phoneNumber?: string | null
|
|
151
|
+
emailVerified?: boolean
|
|
152
|
+
accountData?: Record<string, any>
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**AuthLoginResponse** (interface)
|
|
157
|
+
```typescript
|
|
158
|
+
interface AuthLoginResponse {
|
|
159
|
+
token: string
|
|
160
|
+
user: AuthKitUser
|
|
161
|
+
accountData?: Record<string, any>
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**PhoneSendCodeResponse** (interface)
|
|
166
|
+
```typescript
|
|
167
|
+
interface PhoneSendCodeResponse {
|
|
168
|
+
verificationId: string
|
|
169
|
+
message: string
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**PhoneVerifyResponse** (interface)
|
|
174
|
+
```typescript
|
|
175
|
+
interface PhoneVerifyResponse {
|
|
176
|
+
token: string
|
|
177
|
+
user: AuthKitUser
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**PasswordResetRequestResponse** (interface)
|
|
182
|
+
```typescript
|
|
183
|
+
interface PasswordResetRequestResponse {
|
|
184
|
+
success: boolean
|
|
185
|
+
message: string
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**VerifyResetTokenResponse** (interface)
|
|
190
|
+
```typescript
|
|
191
|
+
interface VerifyResetTokenResponse {
|
|
192
|
+
valid: boolean
|
|
193
|
+
email?: string
|
|
194
|
+
expiresAt?: number
|
|
195
|
+
message?: string
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**PasswordResetCompleteResponse** (interface)
|
|
200
|
+
```typescript
|
|
201
|
+
interface PasswordResetCompleteResponse {
|
|
202
|
+
success: boolean
|
|
203
|
+
message: string
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**EmailVerificationActionResponse** (interface)
|
|
208
|
+
```typescript
|
|
209
|
+
interface EmailVerificationActionResponse {
|
|
210
|
+
success: boolean
|
|
211
|
+
message: string
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**EmailVerifyTokenResponse** (interface)
|
|
216
|
+
```typescript
|
|
217
|
+
interface EmailVerifyTokenResponse {
|
|
218
|
+
success: boolean
|
|
219
|
+
message: string
|
|
220
|
+
token?: string
|
|
221
|
+
user?: AuthKitUser
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**AuthKitBrandingConfig** (interface)
|
|
226
|
+
```typescript
|
|
227
|
+
interface AuthKitBrandingConfig {
|
|
228
|
+
logoUrl?: string
|
|
229
|
+
title?: string
|
|
230
|
+
subtitle?: string
|
|
231
|
+
primaryColor?: string
|
|
232
|
+
secondaryColor?: string
|
|
233
|
+
backgroundColor?: string
|
|
234
|
+
buttonStyle?: string
|
|
235
|
+
fontFamily?: string
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**AuthKitConfig** (interface)
|
|
240
|
+
```typescript
|
|
241
|
+
interface AuthKitConfig {
|
|
242
|
+
clientId: string
|
|
243
|
+
branding?: AuthKitBrandingConfig
|
|
244
|
+
enabledProviders?: string[]
|
|
245
|
+
customCss?: string
|
|
246
|
+
termsUrl?: string
|
|
247
|
+
privacyUrl?: string
|
|
248
|
+
supportEmail?: string
|
|
249
|
+
redirectUrl?: string
|
|
250
|
+
updatedAt?: string
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
139
254
|
### batch
|
|
140
255
|
|
|
141
256
|
**BatchResponse** = `any`
|
|
@@ -221,6 +336,92 @@ interface CollectionResponse {
|
|
|
221
336
|
}
|
|
222
337
|
```
|
|
223
338
|
|
|
339
|
+
### comms
|
|
340
|
+
|
|
341
|
+
**NotificationSubjectTarget** (interface)
|
|
342
|
+
```typescript
|
|
343
|
+
interface NotificationSubjectTarget {
|
|
344
|
+
type: 'product' | 'collection' | 'user' | 'batch' | 'proof'
|
|
345
|
+
id: string
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
**PushNotificationTemplate** (interface)
|
|
350
|
+
```typescript
|
|
351
|
+
interface PushNotificationTemplate {
|
|
352
|
+
title: string
|
|
353
|
+
body: string
|
|
354
|
+
icon?: string
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**EmailNotificationTemplate** (interface)
|
|
359
|
+
```typescript
|
|
360
|
+
interface EmailNotificationTemplate {
|
|
361
|
+
subject: string
|
|
362
|
+
body: string
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**WalletUpdateTemplate** (interface)
|
|
367
|
+
```typescript
|
|
368
|
+
interface WalletUpdateTemplate {
|
|
369
|
+
textModulesData?: Array<{
|
|
370
|
+
id: string
|
|
371
|
+
header: string
|
|
372
|
+
body: string
|
|
373
|
+
}>
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**NotificationTemplate** (interface)
|
|
378
|
+
```typescript
|
|
379
|
+
interface NotificationTemplate {
|
|
380
|
+
push?: PushNotificationTemplate
|
|
381
|
+
email?: EmailNotificationTemplate
|
|
382
|
+
walletUpdate?: WalletUpdateTemplate
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
**SendNotificationRequest** (interface)
|
|
387
|
+
```typescript
|
|
388
|
+
interface SendNotificationRequest {
|
|
389
|
+
subjectTargets: NotificationSubjectTarget[]
|
|
390
|
+
severity: 'low' | 'normal' | 'important' | 'critical'
|
|
391
|
+
mode: 'preferred' | 'all'
|
|
392
|
+
channels : ("push" | "email" | "wallet")[]
|
|
393
|
+
template: NotificationTemplate
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**SendNotificationResponse** (interface)
|
|
398
|
+
```typescript
|
|
399
|
+
interface SendNotificationResponse {
|
|
400
|
+
ok: boolean
|
|
401
|
+
notificationId: string
|
|
402
|
+
counts: {
|
|
403
|
+
contacts: number
|
|
404
|
+
attempts: number
|
|
405
|
+
}
|
|
406
|
+
status: {
|
|
407
|
+
notification: {
|
|
408
|
+
notificationId: string
|
|
409
|
+
state: 'queued' | 'sent' | 'failed' | 'confirmed' | string
|
|
410
|
+
subjectTargets: NotificationSubjectTarget[]
|
|
411
|
+
severity: 'low' | 'normal' | 'important' | 'critical' | string
|
|
412
|
+
channelsOverride: Record<string, any>
|
|
413
|
+
template: NotificationTemplate
|
|
414
|
+
}
|
|
415
|
+
totals: {
|
|
416
|
+
queued: number
|
|
417
|
+
sent: number
|
|
418
|
+
failed: number
|
|
419
|
+
confirmed: number
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
224
425
|
### error
|
|
225
426
|
|
|
226
427
|
**ErrorResponse** (interface)
|
|
@@ -558,6 +759,59 @@ Admin: Get a user bearer token (impersonation/automation). POST /admin/auth/user
|
|
|
558
759
|
**getAccount**() → `Promise<AccountInfoResponse>`
|
|
559
760
|
Gets current account information for the logged in user. Returns user, owner, account, and location objects.
|
|
560
761
|
|
|
762
|
+
### authKit
|
|
763
|
+
|
|
764
|
+
**login**(clientId: string, email: string, password: string) → `Promise<AuthLoginResponse>`
|
|
765
|
+
Login with email + password (public).
|
|
766
|
+
|
|
767
|
+
**register**(clientId: string, data: { email: string; password: string; displayName?: string; accountData?: Record<string, any> }) → `Promise<AuthLoginResponse>`
|
|
768
|
+
Register a new user (public).
|
|
769
|
+
|
|
770
|
+
**googleLogin**(clientId: string, idToken: string) → `Promise<AuthLoginResponse>`
|
|
771
|
+
Google OAuth login (public).
|
|
772
|
+
|
|
773
|
+
**sendPhoneCode**(clientId: string, phoneNumber: string) → `Promise<PhoneSendCodeResponse>`
|
|
774
|
+
Send phone verification code (public).
|
|
775
|
+
|
|
776
|
+
**verifyPhoneCode**(clientId: string, verificationId: string, code: string) → `Promise<PhoneVerifyResponse>`
|
|
777
|
+
Verify phone verification code (public).
|
|
778
|
+
|
|
779
|
+
**requestPasswordReset**(clientId: string, data: { email: string; redirectUrl?: string; clientName?: string }) → `Promise<PasswordResetRequestResponse>`
|
|
780
|
+
Verify phone verification code (public).
|
|
781
|
+
|
|
782
|
+
**verifyResetToken**(clientId: string, token: string) → `Promise<VerifyResetTokenResponse>`
|
|
783
|
+
Verify phone verification code (public).
|
|
784
|
+
|
|
785
|
+
**completePasswordReset**(clientId: string, token: string, newPassword: string) → `Promise<PasswordResetCompleteResponse>`
|
|
786
|
+
Verify phone verification code (public).
|
|
787
|
+
|
|
788
|
+
**sendEmailVerification**(clientId: string, data: { userId: string; email: string; redirectUrl?: string; clientName?: string }) → `Promise<EmailVerificationActionResponse>`
|
|
789
|
+
Verify phone verification code (public).
|
|
790
|
+
|
|
791
|
+
**verifyEmail**(clientId: string, token: string) → `Promise<EmailVerifyTokenResponse>`
|
|
792
|
+
Verify phone verification code (public).
|
|
793
|
+
|
|
794
|
+
**resendEmailVerification**(clientId: string, data: { userId: string; email: string; redirectUrl?: string; clientName?: string }) → `Promise<EmailVerificationActionResponse>`
|
|
795
|
+
Verify phone verification code (public).
|
|
796
|
+
|
|
797
|
+
**load**(authKitId: string) → `Promise<AuthKitConfig>`
|
|
798
|
+
Verify phone verification code (public).
|
|
799
|
+
|
|
800
|
+
**get**(collectionId: string, authKitId: string) → `Promise<AuthKitConfig>`
|
|
801
|
+
Verify phone verification code (public).
|
|
802
|
+
|
|
803
|
+
**list**(collectionId: string, admin?: boolean) → `Promise<AuthKitConfig[]>`
|
|
804
|
+
Verify phone verification code (public).
|
|
805
|
+
|
|
806
|
+
**create**(collectionId: string, data: any) → `Promise<AuthKitConfig>`
|
|
807
|
+
Verify phone verification code (public).
|
|
808
|
+
|
|
809
|
+
**update**(collectionId: string, authKitId: string, data: any) → `Promise<AuthKitConfig>`
|
|
810
|
+
Verify phone verification code (public).
|
|
811
|
+
|
|
812
|
+
**remove**(collectionId: string, authKitId: string) → `Promise<void>`
|
|
813
|
+
Verify phone verification code (public).
|
|
814
|
+
|
|
561
815
|
### batch
|
|
562
816
|
|
|
563
817
|
**get**(collectionId: string,
|
|
@@ -678,6 +932,12 @@ Look up a serial number by code for a collection (admin only).
|
|
|
678
932
|
value: any) → `Promise<any>`
|
|
679
933
|
Assign a value to a serial number for a collection (admin only).
|
|
680
934
|
|
|
935
|
+
### comms
|
|
936
|
+
|
|
937
|
+
**sendNotification**(collectionId: string,
|
|
938
|
+
request: SendNotificationRequest) → `Promise<SendNotificationResponse>`
|
|
939
|
+
Send a notification to specified targets within a collection. Supports multiple delivery methods including push notifications, email, and wallet pass updates. The notification will be delivered based on user preferences and the specified delivery mode. ```typescript const result = await comms.sendNotification('my-collection', { subjectTargets: [{ type: 'product', id: 'prod_123' }], severity: 'important', mode: 'preferred', template: { push: { title: 'Update available', body: 'We\'ve shipped an important update.', icon: 'https://cdn.example.com/brand/logo-128.png' }, email: { subject: 'Important update for your product', body: 'There\'s an important update. Open your pass or profile to learn more.' }, walletUpdate: { textModulesData: [ { id: 'notice', header: 'Update', body: 'Open your wallet pass for details.' } ] } } }) if (result.ok) { console.log('Notification queued:', result.notificationId) console.log('Totals:', result.status.totals) } ```
|
|
940
|
+
|
|
681
941
|
### crate
|
|
682
942
|
|
|
683
943
|
**get**(collectionId: string, crateId: string) → `Promise<any>`
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AuthLoginResponse, PhoneSendCodeResponse, PhoneVerifyResponse, PasswordResetRequestResponse, VerifyResetTokenResponse, PasswordResetCompleteResponse, EmailVerificationActionResponse, EmailVerifyTokenResponse, AuthKitConfig } from "../types/authKit";
|
|
2
|
+
/**
|
|
3
|
+
* Namespace containing helper functions for the new AuthKit API.
|
|
4
|
+
* Legacy collection-based authKit helpers retained (marked as *Legacy*).
|
|
5
|
+
*/
|
|
6
|
+
export declare namespace authKit {
|
|
7
|
+
/** Login with email + password (public). */
|
|
8
|
+
function login(clientId: string, email: string, password: string): Promise<AuthLoginResponse>;
|
|
9
|
+
/** Register a new user (public). */
|
|
10
|
+
function register(clientId: string, data: {
|
|
11
|
+
email: string;
|
|
12
|
+
password: string;
|
|
13
|
+
displayName?: string;
|
|
14
|
+
accountData?: Record<string, any>;
|
|
15
|
+
}): Promise<AuthLoginResponse>;
|
|
16
|
+
/** Google OAuth login (public). */
|
|
17
|
+
function googleLogin(clientId: string, idToken: string): Promise<AuthLoginResponse>;
|
|
18
|
+
/** Send phone verification code (public). */
|
|
19
|
+
function sendPhoneCode(clientId: string, phoneNumber: string): Promise<PhoneSendCodeResponse>;
|
|
20
|
+
/** Verify phone verification code (public). */
|
|
21
|
+
function verifyPhoneCode(clientId: string, verificationId: string, code: string): Promise<PhoneVerifyResponse>;
|
|
22
|
+
function requestPasswordReset(clientId: string, data: {
|
|
23
|
+
email: string;
|
|
24
|
+
redirectUrl?: string;
|
|
25
|
+
clientName?: string;
|
|
26
|
+
}): Promise<PasswordResetRequestResponse>;
|
|
27
|
+
function verifyResetToken(clientId: string, token: string): Promise<VerifyResetTokenResponse>;
|
|
28
|
+
function completePasswordReset(clientId: string, token: string, newPassword: string): Promise<PasswordResetCompleteResponse>;
|
|
29
|
+
function sendEmailVerification(clientId: string, data: {
|
|
30
|
+
userId: string;
|
|
31
|
+
email: string;
|
|
32
|
+
redirectUrl?: string;
|
|
33
|
+
clientName?: string;
|
|
34
|
+
}): Promise<EmailVerificationActionResponse>;
|
|
35
|
+
function verifyEmail(clientId: string, token: string): Promise<EmailVerifyTokenResponse>;
|
|
36
|
+
function resendEmailVerification(clientId: string, data: {
|
|
37
|
+
userId: string;
|
|
38
|
+
email: string;
|
|
39
|
+
redirectUrl?: string;
|
|
40
|
+
clientName?: string;
|
|
41
|
+
}): Promise<EmailVerificationActionResponse>;
|
|
42
|
+
function load(authKitId: string): Promise<AuthKitConfig>;
|
|
43
|
+
function get(collectionId: string, authKitId: string): Promise<AuthKitConfig>;
|
|
44
|
+
function list(collectionId: string, admin?: boolean): Promise<AuthKitConfig[]>;
|
|
45
|
+
function create(collectionId: string, data: any): Promise<AuthKitConfig>;
|
|
46
|
+
function update(collectionId: string, authKitId: string, data: any): Promise<AuthKitConfig>;
|
|
47
|
+
function remove(collectionId: string, authKitId: string): Promise<void>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { request, post, put, del } from "../http";
|
|
2
|
+
/**
|
|
3
|
+
* Namespace containing helper functions for the new AuthKit API.
|
|
4
|
+
* Legacy collection-based authKit helpers retained (marked as *Legacy*).
|
|
5
|
+
*/
|
|
6
|
+
export var authKit;
|
|
7
|
+
(function (authKit) {
|
|
8
|
+
/* ===================================
|
|
9
|
+
* Authentication (Per client)
|
|
10
|
+
* =================================== */
|
|
11
|
+
/** Login with email + password (public). */
|
|
12
|
+
async function login(clientId, email, password) {
|
|
13
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/login`, { email, password });
|
|
14
|
+
}
|
|
15
|
+
authKit.login = login;
|
|
16
|
+
/** Register a new user (public). */
|
|
17
|
+
async function register(clientId, data) {
|
|
18
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/register`, data);
|
|
19
|
+
}
|
|
20
|
+
authKit.register = register;
|
|
21
|
+
/** Google OAuth login (public). */
|
|
22
|
+
async function googleLogin(clientId, idToken) {
|
|
23
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/google`, { idToken });
|
|
24
|
+
}
|
|
25
|
+
authKit.googleLogin = googleLogin;
|
|
26
|
+
/** Send phone verification code (public). */
|
|
27
|
+
async function sendPhoneCode(clientId, phoneNumber) {
|
|
28
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/phone/send-code`, { phoneNumber });
|
|
29
|
+
}
|
|
30
|
+
authKit.sendPhoneCode = sendPhoneCode;
|
|
31
|
+
/** Verify phone verification code (public). */
|
|
32
|
+
async function verifyPhoneCode(clientId, verificationId, code) {
|
|
33
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/phone/verify`, { verificationId, code });
|
|
34
|
+
}
|
|
35
|
+
authKit.verifyPhoneCode = verifyPhoneCode;
|
|
36
|
+
/* ===================================
|
|
37
|
+
* Password Reset (Public flows)
|
|
38
|
+
* =================================== */
|
|
39
|
+
async function requestPasswordReset(clientId, data) {
|
|
40
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/reset-password`, data);
|
|
41
|
+
}
|
|
42
|
+
authKit.requestPasswordReset = requestPasswordReset;
|
|
43
|
+
async function verifyResetToken(clientId, token) {
|
|
44
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/verify-reset-token`, { token });
|
|
45
|
+
}
|
|
46
|
+
authKit.verifyResetToken = verifyResetToken;
|
|
47
|
+
async function completePasswordReset(clientId, token, newPassword) {
|
|
48
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/complete-reset`, { token, newPassword });
|
|
49
|
+
}
|
|
50
|
+
authKit.completePasswordReset = completePasswordReset;
|
|
51
|
+
/* ===================================
|
|
52
|
+
* Email Verification
|
|
53
|
+
* =================================== */
|
|
54
|
+
async function sendEmailVerification(clientId, data) {
|
|
55
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/send-verification`, data);
|
|
56
|
+
}
|
|
57
|
+
authKit.sendEmailVerification = sendEmailVerification;
|
|
58
|
+
async function verifyEmail(clientId, token) {
|
|
59
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/verify-email`, { token });
|
|
60
|
+
}
|
|
61
|
+
authKit.verifyEmail = verifyEmail;
|
|
62
|
+
async function resendEmailVerification(clientId, data) {
|
|
63
|
+
return post(`/authkit/${encodeURIComponent(clientId)}/auth/resend-verification`, data);
|
|
64
|
+
}
|
|
65
|
+
authKit.resendEmailVerification = resendEmailVerification;
|
|
66
|
+
/* ===================================
|
|
67
|
+
* Collection-based AuthKit
|
|
68
|
+
* =================================== */
|
|
69
|
+
async function load(authKitId) {
|
|
70
|
+
const path = `authKit/${encodeURIComponent(authKitId)}`;
|
|
71
|
+
return request(path);
|
|
72
|
+
}
|
|
73
|
+
authKit.load = load;
|
|
74
|
+
async function get(collectionId, authKitId) {
|
|
75
|
+
const path = `admin/collection/${encodeURIComponent(collectionId)}/authKit/${encodeURIComponent(authKitId)}`;
|
|
76
|
+
return request(path);
|
|
77
|
+
}
|
|
78
|
+
authKit.get = get;
|
|
79
|
+
async function list(collectionId, admin) {
|
|
80
|
+
const base = admin ? "/admin" : "/public";
|
|
81
|
+
const path = `${base}/collection/${encodeURIComponent(collectionId)}/authKit`;
|
|
82
|
+
return request(path);
|
|
83
|
+
}
|
|
84
|
+
authKit.list = list;
|
|
85
|
+
async function create(collectionId, data) {
|
|
86
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/authKit`;
|
|
87
|
+
return post(path, data);
|
|
88
|
+
}
|
|
89
|
+
authKit.create = create;
|
|
90
|
+
async function update(collectionId, authKitId, data) {
|
|
91
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/authKit/${encodeURIComponent(authKitId)}`;
|
|
92
|
+
return put(path, data);
|
|
93
|
+
}
|
|
94
|
+
authKit.update = update;
|
|
95
|
+
async function remove(collectionId, authKitId) {
|
|
96
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/authKit/${encodeURIComponent(authKitId)}`;
|
|
97
|
+
return del(path);
|
|
98
|
+
}
|
|
99
|
+
authKit.remove = remove;
|
|
100
|
+
})(authKit || (authKit = {}));
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SendNotificationRequest, SendNotificationResponse } from "../types/comms";
|
|
2
|
+
/**
|
|
3
|
+
* Communications namespace for sending notifications and managing user communications
|
|
4
|
+
*/
|
|
5
|
+
export declare namespace comms {
|
|
6
|
+
/**
|
|
7
|
+
* Send a notification to specified targets within a collection.
|
|
8
|
+
*
|
|
9
|
+
* Supports multiple delivery methods including push notifications, email, and wallet pass updates.
|
|
10
|
+
* The notification will be delivered based on user preferences and the specified delivery mode.
|
|
11
|
+
*
|
|
12
|
+
* @param collectionId - ID of the collection containing the notification targets
|
|
13
|
+
* @param request - Notification configuration including targets, severity, and content templates
|
|
14
|
+
* @returns Promise resolving to the notification enqueue/queue status and totals
|
|
15
|
+
* @throws ErrorResponse if the request fails or targets are invalid
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const result = await comms.sendNotification('my-collection', {
|
|
20
|
+
* subjectTargets: [{ type: 'product', id: 'prod_123' }],
|
|
21
|
+
* severity: 'important',
|
|
22
|
+
* mode: 'preferred',
|
|
23
|
+
* template: {
|
|
24
|
+
* push: {
|
|
25
|
+
* title: 'Update available',
|
|
26
|
+
* body: 'We\'ve shipped an important update.',
|
|
27
|
+
* icon: 'https://cdn.example.com/brand/logo-128.png'
|
|
28
|
+
* },
|
|
29
|
+
* email: {
|
|
30
|
+
* subject: 'Important update for your product',
|
|
31
|
+
* body: 'There\'s an important update. Open your pass or profile to learn more.'
|
|
32
|
+
* },
|
|
33
|
+
* walletUpdate: {
|
|
34
|
+
* textModulesData: [
|
|
35
|
+
* { id: 'notice', header: 'Update', body: 'Open your wallet pass for details.' }
|
|
36
|
+
* ]
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* })
|
|
40
|
+
* if (result.ok) {
|
|
41
|
+
* console.log('Notification queued:', result.notificationId)
|
|
42
|
+
* console.log('Totals:', result.status.totals)
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
function sendNotification(collectionId: string, request: SendNotificationRequest): Promise<SendNotificationResponse>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/api/comms.ts
|
|
2
|
+
// Communications and notifications API for Smartlinks
|
|
3
|
+
import { post } from "../http";
|
|
4
|
+
/**
|
|
5
|
+
* Communications namespace for sending notifications and managing user communications
|
|
6
|
+
*/
|
|
7
|
+
export var comms;
|
|
8
|
+
(function (comms) {
|
|
9
|
+
/**
|
|
10
|
+
* Send a notification to specified targets within a collection.
|
|
11
|
+
*
|
|
12
|
+
* Supports multiple delivery methods including push notifications, email, and wallet pass updates.
|
|
13
|
+
* The notification will be delivered based on user preferences and the specified delivery mode.
|
|
14
|
+
*
|
|
15
|
+
* @param collectionId - ID of the collection containing the notification targets
|
|
16
|
+
* @param request - Notification configuration including targets, severity, and content templates
|
|
17
|
+
* @returns Promise resolving to the notification enqueue/queue status and totals
|
|
18
|
+
* @throws ErrorResponse if the request fails or targets are invalid
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const result = await comms.sendNotification('my-collection', {
|
|
23
|
+
* subjectTargets: [{ type: 'product', id: 'prod_123' }],
|
|
24
|
+
* severity: 'important',
|
|
25
|
+
* mode: 'preferred',
|
|
26
|
+
* template: {
|
|
27
|
+
* push: {
|
|
28
|
+
* title: 'Update available',
|
|
29
|
+
* body: 'We\'ve shipped an important update.',
|
|
30
|
+
* icon: 'https://cdn.example.com/brand/logo-128.png'
|
|
31
|
+
* },
|
|
32
|
+
* email: {
|
|
33
|
+
* subject: 'Important update for your product',
|
|
34
|
+
* body: 'There\'s an important update. Open your pass or profile to learn more.'
|
|
35
|
+
* },
|
|
36
|
+
* walletUpdate: {
|
|
37
|
+
* textModulesData: [
|
|
38
|
+
* { id: 'notice', header: 'Update', body: 'Open your wallet pass for details.' }
|
|
39
|
+
* ]
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* })
|
|
43
|
+
* if (result.ok) {
|
|
44
|
+
* console.log('Notification queued:', result.notificationId)
|
|
45
|
+
* console.log('Totals:', result.status.totals)
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
async function sendNotification(collectionId, request) {
|
|
50
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/comm/notify`;
|
|
51
|
+
return post(path, request);
|
|
52
|
+
}
|
|
53
|
+
comms.sendNotification = sendNotification;
|
|
54
|
+
})(comms || (comms = {}));
|
package/dist/api/index.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ export { asset } from "./asset";
|
|
|
7
7
|
export { attestation } from "./attestation";
|
|
8
8
|
export { auth } from "./auth";
|
|
9
9
|
export { form } from "./form";
|
|
10
|
+
export { authKit } from "./authKit";
|
|
10
11
|
export { claimSet } from "./claimSet";
|
|
11
12
|
export { crate } from "./crate";
|
|
12
13
|
export { batch } from "./batch";
|
|
13
14
|
export { variant } from "./variant";
|
|
14
15
|
export { ai } from "./ai";
|
|
16
|
+
export { comms } from "./comms";
|
|
15
17
|
export type { AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto } from "./ai";
|
package/dist/api/index.js
CHANGED
|
@@ -9,8 +9,10 @@ export { asset } from "./asset";
|
|
|
9
9
|
export { attestation } from "./attestation";
|
|
10
10
|
export { auth } from "./auth";
|
|
11
11
|
export { form } from "./form";
|
|
12
|
+
export { authKit } from "./authKit";
|
|
12
13
|
export { claimSet } from "./claimSet";
|
|
13
14
|
export { crate } from "./crate";
|
|
14
15
|
export { batch } from "./batch";
|
|
15
16
|
export { variant } from "./variant";
|
|
16
17
|
export { ai } from "./ai";
|
|
18
|
+
export { comms } from "./comms";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./api";
|
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export type { LoginResponse, VerifyTokenResponse, AccountInfoResponse, } from "./api/auth";
|
|
5
5
|
export type { UserAccountRegistrationRequest, } from "./types/auth";
|
|
6
|
+
export type { SendNotificationRequest, SendNotificationResponse, NotificationSubjectTarget, NotificationTemplate, PushNotificationTemplate, EmailNotificationTemplate, WalletUpdateTemplate, } from "./types/comms";
|
|
6
7
|
export type { AttestationResponse, AttestationCreateRequest, AttestationUpdateRequest, } from "./types/attestation";
|
|
7
8
|
export type { BatchResponse, BatchCreateRequest, BatchUpdateRequest, } from "./types/batch";
|
|
8
9
|
export type { VariantResponse, VariantCreateRequest, VariantUpdateRequest, } from "./types/variant";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface AuthKitUser {
|
|
2
|
+
uid: string;
|
|
3
|
+
email?: string;
|
|
4
|
+
displayName?: string | null;
|
|
5
|
+
photoURL?: string | null;
|
|
6
|
+
phoneNumber?: string | null;
|
|
7
|
+
emailVerified?: boolean;
|
|
8
|
+
accountData?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
export interface AuthLoginResponse {
|
|
11
|
+
token: string;
|
|
12
|
+
user: AuthKitUser;
|
|
13
|
+
accountData?: Record<string, any>;
|
|
14
|
+
}
|
|
15
|
+
export interface PhoneSendCodeResponse {
|
|
16
|
+
verificationId: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PhoneVerifyResponse {
|
|
20
|
+
token: string;
|
|
21
|
+
user: AuthKitUser;
|
|
22
|
+
}
|
|
23
|
+
export interface PasswordResetRequestResponse {
|
|
24
|
+
success: boolean;
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
export interface VerifyResetTokenResponse {
|
|
28
|
+
valid: boolean;
|
|
29
|
+
email?: string;
|
|
30
|
+
expiresAt?: number;
|
|
31
|
+
message?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PasswordResetCompleteResponse {
|
|
34
|
+
success: boolean;
|
|
35
|
+
message: string;
|
|
36
|
+
}
|
|
37
|
+
export interface EmailVerificationActionResponse {
|
|
38
|
+
success: boolean;
|
|
39
|
+
message: string;
|
|
40
|
+
}
|
|
41
|
+
export interface EmailVerifyTokenResponse {
|
|
42
|
+
success: boolean;
|
|
43
|
+
message: string;
|
|
44
|
+
token?: string;
|
|
45
|
+
user?: AuthKitUser;
|
|
46
|
+
}
|
|
47
|
+
export interface AuthKitBrandingConfig {
|
|
48
|
+
logoUrl?: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
subtitle?: string;
|
|
51
|
+
primaryColor?: string;
|
|
52
|
+
secondaryColor?: string;
|
|
53
|
+
backgroundColor?: string;
|
|
54
|
+
buttonStyle?: string;
|
|
55
|
+
fontFamily?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface AuthKitConfig {
|
|
58
|
+
clientId: string;
|
|
59
|
+
branding?: AuthKitBrandingConfig;
|
|
60
|
+
enabledProviders?: string[];
|
|
61
|
+
customCss?: string;
|
|
62
|
+
termsUrl?: string;
|
|
63
|
+
privacyUrl?: string;
|
|
64
|
+
supportEmail?: string;
|
|
65
|
+
redirectUrl?: string;
|
|
66
|
+
updatedAt?: string;
|
|
67
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Target subject for notifications (product, collection, etc.)
|
|
3
|
+
*/
|
|
4
|
+
export interface NotificationSubjectTarget {
|
|
5
|
+
/** Type of target entity */
|
|
6
|
+
type: 'product' | 'collection' | 'user' | 'batch' | 'proof';
|
|
7
|
+
/** ID of the target entity */
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Push notification template content
|
|
12
|
+
*/
|
|
13
|
+
export interface PushNotificationTemplate {
|
|
14
|
+
/** Notification title */
|
|
15
|
+
title: string;
|
|
16
|
+
/** Notification body text */
|
|
17
|
+
body: string;
|
|
18
|
+
/** Optional icon URL for the notification */
|
|
19
|
+
icon?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Email notification template content
|
|
23
|
+
*/
|
|
24
|
+
export interface EmailNotificationTemplate {
|
|
25
|
+
/** Email subject line */
|
|
26
|
+
subject: string;
|
|
27
|
+
/** Email body content (plain text or HTML) */
|
|
28
|
+
body: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Wallet pass update template content
|
|
32
|
+
*/
|
|
33
|
+
export interface WalletUpdateTemplate {
|
|
34
|
+
/** Text modules to update in the wallet pass */
|
|
35
|
+
textModulesData?: Array<{
|
|
36
|
+
/** Module ID */
|
|
37
|
+
id: string;
|
|
38
|
+
/** Module header text */
|
|
39
|
+
header: string;
|
|
40
|
+
/** Module body text */
|
|
41
|
+
body: string;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Notification template containing different delivery methods
|
|
46
|
+
*/
|
|
47
|
+
export interface NotificationTemplate {
|
|
48
|
+
/** Push notification content */
|
|
49
|
+
push?: PushNotificationTemplate;
|
|
50
|
+
/** Email notification content */
|
|
51
|
+
email?: EmailNotificationTemplate;
|
|
52
|
+
/** Wallet pass update content */
|
|
53
|
+
walletUpdate?: WalletUpdateTemplate;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Request payload for sending notifications
|
|
57
|
+
*/
|
|
58
|
+
export interface SendNotificationRequest {
|
|
59
|
+
/** Target subjects that should receive the notification */
|
|
60
|
+
subjectTargets: NotificationSubjectTarget[];
|
|
61
|
+
/** Severity level of the notification */
|
|
62
|
+
severity: 'low' | 'normal' | 'important' | 'critical';
|
|
63
|
+
/** Delivery chanell mode preference */
|
|
64
|
+
mode: 'preferred' | 'all';
|
|
65
|
+
/** Specific channels to use for delivery */
|
|
66
|
+
channels: ("push" | "email" | "wallet")[];
|
|
67
|
+
/** Notification content templates for different delivery methods */
|
|
68
|
+
template: NotificationTemplate;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Response from sending notifications
|
|
72
|
+
*/
|
|
73
|
+
export interface SendNotificationResponse {
|
|
74
|
+
/** Whether the request was accepted */
|
|
75
|
+
ok: boolean;
|
|
76
|
+
/** Unique ID for this notification */
|
|
77
|
+
notificationId: string;
|
|
78
|
+
/** Basic counts for contacts and attempts */
|
|
79
|
+
counts: {
|
|
80
|
+
contacts: number;
|
|
81
|
+
attempts: number;
|
|
82
|
+
};
|
|
83
|
+
/** Detailed status for the notification */
|
|
84
|
+
status: {
|
|
85
|
+
notification: {
|
|
86
|
+
/** The notification ID (repeated for convenience) */
|
|
87
|
+
notificationId: string;
|
|
88
|
+
/** Current processing state */
|
|
89
|
+
state: 'queued' | 'sent' | 'failed' | 'confirmed' | string;
|
|
90
|
+
/** Targets this notification refers to */
|
|
91
|
+
subjectTargets: NotificationSubjectTarget[];
|
|
92
|
+
/** Severity of this notification */
|
|
93
|
+
severity: 'low' | 'normal' | 'important' | 'critical' | string;
|
|
94
|
+
/** Optional channel overrides used when sending */
|
|
95
|
+
channelsOverride: Record<string, any>;
|
|
96
|
+
/** The effective template used */
|
|
97
|
+
template: NotificationTemplate;
|
|
98
|
+
};
|
|
99
|
+
/** Totals across all contacts */
|
|
100
|
+
totals: {
|
|
101
|
+
queued: number;
|
|
102
|
+
sent: number;
|
|
103
|
+
failed: number;
|
|
104
|
+
confirmed: number;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED