SDK provides several storages implementation in a single interface that can be used to store temporary token and states.

The following storages are currently available in the SDK by default.

  • NullStorage
  • MemoryStorage
  • LocalStorage
  • FileStorage
  • CookieStorage
const storage = new SSOfy.LocalStorage();
import { Storage, FileStorage } from "@ssofy/javascript-sdk";
import fs from "fs";

const storagePath = fs.mkdtempSync('/tmp/');
const storage = new FileStorage(storagePath);
// write data
await storage.put(
    'some value',
    60 // ttl in seconds

// read data
const value = await storage.get('my-key');

// delete data
await storage.delete('my-key');

// delete all data
await storage.flushAll();

// cleanup
await storage.cleanup();

Unlike flushAll(), the cleanup() function call does not completely remove all data. Instead, it deletes old and expired data from storages that don't have built-in functionality for addressing key expiry cycles (i.e. FileStorage).

You may also build your own custom storage by implementing the Storage Interface.

ssofy Knowledge Base
At our core, we believe that staying up-to-date with the latest trends and advancements in Authentication and related areas is essential. That's why we take great pride in keeping you informed with the latest insights, updates, and news in this rapidly evolving landscape.

Do you need support?
SSOfy is by Cubelet Ltd.
Copyright © 2024 Cubelet Ltd. All rights reserved.