@wepin/storage-js
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

wepin logo


@wepin/storage-js

npm version. npm downloads

Wepin Storage Library from Web. This package is only available in the web environment.

⏩ Install

npm install @wepin/storage-js

or

yarn add @wepin/storage-js

⏩ Import SDK

WepinStorage from '@wepin/storage-js'

⏩ Methods

getLocalStorage

WepinStorage.getLocalStorage(appId, name)

Returns the value of the specified local storage item.

Parameters

  • appId <string>
  • name <string>

Example

WepinStorage.getLocalStorage('APP_ID', 'KEY')

getAllLocalStorage

WepinStorage.getAllLocalStorage(appId)

Returns all local storage data.

Parameters

  • appId <string>

Example

WepinStorage.getAllLocalStorage('APP_ID')

setLocalStorage

WepinStorage.setLocalStorage(appId, name, value)

Sets the value of the specified local storage item.

Parameters

  • appId <string>
  • name <string>
  • value <any>

Example

WepinStorage.setLocalStorage('APP_ID', 'KEY', 'data')

setAllLocalStorage

WepinStorage.setAllLocalStorage(appId, values)

Sets all local storage data.

Parameters

  • appId <string>
  • values <any>

Example

WepinStorage.setAllLocalStorage('APP_ID', 'data')

clearLocalStorage

WepinStorage.clearLocalStorage(appId, name)

Clears the value of the specified local storage item.

Parameters

  • appId <string>
  • name <string>

Example

WepinStorage.clearLocalStorage('APP_ID', 'KEY')

clearAllLocalStorage

WepinStorage.clearAllLocalStorage(appId)

Clears all local storage data.

Parameters

  • appId <string>

Example

WepinStorage.clearAllLocalStorage('APP_ID')

setLoginUserLocalStorage

WepinStorage.setLoginUserLocalStorage(
    appId: string,
    request: {
      provider: string
      token: { idToken: string; refreshToken: string }
    },
    response: any,
  )

Sets the user information of the local storage.

Parameters

  • appId <string>
  • request <string> - response of @wepin/loign-js methods
  • response <string> - response of wepin login api

Example

import {WepinFetch} from '@wepin/fetch-js'
import {WepinLogin} from '@wepin/login-js'

const wepinLogin = new WepinLogin({
    appId: 'APP_ID',
    appKey: 'APP_KEY',
})
const wepinFetch = new WepinFetch({
    appId: 'APP_ID',
    appKey: 'APP_KEY',
    domain: 'APP_DOMAIN',
    sdk: {version: 'SDK_VERSION', type: "SDK_TYPE"}
})
const req = await wepinLogin.loginWithIdToken({token, sign})
const res = await wepinFetch.wepinApi.user.login({
      idToken: req.token.idToken,
    })
WepinStorage.setLoginUserLocalStorage('APP_ID', req, res)

Package Sidebar

Install

npm i @wepin/storage-js

Weekly Downloads

3

Version

0.0.1

License

MIT

Unpacked Size

15.4 kB

Total Files

8

Last publish

Collaborators

  • ke.kim
  • wepin.dev