apps-sdk 2.1.2 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/index.d.ts CHANGED
@@ -37,6 +37,10 @@ declare module 'apps-sdk' {
37
37
  init(): Promise<void>;
38
38
  setDebugMode(debugMode: boolean): void;
39
39
  setConfigEndpoint(endpoint: string): void;
40
+ setUserCreateEndpoint(endpoint: string): void;
41
+ setBaseUrl(baseUrl: string): void;
42
+ getCredits(webappUrl: string, websiteId: string): Promise<number>;
43
+ getWebappBasePayload(websiteId: string, additionalData?: any): any;
40
44
  initSession(): Promise<void>;
41
45
  storeSessionStructure(): Promise<void>;
42
46
  checkFirstOpen(): Promise<void>;
@@ -119,8 +123,42 @@ declare module 'apps-sdk' {
119
123
  isSpecialEvent(eventKeyword: string): boolean;
120
124
  }
121
125
 
126
+ export interface RatingConfigOptions {
127
+ /** Called when the sentiment prompt ("Are you enjoying the app?") should be shown. */
128
+ onShowSentimentPrompt: (source: string) => void;
129
+ /** Called when the feedback form should be shown (user said NO). */
130
+ onShowFeedbackForm: () => void;
131
+ /** Called to track analytics events. */
132
+ onTrackEvent: (eventName: string, properties: Record<string, any>) => void;
133
+ /** Optional: called after feedback text is submitted. */
134
+ onSubmitFeedback?: (feedbackText: string) => Promise<void>;
135
+ }
136
+
122
137
  export class Rating {
123
- showRatingDialog(force?: boolean): Promise<void>;
138
+ /** Register UI callbacks. Call once on app startup after initialize(). */
139
+ configure(options: RatingConfigOptions): void;
140
+ /** Load persisted state from storage. Call on app startup. */
141
+ initialize(): Promise<void>;
142
+ /** Trigger rating flow after a successful AI interaction. */
143
+ onAIInteractionSuccess(isUserInitiated?: boolean): Promise<void>;
144
+ /** Trigger rating flow when credits are running low. */
145
+ onCreditsRunningLow(currentCredits: number): Promise<void>;
146
+ /** Trigger rating flow after user downloads or shares a result. */
147
+ onResultDownloadedOrShared(actionType: 'download' | 'share'): Promise<void>;
148
+ /** Directly call StoreReview.requestReview(). */
149
+ triggerNativeRating(): Promise<void>;
150
+ /** Call this when the user taps YES on the sentiment prompt. */
151
+ onUserRespondedYes(): Promise<void>;
152
+ /** Call this when the user taps NO on the sentiment prompt. */
153
+ onUserRespondedNo(): void;
154
+ /** Submit written feedback text. */
155
+ submitFeedback(feedbackText: string): Promise<void>;
156
+ /** Call when the user dismisses the feedback form without submitting. */
157
+ onFeedbackCanceled(): void;
158
+ /** Reset all persisted rating state (for debugging/testing). */
159
+ reset(): Promise<void>;
160
+ /** @deprecated Legacy method — use the new flow methods instead. */
161
+ showRatingDialog(force?: boolean): Promise<{ success: boolean; shown: boolean; [key: string]: any }>;
124
162
  }
125
163
 
126
164
  export class NotificationsPush {
@@ -305,6 +343,269 @@ declare module 'apps-sdk' {
305
343
  setUserProperty(name: string, value: string): Promise<void>;
306
344
  }
307
345
 
346
+ // ─── Authentication ────────────────────────────────────────────────────────
347
+
348
+ export interface AuthApiResult<T = any> {
349
+ success: boolean;
350
+ data?: T;
351
+ error?: string;
352
+ code?: number;
353
+ message?: string;
354
+ raw?: any;
355
+ }
356
+
357
+ export interface AuthLoginPayload {
358
+ /** Email or username */
359
+ login?: string;
360
+ /** Credential (alias for login) */
361
+ credential?: string;
362
+ /** Password */
363
+ password: string;
364
+ /** Optional website ID (defaults to config value) */
365
+ websiteid?: string;
366
+ }
367
+
368
+ export interface AuthRegisterPayload {
369
+ /** Email or username */
370
+ login?: string;
371
+ /** Email (alias for login) */
372
+ email?: string;
373
+ /** Password */
374
+ password: string;
375
+ /** Optional website ID (defaults to config value) */
376
+ websiteid?: string;
377
+ }
378
+
379
+ export interface AuthRegisterAndLinkPayload {
380
+ email: string;
381
+ password: string;
382
+ }
383
+
384
+ export interface AuthLinkUserPayload {
385
+ /** Web user ID */
386
+ user_id: string;
387
+ /** Mobile app user ID */
388
+ app_user_id: string;
389
+ }
390
+
391
+ export interface AuthCheckLinkPayload {
392
+ user_id: string;
393
+ app_user_id: string;
394
+ }
395
+
396
+ export interface AuthCheckSubscriptionPayload {
397
+ user_id: string;
398
+ app_user_id: string;
399
+ }
400
+
401
+ export interface AuthValidatePhonePayload {
402
+ phoneNumber: string;
403
+ countryCode: string;
404
+ }
405
+
406
+ export interface AuthRequestPasswordResetPayload {
407
+ credential: string;
408
+ }
409
+
410
+ export interface AuthVerifyResetCodePayload {
411
+ code: string;
412
+ }
413
+
414
+ export interface AuthResetPasswordPayload {
415
+ resetToken: string;
416
+ newPassword: string;
417
+ }
418
+
419
+ export interface AuthResendCodePayload {
420
+ credential: string;
421
+ }
422
+
423
+ export interface AuthValidateQrCodePayload {
424
+ qrData: string;
425
+ }
426
+
427
+ export interface AuthLinkWithQrCodePayload {
428
+ user_id: string;
429
+ }
430
+
431
+ export interface AuthUserData {
432
+ us_id: string | number;
433
+ us_login?: string;
434
+ login?: string;
435
+ metadata?: Record<string, any> | any[];
436
+ subscription_data?: AuthSubscriptionData;
437
+ success?: number;
438
+ }
439
+
440
+ export interface AuthSubscriptionData {
441
+ subscription_active?: boolean;
442
+ [key: string]: any;
443
+ }
444
+
445
+ export interface AuthLinkedUserData {
446
+ success: number;
447
+ linked: boolean;
448
+ items?: AuthUserData[];
449
+ }
450
+
451
+ export interface AuthRegisterAndLinkResult {
452
+ success: boolean;
453
+ user?: AuthUserData;
454
+ linked?: boolean;
455
+ error?: string;
456
+ code?: number;
457
+ }
458
+
459
+ export interface AuthQrValidationData {
460
+ valid: boolean;
461
+ user_id?: string;
462
+ }
463
+
464
+ export interface AuthQrLinkData {
465
+ linked: boolean;
466
+ message?: string;
467
+ subscriptionActive?: boolean;
468
+ }
469
+
470
+ export interface AuthCallApiOptions {
471
+ retries?: number;
472
+ timeoutMs?: number;
473
+ silent?: boolean;
474
+ }
475
+
476
+ export class Authentication {
477
+ AUTH_API_BASE_URL: string;
478
+ USER_API_BASE_URL: string;
479
+ CHATCONNECT_API_BASE_URL: string;
480
+
481
+ /** Get website ID from config */
482
+ getWebsiteId(): string;
483
+
484
+ /** Get app user ID from session */
485
+ getAppUserId(): string;
486
+
487
+ /**
488
+ * Generic API call helper with retry logic.
489
+ */
490
+ callApi(url: string, payload: object, opts?: AuthCallApiOptions): Promise<AuthApiResult>;
491
+
492
+ /**
493
+ * Login with credentials.
494
+ * POST /auth/auth-user
495
+ */
496
+ login(payload: AuthLoginPayload): Promise<AuthApiResult<AuthUserData>>;
497
+
498
+ /**
499
+ * Register a new user account.
500
+ * POST /chatconnect/create-user
501
+ */
502
+ register(payload: AuthRegisterPayload): Promise<AuthApiResult<{ user: AuthUserData }>>;
503
+
504
+ /**
505
+ * Complete registration flow: create-user → link-user.
506
+ */
507
+ registerAndLinkAccount(payload: AuthRegisterAndLinkPayload): Promise<AuthRegisterAndLinkResult>;
508
+
509
+ /**
510
+ * Link a user account.
511
+ * POST /user/link
512
+ */
513
+ linkUser(payload: AuthLinkUserPayload): Promise<AuthApiResult<AuthLinkedUserData>>;
514
+
515
+ /**
516
+ * Fetch authenticated user profile using stored credentials.
517
+ */
518
+ fetchUserProfile(): Promise<AuthApiResult<AuthUserData>>;
519
+
520
+ /**
521
+ * Check if user account is linked (using stored data).
522
+ */
523
+ isAccountLinked(): Promise<boolean>;
524
+
525
+ /**
526
+ * Get stored auth user login (email).
527
+ */
528
+ getStoredUserLogin(): Promise<string | null>;
529
+
530
+ /**
531
+ * Check if user is linked.
532
+ * POST /user/check-link
533
+ */
534
+ checkLink(payload: AuthCheckLinkPayload): Promise<AuthApiResult>;
535
+
536
+ /**
537
+ * Check user subscription status.
538
+ * POST /user/check-subs
539
+ */
540
+ checkSubscription(payload: AuthCheckSubscriptionPayload): Promise<AuthApiResult>;
541
+
542
+ /**
543
+ * Check if a credential exists (stub for backward compatibility).
544
+ */
545
+ checkCredential(payload: { credentialType: string; [key: string]: any }): Promise<AuthApiResult<{ exists: boolean; credentialType: string; requiresPhone: boolean }>>;
546
+
547
+ /**
548
+ * Validate phone number (client-side).
549
+ */
550
+ validatePhone(payload: AuthValidatePhonePayload): Promise<AuthApiResult<{ valid: boolean; formattedPhone?: string }>>;
551
+
552
+ /**
553
+ * Request password reset (stub).
554
+ */
555
+ requestPasswordReset(payload: AuthRequestPasswordResetPayload): Promise<AuthApiResult<{ sent: boolean; destination: string; expiresIn: number }>>;
556
+
557
+ /**
558
+ * Verify reset code (stub).
559
+ */
560
+ verifyResetCode(payload: AuthVerifyResetCodePayload): Promise<AuthApiResult<{ valid: boolean; resetToken: string }>>;
561
+
562
+ /**
563
+ * Reset password (stub).
564
+ */
565
+ resetPassword(payload: AuthResetPasswordPayload): Promise<AuthApiResult<{ success: boolean; message: string }>>;
566
+
567
+ /**
568
+ * Resend verification code (stub).
569
+ */
570
+ resendCode(payload: AuthResendCodePayload): Promise<AuthApiResult<{ sent: boolean; canResendAt: string }>>;
571
+
572
+ /**
573
+ * Validate QR code data.
574
+ */
575
+ validateQrCode(payload: AuthValidateQrCodePayload): Promise<AuthApiResult<AuthQrValidationData>>;
576
+
577
+ /**
578
+ * Link account using QR code.
579
+ * POST /user/link
580
+ */
581
+ linkWithQrCode(payload: AuthLinkWithQrCodePayload): Promise<AuthApiResult<AuthQrLinkData>>;
582
+
583
+ /**
584
+ * Logout current user (clears stored auth data).
585
+ */
586
+ logout(): Promise<AuthApiResult<{ success: boolean }>>;
587
+
588
+ /**
589
+ * Check if user is currently authenticated (has stored user ID).
590
+ */
591
+ isAuthenticated(): Promise<boolean>;
592
+
593
+ /**
594
+ * Get stored user ID.
595
+ */
596
+ getStoredUserId(): Promise<string | null>;
597
+
598
+ /**
599
+ * Get stored user metadata.
600
+ */
601
+ getStoredUserMetadata(): Promise<Record<string, any> | null>;
602
+
603
+ /**
604
+ * Get stored subscription data.
605
+ */
606
+ getStoredSubscription(): Promise<AuthSubscriptionData | null>;
607
+ }
608
+
308
609
  export class AppsSDK {
309
610
  initializePushNotifications(): Promise<string>;
310
611
  }
@@ -323,13 +624,16 @@ declare module 'apps-sdk' {
323
624
  mixpanel : MixPanel;
324
625
  tracking : TrackingTransparency;
325
626
  paywallLogic : PayWallLogic;
627
+ /** @deprecated Use `notifications` instead */
326
628
  notificationsPush : NotificationsPush;
629
+ notifications : NotificationsPush;
327
630
  voice : Voice;
328
631
  adapty : Adapty;
329
632
  homeActions : HomeActions;
330
633
  facebook : Facebook;
331
634
  firebase : Firebase;
332
635
  legal : Legal;
636
+ authentication : Authentication;
333
637
  }
334
638
 
335
639
  const Core: AppsSDK;