{"_id":"@superfunctions/oauth-storage","_rev":"2-92aa17cabdc27cbd9b8fedd68e0f2e98","name":"@superfunctions/oauth-storage","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1":{"name":"@superfunctions/oauth-storage","version":"0.0.1","keywords":["oauth","storage","superfunctions"],"author":{"name":"21n"},"license":"MIT","_id":"@superfunctions/oauth-storage@0.0.1","maintainers":[{"name":"21native","email":"npm@21n.org"}],"homepage":"https://github.com/21nCo/super-functions#readme","bugs":{"url":"https://github.com/21nCo/super-functions/issues"},"dist":{"shasum":"db0252151f9ecb5c1f2c2a3540f4a7c8b57578fe","tarball":"https://registry.npmjs.org/@superfunctions/oauth-storage/-/oauth-storage-0.0.1.tgz","fileCount":26,"integrity":"sha512-FPPIjR0sPba51hCZqme+94P6r+N45sMbqjpDOQ4NiuU6wJjAwwvsbhD31zODv9y4P6Bk+z6/B0Ud+sUfjy8/yQ==","signatures":[{"sig":"MEUCIQDc2m5h7tuZn2Xm1mMkKrru6TH/O+C9AIup7gxEuTwD8QIgIF62DjjYtlULmlc9hGth3tMEawKQDnOxpUfPQ+DY/cQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":134474},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"c566cac4b41a7b4a55ff128aad6471f275f03e22","scripts":{"lint":"echo 'lint not configured'","test":"vitest --config ./vitest.config.ts --run","build":"tsc","clean":"rm -rf dist","typecheck":"tsc --noEmit","test:watch":"vitest --config ./vitest.config.ts --watch"},"_npmUser":{"name":"21native","email":"npm@21n.org"},"repository":{"url":"git+https://github.com/21nCo/super-functions.git","type":"git","directory":"packages/oauth-storage"},"_npmVersion":"10.8.2","description":"OAuth state and token storage contracts for Superfunctions","directories":{},"_nodeVersion":"20.20.2","dependencies":{"@superfunctions/db":"0.1.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.2.4","typescript":"^5.6.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/oauth-storage_0.0.1_1778750602930_0.6257379700348749","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@superfunctions/oauth-storage","version":"0.1.0","description":"OAuth state and token storage contracts for Superfunctions","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"build":"tsc","test":"vitest --config ./vitest.config.ts --run","test:watch":"vitest --config ./vitest.config.ts --watch","lint":"echo 'lint not configured'","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"keywords":["oauth","storage","superfunctions"],"author":{"name":"21n"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/21nCo/super-functions.git","directory":"packages/oauth-storage"},"publishConfig":{"access":"public"},"dependencies":{"@superfunctions/db":"0.2.0"},"devDependencies":{"@types/node":"^22.0.0","typescript":"^5.6.0","vitest":"^3.2.4"},"_id":"@superfunctions/oauth-storage@0.1.0","gitHead":"e11bd81db6390dbc38303a5f3da6baadbaef0c8b","bugs":{"url":"https://github.com/21nCo/super-functions/issues"},"homepage":"https://github.com/21nCo/super-functions#readme","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-0x7bMvGspqwD7TsBIQv6A4baxa7VJt5Wehf3Qx6sJ0ZHrWeIDp37Vj/pI7pfuMnXlDAU3/qooengFYWZChtcHA==","shasum":"87be11d568d07f8cc395cfe9a74b9c4701e368fa","tarball":"https://registry.npmjs.org/@superfunctions/oauth-storage/-/oauth-storage-0.1.0.tgz","fileCount":26,"unpackedSize":134474,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD2HEHTLbgrvRc7dbcOUBy4dTNzjXx2ZOrqgn9N689ZzQIhAInXB2bkZ/6Yb+RLbMwNBKIoJwV8bg+AxLsTHpv+V0mG"}]},"_npmUser":{"name":"21native","email":"npm@21n.org"},"directories":{},"maintainers":[{"name":"21native","email":"npm@21n.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/oauth-storage_0.1.0_1787981270988_0.7124134179827963"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-14T09:23:22.795Z","modified":"2026-08-29T05:27:51.350Z","0.0.1":"2026-05-14T09:23:23.088Z","0.1.0":"2026-08-29T05:27:51.155Z"},"bugs":{"url":"https://github.com/21nCo/super-functions/issues"},"author":{"name":"21n"},"license":"MIT","homepage":"https://github.com/21nCo/super-functions#readme","keywords":["oauth","storage","superfunctions"],"repository":{"type":"git","url":"git+https://github.com/21nCo/super-functions.git","directory":"packages/oauth-storage"},"description":"OAuth state and token storage contracts for Superfunctions","maintainers":[{"name":"21native","email":"npm@21n.org"}],"readme":"# @superfunctions/oauth-storage\n\nShared OAuth state and token persistence contracts, adapters, and encryption helpers.\n\n## Install\n\n```bash\nnpm install @superfunctions/oauth-storage @superfunctions/db\n```\n\n## Quick Start\n\nProduction code should persist tokens through `EncryptedTokenVault`.\n\n```ts\nimport {\n  AesGcmTokenCipher,\n  EncryptedTokenVault,\n  MemoryOAuthStateStore,\n  MemoryTokenVault,\n} from \"@superfunctions/oauth-storage\";\n\nconst stateStore = new MemoryOAuthStateStore();\nconst cipher = new AesGcmTokenCipher((keyRef) => {\n  if (keyRef !== \"oauth-default\") {\n    throw new Error(\"unknown keyRef\");\n  }\n\n  return Buffer.alloc(32, 7);\n});\n\nconst tokenVault = new EncryptedTokenVault(new MemoryTokenVault(), cipher);\n```\n\nIf you want the shared DB abstraction, `createOAuthDbStorage(...)` builds the stores with the correct default model names:\n\n```ts\nimport { createOAuthDbStorage } from \"@superfunctions/oauth-storage\";\n\nconst { stateStore, tokenVault, models } = createOAuthDbStorage({\n  adapter,\n});\n\nconsole.log(models.oauthStates); // oauth_states\nconsole.log(models.oauthTokenVault); // oauth_tokens\n```\n\n## Package Boundary\n\n`@superfunctions/oauth-storage` owns:\n\n- `OAuthStateStore` for short-lived redirect state\n- `TokenVault` for connection-bound token records\n- consent and revocation-failure stores\n- in-memory, SQL, and `@superfunctions/db` adapters\n- `EncryptedTokenVault`, `TokenCipher`, and `AesGcmTokenCipher`\n\nIt does not decide when to start OAuth, exchange tokens, or expose HTTP endpoints.\n\n## Production Notes\n\n- The default SQL/DB token model name is `oauth_tokens`.\n- `MemoryOAuthStateStore` and `MemoryTokenVault` are fine for tests and small prototypes, but not for multi-instance production deployments.\n- Prefer `EncryptedTokenVault` for durable token storage so plaintext token JSON never becomes the long-lived record format.\n- If you already use a custom token table/model name, keep passing `models.oauthTokenVault` until your schema migration is complete.\n\n## Related Packages\n\n- OAuth core primitives: [../oauth-core/README.md](../oauth-core/README.md)\n- Flow orchestration: [../oauth-flow/README.md](../oauth-flow/README.md)\n- Test fixtures: [../oauth-testing/README.md](../oauth-testing/README.md)\n","readmeFilename":"README.md"}