{"_id":"@accounts/module-password","_rev":"43-13e6fdd2a7f0e715310994ed40cb0fbb","name":"@accounts/module-password","dist-tags":{"latest":"0.34.0","alpha":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","rc":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3"},"versions":{"0.34.0":{"name":"@accounts/module-password","version":"0.34.0","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"^0.34.0","@accounts/password":"^0.32.0","@accounts/server":"^0.32.0 || ^0.33.0","@accounts/types":"^0.32.0 || ^0.33.0","graphql":"^16.0.0","graphql-modules":"^2.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"^0.34.0","@accounts/password":"^0.32.1","@accounts/server":"^0.33.1","@accounts/types":"^0.33.2","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"2.3.6","@types/request-ip":"0.0.38","graphql":"16.8.0","graphql-modules":"2.2.0","graphql-tag":"2.12.6"},"gitHead":"3153375d7ba666e8bcbbfd28f3e07890cb58d5f3","_id":"@accounts/module-password@0.34.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-ESET0ZpGJkFXnQWYjNPwblFQfJEH+Go4R837tSrRFkqBWp0mfbv6FSuD8QlLhm7vjdDwwHhiynhHjV45+nJd5Q==","shasum":"5ccede97e1af9e9e5a1d47ae84d32b0373f55e6f","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-0.34.0.tgz","fileCount":34,"unpackedSize":74298,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4vezddyUdekVlc3Jy/P/rr2Qc7bTb60V5XFfnBj+70wIgTBLtvBJuyOI+e+2sMoGIRBvdNA267FICuHBlpVR2oDk="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_0.34.0_1694601057260_0.6658312169711762"},"_hasShrinkwrap":false},"1.0.0-alpha-20231022085748-0910b9e1":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231022085748-0910b9e1","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/password":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/server":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/types":"1.0.0-alpha-20231022085748-0910b9e1","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.7","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/password":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/server":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/types":"1.0.0-alpha-20231022085748-0910b9e1","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231018163544-36199b68","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231022085748-0910b9e1","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"0910b9e1ce4a2561830abcf40ba28e728b301c0f","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-PyfjwFiAezKSBwcQkLzdlUzA0rjSPa3BRSXMitx/lddFA3P9sQPK8R7tsRztKwnh+rT2KFX5FG5K32V+tRNvOg==","shasum":"bfa9bd051cf37acc7f12ea9fd948e954b0b1981f","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231022085748-0910b9e1.tgz","fileCount":34,"unpackedSize":71713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDBV4kWnVQ6kMo5WDQj87gjk5IB2yJKoJkeRntzWqgzeAiBiCwhpn27fU7D7c2xV4b8rI1ZjeP01q0mwqeSLk26irw=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231022085748-0910b9e1_1697965474191_0.7026222441524841"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106132410-d312ae00":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231106132410-d312ae00","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231106132410-d312ae00","@accounts/password":"1.0.0-alpha-20231106132410-d312ae00","@accounts/server":"1.0.0-alpha-20231106132410-d312ae00","@accounts/types":"1.0.0-alpha-20231106132410-d312ae00","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231106132410-d312ae00","@accounts/password":"1.0.0-alpha-20231106132410-d312ae00","@accounts/server":"1.0.0-alpha-20231106132410-d312ae00","@accounts/types":"1.0.0-alpha-20231106132410-d312ae00","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231018163544-36199b68","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231106132410-d312ae00","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"d312ae00cd349e865fa6b67119ce0acbee4510a9","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-k4Z+iAc28EqLzxAfJRhQFC/x/R+Dq7ikj4sta7aIi2W4KK3oiaa2pVLAwrnEflffKT9H6o6eEomrQZhm3DD9rQ==","shasum":"68c39473f173137ccbf1e34c1ecc77d0904c8b6b","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231106132410-d312ae00.tgz","fileCount":34,"unpackedSize":71713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCJWuqkF3bTdeLVoV6LgfSbkCBC6PDlssQjMd1Ge9de2AIgBYO2LIngkM0pUHWjEzAalaHt3GtQe2InlmoK9hHXBA0="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231106132410-d312ae00_1699277292534_0.32719903205874656"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106135626-1555665c":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231106135626-1555665c","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231106135626-1555665c","@accounts/password":"1.0.0-alpha-20231106135626-1555665c","@accounts/server":"1.0.0-alpha-20231106135626-1555665c","@accounts/types":"1.0.0-alpha-20231106135626-1555665c","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231106135626-1555665c","@accounts/password":"1.0.0-alpha-20231106135626-1555665c","@accounts/server":"1.0.0-alpha-20231106135626-1555665c","@accounts/types":"1.0.0-alpha-20231106135626-1555665c","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231106135626-1555665c","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"1555665caf435223970acd756ab3a0aacf3daeb2","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-O0fePuTlwSql8cSOPP9+yps8azWulV+F1gk3zE8n1fgJmriOChDCy87snyMCgVqt580YWLclHCsh3dw1lz8PPg==","shasum":"0269f215f999d9a68ff062407cb3938d7e5e8180","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231106135626-1555665c.tgz","fileCount":34,"unpackedSize":71713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCqX0sG/lmKJ44YIPIvLjQWu0EtUyIaUEhI7AH5RyAvyQIgOdGw3EqMMVc7ntqOyKHdU1t8rUhEgMcWeTaB3HW/Qjk="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231106135626-1555665c_1699279395800_0.49460215758828796"},"_hasShrinkwrap":false},"1.0.0-alpha-20231109134411-9db5d55b":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231109134411-9db5d55b","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/password":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/server":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/types":"1.0.0-alpha-20231109134411-9db5d55b","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/password":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/server":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/types":"1.0.0-alpha-20231109134411-9db5d55b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231109134411-9db5d55b","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"9db5d55bfda69d805f2126a4e42e4bcee18467a3","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-CdjvFFrOHiaLWQFE8lt0L83MnEQ9oRMUJaZmAWyaWBIFm+sB2Gdp0de5cvd47Yt3/T6oG4zkNR+tc7oYCczqRw==","shasum":"2db846c6ccfdd9e4f0bdab2d29df45feb5b8f412","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231109134411-9db5d55b.tgz","fileCount":34,"unpackedSize":71713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGIVDOPts5mq5RyYV6PvfTq38GoP3edXHbMmZzTkV7BkAiEA8H3dHgWdGEXOM0cQKc36PXDUFnCtRhj6U+lUACXt+aM="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231109134411-9db5d55b_1699537697781_0.8482270917331205"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110150116-1eb474da":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231110150116-1eb474da","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231110150116-1eb474da","@accounts/password":"1.0.0-alpha-20231110150116-1eb474da","@accounts/server":"1.0.0-alpha-20231110150116-1eb474da","@accounts/types":"1.0.0-alpha-20231110150116-1eb474da","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231110150116-1eb474da","@accounts/password":"1.0.0-alpha-20231110150116-1eb474da","@accounts/server":"1.0.0-alpha-20231110150116-1eb474da","@accounts/types":"1.0.0-alpha-20231110150116-1eb474da","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231110150116-1eb474da","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"1eb474da8502f37184c6b61fa13206867b6d641f","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-nfkswtkzCu4VxT/fCcbanGDcNmddBzGO1PKazYAEhLjTEWP+htD8JBE8D1gYZQY9kc/YRHMFZ6o9dPh3UWnfbQ==","shasum":"755275f5b2b6e0f6361a4864db893af252fc939d","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231110150116-1eb474da.tgz","fileCount":34,"unpackedSize":71713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHTNCgmhfY1URDigA/VSp01loBULlK6pC9My77FFL882AiEA4KJjRuhoiG2BrTElnDEw5aOCPW76owFQbaW6t1if0tQ="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231110150116-1eb474da_1699628863111_0.08483031584930689"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110204039-4238958d":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231110204039-4238958d","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231110204039-4238958d","@accounts/password":"1.0.0-alpha-20231110204039-4238958d","@accounts/server":"1.0.0-alpha-20231110204039-4238958d","@accounts/types":"1.0.0-alpha-20231110204039-4238958d","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231110204039-4238958d","@accounts/password":"1.0.0-alpha-20231110204039-4238958d","@accounts/server":"1.0.0-alpha-20231110204039-4238958d","@accounts/types":"1.0.0-alpha-20231110204039-4238958d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231110204039-4238958d","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"4238958dfb0fd18553e89389a5e8b7300e5df509","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-4X3cQEgSjVB4dJ5nik8UlvvtXC5aAQGM1ju3w5n380jxT/31TYGWmY7Vjp8MHULetl8uKir3pjf/IAA/wuXpQw==","shasum":"1dade26c490d9785232bd684d9c94006c69ad046","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231110204039-4238958d.tgz","fileCount":34,"unpackedSize":71713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEdfEN8IOvr1gkZ0Hbosk0tcjDtn/p2mRI2lAjyo6N4NAiBMslhVmf9Q9uaVDGeoJHry+BfJ58AoDEoDHNpXsbOB5w=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231110204039-4238958d_1699649231377_0.2501677800989044"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111101845-4f997913":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231111101845-4f997913","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231111101845-4f997913","@accounts/password":"1.0.0-alpha-20231111101845-4f997913","@accounts/server":"1.0.0-alpha-20231111101845-4f997913","@accounts/types":"1.0.0-alpha-20231111101845-4f997913","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231111101845-4f997913","@accounts/password":"1.0.0-alpha-20231111101845-4f997913","@accounts/server":"1.0.0-alpha-20231111101845-4f997913","@accounts/types":"1.0.0-alpha-20231111101845-4f997913","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231111101845-4f997913","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"4f9979137f019e0ea303bb9081a97bc47dfb8217","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-O2veYHoFkr5hEHwAXkAfxPi+X5WfL5bKMrNQwZCndHpJFLZg4RtVxdpCFK7fzuUL1zuJCyFzMGqyxGzbZodwbA==","shasum":"f61607156207933e785542100efe5ca226f5e592","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231111101845-4f997913.tgz","fileCount":34,"unpackedSize":71713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG0xc03wC/c70yddrDPFrSj9s1yeqDp/CHKo9em114ETAiEAkPU4SLxXp0LbP6OPKQex6J/B8z39RBcxOdM5k2eLRR8="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231111101845-4f997913_1699698171329_0.08051391637536187"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111172350-25f6cb1d":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231111172350-25f6cb1d","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/password":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/server":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/types":"1.0.0-alpha-20231111172350-25f6cb1d","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/password":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/server":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/types":"1.0.0-alpha-20231111172350-25f6cb1d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231111172350-25f6cb1d","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"25f6cb1dd7fc48465aa719de8dc743e5270af2e7","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-9qMXTfgIYdtQpKoEEa6A1hEBi9Ntk/PEUaLJrP6h+53jl2HbgpREBB2cxscEQog1MP8jZH0TwhuL8tqLVmz79A==","shasum":"2fae86da38521ed89216b9fea0ddbf7ad527d556","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231111172350-25f6cb1d.tgz","fileCount":34,"unpackedSize":71713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC+rXmGfpYz5qVbgTh6OyMk5mdjAWPe9qWiJatG9gBOfAiBu/CAFvK1GQwUAX39/Mr7irpvu5bPftUeRLUgXf5mmDw=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231111172350-25f6cb1d_1699723679789_0.26937795184619584"},"_hasShrinkwrap":false},"1.0.0-alpha-20231113142902-7812b73b":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231113142902-7812b73b","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231113142902-7812b73b","@accounts/password":"1.0.0-alpha-20231113142902-7812b73b","@accounts/server":"1.0.0-alpha-20231113142902-7812b73b","@accounts/types":"1.0.0-alpha-20231113142902-7812b73b","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231113142902-7812b73b","@accounts/password":"1.0.0-alpha-20231113142902-7812b73b","@accounts/server":"1.0.0-alpha-20231113142902-7812b73b","@accounts/types":"1.0.0-alpha-20231113142902-7812b73b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231113142902-7812b73b","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"7812b73b1b566c11efa0fd3a74c5216932d6e263","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-5vB71/KSglEZdNCPGb/0oe7eo/og0+ud9TWxZbeY6mcEw/c2tuDdzozT5m8G0f7ua3oShplP4SKhAEZN9XIiwg==","shasum":"27ccf0a9a96f869fa7e1bf2dfb10bcb97cc0a19d","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231113142902-7812b73b.tgz","fileCount":34,"unpackedSize":73840,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFhqwD0ECsQO2neRYHRTogu2mZYqTR3vQYopp8jERbppAiByWFFoEotZC8q3FkgkeTU8+PIQPuXicIyLtiLuvyKbpg=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231113142902-7812b73b_1699885987419_0.9511574885225409"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115113719-ae2b53a9":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231115113719-ae2b53a9","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/password":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/server":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/types":"1.0.0-alpha-20231115113719-ae2b53a9","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/password":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/server":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/types":"1.0.0-alpha-20231115113719-ae2b53a9","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231115113719-ae2b53a9","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"ae2b53a96a47f3ba1faf1e50802cc227635bec00","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-5cxl7v0HZEGXON1aJ3qZQSCNcuNXxCL4l01tpPQ8Fmk3o3RGxha4nCQDvPNU0H6Prgqoeq1hUsl4JHAc/k6ObQ==","shasum":"b9690b2a3cd386c8998229899eeda0d39f4500e9","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231115113719-ae2b53a9.tgz","fileCount":34,"unpackedSize":73840,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICg1zMCLhZlFyXNP58tG366F/x1W89MhE52sRm9m7kMNAiEAxPJGX9RWhGQ0uisq8U33gydrxLLrWiSMfzW81RHOILI="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231115113719-ae2b53a9_1700048484685_0.3424616175560111"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115205645-aa630d56":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231115205645-aa630d56","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231115205645-aa630d56","@accounts/password":"1.0.0-alpha-20231115205645-aa630d56","@accounts/server":"1.0.0-alpha-20231115205645-aa630d56","@accounts/types":"1.0.0-alpha-20231115205645-aa630d56","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231115205645-aa630d56","@accounts/password":"1.0.0-alpha-20231115205645-aa630d56","@accounts/server":"1.0.0-alpha-20231115205645-aa630d56","@accounts/types":"1.0.0-alpha-20231115205645-aa630d56","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231115205645-aa630d56","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"aa630d56d503af3cbeb2cce6b9ff0bff729cdab1","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-lOn2JUP/aX64jST7gKvqWNH2GGTokxvqp0es/uUkPVGFVrkO0/GKkjLs6H7jyJyQErQLxsEguxZlcxYoep71UA==","shasum":"a7e24e045f9faabb10f5a016502bebcc85cf44e8","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231115205645-aa630d56.tgz","fileCount":34,"unpackedSize":74274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDCqo7rwDnhE56pZcgb8Cay+ZAb+SUI9tgL2E7GHuGcRgIhAMKIghMnOOO1B+fM2AbbLwLw77kMT5ssPOHiv/lD+5Kv"}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231115205645-aa630d56_1700082051155_0.6058203219984324"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116130548-67b64a6a":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231116130548-67b64a6a","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/password":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/server":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/types":"1.0.0-alpha-20231116130548-67b64a6a","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/password":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/server":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/types":"1.0.0-alpha-20231116130548-67b64a6a","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231116130548-67b64a6a","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"67b64a6a72daf6ac00dc5b55dc49aa1480175d0f","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-51cPh1xbRVFAwOAZ1DxR6NhJJv78LQ2pRc42HWQLgw3ztyUm3cyQgZLl4yTMxd66mX6N2CGK2vPpXUiY/tx68g==","shasum":"f21fbef6eed0c10b2d38be9ac990e0fcbe1dc9d4","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231116130548-67b64a6a.tgz","fileCount":34,"unpackedSize":74274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDDbt+SpVUqKX3zj+gTQpKkGzjxUY1evmzqf5DviyDQ9QIgCmMpJAwS9pf9get609VMV+n3b27Fm6fWSckaOVZsOkY="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231116130548-67b64a6a_1700140198866_0.7525031988734883"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116132834-55ee2b96":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231116132834-55ee2b96","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/password":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/server":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/types":"1.0.0-alpha-20231116132834-55ee2b96","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/password":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/server":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/types":"1.0.0-alpha-20231116132834-55ee2b96","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231116132834-55ee2b96","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"55ee2b96a708fcaadfaf69e9e5b4519f8fab389d","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-2W3JAYz2ZtKBRnKrWJoLpXMhSupll0ZB/FgbZ/aMxdiZwx7XIFjRFdcaQgkyHz97c6bWBMsK4fUjaEKHv1xCGA==","shasum":"6ec614f58f8c906984f3811ea74e5f844db8fe70","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231116132834-55ee2b96.tgz","fileCount":34,"unpackedSize":74274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG4PL5KWGY7k0OFs/dvfDm7E+tZ3LdFfZY10x8hZ6i7JAiB++OcYG+uWmKbhQC92cWgjliugbxYnkW1oQVM/a5aktg=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231116132834-55ee2b96_1700141558263_0.3882090794252919"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119093904-9adfd014":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231119093904-9adfd014","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231119093904-9adfd014","@accounts/password":"1.0.0-alpha-20231119093904-9adfd014","@accounts/server":"1.0.0-alpha-20231119093904-9adfd014","@accounts/types":"1.0.0-alpha-20231119093904-9adfd014","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231119093904-9adfd014","@accounts/password":"1.0.0-alpha-20231119093904-9adfd014","@accounts/server":"1.0.0-alpha-20231119093904-9adfd014","@accounts/types":"1.0.0-alpha-20231119093904-9adfd014","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231119093904-9adfd014","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"9adfd01478108dc21a0422e7dcd72e687d52940a","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-XGQoo6f8t5w/hqbv7y9eedDxZp53Nh32Spt+Dip1oMZjYDeNNpQHfBNN1ol+u9KM1u+wqFJC19TbCuSQTpn+Lw==","shasum":"23fc71c41ad8c7a54c6b8722bffd4be1f6245ca7","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231119093904-9adfd014.tgz","fileCount":34,"unpackedSize":74274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDMI5O7qPnI6Gll8Ww+UZCjaK7DrjiawJ49UjimaKS8TAIgCIOb6R7U9YfvL/DwlqaX+vh/K+egPnJX6X8Xa2CeDFY="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231119093904-9adfd014_1700386992864_0.6213211168687216"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119094526-b1fc68c7":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231119094526-b1fc68c7","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/password":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/server":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/types":"1.0.0-alpha-20231119094526-b1fc68c7","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/password":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/server":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/types":"1.0.0-alpha-20231119094526-b1fc68c7","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231119094526-b1fc68c7","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"b1fc68c721c7510c56dba92f87d5affba4aad12e","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-lTGAu1gCfQ4YGeht9J4OWtXprCVj2yvn0UuASJw0R5hV5XhQXyhZzUhLBTOft029I5+RSO/Mv9iZ4Ij3aosFWw==","shasum":"28bd62dabd69f18367e78b9671545bccb1c427ea","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231119094526-b1fc68c7.tgz","fileCount":34,"unpackedSize":74274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCwJcIODEMBYxZ5E/yQnR/C7j9wMp9IjSLDgKYHKft0HwIhANCceJ2YinuauL3VuognX2owq94sxHyz7I7igdtWcXlc"}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231119094526-b1fc68c7_1700387370079_0.0038161074560345565"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120163547-4a461fcc":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231120163547-4a461fcc","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/password":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/server":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/types":"1.0.0-alpha-20231120163547-4a461fcc","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/password":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/server":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/types":"1.0.0-alpha-20231120163547-4a461fcc","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231120163547-4a461fcc","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"4a461fcc1a85be0c2d1134cae1a5da1c6c5286eb","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-HxHPFo/RanWKhFSZWtRYv7FrMmPd/Fs/2BXNCs1cTpBH5pov1idvgcTklraMCA6GBdn73C0zaOryynv0SJpFWQ==","shasum":"b9d19d4a1cbe8f87482b834c639932f5cc8aaa8e","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231120163547-4a461fcc.tgz","fileCount":34,"unpackedSize":74274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD57krok29HW1cFtBFez769iKurbeTOeEmkg+ozwnNvbwIgYrGwC3ZTjIEvMsChqozi8DLHCP3/Hjhp8+4mMs1uSEE="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231120163547-4a461fcc_1700498395580_0.8457021948573977"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120164530-e14d6a81":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231120164530-e14d6a81","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/password":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/server":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/types":"1.0.0-alpha-20231120164530-e14d6a81","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/password":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/server":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/types":"1.0.0-alpha-20231120164530-e14d6a81","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231120164530-e14d6a81","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"e14d6a816254b9190600cc7270fd19d53caef294","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-mOMKAUPUFREqUGdrQa2sw1IusSlCsWcWJLm9mk/lubZjJuIjfDFR67KN+dLd1VtPjgR9lcKDMjuuSa5lw8E4Pg==","shasum":"84f8c67032f856450cb2494080e53f17f82d0e54","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231120164530-e14d6a81.tgz","fileCount":34,"unpackedSize":74274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAd3PUJ06qRqNeBtEHrDDdrANUbsX16r/ft4MU/ehs6VAiEAhBiqu79pLU1joR6sNom01weiSFhY6YPSjBwNo5pgXUw="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231120164530-e14d6a81_1700498975742_0.17259815902418163"},"_hasShrinkwrap":false},"1.0.0-alpha-20231121011122-60a60524":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231121011122-60a60524","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231121011122-60a60524","@accounts/password":"1.0.0-alpha-20231121011122-60a60524","@accounts/server":"1.0.0-alpha-20231121011122-60a60524","@accounts/types":"1.0.0-alpha-20231121011122-60a60524","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231121011122-60a60524","@accounts/password":"1.0.0-alpha-20231121011122-60a60524","@accounts/server":"1.0.0-alpha-20231121011122-60a60524","@accounts/types":"1.0.0-alpha-20231121011122-60a60524","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231121011122-60a60524","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"60a60524a181a9e8a333ea53943db41dd7532181","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-zGoNErB1/vt1VsycQwdR3/ujzYPX2a8hnKV9eRgcOVsWHiYoITNrRBc86ChdwodL2ilrcu0HjtjpDSVnPzXzkA==","shasum":"645ec153c4bcece899f0b5620c5986bb414e2f55","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231121011122-60a60524.tgz","fileCount":34,"unpackedSize":74274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCqNpmZ95gz/ttvLnEfwzyWiwcvY8G/uj/7LxBMW+zonAIgQEzoREHVOipID20dDN1wQTqczYgxqL42VPdRuHx+8Ug="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231121011122-60a60524_1700529330562_0.9242022449999039"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122105229-8edd073f":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231122105229-8edd073f","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231122105229-8edd073f","@accounts/password":"1.0.0-alpha-20231122105229-8edd073f","@accounts/server":"1.0.0-alpha-20231122105229-8edd073f","@accounts/types":"1.0.0-alpha-20231122105229-8edd073f","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231122105229-8edd073f","@accounts/password":"1.0.0-alpha-20231122105229-8edd073f","@accounts/server":"1.0.0-alpha-20231122105229-8edd073f","@accounts/types":"1.0.0-alpha-20231122105229-8edd073f","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231122105229-8edd073f","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"8edd073ff1e6e768a7aec54e42532b7b70e00799","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-v6a+0wdib8ytBD8lOXzd/Fw0LpcZW8SscEvKjoqJoprmV29nBBfvgub4GlvoVgBtMta5SRB9Ah62qLEQNM00BA==","shasum":"dd9cc8e137ee83f90905363b63d54fc68a7f2228","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231122105229-8edd073f.tgz","fileCount":34,"unpackedSize":74424,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICjgR+qr+zoVqe5H7XnzlR7ypItX7NBv30PyWkXc2U5jAiAOQOdPTiBK0sIAFMRVDVZufZalUw73GHhabrjDag5FYg=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231122105229-8edd073f_1700650606281_0.7033312115714336"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122120807-69a661e3":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231122120807-69a661e3","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/module-core":"1.0.0-alpha-20231122120807-69a661e3","@accounts/password":"1.0.0-alpha-20231122120807-69a661e3","@accounts/server":"1.0.0-alpha-20231122120807-69a661e3","@accounts/types":"1.0.0-alpha-20231122120807-69a661e3","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231122120807-69a661e3","@accounts/password":"1.0.0-alpha-20231122120807-69a661e3","@accounts/server":"1.0.0-alpha-20231122120807-69a661e3","@accounts/types":"1.0.0-alpha-20231122120807-69a661e3","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-password@1.0.0-alpha-20231122120807-69a661e3","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"69a661e32e3de6307560a8a0975aa5d4ff9395f1","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-o2rtfg8Vmp+FMDpd4OCj5/6Gs9xj8nOD6QUTnJIOpnJ4UW1+f+AhFo9szRxlZy4/MOEBAkhwyEtpoaPsvX+GGg==","shasum":"b0bcdfa242b6b6d2e1dfed044b7b11a46eec710d","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231122120807-69a661e3.tgz","fileCount":34,"unpackedSize":74459,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEISKBdDskpMnNswGaZc+ybZXGB7Ba6U36h6WMhl69S+AiEA/FnG+WIUgmujqo8FiY3emx/czaRCt+1OJAe0ExvTr84="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231122120807-69a661e3_1700655144828_0.0002362196080982759"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122192915-c0243667":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231122192915-c0243667","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231122192915-c0243667","@accounts/server":"1.0.0-alpha-20231122192915-c0243667","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231122192915-c0243667","@accounts/password":"1.0.0-alpha-20231122192915-c0243667","@accounts/server":"1.0.0-alpha-20231122192915-c0243667","@accounts/types":"1.0.0-alpha-20231122192915-c0243667","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231122192915-c0243667","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"c02436674a81d5ca497a4342dfb943180252ed96","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-2bzQ5YM0LtpNIRHR/KJBvRpM06gPmFMaKlEfaEBgnyrdYV7+rSkLRwz2aKAX+DcaggoiEShi6s9+mS3Pm+Dbvw==","shasum":"4bf53ce05a7a578ae08b3996bc5df75c540c459e","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231122192915-c0243667.tgz","fileCount":34,"unpackedSize":74162,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDWmn16yUZkdJsfZ8flTNYdtT5K/zySjPdGTT3s15HdcAIgUL6GiyK2MPKikSe+36oI4xeSubMFiwlWH8wWVz8EcU8="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231122192915-c0243667_1700681610795_0.07596704722345815"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123103003-4f0c2405":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231123103003-4f0c2405","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/server":"1.0.0-alpha-20231123103003-4f0c2405","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/password":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/server":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/types":"1.0.0-alpha-20231123103003-4f0c2405","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231123103003-4f0c2405","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"4f0c2405f9473b25116d2a04c6288e7e49632bef","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-4UUrlSDpCimOK9VANLClUlhJGtoPEWtL7fE+0jsJK0yiFbTKz1UYNFYrnLsiIHkchwabQPAb0vzsoJKcCLLetg==","shasum":"8a610222b93236fe2fbec8edfec88e9d71505067","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231123103003-4f0c2405.tgz","fileCount":34,"unpackedSize":74162,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDk8sPSR/HS1h/uoUn+S7FbikxOQRv3xoawmKNCZ58HVAIhAKImRcB5dpl+ci3mAlWTXVhUEVqyaxgj957og9bUTMz0"}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231123103003-4f0c2405_1700735649141_0.11300141698765831"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123122853-0ccafb9d":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231123122853-0ccafb9d","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/server":"1.0.0-alpha-20231123122853-0ccafb9d","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/password":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/server":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/types":"1.0.0-alpha-20231123122853-0ccafb9d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231123122853-0ccafb9d","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"0ccafb9dfcf650acb798831b47f778e9f471aef1","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-E5aiLyoRHmwZZGvKyejXrzItSa/Zdrmj4BDnuI+hFQlP0/Jz6Qw1CTT6qGd6I/UPoyGdBs9oZ2Ltx2qLN7xKQA==","shasum":"08445295f2b4c40fc6817ea3e9366c3a3f8df7a9","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231123122853-0ccafb9d.tgz","fileCount":34,"unpackedSize":74162,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDz1ZVuEeln4piSPU+CJKfmrLPXVhC7a2H/7Cq499bj7AIgG5ORILWcy1NkjU0SdVo16aWn3MYTRcmSXhAC/tYO6xY="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231123122853-0ccafb9d_1700742775777_0.7133383145934535"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123131746-58399dcd":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231123131746-58399dcd","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231123131746-58399dcd","@accounts/server":"1.0.0-alpha-20231123131746-58399dcd","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231123131746-58399dcd","@accounts/password":"1.0.0-alpha-20231123131746-58399dcd","@accounts/server":"1.0.0-alpha-20231123131746-58399dcd","@accounts/types":"1.0.0-alpha-20231123131746-58399dcd","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231123131746-58399dcd","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"58399dcde6b8dc6cef8efdea1d098bac61b7d6ad","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-9ds7MwO75yQYsV/BgSk3ehxWiwoexbnBxWTE1JqeIaF6cm2jQsDPaDmrxypL995E0TstDEB4n2qNKO9bRrEQMQ==","shasum":"fd5a842ccbe52970d753efe15cbfe9329de87c79","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231123131746-58399dcd.tgz","fileCount":34,"unpackedSize":74162,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFJx6KpD2V69/7GLOgA4oexW3CdKy1oja+xgS5ga4kMuAiA3/M6k9sOpVtGMBeUti+ywfnuMCmV/MYMFeJyxa6RhZQ=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231123131746-58399dcd_1700745702646_0.39954426753929395"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123183707-51335dc2":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231123183707-51335dc2","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231123183707-51335dc2","@accounts/server":"1.0.0-alpha-20231123183707-51335dc2","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231123183707-51335dc2","@accounts/password":"1.0.0-alpha-20231123183707-51335dc2","@accounts/server":"1.0.0-alpha-20231123183707-51335dc2","@accounts/types":"1.0.0-alpha-20231123183707-51335dc2","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231123183707-51335dc2","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"51335dc29f960d45f5d6a271a22191217de9102d","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-+Sm75qnmQ1cpfAY5gkdjxUigj0G9zTGYzkOQv/EIb3jvoKFHK26OXB7eE4vPlybmqW61/1k0jje2a1uqwqb6rg==","shasum":"92a3c3bfc7660f04e03281b4c8f042e9ecf49b61","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231123183707-51335dc2.tgz","fileCount":34,"unpackedSize":74162,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCouTnGQG61PpFumFJXkpTjdHMtTisU4Jof5rWbDmn0wQIgI2sE68HwNUIXLfTx4Uc5YZk/FCuShW+1cZr3CZWKrXk="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231123183707-51335dc2_1700764872449_0.1100224386646107"},"_hasShrinkwrap":false},"1.0.0-alpha-20231124142337-45cc4d05":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231124142337-45cc4d05","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/server":"1.0.0-alpha-20231124142337-45cc4d05","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/password":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/server":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/types":"1.0.0-alpha-20231124142337-45cc4d05","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231124142337-45cc4d05","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"45cc4d05660f2ebc3b4e2632fa9a4b7fe996c9d2","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-fw9KqkLbAQKusWMrznZ18SF+x06sHAl2zpXYigoo0uftAqnoyEX37bJFUNfL7F6xTjSKywh+hCskzeYMd/ZaYQ==","shasum":"789c64c4e34fd074e37af3ac6de3e5772c6adc55","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231124142337-45cc4d05.tgz","fileCount":34,"unpackedSize":74162,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHQvZr08r78S5B2iFsLglP+ck6qOOLmdsKvX1dP801rcAiEAjvtGTFRrmty444ezkZZwjNWkCKWQqvYSfw19doO4iQE="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231124142337-45cc4d05_1700836070697_0.8071555650071818"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127162849-b5b29d3d":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231127162849-b5b29d3d","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/server":"1.0.0-alpha-20231127162849-b5b29d3d","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/password":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/server":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/types":"1.0.0-alpha-20231127162849-b5b29d3d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231127162849-b5b29d3d","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"b5b29d3d2195ea5160800f6b0fd07bbba7ab71f1","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-DD+9nN77gajKdHDy409TgsWAtUdoB3xM2ov3R4ZtOXVZyiy7AYckc/XNZ54UiePKxHF7OMO33H26/J8TOD7XOA==","shasum":"e328fe68cb682832d7e3c00623574c79905c4566","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231127162849-b5b29d3d.tgz","fileCount":34,"unpackedSize":74162,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCuN75PiA71wr6W19zaLg28YlUwxSyEuZkdJELRMI3jxQIgaHhzK4X7JMRkEhW60LkgZS9OoUJkiI0DLC1lTR9hfaw="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231127162849-b5b29d3d_1701102779815_0.37838800884368173"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127170705-4b0b3391":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231127170705-4b0b3391","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/server":"1.0.0-alpha-20231127170705-4b0b3391","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/password":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/server":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/types":"1.0.0-alpha-20231127170705-4b0b3391","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231127170705-4b0b3391","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"4b0b3391ba3a2d7a7f8d74a726eace215c7878bb","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-f6XVaKCTxfYqK/Quntki1Ewicyt2T+0x7iic/FJUTNTqi1qKwvyrmjwVO+WYtp0EHW9ojcZjyPv7JCdSOqBL5Q==","shasum":"0bcb2b920f89b5e4bd6588cb17e159b7444ad6ba","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231127170705-4b0b3391.tgz","fileCount":34,"unpackedSize":74184,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCToqBeFqk23NaJQqGirnNvXCCY6H9n5XtW+F4nL5EmfAIgLiiKl8D9UPecvhWAGq2XPTkNcO9fqQyqH7bsUxgr00o="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231127170705-4b0b3391_1701105074812_0.060795191757204936"},"_hasShrinkwrap":false},"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/server":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/password":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/server":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/types":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"8345fe6cd6d691fbdd62e2128556729886215165","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-H3cz48f+cEkdU0JQktLt4WkLKTpTWu3KIPLD1cpRkehB32BxK2PkRrGoOQ0LhNTM7Ud0PISaVUA1m5iyHFZ7Bw==","shasum":"ac216d6efdf7763c92a4b44420208925a9ed5d93","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICe6ffUzt1sWBUI9bbI7ofPFaT0gi3K7xwnYkRaVbHIPAiEA8GcNFxtMWy82N6D4qkRQWHxc7tP3mxgh3+oXbgaxX+c="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165_1701341581819_0.8416769278432035"},"_hasShrinkwrap":false},"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/server":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/password":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/server":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/types":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"80de92b5866143888ffa3a9f9a5b859c2cb688db","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-3LwXG0qfdLm17z8n29/SRusPHRBaTDg4bsWX8XjgEuWlKy9v7l8JTf0wl2bfCVVc8w5oo7qwKN5MYbpwyb5vYQ==","shasum":"8072aede83b576018aac09fb1629632fd56d8acb","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC1S9QS6E7E3phtOAXVQTzx3hMcgTV5IBd0m8L6sVqtQAIhALUTZg8AURgtV5V7anWKMGcx6opVTNkVgw8Kwzgxv85r"}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db_1701879311677_0.27226727151667074"},"_hasShrinkwrap":false},"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/server":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/password":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/server":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/types":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"d0b25d8c1fb32653d6d38baded85375166296b9b","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-EQFn9FiU/XZHJ3GcjQJDMd6NG++zrbZIWqdQhLPYY5eRKdX0uMKRz+fY3HDH4GW5Sgd6OUjNKErvIbJAQ5OQWQ==","shasum":"f46f5d72a216bbcf203b894d7bedac4200d244cf","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfzDfVKGKyBUG5d21CbZ75xTwD9vdpv7H1o3ZGqTfa1wIgGFT0naAQh+hYc/m2jCCdqIvZ7WnLI6c1s4TARjtIcRg="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b_1702469637282_0.1095909098517105"},"_hasShrinkwrap":false},"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/server":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/password":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/server":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/types":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-a3NmORzIUaTFTUW7YG4aEir+7gRTp36be2Vh9l/2oY1z/Qn/P20F596A7pnJa14llECnFuJ3tGkq64d0psJ9fA==","shasum":"f39deaadcea583e1fb44e96652aa72583adde718","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHVh16kPmCsvzX0py2EW3YvV9wkQQ+EhjJ5PW/K6LgP3AiAZa+xpipzf/JTzyMQtB0jZGxDv2ytF1wZQwKYzUSrOpw=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd_1702550309072_0.443432972871203"},"_hasShrinkwrap":false},"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":{"name":"@accounts/module-password","version":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/server":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/password":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/server":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/types":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"4099195bd5e8ffdc8eb76f0800ac2e48504820b9","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-3kQzAm+UpPeB904xkOJn8mxkoYwoavn5r8mIKXs7ytz/8PLV6Gu94JYqQqWzYTGx+nBx9ATl7I8lS0srNJXWEQ==","shasum":"527f875b6465992899f07b10bccc7f050e19d28b","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDivEcaqBTUzRstQOa4kM39x/WM7NKnkkaXrZvAv38LkAIhAOgnWQdi8ZceGCPFuF6GZOvYZ+MOmygkmG7zBSGDIXDS"}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9_1702984112033_0.9962809421572656"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":{"name":"@accounts/module-password","version":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/server":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/password":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/server":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/types":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-oioZxG5vl3r4QhjtBiXbjd6zT6RKZIN6XetLgkzeVifzXVY8j2raZhi57YlNcf8HxNzbD7/q8xiBllDkttQ2Ag==","shasum":"89075d2eebe6b43c5ae5ac07e2c422aec81745da","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGLBdV0Rpn54sidlkPaG5U2skieJQYynfJzOd+UsVHQHAiAf3RFzb4weJJnYEzrznAkzv9Tta9wQHB+MC/cRlaYARA=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b_1704640227777_0.8752117120071992"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":{"name":"@accounts/module-password","version":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/server":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/password":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/server":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/types":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"3b08baff26de149c7ac84dd2fc77c459d7d1cf59","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-Tl3SYQS9/W8HjBgPt7u1OjTG8G6EWrV2vt5/J6e59YyEK4SawdrozPRzm3JyEhgi3eSo1MvdeZT8QayO7MGUhQ==","shasum":"c22ab47cdeffb6cf2fbc31a5b420d7046a7371b6","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPh3M4jPY67D7EfW/Z+utMqrlNhLykpNx1OOj8YxQgXgIhAJFjKnSJg1RaOSeJipr7yWyiJsr5uycms6p92fG+EUcE"}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59_1704644246879_0.6514249541684709"},"_hasShrinkwrap":false},"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":{"name":"@accounts/module-password","version":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/server":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/password":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/server":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/types":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"d74c0d3658792ccbd34fa5aa1573654370caaaf0","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-g6SeCyvhUKIW9SO228wHAWJUgb8IEMuqEMKS1LlJjVlYfNzIxdkLdNfS/Pm4EG4MJxw6JneEfRZUwutDoIUsQQ==","shasum":"3c45f61405f62b1662590e037f8910611999e75d","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFldtwEIgaDP7UORTx2eg08+VBOAp+WVUjMrZ/A7N+RuAiAc6n5XuV1Kf88M9liUlZ1PLm0MUddSxXWFHxHVVOGI7g=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0_1704702356163_0.4948952460839846"},"_hasShrinkwrap":false},"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":{"name":"@accounts/module-password","version":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/server":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/password":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/server":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/types":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"511acde0cc05c194e989d0b75b38eb49836c2f45","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-zVdkLMfKCVULAX11e8upuriXt+4pP72WmxYw+esOr/y40WL0UFJGNew0EYZod0tmeNI1r7ofXD7/jSaolRbzzA==","shasum":"8657b0775f95cba4913d43dc7cfed0f8c6d1409a","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45.tgz","fileCount":34,"unpackedSize":74387,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE7P1fty7JhLFw6KhtDavbZEkxgTbucQkpSVt32y8BU5AiEAgnypE3yV0DLBCatNHAlN2Np1CXI5S6XpaeUa9aB4oS4="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45_1704702863472_0.566229127892695"},"_hasShrinkwrap":false},"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":{"name":"@accounts/module-password","version":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/server":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/password":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/server":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/types":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@graphql-codegen/add":"5.0.1","@graphql-codegen/cli":"5.0.1","@graphql-codegen/introspection":"4.0.1","@graphql-codegen/typescript":"4.0.2","@graphql-codegen/typescript-operations":"4.1.0","@graphql-codegen/typescript-resolvers":"4.0.2","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"7e266d9a0972859f936670670463acde6c27c45d","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-inGDPOSwwQhej7ebuKEl827nTCiL3osFIiL3NBsxTO1u4am5J2OLCRf5QOiax/9R+1QRpzsHEnjl1k2+nNPwig==","shasum":"80abdb8457665f9c30fe42c818042ca99a9be3d5","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGx/vW9OnP5wXbzC9x1IO/67AqwOKn9QiIYF3YLxQr83AiEAkZ6h+v5Wdi8KzO/ZRJO/0EOBDFUeQ3xQcXjUMy1fxCw="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d_1706708501643_0.06438135307782722"},"_hasShrinkwrap":false},"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":{"name":"@accounts/module-password","version":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/server":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/password":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/server":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/types":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@graphql-codegen/add":"5.0.1","@graphql-codegen/cli":"5.0.1","@graphql-codegen/introspection":"4.0.1","@graphql-codegen/typescript":"4.0.2","@graphql-codegen/typescript-operations":"4.1.0","@graphql-codegen/typescript-resolvers":"4.0.2","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-an4LWsBWMNRBab1oBQHth0nehNt3CafaP5jISFT9WcVGEMByOuxXk0gFtrT6UROaSp+WrK5xnOAhZmAZh5s9aA==","shasum":"6ac1ce939abaa129ecc9b2e2fbf61e0ffcd5b987","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39.tgz","fileCount":34,"unpackedSize":74387,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE4ollLOkkSNvylkh1VxanW4WyuZ5Svk702q81vWUU27AiEAzFouFwW6X59Jfg9vQsIqIPEEdABSjs++0glgNvuZ7Og="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39_1706709010798_0.2943056746795816"},"_hasShrinkwrap":false},"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":{"name":"@accounts/module-password","version":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/server":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/password":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/server":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/types":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@graphql-codegen/add":"5.0.2","@graphql-codegen/cli":"5.0.2","@graphql-codegen/introspection":"4.0.2","@graphql-codegen/typescript":"4.0.4","@graphql-codegen/typescript-operations":"4.1.2","@graphql-codegen/typescript-resolvers":"4.0.4","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"7d2c4bb20c8b189e9becbfca91d8414aab36775a","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-nh56BfmpXtIcf5vojbCVMvl5ER3NdVT4pxdbI7VTv/FLJHnPz4/Jx5pvEaWtELjHvgXdhLy8moPR2usgse7IzA==","shasum":"33df8cb26b60ce257dd8b7c12ed10bdcf45dc2f3","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGXiM3Y3PYKhRfrOEfJfPWEBa21fPDQy+YQ1Y9suz0f3AiEAlZxOe8pMz+mkdiyytHBe2ZGRiwD0LYYttHJepADuwoo="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a_1707394480662_0.13173006386082475"},"_hasShrinkwrap":false},"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":{"name":"@accounts/module-password","version":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/server":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/password":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/server":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/types":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@graphql-codegen/add":"5.0.2","@graphql-codegen/cli":"5.0.2","@graphql-codegen/introspection":"4.0.2","@graphql-codegen/typescript":"4.0.4","@graphql-codegen/typescript-operations":"4.1.2","@graphql-codegen/typescript-resolvers":"4.0.4","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"283f2825621f91e014475c969d330ad5c036dadf","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-PJqP0TFLgtrvwVZI8dYmuJOazwnIEjrmyBt8waUYpHx0tNHPAdhjkaxec9ZdxET26UyZSd3O9uoDz5no2cARPw==","shasum":"86657f3f61d29e41946560cdbb1082600b8c6d64","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf.tgz","fileCount":34,"unpackedSize":74387,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHt5nIINzPPROethQgvk9GBFNXAPBqoWDqhyBhWPpSJiAiEA/25XWEl375uSws1oo26EwJSGeE/Pua1bAoN2/3uFJQg="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf_1707395108077_0.3323562900298531"},"_hasShrinkwrap":false},"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":{"name":"@accounts/module-password","version":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/server":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/password":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/server":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/types":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@graphql-codegen/add":"5.0.2","@graphql-codegen/cli":"5.0.2","@graphql-codegen/introspection":"4.0.3","@graphql-codegen/typescript":"4.0.6","@graphql-codegen/typescript-operations":"4.2.0","@graphql-codegen/typescript-resolvers":"4.0.6","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"4af4256ffa4b58ff4654fa2e3514291b689b076a","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-LgYLARGEYl4c+4hMaY/isrixWN5nUbjrd0uooQktBs4JNi1YSLhIGakzeESVJM05LXUkTbESDPqXvCmL3/9pDw==","shasum":"64aca67a2c37e3c2612f4fab7bacb4b1f4bd3fcd","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a.tgz","fileCount":34,"unpackedSize":74408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD3e50NPbQgh7amMWA9/kfyG/TUGI+W+MEdQB86jeNEhwIhAKi9AYJgQSLgMJnYc4D8btQUMufdEuYw16QS5uT48xP1"}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a_1709894091434_0.5020659797730023"},"_hasShrinkwrap":false},"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":{"name":"@accounts/module-password","version":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","description":"Password module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/password":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/server":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/module-core":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/password":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/server":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/types":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@graphql-codegen/add":"5.0.2","@graphql-codegen/cli":"5.0.2","@graphql-codegen/introspection":"4.0.3","@graphql-codegen/typescript":"4.0.6","@graphql-codegen/typescript-operations":"4.2.0","@graphql-codegen/typescript-resolvers":"4.0.6","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-password@1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","readme":"# @accounts/graphql-api\n\n_Schema, Resolvers and Utils for GraphQL server with JSAccounts_\n\n[![npm](https://img.shields.io/npm/v/@accounts/graphql-api.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/graphql-api)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n> This package does not requires any network interface / express in order to combine with your GraphQL - it's just a collection of GraphQL schema, resolvers and utils!\n\n## How to use this package?\n\nThis package exports GraphQL schema and GraphQL resolvers, which you can extend with your existing GraphQL schema server.\n\nStart by installing it from NPM / Yarn:\n\n```bash\n// Npm\nnpm install --save @accounts/server @accounts/graphql-api @graphql-modules/core\n\n// Yarn\nyarn add @accounts/server @accounts/graphql-api @graphql-modules/core\n```\n\n> This package does not create a transport or anything else, only schema and string and resolvers as object.\n\nStart by configuring your `AccountsServer` as you wish. For example, using MongoDB:\n\n```js\nimport mongoose from 'mongoose'\nimport AccountsServer from '@accounts/server'\nimport AccountsPassword from '@accounts/password'\nimport MongoDBInterface from '@accounts/mongo'\n\nconst db = mongoose.connection\n\nconst password = new AccountsPassword()\n\nconst accountsServer = new AccountsServer({\n  {\n    db: new MongoDBInterface(db),\n    tokenSecret: 'SECRET',\n  },\n  {\n    password,\n  }\n});\n```\n\nNext, import `AccountsModule` from this package, and run it with your `AccountsServer`:\n\n```js\nimport { AccountsModule } from '@accounts/graphql-api';\n\nconst accountsGraphQL = AccountsModule.forRoot({\n  accountsServer,\n});\n```\n\nNow, add `accountsGraphQL.typeDefs` to your schema definition (just before using it with `makeExecutableSchema`), and merge your resolvers object with `accountsGraphQL.resolvers` by using `@graphql-tools/epoxy`, for example:\n\n```js\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nimport { mergeGraphQLSchemas, mergeResolvers } from '@graphql-tools/epoxy';\n\nconst typeDefs = [\n  `\n  type Query {\n    myQuery: String\n  }\n\n  type Mutation {\n    myMutation: String\n  }\n\n  schema {\n      query: Query,\n      mutation: Mutation\n  }\n  `,\n  accountsGraphQL.typeDefs,\n];\n\nlet myResolvers = {\n  Query: {\n    myQuery: () => 'Hello',\n  },\n  Mutation: {\n    myMutation: () => 'Hello',\n  },\n};\n\nconst schema = makeExecutableSchema({\n  resolvers: mergeResolvers([accountsGraphQL.resolvers, myResolvers]),\n  typeDefs: mergeGraphQLSchemas([typeDefs]),\n});\n```\n\nThe last step is to extend your `graphqlExpress` with a context middleware, that extracts the authentication token from the HTTP request, so AccountsServer will automatically validate it:\n\n```js\napp.use(\n  GRAPHQL_ROUTE,\n  bodyParser.json(),\n  graphqlExpress((request) => {\n    return {\n      context: {\n        ...accountsGraphQL(request),\n        // your context\n      },\n      schema,\n    };\n  })\n);\n```\n\n## Authenticating Resolvers\n\nYou can authenticate your own resolvers with `JSAccounts` authentication flow, by using `authenticated` method from this package.\n\nThis method composer also extends `context` with the current authenticated user!\n\nThis is an example for a protected mutation:\n\n```js\nimport AccountsServer from '@accounts/server';\nimport { authenticated } from '@accounts/graphql-api';\n\nexport const resolver = {\n  Mutation: {\n    updateUserProfile: authenticated((rootValue, args, context) => {\n      // Write your resolver here\n      // context.user - the current authenticated user!\n    }),\n  },\n};\n```\n\n## Customization\n\nThis package allow you to customize the GraphQL schema and it's resolvers.\n\nFor example, some application main query called `MyQuery` or `RootQuery` instead of query, so you can customize the name, without modifying you application's schema.\n\nThese are the available customizations:\n\n- `rootQueryName` (string) - The name of the root query, default: `Query`.\n- `rootMutationName` (string) - The name of the root mutation, default: `Mutation`.\n- `extend` (boolean) - whether to add `extend` before the root type declaration, default: `true`.\n- `withSchemaDefinition` (boolean): whether to add `schema { ... }` declaration to the generation schema, default: `false`.\n\nPass a second object to `createAccountsGraphQL`, for example:\n\nAnother possible customization is to modify the name of the authentication header, use it with `accountsContext` (the default is `Authorization`):\n\n```js\nconst myCustomGraphQLAccounts = AccountsModule.forRoot({\n  accountsServer,\n  rootQueryName: 'RootQuery',\n  rootMutationName: 'RootMutation',\n  headerName: 'MyCustomHeader',\n});\n```\n\n## Extending `User`\n\nTo extend `User` object with custom fields and logic, add your own GraphQL type definition of `User` with the prefix of `extend`, and add your fields:\n\n```graphql\nextend type User {\n  firstName: String\n  lastName: String\n}\n```\n\nAnd also implement a regular resolver, for the fields you added:\n\n```js\nconst UserResolver = {\n  firstName: () => 'Dotan',\n  lastName: () => 'Simha',\n};\n```\n\n## Extending `User` during password creation\n\nTo extend the user object during the user creation you need to extend the `CreateUserInput` type and add your fields:\n\n```graphql\nextend input CreateUserInput {\n  profile: CreateUserProfileInput!\n}\n\ninput CreateUserProfileInput {\n  firstName: String!\n  lastName: String!\n}\n```\n\nThe user will be saved in the db with the profile key set.\n\n## Example: Authenticate with a Service\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).\n2. `params` - These will be different depending on the service you are using.\n\n- Twitter/Instagram\n\n```graphql\nmutation Authenticate {\n  authenticate(\n    serviceName: \"twitter\"\n    params: { access_token: \"<access-token>\", access_token_secret: \"<access-token-secret>\" }\n  )\n}\n```\n\n- OAuth\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"oauth\", params: { provider: \"<your-provider>\" })\n}\n```\n\n- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"password\", params: { password: \"<pw>\", user: { email: \"<email>\" } })\n}\n```\n\n- Two Factor\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"two-factor\", params: { code: \"<two-factor-code>\" })\n}\n```\n\n- Token\n\n```graphql\nmutation Authenticate {\n  authenticate(serviceName: \"token\", params: { token: \"<token>\" })\n}\n```\n\n### Verify Authentication\n\nThe way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:\n\n```graphql\nmutation Verify {\n  verifyAuthentication(\n    serviceName: \"password\"\n    params: { password: \"<pw>\", user: { email: \"<email>\" } }\n  )\n}\n```\n\nThis will return a result similar to this, if your user has been successfully authenticated:\n\n```json\n{\n  \"data\": {\n    \"verifyAuthentication\": true\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-XHh2909QCPQDH4k5ZTuJYpAcSDIsGhb8S69VMYyyxijw+yj2Vr0Vqw/MZBgfT7u4UG6s2V5S7By7qOq/qswr+Q==","shasum":"9af5e4beb4ecd706f01c1f43b85c4fd11b8eedcc","tarball":"https://registry.npmjs.org/@accounts/module-password/-/module-password-1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3.tgz","fileCount":34,"unpackedSize":74387,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIENinU4m4H+Vp6MT5Ipl3znjRWIIZs1ovD89GsPmOlW+AiBVtLsj1il10+rI7nhAHR8xTlKu9RDzWDBfgeXIFn1A0A=="}]},"_npmUser":{"name":"leopradel","email":"pradel.leo@gmail.com"},"directories":{},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module-password_1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3_1709894964610_0.6318855579408575"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-13T10:30:57.099Z","0.34.0":"2023-09-13T10:30:57.533Z","modified":"2024-03-08T10:49:25.259Z","1.0.0-alpha-20231022085748-0910b9e1":"2023-10-22T09:04:34.420Z","1.0.0-alpha-20231106132410-d312ae00":"2023-11-06T13:28:12.697Z","1.0.0-alpha-20231106135626-1555665c":"2023-11-06T14:03:16.219Z","1.0.0-alpha-20231109134411-9db5d55b":"2023-11-09T13:48:18.014Z","1.0.0-alpha-20231110150116-1eb474da":"2023-11-10T15:07:43.276Z","1.0.0-alpha-20231110204039-4238958d":"2023-11-10T20:47:11.564Z","1.0.0-alpha-20231111101845-4f997913":"2023-11-11T10:22:51.560Z","1.0.0-alpha-20231111172350-25f6cb1d":"2023-11-11T17:27:59.994Z","1.0.0-alpha-20231113142902-7812b73b":"2023-11-13T14:33:07.566Z","1.0.0-alpha-20231115113719-ae2b53a9":"2023-11-15T11:41:24.893Z","1.0.0-alpha-20231115205645-aa630d56":"2023-11-15T21:00:51.318Z","1.0.0-alpha-20231116130548-67b64a6a":"2023-11-16T13:09:59.098Z","1.0.0-alpha-20231116132834-55ee2b96":"2023-11-16T13:32:38.447Z","1.0.0-alpha-20231119093904-9adfd014":"2023-11-19T09:43:13.013Z","1.0.0-alpha-20231119094526-b1fc68c7":"2023-11-19T09:49:30.338Z","1.0.0-alpha-20231120163547-4a461fcc":"2023-11-20T16:39:55.773Z","1.0.0-alpha-20231120164530-e14d6a81":"2023-11-20T16:49:35.914Z","1.0.0-alpha-20231121011122-60a60524":"2023-11-21T01:15:30.697Z","1.0.0-alpha-20231122105229-8edd073f":"2023-11-22T10:56:46.433Z","1.0.0-alpha-20231122120807-69a661e3":"2023-11-22T12:12:25.019Z","1.0.0-alpha-20231122192915-c0243667":"2023-11-22T19:33:30.983Z","1.0.0-alpha-20231123103003-4f0c2405":"2023-11-23T10:34:09.371Z","1.0.0-alpha-20231123122853-0ccafb9d":"2023-11-23T12:32:55.958Z","1.0.0-alpha-20231123131746-58399dcd":"2023-11-23T13:21:42.901Z","1.0.0-alpha-20231123183707-51335dc2":"2023-11-23T18:41:12.662Z","1.0.0-alpha-20231124142337-45cc4d05":"2023-11-24T14:27:50.860Z","1.0.0-alpha-20231127162849-b5b29d3d":"2023-11-27T16:33:00.057Z","1.0.0-alpha-20231127170705-4b0b3391":"2023-11-27T17:11:15.114Z","1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":"2023-11-30T10:53:02.100Z","1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":"2023-12-06T16:15:11.894Z","1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":"2023-12-13T12:13:57.529Z","1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":"2023-12-14T10:38:29.287Z","1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":"2023-12-19T11:08:32.206Z","1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":"2024-01-07T15:10:27.940Z","1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":"2024-01-07T16:17:27.116Z","1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":"2024-01-08T08:25:56.309Z","1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":"2024-01-08T08:34:23.631Z","1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":"2024-01-31T13:41:41.800Z","1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":"2024-01-31T13:50:10.953Z","1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":"2024-02-08T12:14:40.859Z","1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":"2024-02-08T12:25:08.286Z","1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":"2024-03-08T10:34:51.601Z","1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":"2024-03-08T10:49:24.782Z"},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"description":"Password module","homepage":"https://github.com/js-accounts/accounts","repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"license":"MIT","readme":"","readmeFilename":""}