This SDK facilitates integration with App Pass for Chrome Extensions. It provides methods to check App Pass status and activate App Pass. For more information, see https://joinapppass.com/.
npm install @chrome-stats/app-pass-sdkTo check if the user has a valid App Pass:
import { checkAppPass } from '@chrome-stats/app-pass-sdk';
const response = await checkAppPass();
if (response.status === 'ok') {
console.log('App Pass is valid');
} else {
console.log('App Pass invalid:', response.message);
}To initiate the activation flow (requests permissions and opens activation page):
import { activateAppPass } from '@chrome-stats/app-pass-sdk';
const response = await activateAppPass();To open the App Pass management page:
import { manageAppPass } from '@chrome-stats/app-pass-sdk';
await manageAppPass();If you need to verify the App Pass status on your server (e.g., to unlock premium features in your backend), follow these steps:
- Retrieve Token: On the client side (extension), obtain the
appPassTokenfrom thecheckAppPass()response. This token is available only whenstatusis'ok'.
const response = await checkAppPass();
if (response.status === 'ok' && response.appPassToken) {
// Send response.appPassToken to your server
}- Verify Token: On your server, make a GET request to the App Pass API to validate the token.
- Endpoint:
https://joinapppass.com/api/check-app-pass - Method:
GET - Headers:
app-pass-token: The token received from the client.
Example (Node.js/fetch):
const response = await fetch('https://joinapppass.com/api/check-app-pass', {
method: 'GET',
headers: {
'app-pass-token': receivedAppPassToken
}
});
const data = await response.json();
if (data.status === 'ok') {
console.log('User is verified:', data.email);
}