{"_id":"@accounts/module-core","_rev":"43-e9aff133f2252450686fd430c606b64a","name":"@accounts/module-core","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-core","version":"0.34.0","description":"Server side GraphQL transport for accounts","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/server":"^0.32.0 || ^0.33.0","@accounts/types":"^0.32.0 || ^0.33.0","@graphql-tools/schema":"^10.0.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/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","@graphql-tools/schema":"10.0.0","@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-core@0.34.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-Berr7ibmzeKzNP2g23Po5X1tuG6r5+I4xaMtU9yovY1BDrFevx/kYDJossNHUBxVOSzKs3pRb2Peg0VmnTr3tg==","shasum":"416aa44637cda49467204724f60ca4c778f9e82d","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-0.34.0.tgz","fileCount":62,"unpackedSize":72942,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE4qpWrXMKOysI4G7g4r+gTkp6bm0TvSC1/9ZadQRcwzAiEAvxYCbfrr2opGb9CW+3lYbKZjck1l/QHHzSbGR3UDY8Q="}]},"_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-core_0.34.0_1694601056989_0.07039667213067102"},"_hasShrinkwrap":false},"1.0.0-alpha-20231022085748-0910b9e1":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231022085748-0910b9e1","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/types":"1.0.0-alpha-20231022085748-0910b9e1","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231018163544-36199b68","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-JUtCZ4MefnQcTtrd6JwHnDrbedRG6LP0exWZ6aBMpvK0XV7ShtlxnIqo/7QFG1cJWZ9MX7Z4mAssBZjtYZA7jA==","shasum":"44d8b2c08b5152edcc9b78e7f07d3f5f14a5ad7a","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231022085748-0910b9e1.tgz","fileCount":62,"unpackedSize":75398,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCMk3cpJR6kr9QNzYnNsFeExUuTwaGb0deviDuoHLk8wAIgNHM5qGP+lP7+ealSzy9pRBoJPgi5dwM41J0rYe+c1SI="}]},"_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-core_1.0.0-alpha-20231022085748-0910b9e1_1697965476798_0.2981344279468172"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106132410-d312ae00":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231106132410-d312ae00","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231106132410-d312ae00","@accounts/types":"1.0.0-alpha-20231106132410-d312ae00","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231018163544-36199b68","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-90Wxud/RP4ZgiiDFRpXhkZAHVBe/oiS6VQJRnaVMuMUuOu/Vj4Ich7MnI13KJkwLhxYuusZ/CRnhP5AlPg8zkg==","shasum":"e7364340854d8db2ac166cee159b198b604df059","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231106132410-d312ae00.tgz","fileCount":62,"unpackedSize":75398,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEbzSMV6IXnPeFzLdpQIwR+h3oQqKno4qSp/IH/9gRq9AiBRulGtaEvKSqltoNXnRMfl/j5iUax0GKqVtWBnJAzdmA=="}]},"_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-core_1.0.0-alpha-20231106132410-d312ae00_1699277292008_0.24279891166415246"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106135626-1555665c":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231106135626-1555665c","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231106135626-1555665c","@accounts/types":"1.0.0-alpha-20231106135626-1555665c","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-5npsWKNmEFle/kuey0KE0rwJtlZFk73HychDiW8CqdXffjwqi6qnUjX4B5WIXLLOnPS+Hw51wZb4mf6R5fV7kQ==","shasum":"9d51caaabf00f5b8f1b7d52d84cd3ca03171df1c","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231106135626-1555665c.tgz","fileCount":62,"unpackedSize":75093,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCOCKyzDDZjw9D3ChTrQ96UPSzOssrK9T4beoDqDFDcSwIhAOpRYJk6UM3B8ON7Ia7ZZrIhtWu8jmtYojahfAQEhgO1"}]},"_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-core_1.0.0-alpha-20231106135626-1555665c_1699279397096_0.6084360991401303"},"_hasShrinkwrap":false},"1.0.0-alpha-20231109134411-9db5d55b":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231109134411-9db5d55b","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/types":"1.0.0-alpha-20231109134411-9db5d55b","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-yusX6bIjT3O/329qdwQXFEZ2vzZ4apYM1FqbSyRSoWw98vMloqShOhCKsjYT/0tzoZ+z+8wvfT7urK7PKl9PJA==","shasum":"c5b5dc9d2a777bddc3bc66301b882a75acd64b19","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231109134411-9db5d55b.tgz","fileCount":62,"unpackedSize":75093,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCmqwjYa9II5wXN/ST3Q6c7um78AGBlHdmLZiftXqAs+gIhAOxWqnxFhhW+mjaDI+lh49KZlVFPjC8+nuoKxDb4ujUG"}]},"_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-core_1.0.0-alpha-20231109134411-9db5d55b_1699537698488_0.29920408206584326"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110150116-1eb474da":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231110150116-1eb474da","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231110150116-1eb474da","@accounts/types":"1.0.0-alpha-20231110150116-1eb474da","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-Ym7zL1AOeudqvqBR/dh1Vqbvgpte01VvZ9Gc9gBavBpu+1Wsd0HfR7HMxViol/FlDE0r9W9THJbDOBlLJ+WtwA==","shasum":"8256947ac192d268e352e7954b1b2b9dd3aa48be","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231110150116-1eb474da.tgz","fileCount":62,"unpackedSize":74578,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC2PFmas/nuGcEWMuRZLqcuBdDZyWkKyTpkWGftqKp5/AIgbcQ8EsJyZAuu4bAYgdfoOwcSmwAk3jYaK9s5nz2FnSo="}]},"_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-core_1.0.0-alpha-20231110150116-1eb474da_1699628864150_0.35599793175852423"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110204039-4238958d":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231110204039-4238958d","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231110204039-4238958d","@accounts/types":"1.0.0-alpha-20231110204039-4238958d","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-lGUFnzOh0iYP0QoXxc2fcnLXQtmD6dhQX5/j9mMmbILk9ObliurO2XlA2NhujiYd7oW/3vStpW9cTT/QSIv/Aw==","shasum":"7bf491528dcc4169284ebef6000511b4b721f1de","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231110204039-4238958d.tgz","fileCount":62,"unpackedSize":75492,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtxEdAwdn0JAmn9OE3Sl6o1fY7Jp1bvg3mwBGJ/hnJ/wIgKBXHZhhGJlUBBOSJH/kbK9IbEaFMyG1GVwBZcLWYTHg="}]},"_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-core_1.0.0-alpha-20231110204039-4238958d_1699649237884_0.9977733095300725"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111101845-4f997913":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231111101845-4f997913","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231111101845-4f997913","@accounts/types":"1.0.0-alpha-20231111101845-4f997913","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-y6gkUxzrw8viyDRZeX9HbEonynlPy5ggdvY3l83mtFb8EdP9VBJGXm7REdrb9RhQ207qDcQ8PdLEGlYMbW6Xfg==","shasum":"78bd93f9015346f0b9e0ecf03b4c89a919294067","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231111101845-4f997913.tgz","fileCount":62,"unpackedSize":75931,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCeKlzlMau+DbSToKL/X+IpoBwEvnZZN0/ZmpHEfN3EVgIgJuE6LPwfxh+dZp6R9ceOGfsOxO08exYSEApKncq3lgA="}]},"_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-core_1.0.0-alpha-20231111101845-4f997913_1699698171540_0.022566321267719847"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111172350-25f6cb1d":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231111172350-25f6cb1d","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/types":"1.0.0-alpha-20231111172350-25f6cb1d","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-l6EjK5lRABra7eG5yOdnmkSoIok3JvSPbyffPrMN6wfXAwLnUGKODW8WJ6gwIoU/BE7YGq+4fuZjQrEEntftkg==","shasum":"81e6d676f6ea888965a86bc8a0c948246dde56a2","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231111172350-25f6cb1d.tgz","fileCount":62,"unpackedSize":76389,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCOcsAMq9V1aWfhPYOQcx4vTEB+UhMNFoTfJiodoDmIGgIgXtAuH42Ikv4lRsfrlRXqLD91fVSwK2GjUgaqgnHOTNY="}]},"_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-core_1.0.0-alpha-20231111172350-25f6cb1d_1699723678954_0.798038392156112"},"_hasShrinkwrap":false},"1.0.0-alpha-20231113142902-7812b73b":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231113142902-7812b73b","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231113142902-7812b73b","@accounts/types":"1.0.0-alpha-20231113142902-7812b73b","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-cmvshKzXFydPvxq23LkE7kHVk30zL490uV0J0FjmJaqk5ZEU6qVIRiFkbO4T6GzUpyCP381UZNEWHyJnVFofiw==","shasum":"19bde54d57969c08037b3672f03ec2350d23c087","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231113142902-7812b73b.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDC/IYaJZS0E15rEjkkqB6rDprJ9QzgkPojv4MZTcI4zAIgP8IMDTEP9fIQ1bbcL0iDc7TnpuEO9DA1L66Wfatsc5c="}]},"_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-core_1.0.0-alpha-20231113142902-7812b73b_1699885987368_0.14753248922974427"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115113719-ae2b53a9":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231115113719-ae2b53a9","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/types":"1.0.0-alpha-20231115113719-ae2b53a9","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-YMME973cKjJ8AiQtqCFCU3RlbZMATHrcGzlzqziqlb4A9fDPTlZNWAYlYNDoP4bQoBe27SrQBstW+Y10LEBouw==","shasum":"466a48c38addacf2f47b80a8754a65d87590d3f4","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231115113719-ae2b53a9.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBpbWpnVBJuaFnLr1aYs0ffaxI8NQ69AnVYG3deWGH81AiBL44QbwbaLMWcL/YxMbF953De9/ExSqAXRyZ4joQhK0A=="}]},"_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-core_1.0.0-alpha-20231115113719-ae2b53a9_1700048484880_0.22927935612281924"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115205645-aa630d56":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231115205645-aa630d56","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231115205645-aa630d56","@accounts/types":"1.0.0-alpha-20231115205645-aa630d56","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-qypsn/bgnEnSkVFxQoiUQaVCDaPf1/yy3jQwRNsreqcKA+2ePPzuUfXObrDTwxOER5y0/RUj2a7v3uTF2MBG5A==","shasum":"e2ef7392743821bd23b968beeeece5ce0e8c6ad5","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231115205645-aa630d56.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtnKQHh1F4JVq6lTD6mh9SHOSixFdBWLOrTKx+kpgSNAIgf14hRV18JpnDhgd5CxP8ZsqQGJibA4txYjctS+NCmGs="}]},"_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-core_1.0.0-alpha-20231115205645-aa630d56_1700082050305_0.05458669435368502"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116130548-67b64a6a":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231116130548-67b64a6a","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/types":"1.0.0-alpha-20231116130548-67b64a6a","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-KXIyOfjuS+6C3YaxXX8kHdYBVww1d1mp2ULWXW07MUQJARYB8ICSMDO6y1cZ7QTXn/DYZEBNXbDr2qAQFJkjuA==","shasum":"012604de661e48980ea088fe5d2972265d87da90","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231116130548-67b64a6a.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF4uI90t/Nt91D0xqD5xB73YlIEliAtrNV5AvnstGp2VAiAIiSqlhGq2WLPQEdj9CGcmrXWuse/Z/P9OHwJ0v+r5vA=="}]},"_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-core_1.0.0-alpha-20231116130548-67b64a6a_1700140198957_0.8564989859187451"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116132834-55ee2b96":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231116132834-55ee2b96","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/types":"1.0.0-alpha-20231116132834-55ee2b96","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-PekNLherwlWaIr1j7CEXmo91838f+GLFHDjrnQ+NHByOxBAjkglHC44bRtintWe9jo2Eayg1SZMd73x0TurD0Q==","shasum":"c1d88ba46120c709ee2a69136fd6d863bf95f4cd","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231116132834-55ee2b96.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDC6WwZEa1vPYGeClGKLV+udoUnnera7qN+HnXdoXBKEgIhAOYIg4OwpbKoDdKQtHyRyUCC31JnqDshNMvUU9rf5olI"}]},"_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-core_1.0.0-alpha-20231116132834-55ee2b96_1700141558267_0.6127970642642329"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119093904-9adfd014":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231119093904-9adfd014","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231119093904-9adfd014","@accounts/types":"1.0.0-alpha-20231119093904-9adfd014","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-TyVHJhOVNAUbaRz5Tnt/ct0lQaAxcd3lNm6d3rNICKd6pu5D5wgeu1GPAoEf5nRT1BN63tMukVCHBjZM1xPuug==","shasum":"c3e9f1e4a67d145109c4af3b4ce3769d5f1e097a","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231119093904-9adfd014.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbKRr+47Y6330NQOHT8km9ibFR1Ha6tcZOcDKEKlsYJAIhAP3vVyha421jifvIyFoQrA9I8XN2m/RQ5H+JW1rA/OhR"}]},"_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-core_1.0.0-alpha-20231119093904-9adfd014_1700386994956_0.8377711879400613"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119094526-b1fc68c7":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231119094526-b1fc68c7","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/types":"1.0.0-alpha-20231119094526-b1fc68c7","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-SNHvoYcZdn8iKTG1MuFD+y3NX1bkvQVMfuRqnJUWSlcYeYcED928bpSrmFbhQhoq4jFFkEuOE926HiIo3y22Hg==","shasum":"36e64384de8221e3c7f3fcfe8f8931f29de9c867","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231119094526-b1fc68c7.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDU4DBX2DDE0lDrjHocrsRyMlijMoSqrMSJXFLsbEkZmQIgFIsubkGYMXTwcZrmp/xe8iGZKS/WdUVVX+vbxQAEhVE="}]},"_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-core_1.0.0-alpha-20231119094526-b1fc68c7_1700387371913_0.5807654237519668"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120163547-4a461fcc":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231120163547-4a461fcc","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/types":"1.0.0-alpha-20231120163547-4a461fcc","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-o9vTUdo9kF+YjMKez2uGQWHrAZJNfrhYntJ8qynLAhtKwDXUMuIdO9yRU7dtNiCOu55i3QBPkzjVsanInd8l9Q==","shasum":"ebe4d25cd601a72bc5c02096981465b6ae106788","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231120163547-4a461fcc.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDn2gK5PKDwTVHD8yhjNpRQdw/ntC66CiWO0eqvqVpveAIhAMyHp0sZJhNsMnPwwq540nSglg6e2ycHXpbKpe35Tvse"}]},"_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-core_1.0.0-alpha-20231120163547-4a461fcc_1700498393142_0.5780477330622129"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120164530-e14d6a81":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231120164530-e14d6a81","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/types":"1.0.0-alpha-20231120164530-e14d6a81","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-isT5Fn/mI8BPXttyASuKWc97KIJtt823QmGGqq834PBE7Eu8MkfWDYIkW/jyrIgku/5hTAgJ4Qchj9LP4/At2Q==","shasum":"ac0e1862e1b664fa356ad23b9f20c407d3f55680","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231120164530-e14d6a81.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCQ3gIjfBzNTP0Hlp2iKOYZM3m9vMUntD4O/xJTYajipQIgBXk/bSAw3KSmNLu0q39rhoGBXgzcs7FFvTXwKtXtkQM="}]},"_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-core_1.0.0-alpha-20231120164530-e14d6a81_1700498977143_0.9891681109317636"},"_hasShrinkwrap":false},"1.0.0-alpha-20231121011122-60a60524":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231121011122-60a60524","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231121011122-60a60524","@accounts/types":"1.0.0-alpha-20231121011122-60a60524","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-bQatSl8MsNJorj0WanTwafxTzc8+NlrhxZPzVpH6vWYgLzbbxTUg37Mt02nGYQ1z6zJMq8dMFdpbuUwgDuMz9Q==","shasum":"cb581f9bbf9d8e646bb2f9d8c748a3000252a287","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231121011122-60a60524.tgz","fileCount":62,"unpackedSize":76848,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDgFws868FYA90CeBl6GmY5BKanRIbaSNMG5YdjCS/RaAiB6FMPbos9BX8xftcot4JPPaGmC/0Vm46fzbziHnWs6Jg=="}]},"_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-core_1.0.0-alpha-20231121011122-60a60524_1700529331749_0.04727659728027023"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122105229-8edd073f":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231122105229-8edd073f","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231122105229-8edd073f","@accounts/types":"1.0.0-alpha-20231122105229-8edd073f","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-uTdBGJoFGz/cs9yd193FHubdmFh972cL4Lf+kBzuWUPy6o4L9qmb4Hm7qcklnoPqGosLNydRafzkTDYBafGp0w==","shasum":"2df37c3d55835a14b29d2331f86261c93bf7b5fa","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231122105229-8edd073f.tgz","fileCount":62,"unpackedSize":77039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH1+OT8MIFAvEEwH7mfLW/9ME2U0qy4F+zWY3ebglSs7AiEAs0DswJydP8huIyVfRZZQno70QS3MM9l+ZO6asFa9oBw="}]},"_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-core_1.0.0-alpha-20231122105229-8edd073f_1700650603818_0.8747663092805007"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122120807-69a661e3":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231122120807-69a661e3","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231122120807-69a661e3","@accounts/types":"1.0.0-alpha-20231122120807-69a661e3","@graphql-tools/schema":"^10.0.0","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/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","@graphql-tools/schema":"10.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-core@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-FjGobPbqZ6nBs8+Mr8WNQbwK4hCVfgTDIjQnmRdlVbYmObmcjdf6JfIm4Iq34a6C8lh5cuiP/CT8YFloK3rD7Q==","shasum":"42d01101f50fb77a9f7c3f7cf8eea6ed36245e8f","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231122120807-69a661e3.tgz","fileCount":62,"unpackedSize":77234,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPAkaQSph45wFmcjj74dOiq4/wIIh6DbsWKwKwudBNrAIhAJeUGi0hk5Te9N1qV15g0si4Hv5Tbdomuk/GWittIKhB"}]},"_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-core_1.0.0-alpha-20231122120807-69a661e3_1700655145176_0.9190218811802398"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122192915-c0243667":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231122192915-c0243667","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231122192915-c0243667","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.10","graphql-tag":"2.12.6","request-ip":"3.3.0"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-WQvLvpu5h2hjQr/LXvOPbR6OQHEAR5Pqi313lJRgWoBUp1ok1zXoj5LZjE0qb2hQpkb/UgRPCY7K0tNPlRq3uA==","shasum":"5cc62b1a58af1f306ea0c1495d9ce8f6a1db6fa7","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231122192915-c0243667.tgz","fileCount":62,"unpackedSize":77103,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCIqDuyGdfF59sCm4jWELLu59AFCg2LDECF4+hW/t+3agIgFcfJxFqQt/bDBAzZM8XRckjJoxtdYuhoPU+cMpfewuM="}]},"_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-core_1.0.0-alpha-20231122192915-c0243667_1700681611940_0.39593776257462965"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123103003-4f0c2405":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231123103003-4f0c2405","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231123103003-4f0c2405","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.10","graphql-tag":"2.12.6","request-ip":"3.3.0"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-GDnYXx2a/MZYxsLk9N5W2VlVaG3RNfhP7KW2ZxcIfZV066H+VZWB8sxNeH7CmXkSLzOEjsy7IbnsbC6k+zVd5g==","shasum":"fb82cc0449f3c94c1337c87f30b89fa149a6364e","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231123103003-4f0c2405.tgz","fileCount":62,"unpackedSize":77103,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDkVJ/VQ0BP8/7ew00/co+Gm4ISVdhrs76T7eVIq8tXkwIhAL13lffmQVFWiwIN3dezmR8gZ3u0eBhnqSBzb2DYOc5t"}]},"_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-core_1.0.0-alpha-20231123103003-4f0c2405_1700735652681_0.8162649968334086"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123122853-0ccafb9d":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231123122853-0ccafb9d","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231123122853-0ccafb9d","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.10","graphql-tag":"2.12.6","request-ip":"3.3.0"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-FBSblalRHVk4wZ6tKewdNb31AZCPkv4PH0pUAZmmZ19AC4dnlDjRw2l9qBHnp+dmq76P0ocQzPFK3XaeVTaLcQ==","shasum":"f24dd74678918fa1c1893add3951d15c44ec1648","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231123122853-0ccafb9d.tgz","fileCount":62,"unpackedSize":77103,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD30tjo5sulB+YGO/dhNCkdqo0p0/ubR1cGx0prLux2sAIgeKom3gY5RwtvKZVyMVvqSQG/i0UFYpTbxrDfTx5mEbE="}]},"_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-core_1.0.0-alpha-20231123122853-0ccafb9d_1700742776411_0.45789893294957085"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123131746-58399dcd":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231123131746-58399dcd","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231123131746-58399dcd","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.10","graphql-tag":"2.12.6","request-ip":"3.3.0"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-X8LQWEaiG9YN8jGUtoSqiZWHsUFD4Wo9L9UkgZW3zq+l79lVzIKmPZfCHBHkCyQVDGfWBeG22QWLoIBQn4wBig==","shasum":"c22215344dc471c8c218cb3ef4eec127bad05f27","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231123131746-58399dcd.tgz","fileCount":62,"unpackedSize":77103,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBCaV0ieOq/q+eDmWlC4FcK0G9kHI753sGusfuWX+f+mAiB1gqYzkBcI/eMp9xkFAWmUQ+ryYhUgzlMnKFjgtnzOuw=="}]},"_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-core_1.0.0-alpha-20231123131746-58399dcd_1700745702652_0.5645009714256009"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123183707-51335dc2":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231123183707-51335dc2","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231123183707-51335dc2","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.11","graphql-tag":"2.12.6","request-ip":"3.3.0"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-mViw6ZDMPeNjqOAUYVCEoLzwO9hcYBmVbv+rOVJ1UKv3Sh6w/rzbYrrESeyeMxKEo8BMrhfO4lBwpSTM/0lkuA==","shasum":"86290be3a798f42a432be8c1a5a8bd1dabc6f3bc","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231123183707-51335dc2.tgz","fileCount":62,"unpackedSize":77103,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDjNG77fLN2egiTy8t+x+GtKce48jeqFSjzwzIhZTHrBAIhAK/a50nnhtz1ttFvskERzArQr6lGli3DXcEYKyTpEg1+"}]},"_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-core_1.0.0-alpha-20231123183707-51335dc2_1700764871145_0.9423851308728619"},"_hasShrinkwrap":false},"1.0.0-alpha-20231124142337-45cc4d05":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231124142337-45cc4d05","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231124142337-45cc4d05","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.11","graphql-tag":"2.12.6","request-ip":"3.3.0"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-Pa/bfFqhjHCB3dhFY+sWInxYfrQ6ZF8JYw1xoPTz/BA6RnC6vnjttmnxwQ1JzGgp46KL188gUIDAWfk+wpTOTQ==","shasum":"66743cb8d8953d37fdd84c8fba8948e86a9c7c50","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231124142337-45cc4d05.tgz","fileCount":62,"unpackedSize":77103,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCJsZGXg0UwK5awUN6YI8V+Im68A8KlS1H9xSCgFkE8tgIhAPi5Yd4y0HUAqrUMQKSEtkejvS4O/mqvSBTBhxJowApK"}]},"_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-core_1.0.0-alpha-20231124142337-45cc4d05_1700836069796_0.4280437091073801"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127162849-b5b29d3d":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231127162849-b5b29d3d","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231127162849-b5b29d3d","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.11","graphql-tag":"2.12.6","request-ip":"3.3.0"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-oPq5rKvoVZlVZT5i5+Sh6wP+1+tjBIVeLMRt6yBJ2GEJk4B2M9D1dEXNJib9W7ZNxjCDq3mc6BRzMYb3gJKJSA==","shasum":"f53253ec7567dc67bdad6ba2988389eb8ed58df0","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231127162849-b5b29d3d.tgz","fileCount":62,"unpackedSize":77103,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFF7wH3pqM65q4yXXYWxKKXkNpreqCs00ErkLD4cjGXKAiEAp8GyYqa8sA+GTJtSg9nbmOth5qKSq4iM1uMBn1xTRWY="}]},"_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-core_1.0.0-alpha-20231127162849-b5b29d3d_1701102782589_0.1256315916057975"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127170705-4b0b3391":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231127170705-4b0b3391","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231127170705-4b0b3391","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.11","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-Fxu5AFLkij1hOiOVnFrmQ/0+wc+u+jaMZzWWF+Lyvy0lLtsCt49uWqNr83O41jVaXBa3EUBybcKyGxC+gV40zw==","shasum":"ca9f12b28f6b0c174b0c127586b351aa2e30a0cf","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231127170705-4b0b3391.tgz","fileCount":62,"unpackedSize":77125,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDjvS8+GGbniMNdxHTXmf7nQDL6XCyKvOWJhhXDFoOzcgIhANhfdGOjrpANNLH+2oWavxUv97cEnzW5sIKQPnL3ofDq"}]},"_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-core_1.0.0-alpha-20231127170705-4b0b3391_1701105073641_0.23617424931436704"},"_hasShrinkwrap":false},"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.11","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-X+21gNADoG/siMvDJOR+3WFE0SYJQRKrMNraCNpQcPwfiwqF6Tfqxf4Zvmr86xHrZNZhwNnprqHB7PZoEphehg==","shasum":"78722368538dbc2ead655e16042270749b2e950e","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCqr/gCcP5B+MCHlwGd1uaEt4Eih0i04r3Tuil358anUgIgDRocszITpdLVTP9nTWLbDTTshBdgNSaGHnK1L1XR59M="}]},"_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-core_1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165_1701341580758_0.3401839136329263"},"_hasShrinkwrap":false},"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.11","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-HSm+w6B4nl8CH4WIAe6vvCNpuYZ3kX7oEeqTFsC8G8beOoXQHlo9E+TXI10YacCvYl8MsoLKGJl4ItlvVvObuQ==","shasum":"79a07097b19459fe5315a1f232c2457facce09bd","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDU0FMuj+vEC+aTj4mljx2nZjnKenVWZDJpJxTuYvAggQIhAK6oCsAglhSXXIaMv5En5A99zdrt88aZlgUIydxoi8rL"}]},"_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-core_1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db_1701879309934_0.295834515539964"},"_hasShrinkwrap":false},"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.11","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-WNUW/Y/e2SgZ96NIaPIGGWN13k3c2xNntA1bRgZ4MglKfL0I1UXIa0dYElnjyXn0RukQRBwJrKVlD61IVC0A1Q==","shasum":"45693ddb02b7d8bfd4d7aaa4135ed65ef138934d","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCgRiVy76O1G32lhlpwIv6kEVFe3s7AkWHB2Qx3BLfRggIgYvVwuZnQLNzxRNs1MGrMGyWp3d6XSb2cYgaUYnwGwJs="}]},"_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-core_1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b_1702469636995_0.6383329537323139"},"_hasShrinkwrap":false},"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.11","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-SZ0KtcyegkT20M5vWeAiFj5p1QnYA6M3TUbuRyYJES9EZ0jbN7q7YMQYPJDWssGSFbVpuPL9jIOeAe6GZ4QtfA==","shasum":"837a542902d1cbbf47dfd27ba90753fdab4148e9","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDC5KpW9XflOUK3vzRd6m1RIlGGl7/TlKGOCZWCfmQlDgIhAJH0sWDyNVFO16rmWqwu8LIf37EBFM5x+yDFljKx+Qkz"}]},"_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-core_1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd_1702550311994_0.29887011486908066"},"_hasShrinkwrap":false},"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":{"name":"@accounts/module-core","version":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.11","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-iwKj4ST6jy1GK+8U6tF2c5yimC6gwG6YkPH8ZeW10NMpTX6iA0iAjZGwVpFdFbA1ai9PjOcS2TslFoiFfEKqxQ==","shasum":"9216ee76a8280f4db041a2ef17929975ad45f405","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC5kmVppYd1ETdmx70P6rhT1Ltx5VtYKm9j16dLHAUCmQIhAJtnBJujRHkCRAAyk0wSlAZa8Yy9zFrtNZB4/BvGo7o7"}]},"_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-core_1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9_1702984112898_0.7508948243209947"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":{"name":"@accounts/module-core","version":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.12","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-wVz3qwMZbjQZNC2GB+9o6Bw11XQGK2XYMX2plnfzduZnadVh9JMCRE7LK0QLeyFIvcP2HyjUOmfm5hMIq23PqA==","shasum":"cce1d08bbe8f23e58001eabdadbe7018aa11cf12","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCeUQm9IX7iZW4sYQjDynT+dgQip+5VXgUVKG9tfqYocgIgIsh6gViHRDkpfcC8JhRokOOh7PP4uY1vRrSeTPR/jU4="}]},"_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-core_1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b_1704640228299_0.07490827907358155"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":{"name":"@accounts/module-core","version":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.12","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-fUcbTA0BuGKJzNC5YOPYsUecCjxPPz9EHbxPi4c9FAexBZuCyXwy1byi1l0WykqEwrNM1cP7t0etE+VDqoBLFw==","shasum":"ce701ccc06c253f1ae672976a3a1a2585f1e35cb","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCuEAl/5dJA2Ty4Q1LxjnuyvK3uTCPP1pZgqaHwYal0SAIgcUawtUabexx+2NDW58bSOQ+DN7UsBbPXzv4oPAqPfeo="}]},"_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-core_1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59_1704644245945_0.8111983963749054"},"_hasShrinkwrap":false},"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":{"name":"@accounts/module-core","version":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.12","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-vQQ4U/Ls0B2ow47FgURY7D1QrJi9fQ2HBgbYdb9DUl9PqJyCAA/oU91Lv3R98ArtaU3/nNRugjHSg7oWa+zHaA==","shasum":"9d0f0650b05e4263923241cb44d0f5ab4823b17c","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICZQ6njDhTX2E8qc8HFRENcElK4x0GKyngP6+v47kllUAiEAuZ6HNAOA+fgVPtl6lCdaxnynioy0HLS2jNxXPQynIU4="}]},"_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-core_1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0_1704702352631_0.2744474633596219"},"_hasShrinkwrap":false},"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":{"name":"@accounts/module-core","version":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.12","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-glhD2mknptuqnzSCy3sNMQsvxbwjW993pVDL/9OIOZrUBlvtY9fuWIqO5zmAEohvirADd8FpsaNKTNVScbvFsA==","shasum":"85dc94ce7d69fb363adc0d0de964266f64b8a212","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45.tgz","fileCount":62,"unpackedSize":77241,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBCulMB8ZVTV7UWOiz+oCN9prxe1zoDUJBb3PnlS8zAmAiEA1wDW+KAxKYic5rZSEWYnwhg95iQDjCi2IaIc9nlJBN4="}]},"_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-core_1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45_1704702862045_0.7169179119746181"},"_hasShrinkwrap":false},"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":{"name":"@accounts/module-core","version":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.13","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-GWHQnmFV801nlUujWZAS9HtK7kcbQMkqReqSrxKjoMKNTTjMuyCNn2fkimOHS3dujLYftSmdplQHU89f+XD0/A==","shasum":"334bef0c999ceb0d72679f4b3d635e8230721367","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDBJJaLk5j61LYIGR+YYs3iZazFW4eJni4RsrZosEcVbgIhAKemeRYNNStzyIMrgWqriNPXdUApba2WYafst9vJTi/S"}]},"_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-core_1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d_1706708500167_0.5129254157307597"},"_hasShrinkwrap":false},"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":{"name":"@accounts/module-core","version":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.13","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-1SufKZ9wvOFJ8dvYSHHeOLeSUbOR5iTeiHSj1GoGmXnuA0DRpMn9BqQp2eXbAH+UEVLKQyUYeofj+1pU4PH/0w==","shasum":"eabc272cef28efdc82e6e40e5a8c1d959f10cdfc","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39.tgz","fileCount":62,"unpackedSize":77241,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHgai/uEBDd0wAj3s47Yn0P1e2rzfN7NnazAq+NjRfIUAiBLZzAsZglHCY38lNf5zXmTSndYMOZ10jjwvz7Zc8CxIQ=="}]},"_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-core_1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39_1706709010377_0.5647891016644608"},"_hasShrinkwrap":false},"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":{"name":"@accounts/module-core","version":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.13","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-SlYhG8k2Z74+SsF5qarckCxhVIV2qiz0rttC8NxC+McoJ4hbb+5NBA7a/IPID4GGkK0JxaZt5GrBlCsyZrHTRw==","shasum":"916dac6b308336985529c9cad379c4bd42190b1c","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a.tgz","fileCount":62,"unpackedSize":77253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGXA9lI7uS1PZO4Sx9dakoTzkA4gJpboRMVUYXpT0bSLAiEA4oNJpEAfoqvDIKa6g5IF5kkciz/l8YUDShjtLHwGcL4="}]},"_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-core_1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a_1707394483211_0.20009195256079804"},"_hasShrinkwrap":false},"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":{"name":"@accounts/module-core","version":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.1","@graphql-tools/schema":"10.0.2","@graphql-tools/utils":"10.0.13","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-iBVGPox3Fk1xCEdEhXNHNnIzR5SATWJ7ep95l1G9P8ZTAiyJSHc+rrN2+7hLt0jjav9M8jiSYi91UhffnwqEpw==","shasum":"6142f250dd85c0e70f49e9057155ba517239dfe6","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf.tgz","fileCount":62,"unpackedSize":77241,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAgfB/9asIOjOO6gCNSnZMPHwE+szEWNdLip0IjaVBW7AiADM4A8QRPDsOlWR/UJqR7Cshcu/xhvIzQtSIhU8epLXA=="}]},"_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-core_1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf_1707395108196_0.095293344431153"},"_hasShrinkwrap":false},"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":{"name":"@accounts/module-core","version":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.3","@graphql-tools/schema":"10.0.3","@graphql-tools/utils":"10.1.0","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-+rGSpDvCIxWkNc+YGmLa2OTTf6Xl7XxP6YOVvl6Ld4eFRuwuvU3wW8x7w/N+03UXh52cWFMm7qedr1mKS/M15w==","shasum":"2e2e4acae4204df35f4f44a10e545551ae41dd4b","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a.tgz","fileCount":62,"unpackedSize":77252,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCm45/yQlrxJnZFPYOX58ptu9BCA95j8NPkbvUmOei2TQIhANt0KgKPjaCk0rdKac2gNwaquFFRf6AxxlTl03MB22S7"}]},"_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-core_1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a_1709894096219_0.9057697294424936"},"_hasShrinkwrap":false},"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":{"name":"@accounts/module-core","version":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","description":"Server side GraphQL transport for accounts","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/server":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"@graphql-tools/merge":"9.0.3","@graphql-tools/schema":"10.0.3","@graphql-tools/utils":"10.1.0","graphql-tag":"2.12.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@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","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-http":"1.22.0","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-core@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-2CaMHJEGA/qmONkSSR6Jl/2V0Cb84WCKJ/bcvzrZfsLN+IOdL7nhfDO6VIVSljqIpdEeRIDVRGmg5H1gu9Xaag==","shasum":"018b910e2f2b199feda90bd26fa43398fa605e96","tarball":"https://registry.npmjs.org/@accounts/module-core/-/module-core-1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3.tgz","fileCount":62,"unpackedSize":77240,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBuvWhxjs1tnpmp51vZzBBQo+wbKxvb/5LhxanX9ydjLAiBPFdaeFpmzKB3qtOLAgURiIEj2YVgM4gC94p90w3Oe9g=="}]},"_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-core_1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3_1709894965091_0.5635645224610153"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-13T10:30:56.864Z","0.34.0":"2023-09-13T10:30:57.222Z","modified":"2024-03-08T10:49:25.713Z","1.0.0-alpha-20231022085748-0910b9e1":"2023-10-22T09:04:37.081Z","1.0.0-alpha-20231106132410-d312ae00":"2023-11-06T13:28:12.267Z","1.0.0-alpha-20231106135626-1555665c":"2023-11-06T14:03:17.458Z","1.0.0-alpha-20231109134411-9db5d55b":"2023-11-09T13:48:18.692Z","1.0.0-alpha-20231110150116-1eb474da":"2023-11-10T15:07:44.317Z","1.0.0-alpha-20231110204039-4238958d":"2023-11-10T20:47:18.079Z","1.0.0-alpha-20231111101845-4f997913":"2023-11-11T10:22:51.726Z","1.0.0-alpha-20231111172350-25f6cb1d":"2023-11-11T17:27:59.202Z","1.0.0-alpha-20231113142902-7812b73b":"2023-11-13T14:33:07.556Z","1.0.0-alpha-20231115113719-ae2b53a9":"2023-11-15T11:41:25.072Z","1.0.0-alpha-20231115205645-aa630d56":"2023-11-15T21:00:50.504Z","1.0.0-alpha-20231116130548-67b64a6a":"2023-11-16T13:09:59.124Z","1.0.0-alpha-20231116132834-55ee2b96":"2023-11-16T13:32:38.430Z","1.0.0-alpha-20231119093904-9adfd014":"2023-11-19T09:43:15.134Z","1.0.0-alpha-20231119094526-b1fc68c7":"2023-11-19T09:49:32.099Z","1.0.0-alpha-20231120163547-4a461fcc":"2023-11-20T16:39:53.338Z","1.0.0-alpha-20231120164530-e14d6a81":"2023-11-20T16:49:37.367Z","1.0.0-alpha-20231121011122-60a60524":"2023-11-21T01:15:31.899Z","1.0.0-alpha-20231122105229-8edd073f":"2023-11-22T10:56:44.010Z","1.0.0-alpha-20231122120807-69a661e3":"2023-11-22T12:12:25.348Z","1.0.0-alpha-20231122192915-c0243667":"2023-11-22T19:33:32.095Z","1.0.0-alpha-20231123103003-4f0c2405":"2023-11-23T10:34:12.854Z","1.0.0-alpha-20231123122853-0ccafb9d":"2023-11-23T12:32:56.807Z","1.0.0-alpha-20231123131746-58399dcd":"2023-11-23T13:21:42.873Z","1.0.0-alpha-20231123183707-51335dc2":"2023-11-23T18:41:11.324Z","1.0.0-alpha-20231124142337-45cc4d05":"2023-11-24T14:27:50.114Z","1.0.0-alpha-20231127162849-b5b29d3d":"2023-11-27T16:33:02.788Z","1.0.0-alpha-20231127170705-4b0b3391":"2023-11-27T17:11:13.831Z","1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":"2023-11-30T10:53:00.940Z","1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":"2023-12-06T16:15:10.129Z","1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":"2023-12-13T12:13:57.225Z","1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":"2023-12-14T10:38:32.301Z","1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":"2023-12-19T11:08:33.075Z","1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":"2024-01-07T15:10:28.489Z","1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":"2024-01-07T16:17:26.116Z","1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":"2024-01-08T08:25:52.783Z","1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":"2024-01-08T08:34:22.197Z","1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":"2024-01-31T13:41:40.356Z","1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":"2024-01-31T13:50:10.601Z","1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":"2024-02-08T12:14:43.446Z","1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":"2024-02-08T12:25:08.385Z","1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":"2024-03-08T10:34:56.353Z","1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":"2024-03-08T10:49:25.246Z"},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"description":"Server side GraphQL transport for accounts","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":""}