@frontiertower/frontier-sdk 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -60,7 +60,10 @@ Your app must declare required permissions in the Frontier app registry:
60
60
 
61
61
  ### User Permissions
62
62
  - `user:getDetails` - Access current user details
63
- - `user:getProfile` - Access user profile information
63
+ - `user:getProfile` - Access current user profile information
64
+ - `user:getReferralOverview` - Access referral statistics
65
+ - `user:getReferralDetails` - Access detailed referral information
66
+ - `user:addUserContact` - Add user contact information
64
67
 
65
68
  ### Chain Permissions
66
69
  - `chain:getCurrentNetwork` - Get current network name
package/dist/index.d.mts CHANGED
@@ -461,12 +461,60 @@ interface UserProfile {
461
461
  /** Whether user has a usable password */
462
462
  hasUsablePassword: string;
463
463
  }
464
+ /**
465
+ * Paginated response wrapper
466
+ */
467
+ interface PaginatedResponse<T> {
468
+ /** Total count of items */
469
+ count: number;
470
+ /** Array of results */
471
+ results: T[];
472
+ }
473
+ /**
474
+ * Referral overview statistics
475
+ */
476
+ interface ReferralOverview {
477
+ /** Total number of referrals */
478
+ totalReferrals: number;
479
+ /** Number of active referrals */
480
+ activeReferrals: number;
481
+ /** Total rewards earned */
482
+ totalRewards: number;
483
+ }
484
+ /**
485
+ * Detailed referral information
486
+ */
487
+ interface ReferralDetails {
488
+ /** Referral ID */
489
+ id: string;
490
+ /** Referred user email */
491
+ email: string;
492
+ /** Referral status */
493
+ status: string;
494
+ /** Date of referral */
495
+ createdAt: string;
496
+ /** Reward amount */
497
+ reward?: number;
498
+ }
499
+ /**
500
+ * User contact information payload
501
+ */
502
+ interface UserContactPayload {
503
+ /** Contact email */
504
+ email?: string;
505
+ /** Contact phone number */
506
+ phoneNumber?: string;
507
+ /** Additional contact information */
508
+ [key: string]: any;
509
+ }
464
510
  /**
465
511
  * User access class for interacting with user information
466
512
  *
467
513
  * This class provides methods to:
468
514
  * - Get current user details
469
515
  * - Get detailed user profiles
516
+ * - Access referral information
517
+ * - Add user contact information
470
518
  *
471
519
  * All methods require appropriate permissions and authentication.
472
520
  */
@@ -491,24 +539,82 @@ declare class UserAccess {
491
539
  */
492
540
  getDetails(): Promise<User>;
493
541
  /**
494
- * Get user profile by ID
542
+ * Get current user profile
495
543
  *
496
- * Returns detailed profile information for a specific user,
544
+ * Returns detailed profile information for the currently authenticated user,
497
545
  * including social media handles, preferences, and community information.
498
546
  *
499
- * @param id - The profile ID to fetch
500
547
  * @returns UserProfile object with detailed information
501
- * @throws {Error} If profile is not found or access is denied
548
+ * @throws {Error} If user is not authenticated or profile is not found
502
549
  *
503
550
  * @example
504
551
  * ```typescript
505
- * const profile = await sdk.getUser().getProfile(123);
552
+ * const profile = await sdk.getUser().getProfile();
506
553
  * console.log('Nickname:', profile.nickname);
507
554
  * console.log('GitHub:', profile.githubHandle);
508
555
  * console.log('Community:', profile.communityName);
509
556
  * ```
510
557
  */
511
- getProfile(id: number): Promise<UserProfile>;
558
+ getProfile(): Promise<UserProfile>;
559
+ /**
560
+ * Get referral overview for current user
561
+ *
562
+ * Returns statistics about the user's referrals, including total count,
563
+ * active referrals, and total rewards earned.
564
+ *
565
+ * @returns ReferralOverview object with referral statistics
566
+ * @throws {Error} If user is not authenticated
567
+ *
568
+ * @example
569
+ * ```typescript
570
+ * const overview = await sdk.getUser().getReferralOverview();
571
+ * console.log('Total referrals:', overview.totalReferrals);
572
+ * console.log('Total rewards:', overview.totalRewards);
573
+ * ```
574
+ */
575
+ getReferralOverview(): Promise<ReferralOverview>;
576
+ /**
577
+ * Get referral details for current user with optional pagination
578
+ *
579
+ * Returns detailed information about each referral, including status,
580
+ * date, and rewards. Supports pagination for large result sets.
581
+ *
582
+ * @param page - Optional page number for pagination (1-indexed)
583
+ * @returns Paginated response with referral details
584
+ * @throws {Error} If user is not authenticated
585
+ *
586
+ * @example
587
+ * ```typescript
588
+ * const details = await sdk.getUser().getReferralDetails();
589
+ * console.log('Total referrals:', details.count);
590
+ * details.results.forEach(ref => {
591
+ * console.log(`${ref.email} - ${ref.status}`);
592
+ * });
593
+ *
594
+ * // With pagination
595
+ * const page2 = await sdk.getUser().getReferralDetails(2);
596
+ * ```
597
+ */
598
+ getReferralDetails(page?: number): Promise<PaginatedResponse<ReferralDetails>>;
599
+ /**
600
+ * Add user contact information
601
+ *
602
+ * Submits contact information for the current user. This can include
603
+ * email, phone number, or other contact details.
604
+ *
605
+ * @param data - Contact information payload
606
+ * @returns Promise that resolves when contact is added
607
+ * @throws {Error} If user is not authenticated or data is invalid
608
+ *
609
+ * @example
610
+ * ```typescript
611
+ * await sdk.getUser().addUserContact({
612
+ * email: 'contact@example.com',
613
+ * phoneNumber: '+1234567890'
614
+ * });
615
+ * ```
616
+ */
617
+ addUserContact(data: UserContactPayload): Promise<void>;
512
618
  }
