@playporter/sdk 0.1.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/README.md +22 -0
- package/dist/adapters/discord.d.ts +16 -0
- package/dist/adapters/discord.js +50 -0
- package/dist/adapters/discord.js.map +1 -0
- package/dist/adapters/reddit.d.ts +13 -0
- package/dist/adapters/reddit.js +21 -0
- package/dist/adapters/reddit.js.map +1 -0
- package/dist/adapters/telegram.d.ts +35 -0
- package/dist/adapters/telegram.js +48 -0
- package/dist/adapters/telegram.js.map +1 -0
- package/dist/adapters/types.d.ts +18 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/adapters/web.d.ts +11 -0
- package/dist/adapters/web.js +21 -0
- package/dist/adapters/web.js.map +1 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.js +248 -0
- package/dist/index.js.map +1 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @playporter/sdk
|
|
2
|
+
|
|
3
|
+
PlayPorter SDK for portable identity, storage, analytics, LiveOps, social adapters and artifact-safe deployment workflows.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @playporter/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quickstart
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { PlayPorterClient } from "@playporter/sdk";
|
|
15
|
+
|
|
16
|
+
const playporter = await PlayPorterClient.initialize({
|
|
17
|
+
apiBaseUrl: "https://playporter.net",
|
|
18
|
+
projectKey: process.env.PLAYPORTER_PROJECT_KEY!,
|
|
19
|
+
platform: "auto",
|
|
20
|
+
appVersion: "1.0.0",
|
|
21
|
+
});
|
|
22
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PlatformAdapter, PlatformCredential } from "./types.js";
|
|
2
|
+
export declare class DiscordAdapter implements PlatformAdapter {
|
|
3
|
+
private readonly clientId;
|
|
4
|
+
readonly platform: "discord";
|
|
5
|
+
private readonly sdk;
|
|
6
|
+
private authCode?;
|
|
7
|
+
constructor(clientId: string);
|
|
8
|
+
initialize(): Promise<void>;
|
|
9
|
+
getCredential(): Promise<PlatformCredential>;
|
|
10
|
+
getContext(): Record<string, unknown>;
|
|
11
|
+
invite(message: string): Promise<void>;
|
|
12
|
+
share(payload: {
|
|
13
|
+
text: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DiscordSDK } from "@discord/embedded-app-sdk";
|
|
2
|
+
export class DiscordAdapter {
|
|
3
|
+
clientId;
|
|
4
|
+
platform = "discord";
|
|
5
|
+
sdk;
|
|
6
|
+
authCode;
|
|
7
|
+
constructor(clientId) {
|
|
8
|
+
this.clientId = clientId;
|
|
9
|
+
if (!clientId)
|
|
10
|
+
throw new Error("Discord clientId est requis.");
|
|
11
|
+
this.sdk = new DiscordSDK(clientId);
|
|
12
|
+
}
|
|
13
|
+
async initialize() {
|
|
14
|
+
await this.sdk.ready();
|
|
15
|
+
const authorization = await this.sdk.commands.authorize({
|
|
16
|
+
client_id: this.clientId,
|
|
17
|
+
response_type: "code",
|
|
18
|
+
state: "",
|
|
19
|
+
prompt: "none",
|
|
20
|
+
scope: ["identify"],
|
|
21
|
+
});
|
|
22
|
+
if (!authorization.code)
|
|
23
|
+
throw new Error("Discord n'a pas retourné de code OAuth.");
|
|
24
|
+
this.authCode = authorization.code;
|
|
25
|
+
}
|
|
26
|
+
async getCredential() {
|
|
27
|
+
if (!this.authCode)
|
|
28
|
+
throw new Error("L'adaptateur Discord n'est pas initialisé.");
|
|
29
|
+
return {
|
|
30
|
+
platform: this.platform,
|
|
31
|
+
credential: { code: this.authCode },
|
|
32
|
+
context: this.getContext(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
getContext() {
|
|
36
|
+
return {
|
|
37
|
+
instanceId: this.sdk.instanceId,
|
|
38
|
+
channelId: this.sdk.channelId,
|
|
39
|
+
guildId: this.sdk.guildId,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async invite(message) {
|
|
43
|
+
await this.sdk.commands.openInviteDialog();
|
|
44
|
+
void message;
|
|
45
|
+
}
|
|
46
|
+
async share(payload) {
|
|
47
|
+
await this.sdk.commands.shareLink({ message: payload.text, custom_id: payload.url ?? "playporter-share" });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=discord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discord.js","sourceRoot":"","sources":["../../src/adapters/discord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,MAAM,OAAO,cAAc;IAKI;IAJpB,QAAQ,GAAG,SAAkB,CAAC;IACtB,GAAG,CAAa;IACzB,QAAQ,CAAU;IAE1B,YAA6B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAC3C,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC/D,IAAI,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACvB,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC;YACtD,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,aAAa,EAAE,MAAM;YACrB,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,CAAC,UAAU,CAAC;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACpF,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAClF,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;YACnC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;SAC3B,CAAC;IACJ,CAAC;IAED,UAAU;QACR,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU;YAC/B,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS;YAC7B,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO;SAC1B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC;QAC3C,KAAK,OAAO,CAAC;IACf,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAuC;QACjD,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,IAAI,kBAAkB,EAAE,CAAC,CAAC;IAC7G,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PlatformAdapter, PlatformCredential } from "./types.js";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
__PLAYPORTER_REDDIT_CONTEXT__?: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare class RedditAdapter implements PlatformAdapter {
|
|
8
|
+
readonly platform: "reddit";
|
|
9
|
+
private assertion?;
|
|
10
|
+
initialize(): Promise<void>;
|
|
11
|
+
getCredential(): Promise<PlatformCredential>;
|
|
12
|
+
getContext(): Record<string, unknown>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class RedditAdapter {
|
|
2
|
+
platform = "reddit";
|
|
3
|
+
assertion;
|
|
4
|
+
async initialize() {
|
|
5
|
+
const response = await fetch("/api/playporter-session", { credentials: "include" });
|
|
6
|
+
if (!response.ok)
|
|
7
|
+
throw new Error(`Échec de l'identité Reddit (${response.status}).`);
|
|
8
|
+
const body = await response.json();
|
|
9
|
+
this.assertion = body.assertion;
|
|
10
|
+
window.__PLAYPORTER_REDDIT_CONTEXT__ = body.context ?? {};
|
|
11
|
+
}
|
|
12
|
+
async getCredential() {
|
|
13
|
+
if (!this.assertion)
|
|
14
|
+
throw new Error("L'adaptateur Reddit n'est pas initialisé.");
|
|
15
|
+
return { platform: this.platform, credential: { assertion: this.assertion }, context: this.getContext() };
|
|
16
|
+
}
|
|
17
|
+
getContext() {
|
|
18
|
+
return window.__PLAYPORTER_REDDIT_CONTEXT__ ?? {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=reddit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reddit.js","sourceRoot":"","sources":["../../src/adapters/reddit.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,aAAa;IACf,QAAQ,GAAG,QAAiB,CAAC;IAC9B,SAAS,CAAU;IAE3B,KAAK,CAAC,UAAU;QACd,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,yBAAyB,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;QACpF,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC;QACtF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAA8D,CAAC;QAC/F,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,MAAM,CAAC,6BAA6B,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAClF,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;IAC5G,CAAC;IAED,UAAU;QACR,OAAO,MAAM,CAAC,6BAA6B,IAAI,EAAE,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { PlatformAdapter, PlatformCredential } from "./types.js";
|
|
2
|
+
type TelegramWebApp = {
|
|
3
|
+
initData: string;
|
|
4
|
+
initDataUnsafe?: {
|
|
5
|
+
start_param?: string;
|
|
6
|
+
user?: {
|
|
7
|
+
id?: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
platform?: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
colorScheme?: string;
|
|
13
|
+
ready(): void;
|
|
14
|
+
expand(): void;
|
|
15
|
+
openTelegramLink?(url: string): void;
|
|
16
|
+
};
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
Telegram?: {
|
|
20
|
+
WebApp?: TelegramWebApp;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare class TelegramAdapter implements PlatformAdapter {
|
|
25
|
+
readonly platform: "telegram";
|
|
26
|
+
private app?;
|
|
27
|
+
initialize(): Promise<void>;
|
|
28
|
+
getCredential(): Promise<PlatformCredential>;
|
|
29
|
+
getContext(): Record<string, unknown>;
|
|
30
|
+
share(payload: {
|
|
31
|
+
text: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export class TelegramAdapter {
|
|
2
|
+
platform = "telegram";
|
|
3
|
+
app;
|
|
4
|
+
async initialize() {
|
|
5
|
+
this.app = await loadTelegramSdk();
|
|
6
|
+
this.app.ready();
|
|
7
|
+
this.app.expand();
|
|
8
|
+
}
|
|
9
|
+
async getCredential() {
|
|
10
|
+
if (!this.app?.initData)
|
|
11
|
+
throw new Error("Telegram initData est absent; ouvrez le jeu depuis le bot Telegram.");
|
|
12
|
+
return {
|
|
13
|
+
platform: this.platform,
|
|
14
|
+
credential: { initData: this.app.initData },
|
|
15
|
+
context: this.getContext(),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
getContext() {
|
|
19
|
+
return {
|
|
20
|
+
telegramPlatform: this.app?.platform,
|
|
21
|
+
telegramVersion: this.app?.version,
|
|
22
|
+
colorScheme: this.app?.colorScheme,
|
|
23
|
+
startParam: this.app?.initDataUnsafe?.start_param,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async share(payload) {
|
|
27
|
+
const target = `https://t.me/share/url?url=${encodeURIComponent(payload.url ?? location.href)}&text=${encodeURIComponent(payload.text)}`;
|
|
28
|
+
if (this.app?.openTelegramLink)
|
|
29
|
+
this.app.openTelegramLink(target);
|
|
30
|
+
else
|
|
31
|
+
location.href = target;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function loadTelegramSdk() {
|
|
35
|
+
if (window.Telegram?.WebApp)
|
|
36
|
+
return window.Telegram.WebApp;
|
|
37
|
+
await new Promise((resolve, reject) => {
|
|
38
|
+
const script = document.createElement("script");
|
|
39
|
+
script.src = "https://telegram.org/js/telegram-web-app.js";
|
|
40
|
+
script.onload = () => resolve();
|
|
41
|
+
script.onerror = () => reject(new Error("Impossible de charger Telegram WebApp SDK."));
|
|
42
|
+
document.head.appendChild(script);
|
|
43
|
+
});
|
|
44
|
+
if (!window.Telegram?.WebApp)
|
|
45
|
+
throw new Error("Telegram WebApp SDK indisponible.");
|
|
46
|
+
return window.Telegram.WebApp;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=telegram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram.js","sourceRoot":"","sources":["../../src/adapters/telegram.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAO,eAAe;IACjB,QAAQ,GAAG,UAAmB,CAAC;IAChC,GAAG,CAAkB;IAE7B,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,GAAG,GAAG,MAAM,eAAe,EAAE,CAAC;QACnC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACjB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;QAChH,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC3C,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;SAC3B,CAAC;IACJ,CAAC;IAED,UAAU;QACR,OAAO;YACL,gBAAgB,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ;YACpC,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO;YAClC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,WAAW;YAClC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,WAAW;SAClD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAuC;QACjD,MAAM,MAAM,GAAG,8BAA8B,kBAAkB,CAAC,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzI,IAAI,IAAI,CAAC,GAAG,EAAE,gBAAgB;YAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;;YAC7D,QAAQ,CAAC,IAAI,GAAG,MAAM,CAAC;IAC9B,CAAC;CACF;AAED,KAAK,UAAU,eAAe;IAC5B,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC3D,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,GAAG,6CAA6C,CAAC;QAC3D,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;QAChC,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC,CAAC;QACvF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Platform } from "@playporter/core";
|
|
2
|
+
export interface PlatformCredential {
|
|
3
|
+
platform: Platform;
|
|
4
|
+
credential: Record<string, unknown>;
|
|
5
|
+
context?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface PlatformAdapter {
|
|
8
|
+
readonly platform: Platform;
|
|
9
|
+
initialize(): Promise<void>;
|
|
10
|
+
getCredential(): Promise<PlatformCredential>;
|
|
11
|
+
getContext(): Record<string, unknown>;
|
|
12
|
+
invite?(message: string): Promise<void>;
|
|
13
|
+
share?(payload: {
|
|
14
|
+
text: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
imageUrl?: string;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PlatformAdapter, PlatformCredential } from "./types.js";
|
|
2
|
+
export declare class WebAdapter implements PlatformAdapter {
|
|
3
|
+
readonly platform: "web";
|
|
4
|
+
initialize(): Promise<void>;
|
|
5
|
+
getCredential(): Promise<PlatformCredential>;
|
|
6
|
+
getContext(): Record<string, unknown>;
|
|
7
|
+
share(payload: {
|
|
8
|
+
text: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class WebAdapter {
|
|
2
|
+
platform = "web";
|
|
3
|
+
async initialize() { }
|
|
4
|
+
async getCredential() {
|
|
5
|
+
const key = "playporter.device-id";
|
|
6
|
+
let deviceId = localStorage.getItem(key);
|
|
7
|
+
if (!deviceId) {
|
|
8
|
+
deviceId = globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
|
|
9
|
+
localStorage.setItem(key, deviceId);
|
|
10
|
+
}
|
|
11
|
+
return { platform: this.platform, credential: { deviceId } };
|
|
12
|
+
}
|
|
13
|
+
getContext() {
|
|
14
|
+
return { language: navigator.language, userAgent: navigator.userAgent };
|
|
15
|
+
}
|
|
16
|
+
async share(payload) {
|
|
17
|
+
if (navigator.share)
|
|
18
|
+
await navigator.share({ title: payload.text, text: payload.text, url: payload.url });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/adapters/web.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,UAAU;IACZ,QAAQ,GAAG,KAAc,CAAC;IACnC,KAAK,CAAC,UAAU,KAAmB,CAAC;IACpC,KAAK,CAAC,aAAa;QACjB,MAAM,GAAG,GAAG,sBAAsB,CAAC;QACnC,IAAI,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACjF,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC;IAC/D,CAAC;IACD,UAAU;QACR,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;IAC1E,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,OAAuC;QACjD,IAAI,SAAS,CAAC,KAAK;YAAE,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5G,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { PassportSummary, EffectiveConfig, EnvironmentName, JsonValue, Platform, PlayerProfile } from "@playporter/core";
|
|
2
|
+
export interface PlayPorterOptions {
|
|
3
|
+
apiBaseUrl: string;
|
|
4
|
+
projectKey: string;
|
|
5
|
+
environment?: EnvironmentName;
|
|
6
|
+
platform?: Platform | "auto";
|
|
7
|
+
discordClientId?: string;
|
|
8
|
+
appVersion?: string;
|
|
9
|
+
autoTrackLifecycle?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class PlayPorterClient {
|
|
12
|
+
private readonly options;
|
|
13
|
+
readonly platform: Platform;
|
|
14
|
+
private readonly adapter;
|
|
15
|
+
private token?;
|
|
16
|
+
private currentPlayer?;
|
|
17
|
+
private eventQueue;
|
|
18
|
+
private flushTimer?;
|
|
19
|
+
private readonly sessionId;
|
|
20
|
+
private constructor();
|
|
21
|
+
static initialize(options: PlayPorterOptions): Promise<PlayPorterClient>;
|
|
22
|
+
readonly player: {
|
|
23
|
+
getCurrent: () => PlayerProfile;
|
|
24
|
+
createLinkCode: () => Promise<{
|
|
25
|
+
code: string;
|
|
26
|
+
expiresAt: string;
|
|
27
|
+
}>;
|
|
28
|
+
confirmLink: (code: string, explicitConsent: boolean) => Promise<{
|
|
29
|
+
player: PlayerProfile;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
readonly identity: {
|
|
33
|
+
getPlayer: () => Promise<PlayerProfile>;
|
|
34
|
+
createLinkCode: () => Promise<{
|
|
35
|
+
code: string;
|
|
36
|
+
expiresAt: string;
|
|
37
|
+
}>;
|
|
38
|
+
confirmLink: (code: string, explicitConsent: boolean) => Promise<{
|
|
39
|
+
player: PlayerProfile;
|
|
40
|
+
}>;
|
|
41
|
+
getPassport: () => Promise<PassportSummary>;
|
|
42
|
+
};
|
|
43
|
+
readonly liveops: {
|
|
44
|
+
getConfig: () => Promise<EffectiveConfig>;
|
|
45
|
+
};
|
|
46
|
+
readonly analytics: {
|
|
47
|
+
track: (name: string, properties?: Record<string, JsonValue>) => void;
|
|
48
|
+
flush: () => Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
readonly storage: {
|
|
51
|
+
get: <T extends JsonValue>(key: string) => Promise<T | null>;
|
|
52
|
+
set: (key: string, value: JsonValue) => Promise<void>;
|
|
53
|
+
delete: (key: string) => Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
readonly leaderboards: {
|
|
56
|
+
submit: (leaderboard: string, score: number, metadata?: Record<string, JsonValue>) => Promise<void>;
|
|
57
|
+
top: (leaderboard: string, limit?: number) => Promise<Array<{
|
|
58
|
+
rank: number;
|
|
59
|
+
score: number;
|
|
60
|
+
player: PlayerProfile;
|
|
61
|
+
}>>;
|
|
62
|
+
};
|
|
63
|
+
readonly payments: {
|
|
64
|
+
purchase: (sku: string, metadata?: Record<string, JsonValue>) => Promise<{
|
|
65
|
+
status: "tracked";
|
|
66
|
+
sku: string;
|
|
67
|
+
}>;
|
|
68
|
+
};
|
|
69
|
+
readonly passport: {
|
|
70
|
+
get: () => Promise<PassportSummary>;
|
|
71
|
+
updateProfile: (profile: Record<string, JsonValue>) => Promise<void>;
|
|
72
|
+
updatePreferences: (preferences: Record<string, JsonValue>) => Promise<void>;
|
|
73
|
+
unlockAchievement: (achievementId: string, metadata?: Record<string, JsonValue>) => Promise<void>;
|
|
74
|
+
recordPurchase: (sku: string, metadata?: Record<string, JsonValue>) => Promise<void>;
|
|
75
|
+
addFriend: (friend: {
|
|
76
|
+
id: string;
|
|
77
|
+
displayName?: string | null;
|
|
78
|
+
platform?: Platform;
|
|
79
|
+
}) => Promise<void>;
|
|
80
|
+
};
|
|
81
|
+
readonly social: {
|
|
82
|
+
invite: (message: string) => Promise<void>;
|
|
83
|
+
share: (payload: {
|
|
84
|
+
text: string;
|
|
85
|
+
url?: string;
|
|
86
|
+
imageUrl?: string;
|
|
87
|
+
}) => Promise<void>;
|
|
88
|
+
};
|
|
89
|
+
private authenticate;
|
|
90
|
+
private request;
|
|
91
|
+
private installLifecycleTracking;
|
|
92
|
+
private ensureFlushTimer;
|
|
93
|
+
private flushEvents;
|
|
94
|
+
private sessionKey;
|
|
95
|
+
}
|
|
96
|
+
export * from "@playporter/core";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { DiscordAdapter } from "./adapters/discord.js";
|
|
2
|
+
import { RedditAdapter } from "./adapters/reddit.js";
|
|
3
|
+
import { TelegramAdapter } from "./adapters/telegram.js";
|
|
4
|
+
import { WebAdapter } from "./adapters/web.js";
|
|
5
|
+
export class PlayPorterClient {
|
|
6
|
+
options;
|
|
7
|
+
platform;
|
|
8
|
+
adapter;
|
|
9
|
+
token;
|
|
10
|
+
currentPlayer;
|
|
11
|
+
eventQueue = [];
|
|
12
|
+
flushTimer;
|
|
13
|
+
sessionId = globalThis.crypto?.randomUUID?.() ?? `pp_${Date.now().toString(36)}`;
|
|
14
|
+
constructor(options, adapter) {
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.adapter = adapter;
|
|
17
|
+
this.platform = adapter.platform;
|
|
18
|
+
}
|
|
19
|
+
static async initialize(options) {
|
|
20
|
+
const normalized = {
|
|
21
|
+
environment: "production",
|
|
22
|
+
platform: "auto",
|
|
23
|
+
appVersion: "0.0.0",
|
|
24
|
+
autoTrackLifecycle: true,
|
|
25
|
+
...options,
|
|
26
|
+
apiBaseUrl: options.apiBaseUrl.replace(/\/$/, ""),
|
|
27
|
+
};
|
|
28
|
+
const adapter = createAdapter(normalized.platform, normalized.discordClientId);
|
|
29
|
+
const client = new PlayPorterClient(normalized, adapter);
|
|
30
|
+
await adapter.initialize();
|
|
31
|
+
await client.authenticate();
|
|
32
|
+
if (normalized.autoTrackLifecycle)
|
|
33
|
+
client.installLifecycleTracking();
|
|
34
|
+
return client;
|
|
35
|
+
}
|
|
36
|
+
player = {
|
|
37
|
+
getCurrent: () => {
|
|
38
|
+
if (!this.currentPlayer)
|
|
39
|
+
throw new Error("PlayPorter n'est pas authentifié.");
|
|
40
|
+
return this.currentPlayer;
|
|
41
|
+
},
|
|
42
|
+
createLinkCode: async () => this.request("/api/v1/identity/link/start", { method: "POST" }),
|
|
43
|
+
confirmLink: async (code, explicitConsent) => this.request("/api/v1/identity/link/confirm", {
|
|
44
|
+
method: "POST",
|
|
45
|
+
body: JSON.stringify({ code, explicitConsent }),
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
identity = {
|
|
49
|
+
getPlayer: async () => this.player.getCurrent(),
|
|
50
|
+
createLinkCode: this.player.createLinkCode,
|
|
51
|
+
confirmLink: this.player.confirmLink,
|
|
52
|
+
getPassport: async () => this.request("/api/v1/identity/passport"),
|
|
53
|
+
};
|
|
54
|
+
liveops = {
|
|
55
|
+
getConfig: async () => this.request(`/api/v1/config/effective?environment=${encodeURIComponent(this.options.environment)}&platform=${this.platform}&appVersion=${encodeURIComponent(this.options.appVersion)}`),
|
|
56
|
+
};
|
|
57
|
+
analytics = {
|
|
58
|
+
track: (name, properties = {}) => {
|
|
59
|
+
this.eventQueue.push({ name, occurredAt: new Date().toISOString(), sessionId: this.sessionId, properties });
|
|
60
|
+
if (this.eventQueue.length >= 20)
|
|
61
|
+
void this.flushEvents();
|
|
62
|
+
else
|
|
63
|
+
this.ensureFlushTimer();
|
|
64
|
+
},
|
|
65
|
+
flush: () => this.flushEvents(),
|
|
66
|
+
};
|
|
67
|
+
storage = {
|
|
68
|
+
get: async (key) => {
|
|
69
|
+
const result = await this.request(`/api/v1/storage/${encodeURIComponent(key)}`);
|
|
70
|
+
return result.value;
|
|
71
|
+
},
|
|
72
|
+
set: async (key, value) => {
|
|
73
|
+
await this.request(`/api/v1/storage/${encodeURIComponent(key)}`, { method: "PUT", body: JSON.stringify({ value }) });
|
|
74
|
+
},
|
|
75
|
+
delete: async (key) => {
|
|
76
|
+
await this.request(`/api/v1/storage/${encodeURIComponent(key)}`, { method: "DELETE" });
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
leaderboards = {
|
|
80
|
+
submit: async (leaderboard, score, metadata = {}) => {
|
|
81
|
+
await this.request("/api/v1/leaderboards/submit", {
|
|
82
|
+
method: "POST",
|
|
83
|
+
body: JSON.stringify({ leaderboard, score, metadata }),
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
top: async (leaderboard, limit = 20) => this.request(`/api/v1/leaderboards/${encodeURIComponent(leaderboard)}?limit=${limit}`),
|
|
87
|
+
};
|
|
88
|
+
payments = {
|
|
89
|
+
purchase: async (sku, metadata = {}) => {
|
|
90
|
+
this.analytics.track("purchase_requested", { sku, ...metadata });
|
|
91
|
+
return { status: "tracked", sku };
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
passport = {
|
|
95
|
+
get: async () => this.identity.getPassport(),
|
|
96
|
+
updateProfile: async (profile) => {
|
|
97
|
+
await this.storage.set("passport:profile", profile);
|
|
98
|
+
this.analytics.track("passport_profile_updated", { fields: Object.keys(profile).length });
|
|
99
|
+
},
|
|
100
|
+
updatePreferences: async (preferences) => {
|
|
101
|
+
await this.storage.set("passport:preferences", preferences);
|
|
102
|
+
this.analytics.track("passport_preferences_updated", { fields: Object.keys(preferences).length });
|
|
103
|
+
},
|
|
104
|
+
unlockAchievement: async (achievementId, metadata = {}) => {
|
|
105
|
+
const achievements = await this.storage.get("passport:achievements") ?? [];
|
|
106
|
+
if (!achievements.some((entry) => entry.id === achievementId)) {
|
|
107
|
+
achievements.push({ id: achievementId, unlockedAt: new Date().toISOString(), metadata });
|
|
108
|
+
await this.storage.set("passport:achievements", achievements);
|
|
109
|
+
}
|
|
110
|
+
this.analytics.track("passport_achievement_unlocked", { achievementId, ...metadata });
|
|
111
|
+
},
|
|
112
|
+
recordPurchase: async (sku, metadata = {}) => {
|
|
113
|
+
const purchases = await this.storage.get("passport:purchases") ?? [];
|
|
114
|
+
purchases.push({ id: globalThis.crypto?.randomUUID?.() ?? `${sku}-${Date.now()}`, sku, purchasedAt: new Date().toISOString(), metadata });
|
|
115
|
+
await this.storage.set("passport:purchases", purchases);
|
|
116
|
+
this.analytics.track("passport_purchase_recorded", { sku, ...metadata });
|
|
117
|
+
},
|
|
118
|
+
addFriend: async (friend) => {
|
|
119
|
+
const friends = await this.storage.get("passport:friends") ?? [];
|
|
120
|
+
if (!friends.some((entry) => entry.id === friend.id)) {
|
|
121
|
+
friends.push({ ...friend, linkedAt: new Date().toISOString() });
|
|
122
|
+
await this.storage.set("passport:friends", friends);
|
|
123
|
+
}
|
|
124
|
+
this.analytics.track("passport_friend_added", { friendId: friend.id, platform: friend.platform ?? "web" });
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
social = {
|
|
128
|
+
invite: async (message) => {
|
|
129
|
+
if (!this.adapter.invite)
|
|
130
|
+
throw new Error(`Les invitations ne sont pas disponibles sur ${this.platform}.`);
|
|
131
|
+
await this.adapter.invite(message);
|
|
132
|
+
},
|
|
133
|
+
share: async (payload) => {
|
|
134
|
+
if (!this.adapter.share)
|
|
135
|
+
throw new Error(`Le partage n'est pas disponible sur ${this.platform}.`);
|
|
136
|
+
await this.adapter.share(payload);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
async authenticate() {
|
|
140
|
+
const existing = sessionStorage.getItem(this.sessionKey());
|
|
141
|
+
if (existing) {
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(existing);
|
|
144
|
+
if (new Date(parsed.expiresAt).getTime() > Date.now() + 30_000) {
|
|
145
|
+
this.token = parsed.token;
|
|
146
|
+
this.currentPlayer = parsed.player;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
sessionStorage.removeItem(this.sessionKey());
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const platformCredential = await this.adapter.getCredential();
|
|
155
|
+
const endpoint = this.platform === "web" ? "/api/v1/auth/guest" : "/api/v1/auth/platform";
|
|
156
|
+
const session = await this.request(endpoint, {
|
|
157
|
+
method: "POST",
|
|
158
|
+
unauthenticated: true,
|
|
159
|
+
body: JSON.stringify({ ...platformCredential, appVersion: this.options.appVersion }),
|
|
160
|
+
});
|
|
161
|
+
this.token = session.token;
|
|
162
|
+
this.currentPlayer = session.player;
|
|
163
|
+
sessionStorage.setItem(this.sessionKey(), JSON.stringify(session));
|
|
164
|
+
}
|
|
165
|
+
async request(path, init = {}) {
|
|
166
|
+
const headers = new Headers(init.headers);
|
|
167
|
+
headers.set("content-type", "application/json");
|
|
168
|
+
headers.set("x-playporter-game-key", this.options.projectKey);
|
|
169
|
+
if (!init.unauthenticated && this.token)
|
|
170
|
+
headers.set("authorization", `Bearer ${this.token}`);
|
|
171
|
+
const response = await fetch(`${this.options.apiBaseUrl}${path}`, { ...init, headers });
|
|
172
|
+
if (!response.ok) {
|
|
173
|
+
const details = await response.json().catch(() => ({ error: response.statusText }));
|
|
174
|
+
throw new Error(details.error ?? `PlayPorter API error ${response.status}`);
|
|
175
|
+
}
|
|
176
|
+
if (response.status === 204)
|
|
177
|
+
return undefined;
|
|
178
|
+
return response.json();
|
|
179
|
+
}
|
|
180
|
+
installLifecycleTracking() {
|
|
181
|
+
this.analytics.track("session_started", { platform: this.platform, appVersion: this.options.appVersion });
|
|
182
|
+
document.addEventListener("visibilitychange", () => {
|
|
183
|
+
this.analytics.track(document.hidden ? "session_backgrounded" : "session_resumed");
|
|
184
|
+
if (document.hidden)
|
|
185
|
+
void this.flushEvents();
|
|
186
|
+
});
|
|
187
|
+
addEventListener("pagehide", () => void this.flushEvents(true));
|
|
188
|
+
}
|
|
189
|
+
ensureFlushTimer() {
|
|
190
|
+
if (this.flushTimer)
|
|
191
|
+
return;
|
|
192
|
+
this.flushTimer = window.setTimeout(() => {
|
|
193
|
+
this.flushTimer = undefined;
|
|
194
|
+
void this.flushEvents();
|
|
195
|
+
}, 5_000);
|
|
196
|
+
}
|
|
197
|
+
async flushEvents(useBeacon = false) {
|
|
198
|
+
if (this.eventQueue.length === 0 || !this.token)
|
|
199
|
+
return;
|
|
200
|
+
const events = this.eventQueue.splice(0, 50);
|
|
201
|
+
const body = JSON.stringify({ events, platform: this.platform, appVersion: this.options.appVersion });
|
|
202
|
+
const url = `${this.options.apiBaseUrl}/api/v1/events/batch`;
|
|
203
|
+
if (useBeacon) {
|
|
204
|
+
// sendBeacon cannot add authorization headers; fetch keepalive preserves authenticated delivery.
|
|
205
|
+
void fetch(url, {
|
|
206
|
+
method: "POST",
|
|
207
|
+
keepalive: true,
|
|
208
|
+
headers: {
|
|
209
|
+
"content-type": "application/json",
|
|
210
|
+
"x-playporter-game-key": this.options.projectKey,
|
|
211
|
+
authorization: `Bearer ${this.token}`,
|
|
212
|
+
},
|
|
213
|
+
body,
|
|
214
|
+
});
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
await this.request("/api/v1/events/batch", { method: "POST", body });
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
this.eventQueue.unshift(...events);
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
sessionKey() {
|
|
226
|
+
return `playporter.session.${this.options.projectKey}.${this.platform}`;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function createAdapter(requested, discordClientId) {
|
|
230
|
+
const detected = requested === "auto" ? detectPlatform() : requested;
|
|
231
|
+
switch (detected) {
|
|
232
|
+
case "discord": return new DiscordAdapter(discordClientId ?? "");
|
|
233
|
+
case "telegram": return new TelegramAdapter();
|
|
234
|
+
case "reddit": return new RedditAdapter();
|
|
235
|
+
default: return new WebAdapter();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function detectPlatform() {
|
|
239
|
+
if (new URLSearchParams(location.search).has("frame_id") || location.hostname.endsWith("discordsays.com"))
|
|
240
|
+
return "discord";
|
|
241
|
+
if (window.Telegram?.WebApp || /Telegram/i.test(navigator.userAgent))
|
|
242
|
+
return "telegram";
|
|
243
|
+
if (location.hostname.endsWith("reddit.com") || location.pathname.startsWith("/r/"))
|
|
244
|
+
return "reddit";
|
|
245
|
+
return "web";
|
|
246
|
+
}
|
|
247
|
+
export * from "@playporter/core";
|
|
248
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../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,cAAc;IACrB,IAAI,IAAI,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5H,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;QAAE,OAAO,UAAU,CAAC;IACxF,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IACrG,OAAO,KAAK,CAAC;AACf,CAAC;AAED,cAAc,kBAAkB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@playporter/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"package.json",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@discord/embedded-app-sdk": "^2.4.0",
|
|
18
|
+
"@playporter/core": "0.1.0"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
23
|
+
"prepublishOnly": "npm run build && npm run typecheck"
|
|
24
|
+
}
|
|
25
|
+
}
|