{"_id":"@carvajalconsultants/cognito","_rev":"4-40a4550267dd56d540f92295ffcc3896","name":"@carvajalconsultants/cognito","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@carvajalconsultants/cognito","version":"0.0.1","author":{"name":"Carvajal Consultants, Inc.","email":"support@carvajalonline.com"},"license":"MIT","_id":"@carvajalconsultants/cognito@0.0.1","maintainers":[{"name":"miguelocarvajal","email":"omar@carvajalonline.com"}],"dist":{"shasum":"624bbc3c15d9e80a9f4ba020fdc22c0bb373344a","tarball":"https://registry.npmjs.org/@carvajalconsultants/cognito/-/cognito-0.0.1.tgz","fileCount":12,"integrity":"sha512-Fy8wo/AZE5Tl1WFn3z0B+uJ7Kez2uTHHnsEuyB4PbOD+H5slFe91ZEisK+NVMYyEMwXvU6tPQQo/5KgOThywqw==","signatures":[{"sig":"MEUCIEM5zpXsywxZfdM4Znb1/7M0oBzjeqN1PV/JzE8vHUFhAiEA5NO8mRUXukDi+w5FCTtDwhrfNkT64gzCvdjYmBqEVnI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28658},"main":"index.ts","private":false,"scripts":{"lint":"eslint --report-unused-disable-directives --max-warnings 0 --fix && prettier --w .","prepare":"husky"},"_npmUser":{"name":"miguelocarvajal","email":"omar@carvajalonline.com"},"repository":{"url":"git@github.com:carvajalconsultants/cognito.git","type":"git"},"description":"Simple Cognito with SRP and e-mail authentication without all of the bloat of the AWS library.","directories":{},"lint-staged":{"**/*.{ts,tsx,js,jsx}":["eslint --report-unused-disable-directives --max-warnings 0 --fix","prettier --w"]},"dependencies":{"globals":"16.0.0","aws-jwt-verify":"^5.0.0","cognito-srp-helper":"^2.3.3","@aws-sdk/client-cognito-identity-provider":"^3.787.0"},"_hasShrinkwrap":false,"devDependencies":{"h3":"^1.15.1","husky":"^9.1.7","eslint":"^9.24.0","grafast":"^0.1.1-beta.21","graphql":"^16.10.0","grafserv":"^0.1.1-beta.24","prettier":"^3.5.3","@eslint/js":"^9.24.0","typescript":"^5.8.3","lint-staged":"^15.5.1","@dataplan/pg":"^0.0.1-beta.32","graphile-config":"^0.0.1-beta.15","typescript-eslint":"^8.29.1","eslint-plugin-react":"^7.37.5","eslint-config-prettier":"^10.1.2","eslint-plugin-import-x":"^4.10.2","eslint-plugin-storybook":"^0.12.0","@typescript-eslint/parser":"^8.29.1","eslint-plugin-react-hooks":"^5.2.0","eslint-plugin-react-refresh":"^0.4.19","@typescript-eslint/eslint-plugin":"^8.29.1","eslint-import-resolver-typescript":"^4.3.2","@carvajalconsultants/eslint-config":"^0.0.2","@ianvs/prettier-plugin-sort-imports":"^4.4.1","eslint-plugin-prefer-arrow-functions":"^3.6.2"},"peerDependencies":{"grafast":"^0.1.1-beta.21","graphql":"^16.10.0","grafserv":"^0.1.1-beta.24","@dataplan/pg":"^0.0.1-beta.32","graphile-config":"^0.0.1-beta.15"},"_npmOperationalInternal":{"tmp":"tmp/cognito_0.0.1_1744562391018_0.7905490260927415","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@carvajalconsultants/cognito","version":"0.0.2","author":{"name":"Carvajal Consultants, Inc.","email":"support@carvajalonline.com"},"license":"MIT","_id":"@carvajalconsultants/cognito@0.0.2","maintainers":[{"name":"miguelocarvajal","email":"omar@carvajalonline.com"}],"dist":{"shasum":"8d62958b1786057a682844d3d8995559a59238ea","tarball":"https://registry.npmjs.org/@carvajalconsultants/cognito/-/cognito-0.0.2.tgz","fileCount":5,"integrity":"sha512-UaKcVBp0U4FKXtX03pXlUeLyCaErMpzZKotiFTmjFrznt0EJzPoiAVneqJvChPlzsJRhDnDM26A6+e4ZhHP1tQ==","signatures":[{"sig":"MEUCIQCfr62kS7HoFXtAhILFrhArbvU3k2NKr2rG5utTT6wRVgIge3PbMo9RXT0c0lVkbBtUC0zG9M5oX2UMtDXkBUTlMps=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27715},"main":"index.ts","private":false,"scripts":{"lint":"eslint --report-unused-disable-directives --max-warnings 0 --fix && prettier --w .","prepare":"husky"},"_npmUser":{"name":"miguelocarvajal","email":"omar@carvajalonline.com"},"repository":{"url":"git@github.com:carvajalconsultants/cognito.git","type":"git"},"description":"Simple Cognito with SRP and e-mail authentication without all of the bloat of the AWS library.","directories":{},"lint-staged":{"**/*.{ts,tsx,js,jsx}":["eslint --report-unused-disable-directives --max-warnings 0 --fix","prettier --w"]},"dependencies":{"globals":"16.0.0","aws-jwt-verify":"^5.0.0","cognito-srp-helper":"^2.3.3","@aws-sdk/client-cognito-identity-provider":"^3.787.0"},"_hasShrinkwrap":false,"devDependencies":{"h3":"^1.15.1","husky":"^9.1.7","eslint":"^9.24.0","grafast":"^0.1.1-beta.21","graphql":"^16.10.0","grafserv":"^0.1.1-beta.24","prettier":"^3.5.3","@eslint/js":"^9.24.0","typescript":"^5.8.3","lint-staged":"^15.5.1","@dataplan/pg":"^0.0.1-beta.32","graphile-config":"^0.0.1-beta.15","typescript-eslint":"^8.29.1","eslint-plugin-react":"^7.37.5","eslint-config-prettier":"^10.1.2","eslint-plugin-import-x":"^4.10.2","eslint-plugin-storybook":"^0.12.0","@typescript-eslint/parser":"^8.29.1","eslint-plugin-react-hooks":"^5.2.0","eslint-plugin-react-refresh":"^0.4.19","@typescript-eslint/eslint-plugin":"^8.29.1","eslint-import-resolver-typescript":"^4.3.2","@carvajalconsultants/eslint-config":"^0.0.2","@ianvs/prettier-plugin-sort-imports":"^4.4.1","eslint-plugin-prefer-arrow-functions":"^3.6.2"},"peerDependencies":{"grafast":"^0.1.1-beta.21","graphql":"^16.10.0","grafserv":"^0.1.1-beta.24","@dataplan/pg":"^0.0.1-beta.32","graphile-config":"^0.0.1-beta.15"},"_npmOperationalInternal":{"tmp":"tmp/cognito_0.0.2_1744563404974_0.6922989911187547","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@carvajalconsultants/cognito","version":"0.0.3","author":{"name":"Carvajal Consultants, Inc.","email":"support@carvajalonline.com"},"license":"MIT","_id":"@carvajalconsultants/cognito@0.0.3","maintainers":[{"name":"miguelocarvajal","email":"omar@carvajalonline.com"}],"dist":{"shasum":"34dd24d2d9d569a9ebda433f25d2921a449b97a0","tarball":"https://registry.npmjs.org/@carvajalconsultants/cognito/-/cognito-0.0.3.tgz","fileCount":5,"integrity":"sha512-UcXNLCiQQ3+NmSP0+JnDIGZYT2n3RI8BRlrTXnbkDsyeU6IQiHw5Jun+ZMi2hGggxbnZ+fPSi3BiB5DcyW9QFg==","signatures":[{"sig":"MEUCIQD5vbAbmvDjEmxNRsZ6RtYu2rg0JMjv2KoAujm6TIhfBwIgGZPng6i63Petzuw2y0b6T7C4QH7OBFlvYMDjDBtyOM4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27713},"main":"index.ts","private":false,"scripts":{"lint":"eslint --report-unused-disable-directives --max-warnings 0 --fix && prettier --w .","prepare":"husky"},"_npmUser":{"name":"miguelocarvajal","email":"omar@carvajalonline.com"},"repository":{"url":"git@github.com:carvajalconsultants/cognito.git","type":"git"},"description":"Simple Cognito with SRP and e-mail authentication without all of the bloat of the AWS library.","directories":{},"lint-staged":{"**/*.{ts,tsx,js,jsx}":["eslint --report-unused-disable-directives --max-warnings 0 --fix","prettier --w"]},"dependencies":{"globals":"16.0.0","aws-jwt-verify":"^5.0.0","cognito-srp-helper":"^2.3.3","@aws-sdk/client-cognito-identity-provider":"^3.787.0"},"_hasShrinkwrap":false,"devDependencies":{"h3":"^1.15.1","husky":"^9.1.7","eslint":"^9.24.0","grafast":"^0.1.1-beta.21","graphql":"^16.10.0","grafserv":"^0.1.1-beta.24","prettier":"^3.5.3","@eslint/js":"^9.24.0","typescript":"^5.8.3","lint-staged":"^15.5.1","@dataplan/pg":"^0.0.1-beta.32","graphile-config":"^0.0.1-beta.15","typescript-eslint":"^8.29.1","eslint-plugin-react":"^7.37.5","eslint-config-prettier":"^10.1.2","eslint-plugin-import-x":"^4.10.2","eslint-plugin-storybook":"^0.12.0","@typescript-eslint/parser":"^8.29.1","eslint-plugin-react-hooks":"^5.2.0","eslint-plugin-react-refresh":"^0.4.19","@typescript-eslint/eslint-plugin":"^8.29.1","eslint-import-resolver-typescript":"^4.3.2","@carvajalconsultants/eslint-config":"^0.0.2","@ianvs/prettier-plugin-sort-imports":"^4.4.1","eslint-plugin-prefer-arrow-functions":"^3.6.2"},"peerDependencies":{"grafast":"^0.1.1-beta.21","graphql":"^16.10.0","grafserv":"^0.1.1-beta.24","@dataplan/pg":"^0.0.1-beta.32","graphile-config":"^0.0.1-beta.15"},"_npmOperationalInternal":{"tmp":"tmp/cognito_0.0.3_1744563488528_0.5523663525043285","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-04-13T16:39:50.952Z","modified":"2026-01-21T16:44:59.806Z","0.0.1":"2025-04-13T16:39:51.215Z","0.0.2":"2025-04-13T16:56:45.196Z","0.0.3":"2025-04-13T16:58:08.711Z"},"author":{"name":"Carvajal Consultants, Inc.","email":"support@carvajalonline.com"},"license":"MIT","repository":{"url":"git@github.com:carvajalconsultants/cognito.git","type":"git"},"description":"Simple Cognito with SRP and e-mail authentication without all of the bloat of the AWS library.","maintainers":[{"email":"hmosquera@carvajalonline.com","name":"hmosquera_cci"},{"email":"omar@carvajalonline.com","name":"miguelocarvajal"}],"readme":"## Cognito Auth\n\nSimple Cognito with SRP and e-mail authentication without all of the bloat of the AWS library.\n\nCurrently it ONLY supports SRP with e-mail.\n\nIt also includes a helper preset (GraphileCognitoPreset) for Graphile that configures session checking prior to executing requests in Grafast.\n\nThis works nicely with @carvajalconsultants/headstart. It can be configured by adding `cognito.config.ts` at the root of your project:\n\n```typescript\n// cognito.config.ts\nimport { configureCognito } from \"@carvajalconsultants/cognito\";\nimport { getCookie, removeCookie, setCookie } from \"@carvajalconsultants/headstart/cookies\";\n\n// Configure Cognito for client side use\nconfigureCognito({\n  userPoolId: \"VALUEHERE\",\n  clientId: \"VALUEHERE\",\n  region: \"VALUEHERE\",\n\n  // Functions used to manage cookies on both the server AND the client.\n  getCookie: (name: string) => getCookie(name),\n  setCookie: (name: string, value: string, options) => setCookie(name, value, options),\n  removeCookie: (name: string) => removeCookie(name),\n});\n```\n\nThis `cognito.config.ts` must then be included in both client and server files.\n\nFor example, when using Tanstack Start you would first create an authenticated route:\n\n```typescript\nimport \"~/cognito.config\";\n\nimport { createFileRoute, Outlet, redirect } from \"@tanstack/react-router\";\n\nimport { getSession } from \"@carvajalconsultants/cognito\";\n\nconst AuthLayout = () => (\n  ...\n);\n\nexport const Route = createFileRoute(\"/_authenticated\")({\n  component: AuthLayout,\n  errorComponent: () => <div>Error</div>,\n  beforeLoad: async () => {\n    try {\n      // If a valid session is not available, this throws an error which means the user cannot access the resource.\n      await getSession();\n    } catch {\n      throw redirect({ to: \"/auth/login\" });\n    }\n  },\n});\n```\n\nNow on a server only file, where you need to do authentication you must also call `cognito.config.ts`. A helper preset for Graphile is included, so if using that, you would do something like this:\n\n```typescript\nimport \"./cognito.config\";\n\nimport { GraphileCognitoPreset } from \"@carvajalconsultants/cognito/GraphileCognitoPreset\";\nimport { GraphileCarvajalPreset } from \"@carvajalconsultants/graphile\";\nimport { makePgService } from \"postgraphile/adaptors/pg\";\n\nimport type { GraphileConfig } from \"graphile-config\";\n\n/**\n * PostGraphile configuration preset that sets up a secure, performant GraphQL API\n * with AWS Cognito authentication integration.\n *\n * This configuration enables:\n * - Secure user authentication via AWS Cognito\n * - Real-time data updates through event streams\n * - Interactive GraphQL development environment\n * - Simplified database schema naming\n */\nconst preset: GraphileConfig.Preset = {\n  extends: [GraphileCarvajalPreset, GraphileCognitoPreset],\n\n  grafserv: {\n    port: 5678,\n    graphiql: true,\n    watch: true,\n    graphqlPath: \"/api/graphql\",\n    eventStreamPath: \"/api/graphql\",\n  },\n\n  /**\n   * Database connection configuration that specifies which schemas contain\n   * our business logic and data models.\n   *\n   * - app_public: Contains publicly accessible database objects\n   */\n  pgServices: [\n    makePgService({\n      connectionString: process.env.POSTGRES_CONNECTION_STRING,\n\n      schemas: [\"app_public\"],\n    }),\n  ],\n};\n\nexport default preset;\n```\n","readmeFilename":"README.md"}