1.3.1 • Published 1 year ago
@tryrolljs/sdk v1.3.1
@tryrolljs/sdk
About
This package is intended to help applications that depend on the Roll API to manage their credentials, whether they are invoking endpoints as an API client or on behalf of a user via Oauth credentials.
Install
yarn add @tryrolljs/sdk @tryrolljs/api-client
npm i @tryrolljs/sdk @tryrolljs/api-client`
Quick Start
import { token } from '@tryrolljs/api'
import Client from '@tryrolljs/api-client'
import { auth } from '@tryrolljs/sdk'
// The Roll SDK uses the storage interface to manage oauth tokens on your behalf,
// refreshing as needed per request. Pass in an object or class that fulfills these function signatures,
// backed by a database, an in-memory datastore, or browser storage such as localstorage or sessionstorage
// export interface Storage {
// setItem(key: string, value: string): void | Promise<void>
// getItem(key: string): string | undefined | Promise<string | undefined>
// removeItem(key: string): void | Promise<void>
// }
const storage = new YourStorageImplementation() (an implementation of a storage mechanism that suits your needs)
// initialize an instance of the Roll API SDK, backed by client credentials
const clientAuthSdk = new auth.ClientSDK(
{
issuerUrl: "https://oauth.tryroll.com/oauth2",
clientId: process.env.YOUR_CLIENT_ID,
clientSecret: process.env.YOUR_CLIENT_SECRET,
},
storage
)
// generate an auth token for your api client
await clientAuthSdk.generateToken()
// initialize an apiClient with your authentication manager
const apiClient = new Client.default(
{ baseUrl: "https://api.tryroll.com" },
clientAuthSdk,
)
// invoke an api function while passing in the api client
const tokenList = await token.getTokens(apiClient, { limit: 10, offset: 0})
Examples
1.3.1
1 year ago
1.3.0
1 year ago
1.2.0
1 year ago
1.1.0
1 year ago
1.0.0
1 year ago
1.2.1
1 year ago
0.3.0
1 year ago
0.2.1
1 year ago
0.1.0
1 year ago
0.1.2
1 year ago
0.2.0
1 year ago
0.1.1
1 year ago
0.1.4
1 year ago
0.1.3
1 year ago
0.0.11
1 year ago
0.0.10
1 year ago
0.0.9
1 year ago
0.0.8
1 year ago
0.0.7
1 year ago
0.0.6
1 year ago
0.0.5
1 year ago
0.0.4
1 year ago
0.0.3
1 year ago
0.0.2
1 year ago
0.0.1
1 year ago