@abstraxn/passkey-manager
Version:
@abstraxn/passkey-manager is an npm package that provides a set of utilities and classes for creating and managing WebAuthn passkeys, extracting signatures, and handling local storage formats. The package is designed with an object-oriented approach, maki
30 lines • 1.08 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getItem = exports.setItem = void 0;
/**
* Sets an item in the local storage.
* @param key - The key to set the item with.
* @param value - The value to be stored. It will be converted to a string using JSON.stringify.
* @template T - The type of the value being stored.
*/
function setItem(key, value) {
// to prevent silly mistakes with double stringifying
if (typeof value === "string") {
localStorage.setItem(key, value);
}
else {
localStorage.setItem(key, JSON.stringify(value, (_key, value) => typeof value === "bigint" ? "0x" + value.toString(16) : value));
}
}
exports.setItem = setItem;
/**
* Retrieves the value associated with the specified key from the local storage.
*
* @param key - The key of the item to retrieve.
* @returns The value associated with the key, or null if the key does not exist.
*/
function getItem(key) {
return localStorage.getItem(key);
}
exports.getItem = getItem;
//# sourceMappingURL=StorageManager.js.map
;