cloudbase-accesstoken-cache
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -20,9 +20,28 @@ import type { Database } from '@cloudbase/node-sdk'; | ||
collectionName?: string; | ||
/** | ||
* 是否在内存中备份,多次调用时只会验证内存中的access token的过期时间, | ||
* 直到过期才会重新从 cloudbase db 远端获取 | ||
* 优点为, 不同每次都从远端 db 中去获取 | ||
* 缺点为,当另外一个获取access token的请求,让内存中的这个 token 强制过期时,需要手动干预 | ||
* 默认为 true | ||
*/ | ||
memoize?: boolean; | ||
} | ||
export interface ISingleCacheManagerInnerCache { | ||
appid: string; | ||
accessToken: string; | ||
expiresIn: number; | ||
} | ||
export interface IRemoteTokenResponse { | ||
access_token: string; | ||
expires_in: number; | ||
} | ||
export declare class SingleCacheManager { | ||
appid: string; | ||
secret: string; | ||
db: Database.Db; | ||
collectionName: string; | ||
tokenCol: Database.CollectionReference; | ||
private appid; | ||
private secret; | ||
private db; | ||
private collectionName; | ||
private tokenCol; | ||
private cache?; | ||
private memoize; | ||
constructor(config: ISingleCacheManagerConfig); | ||
@@ -33,3 +52,3 @@ private getAccessTokenByHttp; | ||
*/ | ||
forceGetAccessTokenByHttp(): Promise<any>; | ||
forceGetAccessTokenByHttp(): Promise<IRemoteTokenResponse>; | ||
/** | ||
@@ -39,3 +58,14 @@ * 创建此 Collection | ||
createCollection(): import("@cloudbase/node-sdk").IBaseRes; | ||
createCacheItem(ts: number): Promise<ISingleCacheManagerInnerCache>; | ||
/** | ||
* 远端策略 | ||
* @returns | ||
*/ | ||
remoteStrategy(): Promise<any>; | ||
/** | ||
* 内存策略 | ||
* @returns | ||
*/ | ||
memoizeStrategy(): Promise<any>; | ||
/** | ||
* 调用时,请确保 Collection 存在,如果不存在请调用 createCollection | ||
@@ -42,0 +72,0 @@ */ |
{ | ||
"name": "cloudbase-accesstoken-cache", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "cloudbase-accesstoken-cache , use cloudbase database to manager your accesstoken easily !", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# cloudbase-accesstoken-cache | ||
> 轻松快捷的管理您的 Access Token | ||
> 微信公众号和小程序的 Access Token 小助手, 轻松快捷的管理您的Token策略 | ||
@@ -5,0 +5,0 @@ ## Usage |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
0
3
16019
363