Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
A low-level API for getting data from the PlayStation Network.
PSN API is a reference implementation of a community effort to document Sony's APIs for PlayStation authorization and trophy metadata. It saves you the hassle of implementing this community reference yourself by offering a strongly-typed, well-tested, and lightweight package.
✅ Modular by design, supports tree-shaking.
✅ Aligns with the community PSN API documentation.
✅ Supports Node environments (14 and above).
✅ Supports browsers.
✅ Ships with TypeScript support and types.
✅ Tiny, <2Kb.
npm install --save psn-api
OR
yarn add psn-api
Node 14 and above are officially supported. The package can be imported via:
const psn = require("psn-api");
You can use import
syntax to utilize the package in your app. This library provides its own type definitions. "It just works", no need to install anything from @types
.
import { getTrophiesEarnedForTitle } from "psn-api";
All methods in the API are async and return a native Promise.
These methods can be used with the native Promise API or the more modern async/await syntax.
// Native Promise API.
exchangeCodeForAccessToken("myCode").then((accessTokenResponse) => {
console.log({ accessTokenResponse });
});
// async/await syntax.
const accessTokenResponse = await exchangeCodeForAccessToken("myCode");
console.log({ accessTokenResponse });
To use any endpoint function in the API, you must first be authorized by PSN. Fortunately, this is a fairly straightforward process.
In your web browser, visit https://my.playstation.com/ and log in with a PSN account.
In the same browser (due to a persisted cookie), visit https://ca.account.sony.com/api/v1/ssocookie. You will see a JSON response that looks something like:
{"npsso":"Hwl9Vq..."}
Copy your NPSSO. Do not expose it anywhere publicly, it is equivalent to your password.
// This is the value you copied from the previous step.
const myNpsso = "Hwl9Vq...";
// We'll exchange your NPSSO for a special access code.
const accessCode = await exchangeNpssoForCode(npsso);
// We can use the access code to get your access token and refresh token.
const authorization = await exchangeCodeForAccessToken(accessCode);
const authorization = await exchangeCodeForAccessToken(accessCode);
// This returns a list of all the games you've earned trophies for.
const trophyTitlesResponse = await getTrophyTitlesForUser(
{ accessToken: authorization.accessToken },
"me"
);
Click the function names for complete docs.
exchangeCodeForAccessToken()
- Exchange your access code for access and refresh tokens.exchangeNpssoForCode()
- Exchange your NPSSO for an access code.getSummarizedTrophiesByTrophyGroup()
- Get a summary of trophies earned for a user broken down by trophy group within a title.getTitleTrophyGroups()
- Get a list of trophy groups (typically the base set and DLCs) for a title.getTrophiesEarnedForTitle()
- Retrieve the earned status of trophies for a user from either a single or all trophy groups in a title.getTrophiesForTitle()
- Retrieve the individual trophy details of a single or all trophy groups for a title.getTrophyProfileSummary()
- Retrieve an overall summary of the number of trophies earned for a user broken down by type.getTrophyTitlesForUser()
- Retrieve a list of the titles associated with an account and a summary of trophies earned from them.Before beginning, please make sure you have the following tools installed.
git clone https://github.com/achievements-app/psn-api.git
cd psn-api
yarn
Start a local dev server in watch mode with yarn dev
.
There is a dev playground set up in src/__dev-playground.ts. When changes are made to this file, you will see updates in your terminal.
Tests can be executed using yarn test
.
FAQs
A well-tested library that lets you get trophy, user, and game data from the PlayStation Network.
The npm package psn-api receives a total of 359 weekly downloads. As such, psn-api popularity was classified as not popular.
We found that psn-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.