aptx-token-store-cookie
14
总安装量
14
周安装量
#24074
全站排名
安装命令
npx skills add https://github.com/haibaraaiaptx/aptx-skill --skill aptx-token-store-cookie
Agent 安装分布
opencode
14
gemini-cli
14
claude-code
14
github-copilot
14
codex
14
kimi-cli
14
Skill 文档
aptx-token-store-cookie
Quick Start
Create store with default configuration:
import { createCookieTokenStore } from "@aptx/token-store-cookie";
const store = createCookieTokenStore({
tokenKey: "aptx_token",
metaKey: "aptx_token_meta",
syncExpiryFromMeta: true,
cookie: {
path: "/",
sameSite: "lax",
secure: true,
},
});
è¿é¶ï¼ä½¿ç¨ CookieTokenStore ç±»
é¤äº createCookieTokenStore å·¥å彿°ï¼è¿å¯ä»¥ç´æ¥ä½¿ç¨ CookieTokenStore ç±»ï¼
import { CookieTokenStore, CookieTokenStoreOptions } from "@aptx/token-store-cookie";
const options: CookieTokenStoreOptions = {
tokenKey: "aptx_token",
metaKey: "aptx_token_meta",
syncExpiryFromMeta: true,
cookie: {
path: "/",
sameSite: "lax",
secure: true,
},
};
// ç´æ¥å®ä¾å
const store = new CookieTokenStore(options);
éç¨äºéè¦æ´å¤æ§å¶æçåºæ¯ã
SSR / Node ç¯å¢è¯´æ
@aptx/token-store-cookie åºäº js-cookieï¼å±äºæµè§å¨å®ç°ï¼ä¸éç¨äº SSR/Nodeã
SSR åºæ¯æ¨èï¼
- æ¯ä¸ª SSR request å建èªå·±ç
TokenStoreï¼request-scopedï¼ï¼ä»å ¥ç«Cookie读å tokenï¼å¹¶éè¿Set-Cookieååååºã - å¯ä½¿ç¨
@aptx/token-store-ssr-cookieï¼æ¬ä»åºæ°å¢ï¼ä½ä¸º SSR cookie storeã
Implementation Workflow
When integrating cookie token storage:
- Create store using
createCookieTokenStore({ tokenKey, metaKey, cookie, syncExpiryFromMeta }) - Keep
syncExpiryFromMeta: true(default) to auto-syncmeta.expiresAtâ cookieexpires - Set
syncExpiryFromMeta: falseonly if gateway controls cookie expiration independently - Inject store into
@aptx/api-plugin-auth‘sstorefield - Test: token/meta I/O, clear, expiry sync, and disabled sync scenarios
Documentation
- API Reference – Method signatures and descriptions
- Configuration – All options and expiry sync rules
- Testing – Mock patterns, validation examples, and test coverage checklist
- Extensions – Custom fields and type imports