513
619
 
514
620
  declare class FrontierSDK {
package/dist/index.d.ts CHANGED
@@ -461,12 +461,60 @@ interface UserProfile {
461
461
  /** Whether user has a usable password */
462
462
  hasUsablePassword: string;
463
463
  }
464
+ /**
465
+ * Paginated response wrapper
466
+ */
467
+ interface PaginatedResponse<T> {
468
+ /** Total count of items */
469
+ count: number;
470
+ /** Array of results */
471
+ results: T[];
472
+ }
473
+ /**
474
+ * Referral overview statistics
475
+ */
476
+ interface ReferralOverview {
477
+ /** Total number of referrals */
478
+ totalReferrals: number;
479
+ /** Number of active referrals */
480
+ activeReferrals: number;
481
+ /** Total rewards earned */
482
+ totalRewards: number;
483
+ }
484
+ /**
485
+ * Detailed referral information
486
+ */
487
+ interface ReferralDetails {
488
+ /** Referral ID */
489
+ id: string;
490
+ /** Referred user email */
491
+ email: string;
492
+ /** Referral status */
493
+ status: string;
494
+ /** Date of referral */
495
+ createdAt: string;
496
+ /** Reward amount */
497
+ reward?: number;
498
+ }
499
+ /**
500
+ * User contact information payload
501
+ */
502
+ interface UserContactPayload {
503
+ /** Contact email */
504
+ email?: string;
505
+ /** Contact phone number */
506
+ phoneNumber?: string;
507
+ /** Additional contact information */
508
+ [key: string]: any;
509
+ }
464
510
  /**
465
511
  * User access class for interacting with user information
466
512
  *
467
513
  * This class provides methods to:
468
514
  * - Get current user details
469
515
  * - Get detailed user profiles
516
+ * - Access referral information
517
+ * - Add user contact information
470
518
  *
471
519
  * All methods require appropriate permissions and authentication.
472
520
  */
@@ -491,24 +539,82 @@ declare class UserAccess {
491
539
  */
492
540
  getDetails(): Promise<User>;
493
541
  /**
494
- * Get user profile by ID
542
+ * Get current user profile
495
543
  *
496
- * Returns detailed profile information for a specific user,
544
+ * Returns detailed profile information for the currently authenticated user,
497
545
  * including social media handles, preferences, and community information.
498
546
  *
499
- * @param id - The profile ID to fetch
500
547
  * @returns UserProfile object with detailed information
501
- * @throws {Error} If profile is not found or access is denied
548
+ * @throws {Error} If user is not authenticated or profile is not found
502
549
  *
503
550
  * @example
504
551
  * ```typescript
505
- * const profile = await sdk.getUser().getProfile(123);
552
+ * const profile = await sdk.getUser().getProfile();
506
553
  * console.log('Nickname:', profile.nickname);
507
554
  * console.log('GitHub:', profile.githubHandle);
508
555
  * console.log('Community:', profile.communityName);
509
556
  * ```
510
557
  */
511
- getProfile(id: number): Promise<UserProfile>;
558
+ getProfile(): Promise<UserProfile>;
559
+ /**
560
+ * Get referral overview for current user
561
+ *
562
+ * Returns statistics about the user's referrals, including total count,
563
+ * active referrals, and total rewards earned.
564
+ *
565
+ * @returns ReferralOverview object with referral statistics
566
+ * @throws {Error} If user is not authenticated
567
+ *
568
+ * @example
569
+ * ```typescript
570
+ * const overview = await sdk.getUser().getReferralOverview();
571
+ * console.log('Total referrals:', overview.totalReferrals);
572
+ * console.log('Total rewards:', overview.totalRewards);
573
+ * ```
574
+ */
575
+ getReferralOverview(): Promise<ReferralOverview>;
576
+ /**
577
+ * Get referral details for current user with optional pagination
578
+ *
579
+ * Returns detailed information about each referral, including status,
580
+ * date, and rewards. Supports pagination for large result sets.
581
+ *
582
+ * @param page - Optional page number for pagination (1-indexed)
583
+ * @returns Paginated response with referral details
584
+ * @throws {Error} If user is not authenticated
585
+ *
586
+ * @example
587
+ * ```typescript
588
+ * const details = await sdk.getUser().getReferralDetails();
589
+ * console.log('Total referrals:', details.count);
590
+ * details.results.forEach(ref => {
591
+ * console.log(`${ref.email} - ${ref.status}`);
592
+ * });
593
+ *
594
+ * // With pagination
595
+ * const page2 = await sdk.getUser().getReferralDetails(2);
596
+ * ```
597
+ */
598
+ getReferralDetails(page?: number): Promise<PaginatedResponse<ReferralDetails>>;
599
+ /**
600
+ * Add user contact information
601
+ *
602
+ * Submits contact information for the current user. This can include
603
+ * email, phone number, or other contact details.
604
+ *
605
+ * @param data - Contact information payload
606
+ * @returns Promise that resolves when contact is added
607
+ * @throws {Error} If user is not authenticated or data is invalid
608
+ *
609
+ * @example
610
+ * ```typescript
611
+ * await sdk.getUser().addUserContact({
612
+ * email: 'contact@example.com',
613
+ * phoneNumber: '+1234567890'
614
+ * });
615
+ * ```
616
+ */
617
+ addUserContact(data: UserContactPayload): Promise<void>;
512
618
  }
513
619
 
514
620
  declare class FrontierSDK {
package/dist/index.js CHANGED
@@ -397,25 +397,89 @@ var UserAccess = class {
397
397
  return this.sdk.request("user:getDetails");
398
398
  }
399
399
  /**
400
- * Get user profile by ID
400
+ * Get current user profile
401
401
  *
402
- * Returns detailed profile information for a specific user,
402
+ * Returns detailed profile information for the currently authenticated user,
403
403
  * including social media handles, preferences, and community information.
404
404
  *
405
- * @param id - The profile ID to fetch
406
405
  * @returns UserProfile object with detailed information
407
- * @throws {Error} If profile is not found or access is denied
406
+ * @throws {Error} If user is not authenticated or profile is not found
408
407
  *
409
408
  * @example
410
409
  * ```typescript
411
- * const profile = await sdk.getUser().getProfile(123);
410
+ * const profile = await sdk.getUser().getProfile();
412
411
  * console.log('Nickname:', profile.nickname);
413
412
  * console.log('GitHub:', profile.githubHandle);
414
413
  * console.log('Community:', profile.communityName);
415
414
  * ```
416
415
  */
417
- async getProfile(id) {
418
- return this.sdk.request("user:getProfile", { id });
416
+ async getProfile() {
417
+ return this.sdk.request("user:getProfile");
418
+ }
419
+ /**
420
+ * Get referral overview for current user
421
+ *
422
+ * Returns statistics about the user's referrals, including total count,
423
+ * active referrals, and total rewards earned.
424
+ *
425
+ * @returns ReferralOverview object with referral statistics
426
+ * @throws {Error} If user is not authenticated
427
+ *
428
+ * @example
429
+ * ```typescript
430
+ * const overview = await sdk.getUser().getReferralOverview();
431
+ * console.log('Total referrals:', overview.totalReferrals);
432
+ * console.log('Total rewards:', overview.totalRewards);
433
+ * ```
434
+ */
435
+ async getReferralOverview() {
436
+ return this.sdk.request("user:getReferralOverview");
437
+ }
438
+ /**
439
+ * Get referral details for current user with optional pagination
440
+ *
441
+ * Returns detailed information about each referral, including status,
442
+ * date, and rewards. Supports pagination for large result sets.
443
+ *
444
+ * @param page - Optional page number for pagination (1-indexed)
445
+ * @returns Paginated response with referral details
446
+ * @throws {Error} If user is not authenticated
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * const details = await sdk.getUser().getReferralDetails();
451
+ * console.log('Total referrals:', details.count);
452
+ * details.results.forEach(ref => {
453
+ * console.log(`${ref.email} - ${ref.status}`);
454
+ * });
455
+ *
456
+ * // With pagination
457
+ * const page2 = await sdk.getUser().getReferralDetails(2);
458
+ * ```
459
+ */
460
+ async getReferralDetails(page) {
461
+ return this.sdk.request("user:getReferralDetails", page);
462
+ }
463
+ /**
464
+ * Add user contact information
465
+ *
466
+ * Submits contact information for the current user. This can include
467
+ * email, phone number, or other contact details.
468
+ *
469
+ * @param data - Contact information payload
470
+ * @returns Promise that resolves when contact is added
471
+ * @throws {Error} If user is not authenticated or data is invalid
472
+ *
473
+ * @example
474
+ * ```typescript
475
+ * await sdk.getUser().addUserContact({
476
+ * email: 'contact@example.com',
477
+ * phoneNumber: '+1234567890'
478
+ * });
479
+ * ```
480
+ */
481
+ async addUserContact(data) {
482
+ return this.sdk.request("user:addUserContact", data);
419
483
  }
420
484
  };
421
485
 
package/dist/index.mjs CHANGED
@@ -367,25 +367,89 @@ var UserAccess = class {
367
367
  return this.sdk.request("user:getDetails");
368
368
  }
369
369
  /**
370
- * Get user profile by ID
370
+ * Get current user profile
371
371
  *
372
- * Returns detailed profile information for a specific user,
372
+ * Returns detailed profile information for the currently authenticated user,
373
373
  * including social media handles, preferences, and community information.
374
374
  *
375
- * @param id - The profile ID to fetch
376
375
  * @returns UserProfile object with detailed information
377
- * @throws {Error} If profile is not found or access is denied
376
+ * @throws {Error} If user is not authenticated or profile is not found
378
377
  *
379
378
  * @example
380
379
  * ```typescript
381
- * const profile = await sdk.getUser().getProfile(123);
380
+ * const profile = await sdk.getUser().getProfile();
382
381
  * console.log('Nickname:', profile.nickname);
383
382
  * console.log('GitHub:', profile.githubHandle);
384
383
  * console.log('Community:', profile.communityName);
385
384
  * ```
386
385
  */
387
- async getProfile(id) {
388
- return this.sdk.request("user:getProfile", { id });
386
+ async getProfile() {
387
+ return this.sdk.request("user:getProfile");
388
+ }
389
+ /**
390
+ * Get referral overview for current user
391
+ *
392
+ * Returns statistics about the user's referrals, including total count,
393
+ * active referrals, and total rewards earned.
394
+ *
395
+ * @returns ReferralOverview object with referral statistics
396
+ * @throws {Error} If user is not authenticated
397
+ *
398
+ * @example
399
+ * ```typescript
400
+ * const overview = await sdk.getUser().getReferralOverview();
401
+ * console.log('Total referrals:', overview.totalReferrals);
402
+ * console.log('Total rewards:', overview.totalRewards);
403
+ * ```
404
+ */
405
+ async getReferralOverview() {
406
+ return this.sdk.request("user:getReferralOverview");
407
+ }
408
+ /**
409
+ * Get referral details for current user with optional pagination
410
+ *
411
+ * Returns detailed information about each referral, including status,
412
+ * date, and rewards. Supports pagination for large result sets.
413
+ *
414
+ * @param page - Optional page number for pagination (1-indexed)
415
+ * @returns Paginated response with referral details
416
+ * @throws {Error} If user is not authenticated
417
+ *
418
+ * @example
419
+ * ```typescript
420
+ * const details = await sdk.getUser().getReferralDetails();
421
+ * console.log('Total referrals:', details.count);
422
+ * details.results.forEach(ref => {
423
+ * console.log(`${ref.email} - ${ref.status}`);
424
+ * });
425
+ *
426
+ * // With pagination
427
+ * const page2 = await sdk.getUser().getReferralDetails(2);
428
+ * ```
429
+ */
430
+ async getReferralDetails(page) {
431
+ return this.sdk.request("user:getReferralDetails", page);
432
+ }
433
+ /**
434
+ * Add user contact information
435
+ *
436
+ * Submits contact information for the current user. This can include
437
+ * email, phone number, or other contact details.
438
+ *
439
+ * @param data - Contact information payload
440
+ * @returns Promise that resolves when contact is added
441
+ * @throws {Error} If user is not authenticated or data is invalid
442
+ *
443
+ * @example
444
+ * ```typescript
445
+ * await sdk.getUser().addUserContact({
446
+ * email: 'contact@example.com',
447
+ * phoneNumber: '+1234567890'
448
+ * });
449
+ * ```
450
+ */
451
+ async addUserContact(data) {
452
+ return this.sdk.request("user:addUserContact", data);
389
453
  }
390
454
  };
391
455
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontiertower/frontier-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "SDK for building apps on Frontier Wallet",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -47,5 +47,8 @@
47
47
  "type": "git",
48
48
  "url": "git+https://github.com/BerlinhouseLabs/frontier-sdk.git"
49
49
  },
50
- "readme": "README.md"
50
+ "readme": "README.md",
51
+ "dependencies": {
52
+ "@frontiertower/frontier-sdk": "^0.3.0"
53
+ }
51
54
  }