@notifi-network/notifi-frontend-client
Advanced tools
Comparing version 0.31.1-alpha.20 to 0.31.1-alpha.21
@@ -127,2 +127,38 @@ import { Types, Operations } from '@notifi-network/notifi-graphql'; | ||
export { CreateFunc, EnsureSourceParams, EnsureWebhookParams, FetchFunc, IdentifyFunc, NotifiAptosConfiguration, NotifiEnvironment, NotifiEnvironmentConfiguration, NotifiFrontendConfiguration, NotifiSolanaConfiguration, ValueTransformFunc, ensureBonfidaAuctionSource, ensureEmail, ensureMetaplexAuctionSource, ensureSms, ensureSource, ensureSourceGroup, ensureSourceRaw, ensureTelegram, ensureWebhook, notNullOrEmpty, packFilterOptions }; | ||
declare type StorageDriver = Readonly<{ | ||
get: <T>(key: string) => Promise<T | null>; | ||
set: <T>(key: string, newValue: T | null) => Promise<void>; | ||
has: (key: string) => Promise<boolean>; | ||
}>; | ||
declare type GetStorageType<Key extends string, T> = Readonly<{ | ||
[key in `get${Capitalize<Key>}`]: () => Promise<T | null>; | ||
}>; | ||
declare type SetStorageType<Key extends string, T> = Readonly<{ | ||
[key in `set${Capitalize<Key>}`]: (newValue: T | null) => Promise<void>; | ||
}>; | ||
declare type HasStorageType<Key extends string> = Readonly<{ | ||
[key in `has${Capitalize<Key>}`]: () => Promise<boolean>; | ||
}>; | ||
declare type StorageType<Key extends string, T> = GetStorageType<Key, T> & SetStorageType<Key, T>; | ||
declare type Authorization = Readonly<{ | ||
token: string; | ||
expiry: string; | ||
}>; | ||
declare type AuthorizationStorage = StorageType<'authorization', Authorization>; | ||
declare type Roles = ReadonlyArray<string>; | ||
declare type RolesStorage = StorageType<'roles', Roles>; | ||
declare type NotifiStorage = AuthorizationStorage & RolesStorage; | ||
declare class NotifiFrontendStorage implements NotifiStorage { | ||
private _driver; | ||
constructor(_driver: StorageDriver); | ||
getAuthorization(): Promise<Authorization | null>; | ||
setAuthorization(newValue: Authorization | null): Promise<void>; | ||
hasAuthorization(): Promise<boolean>; | ||
getRoles(): Promise<Roles | null>; | ||
setRoles(newValue: Roles | null): Promise<void>; | ||
hasRoles(): Promise<boolean>; | ||
} | ||
declare const createLocalForageStorageDriver: (config: NotifiFrontendConfiguration) => StorageDriver; | ||
export { Authorization, AuthorizationStorage, CreateFunc, EnsureSourceParams, EnsureWebhookParams, FetchFunc, GetStorageType, HasStorageType, IdentifyFunc, NotifiAptosConfiguration, NotifiEnvironment, NotifiEnvironmentConfiguration, NotifiFrontendConfiguration, NotifiFrontendStorage, NotifiSolanaConfiguration, NotifiStorage, Roles, RolesStorage, SetStorageType, StorageDriver, StorageType, ValueTransformFunc, createLocalForageStorageDriver, ensureBonfidaAuctionSource, ensureEmail, ensureMetaplexAuctionSource, ensureSms, ensureSource, ensureSourceGroup, ensureSourceRaw, ensureTelegram, ensureWebhook, notNullOrEmpty, packFilterOptions }; |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -18,2 +20,6 @@ var __export = (target, all) => { | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -24,2 +30,4 @@ | ||
__export(lib_exports, { | ||
NotifiFrontendStorage: () => NotifiFrontendStorage, | ||
createLocalForageStorageDriver: () => createLocalForageStorageDriver, | ||
ensureBonfidaAuctionSource: () => ensureBonfidaAuctionSource, | ||
@@ -255,4 +263,78 @@ ensureEmail: () => ensureEmail, | ||
}; | ||
// lib/storage/NotifiFrontendStorage.ts | ||
var KEY_AUTHORIZATION = "authorization"; | ||
var KEY_ROLES = "roles"; | ||
var NotifiFrontendStorage = class { | ||
constructor(_driver) { | ||
this._driver = _driver; | ||
} | ||
getAuthorization() { | ||
return this._driver.get(KEY_AUTHORIZATION); | ||
} | ||
setAuthorization(newValue) { | ||
return this._driver.set(KEY_AUTHORIZATION, newValue); | ||
} | ||
hasAuthorization() { | ||
return this._driver.has(KEY_AUTHORIZATION); | ||
} | ||
getRoles() { | ||
return this._driver.get(KEY_ROLES); | ||
} | ||
setRoles(newValue) { | ||
return this._driver.set(KEY_ROLES, newValue); | ||
} | ||
hasRoles() { | ||
return this._driver.has(KEY_ROLES); | ||
} | ||
}; | ||
// lib/storage/LocalForageStorageDriver.ts | ||
var import_localforage = __toESM(require("localforage")); | ||
import_localforage.default.config({ | ||
name: "notifi" | ||
}); | ||
var getEnvPrefix = (env) => { | ||
switch (env) { | ||
case "Production": | ||
return "notifi-jwt"; | ||
case "Development": | ||
return "notifi-jwt:dev"; | ||
case "Staging": | ||
return "notifi-jwt:stg"; | ||
case "Local": | ||
return "notifi-jwt:local"; | ||
} | ||
}; | ||
var createLocalForageStorageDriver = (config) => { | ||
let keyPrefix = `${getEnvPrefix(config.env)}:${config.tenantId}`; | ||
switch (config.walletBlockchain) { | ||
case "SOLANA": { | ||
keyPrefix += `:${config.walletPublicKey}`; | ||
break; | ||
} | ||
case "APTOS": { | ||
keyPrefix += `:${config.accountAddress}:${config.authenticationKey}`; | ||
break; | ||
} | ||
} | ||
const storageDriver = { | ||
get: async (key) => { | ||
const item = await import_localforage.default.getItem(`${keyPrefix}:${key}`); | ||
return item; | ||
}, | ||
set: async (key, newValue) => { | ||
await import_localforage.default.setItem(`${keyPrefix}:${key}`, newValue); | ||
}, | ||
has: async (key) => { | ||
const keys = await import_localforage.default.keys(); | ||
return keys.indexOf(`${keyPrefix}:${key}`) >= 0; | ||
} | ||
}; | ||
return storageDriver; | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
NotifiFrontendStorage, | ||
createLocalForageStorageDriver, | ||
ensureBonfidaAuctionSource, | ||
@@ -259,0 +341,0 @@ ensureEmail, |
export * from './configuration'; | ||
export * from './utils'; | ||
export * from './client'; | ||
export * from './storage'; |
{ | ||
"name": "@notifi-network/notifi-frontend-client", | ||
"version": "0.31.1-alpha.20+e60abe3", | ||
"version": "0.31.1-alpha.21+ca3ade1", | ||
"description": "The frontend client for Notifi", | ||
@@ -36,6 +36,6 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@notifi-network/notifi-graphql": "^0.31.1-alpha.20+e60abe3", | ||
"@notifi-network/notifi-graphql": "^0.31.1-alpha.21+ca3ade1", | ||
"localforage": "^1.10.0" | ||
}, | ||
"gitHead": "e60abe3ba59acffc01b37b43e9865fe633cfdccb" | ||
"gitHead": "ca3ade1398839b396add6b818f0982c0dccba3ef" | ||
} |
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
58419
1621