npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pod-sso-pkce

v2.1.1

Published

This package includes methods for using SSO POD (https://docs.pod.ir/v1.6.0.0/SSO/Introduction/149/SSO) by The PKCE method.

Readme

pod-sso-pkce

This package includes methods for using SSO POD (https://docs.pod.ir/v1.6.0.0/SSO/Introduction/149/SSO) by The PKCE method.

You can use this package in any frontend project.

Installation

Use npm to install the package:

npm i pod-sso-pkce
Notice: All data is stored in Local Storage.

Methods

| Method | Description | | ------------------------- | ----------------------------------------------------------------------------------------- | | authenticate | To login to the account with the SSO POD | | authenticateWithAutologin | To login to the account with the SSO POD by automatic login | | validate | To validate the user after returning from the SSO POD to your app and get an access token | | refreshToken | To get a new access token after the current access token expires | | getAccessToken | Get the user's current access token | | isAuthenticated | Checks if the user is logged in or not | | logout | User logs out from the user account |

authenticate()

| Parameter | Type | Description | Example | | -------------- | ------ | ----------- | --------------------------------- | | ssoURL | string | | https://accounts.pod.ir/ | | clientId | string | | 20200000egh98412ea0a164708f109210 | | redirectUrlSso | string | | http://myapp.ir/validate | | ssoScope | string | | profile email |

After calling this method, your app will be redirected to the SSO POD.

authenticateWithAutologin()

| Parameter | Type | Description | Example | | -------------- | ------ | ----------- | --------------------------------- | | ssoURL | string | | https://accounts.pod.ir/ | | clientId | string | | 20200000egh98412ea0a164708f109210 | | redirectUrlSso | string | | http://myapp.ir/validate | | ssoScope | string | | profile email |

Notice: You must enter 4 parameters in url query string: keyId, accessToken, timestamp, sign

Read this link for more information: https://docs.pod.ir/v1.6.0.0/SSO/User/8660/autologin

After calling this method, your app will be redirected to the SSO POD.

validate()

| Parameter | Type | Description | Example | | ------------------------ | -------- | ----------- | --------------------------------- | | ssoURL | string | | https://accounts.pod.ir/ | | clientId | string | | 20200000egh98412ea0a164708f109210 | | redirectUrlSso | string | | http://myapp.ir/validate | | redirectUrlAfterValidate | string | | http://myapp.ir/mypanel | | onError | function | | () => alert('something wrong') |

After calling this method, if the validation is successful, the user will be redirected to your target url (redirectUrlAfterValidate) but if it isn't, the onError event will occur.

refreshToken()

| Parameter | Type | Description | Example | | --------- | ------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------ | | ssoInfo | Object | | { clientId: '20200000egh98412ea0a164708f109210', ssoURL:'https://accounts.pod.ir/' ,onError: () => alert("something wrong")} |

After calling this method, you can get a new access token with the getAccessToken() Method. the onError event will occurs if an error happens.

getAccessToken()

| Return values | Type | Description | | ------------- | ------ | ------------------------------ | | access token | string | When the user is logged in | | null | null | When the user is not logged in |

isAuthenticated()

| Return values | Type | Description | | ------------- | ------- | ------------------------------ | | true | boolean | When the user is logged in | | false | boolean | When the user is not logged in |

This method is improving...

logout()

| Parameter | Type | Description | example | | ---------------------- | ------ | --------------------------------------------------------------- | ---------------------- | | redirectUrlAfterLogout | string | The page you want the user to see after logout from the account | http://example.ir/home |

Usage

authenticate() Example

import { authenticate } from 'pod-sso-pkce';

function App() {
  const ssoURL = 'https://accounts.pod.ir/';
  const clientId = '20200000egh98412ea0a164708f109210';
  const redirectUrlSso = 'http://myapp.ir/validate';
  const ssoScope = 'profile email';

  // ...
  authenticate(ssoURL, clientId, redirectUrlSso, ssoScope);
  // ...
}

authenticateWithAutologin() Example

sample address: http://myapp.ir/autologin?access_token=123&key_id=456&timestamp=789&signature=101112

import { authenticateWithAutologin } from 'pod-sso-pkce';

function App() {
  const ssoURL = 'https://accounts.pod.ir/';
  const clientId = '20200000egh98412ea0a164708f109210';
  const redirectUrlSso = 'http://myapp.ir/validate';
  const ssoScope = 'profile email';

  // ...
  authenticateWithAutologin(ssoURL, clientId, redirectUrlSso, ssoScope);
  // ...
}

validate() Example

import { validate } from 'pod-sso-pkce';

function App() {
  const ssoURL = 'https://accounts.pod.ir/';
  const clientId = '20200000egh98412ea0a164708f109210';
  const redirectUrlSso = 'http://myapp.ir/validate';
  const ssoScope = 'profile email';
  const redirectUrlAfterValidate = 'http://myapp.ir/mypanel';

  // ...
  validate(ssoURL, clientId, redirectUrlSso, redirectUrlAfterValidate, () => {
    console.log('error in validation');
  });
  // ...
}

refreshToken() Example

import { refreshToken, getAccessToken } from 'pod-sso-pkce';

async function fetch() {
  // ...
  if (error.response.status === 401) {
    await refreshToken({
      clientId: '20200000egh98412ea0a164708f109210',
      ssoURL: 'https://accounts.pod.ir/',
      onError: () => alert('something wrong'),
    });

    const accessToken = getAccessToken();
  }
  // ...
}

getAccessToken() Example

import { getAccessToken } from 'pod-sso-pkce';

function App() {
  // ...
  const accessToken = getAccessToken();
  // ...
}

isAuthenticated() Example

import { isAuthenticated } from 'pod-sso-pkce';

function App() {
  // ...
  if (isAuthenticated()) {
    alert('you are login.');
  } else {
    alert('you are not login');
  }
  // ...
}

logout() Example

import { logout } from 'pod-sso-pkce';

function App() {
  // ...
  logout('http://myapp.ir/home'); // :D
  // ...
}

LICENSE

MIT