@arkadiuminc/sdk 2.23.0 → 2.24.0
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/pkg/api/core/debug-provider.d.ts +23 -0
- package/dist/pkg/api/features/auth/index.d.ts +15 -21
- package/dist/pkg/api/features/persistence/index.d.ts +5 -2
- package/dist/pkg/api/features/wallet/index.d.ts +19 -3
- package/dist/pkg/api/utils/mockUser.d.ts +27 -0
- package/dist/pkg/arkadium-arena-sdk.d.ts +13 -4
- package/dist/pkg/arkadium-game-sdk.d.ts +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RpcProvider } from './rpc';
|
|
2
|
+
import { ObserverFn } from '../utils/observable';
|
|
3
|
+
|
|
4
|
+
export interface DebugProvider {
|
|
5
|
+
setDebugMode?(isEnabled: boolean): void;
|
|
6
|
+
sendDebugEvent(type: string, ...args: any[]): void;
|
|
7
|
+
onDebugEvent?(observer: any): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class DebugProviderArena implements DebugProvider {
|
|
10
|
+
private observers;
|
|
11
|
+
private isDebug;
|
|
12
|
+
constructor(rpcProvider: RpcProvider);
|
|
13
|
+
private initDebugMode;
|
|
14
|
+
private isDebugMode;
|
|
15
|
+
setDebugMode(isEnabled: boolean): void;
|
|
16
|
+
sendDebugEvent(type: string, ...args: any[]): void;
|
|
17
|
+
onDebugEvent(observer: ObserverFn<string>): void;
|
|
18
|
+
}
|
|
19
|
+
export declare class DebugProviderGame implements DebugProvider {
|
|
20
|
+
private rpcProvider;
|
|
21
|
+
constructor(rpcProvider: RpcProvider);
|
|
22
|
+
sendDebugEvent(type: string, ...args: any[]): void;
|
|
23
|
+
}
|
|
@@ -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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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,6 +1,7 @@
|
|
|
1
1
|
import { RpcProvider } from '../../core/rpc';
|
|
2
2
|
import { Backend } from '../backend/backend.api';
|
|
3
3
|
import { IHost } from '../host';
|
|
4
|
+
import { DebugProvider } from '../../core/debug-provider';
|
|
4
5
|
|
|
5
6
|
declare type RemoteStorageValueType = string | object;
|
|
6
7
|
export interface IPersistence {
|
|
@@ -14,11 +15,12 @@ export interface IPersistence {
|
|
|
14
15
|
}
|
|
15
16
|
/** @hidden */
|
|
16
17
|
export declare class PersistenceArena implements IPersistence {
|
|
18
|
+
private debugProvider;
|
|
17
19
|
private ls;
|
|
18
20
|
/**
|
|
19
21
|
* @internal
|
|
20
22
|
*/
|
|
21
|
-
constructor(rpcProvider: RpcProvider);
|
|
23
|
+
constructor(rpcProvider: RpcProvider, debugProvider: DebugProvider);
|
|
22
24
|
getCookie(cookieName: string): Promise<string>;
|
|
23
25
|
getLocalStorageItem(key: string): Promise<string | null>;
|
|
24
26
|
setLocalStorageItem(key: string, value: string): Promise<void>;
|
|
@@ -28,11 +30,12 @@ export declare class PersistenceGame implements IPersistence {
|
|
|
28
30
|
private rpcProvider;
|
|
29
31
|
private host;
|
|
30
32
|
private backend;
|
|
33
|
+
private debugProvider;
|
|
31
34
|
private remoteStorageBlacklist;
|
|
32
35
|
/**
|
|
33
36
|
* @internal
|
|
34
37
|
*/
|
|
35
|
-
constructor(rpcProvider: RpcProvider, host: IHost, backend: Backend);
|
|
38
|
+
constructor(rpcProvider: RpcProvider, host: IHost, backend: Backend, debugProvider: DebugProvider);
|
|
36
39
|
getCookie(cookieName: string): Promise<string>;
|
|
37
40
|
private getPrefixedLocalStorageKey;
|
|
38
41
|
getLocalStorageItem(key: string): Promise<string | null>;
|
|
@@ -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
|
|
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,16 @@ 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 {
|
|
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';
|
|
12
|
+
import { DebugProviderArena } from './api/core/debug-provider';
|
|
11
13
|
|
|
14
|
+
import * as MockUserUtils from './api/utils/mockUser';
|
|
12
15
|
/** @hidden */
|
|
13
16
|
export declare class ArkadiumArenaSdk {
|
|
14
17
|
private rpcProvider;
|
|
@@ -16,24 +19,30 @@ export declare class ArkadiumArenaSdk {
|
|
|
16
19
|
host: HostArena;
|
|
17
20
|
lifecycle: GameLifecycleContract;
|
|
18
21
|
ads: AdsArena;
|
|
19
|
-
auth:
|
|
22
|
+
auth: AuthArena;
|
|
20
23
|
analytics: AnalyticsApiContract;
|
|
21
24
|
private timeoutTester;
|
|
22
25
|
persistence: PersistenceArena;
|
|
26
|
+
private wallet;
|
|
27
|
+
debug: DebugProviderArena;
|
|
23
28
|
private currentEnv;
|
|
24
29
|
private currentTarget;
|
|
25
30
|
private gamePingSender;
|
|
26
31
|
private gamePingListener;
|
|
27
32
|
$pingNotification: Observable<number>;
|
|
28
33
|
version: string;
|
|
29
|
-
constructor(rpcProvider: RpcProvider, backendApi: Backend, host: HostArena, lifecycle: GameLifecycleContract, ads: AdsArena, auth:
|
|
34
|
+
constructor(rpcProvider: RpcProvider, backendApi: Backend, host: HostArena, lifecycle: GameLifecycleContract, ads: AdsArena, auth: AuthArena, analytics: AnalyticsApiContract, timeoutTester: TimeoutTesterContract, persistence: PersistenceArena, wallet: WalletArena, debug: DebugProviderArena);
|
|
30
35
|
setEnv(e: ApiEnv): void;
|
|
31
36
|
initialize(env: ApiEnv, isGameSide: boolean, sessionStorage?: SessionStorageType | null): Promise<void>;
|
|
32
37
|
private envDiscoverListener;
|
|
33
38
|
updateWinReference(target: any): void;
|
|
34
|
-
debugMode(
|
|
39
|
+
debugMode(isEnabled: boolean): void;
|
|
35
40
|
ping(): Promise<any>;
|
|
36
41
|
dispose(): void;
|
|
42
|
+
setMockUserConfig({ isEnabled, mockUser }: {
|
|
43
|
+
isEnabled: boolean;
|
|
44
|
+
mockUser: MockUserUtils.MockUser;
|
|
45
|
+
}): void;
|
|
37
46
|
}
|
|
38
47
|
export { ApiEnv };
|
|
39
48
|
/** @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 {
|
|
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:
|
|
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:
|
|
33
|
+
auth: AuthGame;
|
|
34
34
|
analytics: AnalyticsApiContract;
|
|
35
35
|
timeoutTester: TimeoutTesterContract;
|
|
36
36
|
persistence: PersistenceGame;
|