@arkadiuminc/sdk 2.22.3 → 2.23.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.
@@ -28,30 +28,24 @@ interface AuthUIManagerContract {
28
28
  openAuthRequest: ReturnType<typeof createStore<boolean>>;
29
29
  openAuthForm(): Promise<void>;
30
30
  }
31
- export declare class Auth {
32
- private userProfileReader;
33
- private authUIManager;
34
- private authProblem;
35
- constructor(userProfileReader: UserProfileReaderContract, authUIManager: AuthUIManagerContract);
31
+ export declare abstract class Auth {
32
+ protected userProfileReader: UserProfileReaderContract;
33
+ protected authUIManager: AuthUIManagerContract | undefined;
34
+ constructor(backendApi: Backend, host: IHost);
36
35
  init(): Promise<void>;
37
36
  isUserAuthorized(): Promise<boolean>;
38
- getUserProfile(): Promise<UserProfile | null>;
37
+ abstract getUserProfile(): Promise<UserProfile | null>;
39
38
  onAuthStatusChange(observer: any): () => void;
40
39
  openAuthForm(): Promise<void>;
41
- /**
42
- * this method should be exercised on the game side to let game know about
43
- * issues that happen during auth outside the scope of direct API calls
44
- */
45
- onAuthProblemChange(observer: any): Promise<void>;
46
- /**
47
- * this method should be internally called every time a problem happens
48
- * outside the scope of direct API calls
49
- * @private
50
- * @param error string
51
- */
52
- raiseOnAuthProblem(error: string): void;
53
- onOpenAuthForm(observer: any): () => void;
54
- static getArenaApi(backendApi: Backend, host: IHost, rpcProvider: RpcProvider): Auth;
55
- static getGameApi(backendApi: Backend, host: IHost, rpcProvider: RpcProvider): Auth;
40
+ onOpenAuthForm(observer: any): (() => void) | undefined;
41
+ }
42
+ export declare class AuthArena extends Auth {
43
+ constructor(backendApi: Backend, host: IHost, rpcProvider: RpcProvider);
44
+ getUserProfile(): Promise<UserProfile | null>;
45
+ }
46
+ export declare class AuthGame extends Auth {
47
+ private rpcProvider;
48
+ constructor(backendApi: Backend, host: IHost, rpcProvider: RpcProvider);
49
+ getUserProfile(): Promise<UserProfile | null>;
56
50
  }
57
51
  export {};
@@ -1,19 +1,20 @@
1
1
  import { ApiEnv, Backend } from '../backend/backend.api';
2
2
  import { GameLifecycleContract } from '../game-lifecycle/game-lifecycle.api';
3
+ import { RpcProvider } from '../../core/rpc';
3
4
 
4
5
  export interface Wallet {
5
- init(env: ApiEnv): Promise<void>;
6
+ init?(env: ApiEnv): Promise<void>;
6
7
  getGems(): Promise<number>;
7
8
  consumeGems(amount: number): Promise<boolean>;
8
9
  }
9
- export declare class WalletGame implements Wallet {
10
+ export declare class WalletArena implements Wallet {
10
11
  private backendApi;
11
12
  private lifecycle;
12
13
  private virtualItemsApi;
13
14
  private virtualItemGateway;
14
15
  private currencySku;
15
16
  private isInited;
16
- constructor(backendApi: Backend, lifecycle: GameLifecycleContract);
17
+ constructor(backendApi: Backend, lifecycle: GameLifecycleContract, rpcProvider: RpcProvider);
17
18
  init(env: ApiEnv): Promise<void>;
18
19
  /**
19
20
  * Allows querying for the wallet balance
@@ -27,3 +28,18 @@ export declare class WalletGame implements Wallet {
27
28
  */
28
29
  consumeGems(amount: number): Promise<boolean>;
29
30
  }
31
+ export declare class WalletGame implements Wallet {
32
+ private rpcProvider;
33
+ constructor(rpcProvider: RpcProvider);
34
+ /**
35
+ * Allows querying for the wallet balance
36
+ * @returns the amount of gems in the user wallet
37
+ */
38
+ getGems(): Promise<number>;
39
+ /**
40
+ * Consumes the desired amount of gems from the user wallet
41
+ * @param amount
42
+ * @returns true if the spending of the gem amount was successful, false otherwise
43
+ */
44
+ consumeGems(amount: number): Promise<boolean>;
45
+ }
@@ -0,0 +1,27 @@
1
+ interface Image {
2
+ png: string;
3
+ webp: string;
4
+ }
5
+ interface UserProfile {
6
+ uid: string;
7
+ username: string;
8
+ avatar: Image;
9
+ avatarFrame?: Image;
10
+ avatarBackground?: string;
11
+ isUserSubscriber: boolean;
12
+ aarpMembershipStatus?: boolean;
13
+ coins?: number;
14
+ level?: number;
15
+ }
16
+ export declare type MockUser = {
17
+ profile: UserProfile;
18
+ wallet: {
19
+ getGems: () => number;
20
+ consumeGems: (amount: number) => boolean;
21
+ };
22
+ };
23
+ export declare function getMockUserEnabled(): boolean;
24
+ export declare function setMockUserEnabled(enabled: boolean): void;
25
+ export declare function getMockUser(): MockUser | undefined;
26
+ export declare function setMockUser(user: MockUser): void;
27
+ export {};
@@ -2,13 +2,15 @@ import { ApiEnv, Backend, SessionStorageType } from './api/features/backend/back
2
2
  import { GameLifecycleContract } from './api/features/game-lifecycle/game-lifecycle.api';
3
3
  import { RpcProvider } from './api/core/rpc';
4
4
  import { AdsArena } from './api/features/ads/';
5
- import { Auth } from './api/features/auth/';
5
+ import { AuthArena } from './api/features/auth/';
6
6
  import { AnalyticsApiContract } from './api/features/analytics/analytics.api';
7
7
  import { Observable } from './api/utils/observable';
8
8
  import { TimeoutTesterContract } from './api/core/timeout-tester';
9
9
  import { PersistenceArena } from './api/features/persistence';
10
10
  import { HostArena } from './api/features/host';
11
+ import { WalletArena } from './api/features/wallet';
11
12
 
13
+ import * as MockUserUtils from './api/utils/mockUser';
12
14
  /** @hidden */
13
15
  export declare class ArkadiumArenaSdk {
14
16
  private rpcProvider;
@@ -16,17 +18,18 @@ export declare class ArkadiumArenaSdk {
16
18
  host: HostArena;
17
19
  lifecycle: GameLifecycleContract;
18
20
  ads: AdsArena;
19
- auth: Auth;
21
+ auth: AuthArena;
20
22
  analytics: AnalyticsApiContract;
21
23
  private timeoutTester;
22
24
  persistence: PersistenceArena;
25
+ private wallet;
23
26
  private currentEnv;
24
27
  private currentTarget;
25
28
  private gamePingSender;
26
29
  private gamePingListener;
27
30
  $pingNotification: Observable<number>;
28
31
  version: string;
29
- constructor(rpcProvider: RpcProvider, backendApi: Backend, host: HostArena, lifecycle: GameLifecycleContract, ads: AdsArena, auth: Auth, analytics: AnalyticsApiContract, timeoutTester: TimeoutTesterContract, persistence: PersistenceArena);
32
+ constructor(rpcProvider: RpcProvider, backendApi: Backend, host: HostArena, lifecycle: GameLifecycleContract, ads: AdsArena, auth: AuthArena, analytics: AnalyticsApiContract, timeoutTester: TimeoutTesterContract, persistence: PersistenceArena, wallet: WalletArena);
30
33
  setEnv(e: ApiEnv): void;
31
34
  initialize(env: ApiEnv, isGameSide: boolean, sessionStorage?: SessionStorageType | null): Promise<void>;
32
35
  private envDiscoverListener;
@@ -34,6 +37,10 @@ export declare class ArkadiumArenaSdk {
34
37
  debugMode(enabled: boolean): void;
35
38
  ping(): Promise<any>;
36
39
  dispose(): void;
40
+ setMockUserConfig({ isEnabled, mockUser }: {
41
+ isEnabled: boolean;
42
+ mockUser: MockUserUtils.MockUser;
43
+ }): void;
37
44
  }
38
45
  export { ApiEnv };
39
46
  /** @hidden */
@@ -1,7 +1,7 @@
1
1
  import { ApiEnv, Backend } from './api/features/backend/backend.api';
2
2
  import { GameLifecycleContract } from './api/features/game-lifecycle/game-lifecycle.api';
3
3
  import { AdsGame } from './api/features/ads/';
4
- import { Auth } from './api/features/auth/';
4
+ import { AuthGame } from './api/features/auth/';
5
5
  import { AnalyticsApiContract } from './api/features/analytics/analytics.api';
6
6
  import { RpcProvider } from './api/core/rpc';
7
7
  import { TimeoutTesterContract } from './api/core/timeout-tester';
@@ -19,7 +19,7 @@ export declare class ArkadiumGameSdk {
19
19
  host: HostGame;
20
20
  lifecycle: GameLifecycleContract;
21
21
  ads: AdsGame;
22
- auth: Auth;
22
+ auth: AuthGame;
23
23
  analytics: AnalyticsApiContract;
24
24
  private timeoutTester;
25
25
  persistence: PersistenceGame;
@@ -30,7 +30,7 @@ export declare class ArkadiumGameSdk {
30
30
  host: HostGame;
31
31
  lifecycle: GameLifecycleContract;
32
32
  ads: AdsGame;
33
- auth: Auth;
33
+ auth: AuthGame;
34
34
  analytics: AnalyticsApiContract;
35
35
  timeoutTester: TimeoutTesterContract;
36
36
  persistence: PersistenceGame;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkadiuminc/sdk",
3
- "version": "2.22.3",
3
+ "version": "2.23.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/pkg/arkadium-sdk.umd.js",