@auth/unstorage-adapter
Auth.js / NextAuth.js 的官方 Unstorage 适配器。
安装
npm install unstorage @auth/unstorage-adapter
UnstorageAdapterOptions
这是 Unstorage 适配器选项的接口。
属性
accountByUserIdPrefix?
optional accountByUserIdPrefix: string;
accountByUserId
键的前缀
accountKeyPrefix?
optional accountKeyPrefix: string;
account
键的前缀
authenticatorKeyPrefix?
optional authenticatorKeyPrefix: string;
authenticator
键的前缀
authenticatorUserKeyPrefix?
optional authenticatorUserKeyPrefix: string;
authenticator-by-user-id
键的前缀
baseKeyPrefix?
optional baseKeyPrefix: string;
密钥的基本前缀
emailKeyPrefix?
optional emailKeyPrefix: string;
emailKey
键的前缀
sessionByUserIdKeyPrefix?
optional sessionByUserIdKeyPrefix: string;
sessionByUserId
键的前缀
sessionKeyPrefix?
optional sessionKeyPrefix: string;
sessionKey
键的前缀
useItemRaw?
optional useItemRaw: boolean;
使用 getItemRaw/setItemRaw
而不是 getItem/setItem
。
这是一个实验性功能。请检查 unjs/unstorage#142 了解更多信息。
userKeyPrefix?
optional userKeyPrefix: string;
user
键的前缀
verificationTokenKeyPrefix?
optional verificationTokenKeyPrefix: string;
verificationToken
键的前缀
defaultOptions
const defaultOptions: {
accountByUserIdPrefix: "user:account:by-user-id:";
accountKeyPrefix: "user:account:";
authenticatorKeyPrefix: "authenticator:";
authenticatorUserKeyPrefix: "authenticator:by-user-id:";
baseKeyPrefix: "";
emailKeyPrefix: "user:email:";
sessionByUserIdKeyPrefix: "user:session:by-user-id:";
sessionKeyPrefix: "user:session:";
useItemRaw: false;
userKeyPrefix: "user:";
verificationTokenKeyPrefix: "user:token:";
};
类型声明
accountByUserIdPrefix
accountByUserIdPrefix: string = "user:account:by-user-id:";
accountKeyPrefix
accountKeyPrefix: string = "user:account:";
authenticatorKeyPrefix
authenticatorKeyPrefix: string = "authenticator:";
authenticatorUserKeyPrefix
authenticatorUserKeyPrefix: string = "authenticator:by-user-id:";
baseKeyPrefix
baseKeyPrefix: string = "";
emailKeyPrefix
emailKeyPrefix: string = "user:email:";
sessionByUserIdKeyPrefix
sessionByUserIdKeyPrefix: string = "user:session:by-user-id:";
sessionKeyPrefix
sessionKeyPrefix: string = "user:session:";
useItemRaw
useItemRaw: boolean = false;
userKeyPrefix
userKeyPrefix: string = "user:";
verificationTokenKeyPrefix
verificationTokenKeyPrefix: string = "user:token:";
UnstorageAdapter()
UnstorageAdapter(storage, options): Adapter
参数
参数 | 类型 |
---|---|
存储 | Storage <StorageValue > |
选项 | UnstorageAdapterOptions |
返回
hydrateDates()
hydrateDates(json): any
参数
参数 | 类型 |
---|---|
json | Record <string , any > |
返回
任何