
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@playnation/game-sdk
Advanced tools
This is an SDK for integrating games into Playnation.
The first SDK version follows the concept from game-sdk-example.
Online Demo: https://playnation-sdk-demo.netlify.app
postMessage
and window listening.What is implemented in the game.ts or game-farming.ts:
Init flow: Get basic information
init()
getSDKVersion()
getPlayer()
getTournament()
Play casual game flow
play()
start the gametrackScore()
on playingsignResult()
sign and submit the resultgetPlayer()
to retrieve player dataPlay farming game
play()
start the gamesignPayload()
sign to get the game state with secret key from the gameupdateState()
update signed payload every time the game state changesclone this repository and run the example:
git clone
cd ./examples/iframe-implementation
yarn && yarn dev
Include the SDK in your HTML file:
<script src="https://unpkg.com/@playnation/game-sdk@latest/browser/sdk.js"></script>
Create a JavaScript file (e.g., main.js) with something like this example below:
document.addEventListener('DOMContentLoaded', async () => {
const sdk = window.PlaynationGameSDK;
// Run on init
const initParams = { clientId: 'your-client-id' };
const initResponse = await sdk.init(initParams);
console.log('SDK Initialized:', initResponse);
// Get SDK version
const version = sdk.getVersion();
console.log('SDK Version:', version);
// Get player information
let player = await sdk.getPlayer();
console.log('Player Info:', player);
// Get tournament information
const tournament = await sdk.getTournament();
console.log('Tournament Info:', tournament);
// Play the game
async function playGame() {
// Start the game play
const playResponse = await sdk.play();
console.log('Play Response:', playResponse);
// Track score
await sdk.trackScore(playResponse.token, 100);
console.log('Score tracked');
// Sign result
const signedResult = await sdk.signResult(playResponse.token, 'game-token', 100);
console.log('Signed Result:', signedResult);
// Get player information
player = await sdk.getPlayer();
}
});
npm:
npm install @playnation/sdk
or with yarn:
yarn add @playnation/sdk
Use latest version:
<script src="https://unpkg.com/@playnation/game-sdk@latest/browser/sdk.js"></script>
Or specify version:
<script src="https://unpkg.com/@playnation/game-sdk@1.1.0/browser/sdk.js"></script>
init(params: SDKInitParams): Promise<{ currentTimestamp: string }>
Initializes the SDK with the given parameters.
getVersion(): string
Gets the SDK version.
getPlayer(): Promise<Player>
Gets the player information.
getTournament(): Promise<Tournament | undefined>
Gets the tournament information.
play(): Promise<PlayResponse>
Starts the game play. Note: This method will return a token that should be used to track the score and sign the result.
trackScore(gamePlayId: string, score: number): Promise<void>
Tracks the score for a given game play.
signResult(gamePlayId: string, gameToken: string, score: number): Promise<string>
Signs & submits the result of a game play. The game result will be signed and submitted to the Playnation server.
updateState(payload: UpdateStatePayload): Promise<boolean>
Updates the state of the game. Playnation only updates the game state but does not validate its details, so the data needs to be signed with signPayload and validated between the game and the server to ensure security.
signPayload(payload: any, key: string): Promise<any>
Signs a payload with a given key.
Enum representing various error codes that can be returned by the SDK.
SYSTEM_ERROR
: -1
INVALID_REQUEST
: 10
INVALID_SCORE
: 120
USER_REJECT
: 130
NOT_ENOUGH_ENERGY
: 150
TOUR_NOT_AVAILABLE
: 100
NOT_ENOUGH_NPS
: 110
NOT_ENOUGH_TICKET
: 140
cd ./examples/iframe-implementation
yarn && yarn dev
You also develop your game from the example by modifying the index.html
file.
Change the src
attribute of the iframe to your game URL.
<button class="game-button" data-url="[your-game-url]" type="button">Casual Game</button>
<button class="game-button" data-url="[your-game-url]" type="button">Farming Game</button>
cd ./examples/iframe-implementation
yarn && yarn build
Example will use the SDK from the src
folder in the root directory instead of from node_modules
.
cd ./examples/iframe-implementation
yarn && yarn dev:source
yarn && yarn build
v1.1.1
gamePlayId
FAQs
SDK for the games on Playnation
The npm package @playnation/game-sdk receives a total of 46 weekly downloads. As such, @playnation/game-sdk popularity was classified as not popular.
We found that @playnation/game-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.