@playcademy/sdk 0.0.1-beta.9 → 0.0.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 +511 -124
- package/dist/core/auth/flows/popup.d.ts +14 -0
- package/dist/core/auth/flows/redirect.d.ts +15 -0
- package/dist/core/auth/flows/unified.d.ts +11 -0
- package/dist/core/auth/login.d.ts +20 -0
- package/dist/core/auth/oauth.d.ts +115 -0
- package/dist/core/auth/utils.d.ts +23 -0
- package/dist/core/cache/cooldown-cache.d.ts +31 -0
- package/dist/core/cache/index.d.ts +14 -0
- package/dist/core/cache/permanent-cache.d.ts +39 -0
- package/dist/core/cache/singleton-cache.d.ts +29 -0
- package/dist/core/cache/ttl-cache.d.ts +54 -0
- package/dist/core/cache/types.d.ts +23 -0
- package/dist/core/client.d.ts +444 -68
- package/dist/core/namespaces/achievements.d.ts +84 -0
- package/dist/core/namespaces/admin.d.ts +385 -0
- package/dist/core/namespaces/auth.d.ts +54 -0
- package/dist/core/namespaces/character.d.ts +205 -0
- package/dist/core/namespaces/credits.d.ts +51 -0
- package/dist/core/namespaces/dev.d.ts +323 -0
- package/dist/core/namespaces/games.d.ts +173 -0
- package/dist/core/namespaces/identity.d.ts +91 -0
- package/dist/core/namespaces/index.d.ts +19 -0
- package/dist/core/namespaces/leaderboard.d.ts +48 -0
- package/dist/core/namespaces/levels.d.ts +90 -0
- package/dist/core/namespaces/maps.d.ts +93 -0
- package/dist/core/namespaces/realtime.client.d.ts +129 -0
- package/dist/core/namespaces/realtime.d.ts +90 -0
- package/dist/core/namespaces/runtime.d.ts +222 -0
- package/dist/core/namespaces/scores.d.ts +55 -0
- package/dist/core/namespaces/shop.d.ts +25 -0
- package/dist/core/namespaces/sprites.d.ts +35 -0
- package/dist/core/namespaces/telemetry.d.ts +28 -0
- package/dist/core/namespaces/timeback.d.ts +111 -0
- package/dist/core/namespaces/users.d.ts +172 -0
- package/dist/core/request.d.ts +1 -1
- package/dist/core/static/identity.d.ts +37 -0
- package/dist/core/static/index.d.ts +3 -0
- package/dist/core/static/init.d.ts +21 -0
- package/dist/core/static/login.d.ts +34 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2846 -0
- package/dist/messaging.d.ts +544 -0
- package/dist/types.d.ts +168 -8
- package/dist/types.js +748 -0
- package/package.json +18 -11
- package/dist/bus.d.ts +0 -37
- package/dist/runtime.d.ts +0 -7
- package/dist/runtime.js +0 -377
package/dist/types.d.ts
CHANGED
|
@@ -1,32 +1,170 @@
|
|
|
1
|
-
|
|
1
|
+
export type * from '@playcademy/data/types';
|
|
2
|
+
export { CURRENCIES, BADGES } from '@playcademy/data/constants';
|
|
3
|
+
export type { PlaycademyClient } from './core/client';
|
|
2
4
|
export interface ClientConfig {
|
|
3
5
|
baseUrl: string;
|
|
4
6
|
token?: string;
|
|
5
7
|
gameId?: string;
|
|
6
8
|
}
|
|
9
|
+
export declare const AuthProvider: {
|
|
10
|
+
readonly TIMEBACK: "TIMEBACK";
|
|
11
|
+
};
|
|
12
|
+
export type AuthProviderType = (typeof AuthProvider)[keyof typeof AuthProvider];
|
|
13
|
+
export interface AuthOptions {
|
|
14
|
+
/** The identity provider to use for authentication */
|
|
15
|
+
provider: AuthProviderType;
|
|
16
|
+
/** The OAuth callback URL where your server handles the callback */
|
|
17
|
+
callbackUrl: string;
|
|
18
|
+
/** Authentication mode - auto detects best option based on context */
|
|
19
|
+
mode?: 'auto' | 'popup' | 'redirect';
|
|
20
|
+
/** Callback for authentication state changes */
|
|
21
|
+
onStateChange?: (state: AuthStateUpdate) => void;
|
|
22
|
+
/** Custom OAuth configuration (for users embedding the SDK outside of the Playcademy platform) */
|
|
23
|
+
oauth?: {
|
|
24
|
+
clientId: string;
|
|
25
|
+
authorizationEndpoint?: string;
|
|
26
|
+
tokenEndpoint?: string;
|
|
27
|
+
scope?: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Optional custom data to encode in OAuth state parameter.
|
|
31
|
+
* By default, the SDK automatically includes playcademy_user_id and game_id.
|
|
32
|
+
* Use this to add additional custom data if needed.
|
|
33
|
+
*/
|
|
34
|
+
stateData?: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
export interface AuthStateUpdate {
|
|
37
|
+
/** Current status of the authentication flow */
|
|
38
|
+
status: 'opening_popup' | 'exchanging_token' | 'complete' | 'error';
|
|
39
|
+
/** Human-readable message about the current state */
|
|
40
|
+
message: string;
|
|
41
|
+
/** Error details if status is 'error' */
|
|
42
|
+
error?: Error;
|
|
43
|
+
}
|
|
44
|
+
export interface AuthResult {
|
|
45
|
+
/** Whether authentication was successful */
|
|
46
|
+
success: boolean;
|
|
47
|
+
/** User information if authentication was successful */
|
|
48
|
+
user?: UserInfo;
|
|
49
|
+
/** Error if authentication failed */
|
|
50
|
+
error?: Error;
|
|
51
|
+
}
|
|
52
|
+
export interface UserInfo {
|
|
53
|
+
/** Unique user identifier (sub claim from JWT) */
|
|
54
|
+
sub: string;
|
|
55
|
+
/** User's email address */
|
|
56
|
+
email: string;
|
|
57
|
+
/** User's display name */
|
|
58
|
+
name: string;
|
|
59
|
+
/** Whether the email has been verified */
|
|
60
|
+
email_verified: boolean;
|
|
61
|
+
/** Additional user attributes from the identity provider */
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Authentication state change event payload.
|
|
66
|
+
* Used when authentication state changes in the application.
|
|
67
|
+
*/
|
|
68
|
+
export interface AuthStateChangePayload {
|
|
69
|
+
/** Whether the user is currently authenticated */
|
|
70
|
+
authenticated: boolean;
|
|
71
|
+
/** User information if authenticated, null otherwise */
|
|
72
|
+
user: UserInfo | null;
|
|
73
|
+
/** Error information if authentication failed */
|
|
74
|
+
error: Error | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* OAuth callback event payload.
|
|
78
|
+
* Used when OAuth flow completes in popup/new-tab windows.
|
|
79
|
+
*/
|
|
80
|
+
export interface AuthCallbackPayload {
|
|
81
|
+
/** OAuth authorization code */
|
|
82
|
+
code: string;
|
|
83
|
+
/** OAuth state parameter for CSRF protection */
|
|
84
|
+
state: string;
|
|
85
|
+
/** Error message if OAuth flow failed */
|
|
86
|
+
error: string | null;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Message sent from server callback to opener window.
|
|
90
|
+
* This is the standardized format from our server-first architecture.
|
|
91
|
+
*/
|
|
92
|
+
export interface AuthServerMessage {
|
|
93
|
+
/** Type of the message */
|
|
94
|
+
type: 'PLAYCADEMY_AUTH_STATE_CHANGE';
|
|
95
|
+
/** Whether the user is currently authenticated */
|
|
96
|
+
authenticated: boolean;
|
|
97
|
+
/** Whether the authentication was successful */
|
|
98
|
+
success: boolean;
|
|
99
|
+
/** Timestamp of the message */
|
|
100
|
+
ts: number;
|
|
101
|
+
/** User information if authentication was successful */
|
|
102
|
+
user?: UserInfo;
|
|
103
|
+
/** Error message if authentication failed */
|
|
104
|
+
error?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Token refresh event payload.
|
|
108
|
+
* Sent when authentication token is updated.
|
|
109
|
+
*/
|
|
110
|
+
export interface TokenRefreshPayload {
|
|
111
|
+
/** New authentication token */
|
|
112
|
+
token: string;
|
|
113
|
+
/** Token expiration timestamp */
|
|
114
|
+
exp: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Telemetry event payload.
|
|
118
|
+
* Performance metrics sent from the game.
|
|
119
|
+
*/
|
|
120
|
+
export interface TelemetryPayload {
|
|
121
|
+
/** Frames per second */
|
|
122
|
+
fps: number;
|
|
123
|
+
/** Memory usage in MB */
|
|
124
|
+
mem: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Keyboard event payload.
|
|
128
|
+
* Key events forwarded from the game.
|
|
129
|
+
*/
|
|
130
|
+
export interface KeyEventPayload {
|
|
131
|
+
/** Key value (e.g., 'Escape', 'F1') */
|
|
132
|
+
key: string;
|
|
133
|
+
/** Key code (optional) */
|
|
134
|
+
code?: string;
|
|
135
|
+
/** Event type */
|
|
136
|
+
type: 'keydown' | 'keyup';
|
|
137
|
+
}
|
|
7
138
|
export interface ClientEvents {
|
|
8
139
|
authChange: {
|
|
9
140
|
token: string | null;
|
|
10
141
|
};
|
|
11
142
|
inventoryChange: {
|
|
12
|
-
|
|
143
|
+
itemId: string;
|
|
13
144
|
delta: number;
|
|
14
145
|
newTotal: number;
|
|
15
146
|
};
|
|
147
|
+
levelUp: {
|
|
148
|
+
oldLevel: number;
|
|
149
|
+
newLevel: number;
|
|
150
|
+
creditsAwarded: number;
|
|
151
|
+
};
|
|
152
|
+
xpGained: {
|
|
153
|
+
amount: number;
|
|
154
|
+
totalXP: number;
|
|
155
|
+
leveledUp: boolean;
|
|
156
|
+
};
|
|
16
157
|
}
|
|
17
158
|
export type GameContextPayload = {
|
|
18
159
|
token: string;
|
|
19
160
|
baseUrl: string;
|
|
161
|
+
realtimeUrl: string;
|
|
20
162
|
gameId: string;
|
|
163
|
+
forwardKeys?: string[];
|
|
21
164
|
};
|
|
22
165
|
export type EventListeners = {
|
|
23
166
|
[E in keyof ClientEvents]?: Array<(payload: ClientEvents[E]) => void>;
|
|
24
167
|
};
|
|
25
|
-
export type GameWithManifest = Game & {
|
|
26
|
-
manifest: ManifestV1;
|
|
27
|
-
};
|
|
28
|
-
export type DeveloperStatusValue = DeveloperStatusResponse['status'];
|
|
29
|
-
export type GameState = Record<string, unknown>;
|
|
30
168
|
export type LoginResponse = {
|
|
31
169
|
token: string;
|
|
32
170
|
};
|
|
@@ -40,4 +178,26 @@ export type StartSessionResponse = {
|
|
|
40
178
|
export type InventoryMutationResponse = {
|
|
41
179
|
newTotal: number;
|
|
42
180
|
};
|
|
43
|
-
export type
|
|
181
|
+
export type DevUploadEvent = {
|
|
182
|
+
type: 'init';
|
|
183
|
+
} | {
|
|
184
|
+
type: 's3Progress';
|
|
185
|
+
loaded: number;
|
|
186
|
+
total: number;
|
|
187
|
+
percent: number;
|
|
188
|
+
} | {
|
|
189
|
+
type: 'finalizeStart';
|
|
190
|
+
} | {
|
|
191
|
+
type: 'finalizeProgress';
|
|
192
|
+
percent: number;
|
|
193
|
+
currentFileLabel?: string;
|
|
194
|
+
} | {
|
|
195
|
+
type: 'finalizeStatus';
|
|
196
|
+
message: string;
|
|
197
|
+
} | {
|
|
198
|
+
type: 'close';
|
|
199
|
+
};
|
|
200
|
+
export type DevUploadHooks = {
|
|
201
|
+
onEvent?: (e: DevUploadEvent) => void;
|
|
202
|
+
onClose?: () => void;
|
|
203
|
+
};
|