{"_id":"@accounts/module-mikro-orm","_rev":"43-cb1a126352d5dea99d63e8022d0ff031","name":"@accounts/module-mikro-orm","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-mikro-orm","version":"0.34.0","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"^0.1.0","@accounts/mikro-orm":"^0.34.0","@accounts/module-core":"^0.34.0","@accounts/password":"^0.32.0","@accounts/server":"^0.32.0 || ^0.33.0","@accounts/types":"^0.32.0 || ^0.33.0","@mikro-orm/core":"^5.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/magic-link":"^0.1.1","@accounts/mikro-orm":"^0.34.0","@accounts/module-core":"^0.34.0","@accounts/password":"^0.32.1","@accounts/server":"^0.33.1","@accounts/types":"^0.33.2","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"2.3.6","@mikro-orm/cli":"5.8.1","@mikro-orm/core":"5.8.1","@mikro-orm/entity-generator":"5.8.1","@mikro-orm/knex":"5.8.1","@mikro-orm/migrations":"5.8.1","@mikro-orm/postgresql":"5.8.1","@mikro-orm/reflection":"5.8.1","@types/request-ip":"0.0.38","graphql":"16.8.0","graphql-modules":"2.2.0","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"gitHead":"3153375d7ba666e8bcbbfd28f3e07890cb58d5f3","_id":"@accounts/module-mikro-orm@0.34.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-NTYf9MiUHbTrTY5p0Q9rBxYJ+Ws8E4UkGtsKqovvsajG7O/sYYK87gZo3q4vdyzqoQxSUokd83x/mx9ac5Giww==","shasum":"2f63fff0107a1f24a8ac0cc916ca8a7386e7a60a","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-0.34.0.tgz","fileCount":22,"unpackedSize":19836,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB8UvSQJfNbYFxo58JhjbnZEjqERFDVkkVoRQXkk/ntgAiEA2Nps7E2e5G61AQLDS55thNnDrPtQaMAuSSgJIMTrWqk="}]},"_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-mikro-orm_0.34.0_1694601050226_0.9082591874492529"},"_hasShrinkwrap":false},"1.0.0-alpha-20231022085748-0910b9e1":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231022085748-0910b9e1","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/mikro-orm":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/module-core":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/password":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/server":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/types":"1.0.0-alpha-20231022085748-0910b9e1","@mikro-orm/core":"^5.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/magic-link":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/mikro-orm":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/module-core":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/password":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/server":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/types":"1.0.0-alpha-20231022085748-0910b9e1","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"5.8.10","@mikro-orm/core":"5.8.10","@mikro-orm/entity-generator":"5.8.10","@mikro-orm/knex":"5.8.10","@mikro-orm/migrations":"5.8.10","@mikro-orm/postgresql":"5.8.10","@mikro-orm/reflection":"5.8.10","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231018163544-36199b68","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-fhjuvUzOZ9U0NO8qiKXycfUIb7764Udgb4a4r3pLBUCNTqsuDDN+UPUpKeJLHLe6HIzWNUv0li3xCQfovqcD9g==","shasum":"8629bdbb4998635fbd9b38f022ef0410f85b784c","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231022085748-0910b9e1.tgz","fileCount":22,"unpackedSize":20409,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDAeU1N4PznOFl+mq/OKbR3Q8WFd5tikSyjRGeA7TpHsQIgIuV/l7pCqcJSgeHdtwP8bkjCPKkils2NQtrAcEdHiC8="}]},"_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-mikro-orm_1.0.0-alpha-20231022085748-0910b9e1_1697965448451_0.013559271473301493"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106132410-d312ae00":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231106132410-d312ae00","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231106132410-d312ae00","@accounts/mikro-orm":"1.0.0-alpha-20231106132410-d312ae00","@accounts/module-core":"1.0.0-alpha-20231106132410-d312ae00","@accounts/password":"1.0.0-alpha-20231106132410-d312ae00","@accounts/server":"1.0.0-alpha-20231106132410-d312ae00","@accounts/types":"1.0.0-alpha-20231106132410-d312ae00","@mikro-orm/core":"^5.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/magic-link":"1.0.0-alpha-20231106132410-d312ae00","@accounts/mikro-orm":"1.0.0-alpha-20231106132410-d312ae00","@accounts/module-core":"1.0.0-alpha-20231106132410-d312ae00","@accounts/password":"1.0.0-alpha-20231106132410-d312ae00","@accounts/server":"1.0.0-alpha-20231106132410-d312ae00","@accounts/types":"1.0.0-alpha-20231106132410-d312ae00","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"5.9.2","@mikro-orm/core":"5.9.2","@mikro-orm/entity-generator":"5.9.2","@mikro-orm/knex":"5.9.2","@mikro-orm/migrations":"5.9.2","@mikro-orm/postgresql":"5.9.2","@mikro-orm/reflection":"5.9.2","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231018163544-36199b68","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-wYUNSgyXXruWBBh2KnVX86sL/aOCpw4HLSpzaRhQvsEkotWz7L1Nf2QSQFTxKKXojPI+LT+aXFBJbbMQ0xF8WA==","shasum":"5cd7eabf1edc41e2117bc86bf765c167d786f239","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231106132410-d312ae00.tgz","fileCount":22,"unpackedSize":20402,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC+UXo/ZpPni/z7CdkIO//4b3bUMsNChijpfvuWbLox5gIhAMPZTzLvrmD9Xo5GndNEdOWBU5CZjz1EUJBRhtqgNkop"}]},"_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-mikro-orm_1.0.0-alpha-20231106132410-d312ae00_1699277278311_0.250009743278198"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106135626-1555665c":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231106135626-1555665c","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231106135626-1555665c","@accounts/mikro-orm":"1.0.0-alpha-20231106135626-1555665c","@accounts/module-core":"1.0.0-alpha-20231106135626-1555665c","@accounts/password":"1.0.0-alpha-20231106135626-1555665c","@accounts/server":"1.0.0-alpha-20231106135626-1555665c","@accounts/types":"1.0.0-alpha-20231106135626-1555665c","@mikro-orm/core":"^5.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/magic-link":"1.0.0-alpha-20231106135626-1555665c","@accounts/mikro-orm":"1.0.0-alpha-20231106135626-1555665c","@accounts/module-core":"1.0.0-alpha-20231106135626-1555665c","@accounts/password":"1.0.0-alpha-20231106135626-1555665c","@accounts/server":"1.0.0-alpha-20231106135626-1555665c","@accounts/types":"1.0.0-alpha-20231106135626-1555665c","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"5.9.2","@mikro-orm/core":"5.9.2","@mikro-orm/entity-generator":"5.9.2","@mikro-orm/knex":"5.9.2","@mikro-orm/migrations":"5.9.2","@mikro-orm/postgresql":"5.9.2","@mikro-orm/reflection":"5.9.2","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-PztManG/5GTb22fnjosZHfqcQHnw6kALr+ggwUJvQ9AxK/ztdcKHf7OFOBDdYdaOg2CjK/bx8btextsJmy7Bpw==","shasum":"8192d728736c173e6a9079179e222746ac679695","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231106135626-1555665c.tgz","fileCount":22,"unpackedSize":20402,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWpj5tSbco9/auNuJRyPAArT7qp/TC379tlKVhSdUZXwIgWl3YFeJPo6Hq45vE30gIyKxp5Mal57cMXJajkI0LqUs="}]},"_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-mikro-orm_1.0.0-alpha-20231106135626-1555665c_1699279370294_0.5665892582982492"},"_hasShrinkwrap":false},"1.0.0-alpha-20231109134411-9db5d55b":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231109134411-9db5d55b","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/mikro-orm":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/module-core":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/password":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/server":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/types":"1.0.0-alpha-20231109134411-9db5d55b","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/mikro-orm":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/module-core":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/password":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/server":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/types":"1.0.0-alpha-20231109134411-9db5d55b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-WnvEwO/SaC6Wfn/mE7Sq2H0X4uByge08hktFndO0Zx1PRr/cU+l5r0XKS78YpKclglqIfHqF8TLN2LND1K6VnQ==","shasum":"22144f9678663b567820d9708f397cce8ab2663f","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231109134411-9db5d55b.tgz","fileCount":22,"unpackedSize":20752,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCF3jnrgIKIxY1y2G3h7bweuBGc1WyUBUWtk2X0cnu/FQIgSBkPGG+8y/w8G3QQ3nE/xfUj68mGeeSqg1qE2Si1/WE="}]},"_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-mikro-orm_1.0.0-alpha-20231109134411-9db5d55b_1699537685773_0.1048889054513149"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110150116-1eb474da":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231110150116-1eb474da","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231110150116-1eb474da","@accounts/mikro-orm":"1.0.0-alpha-20231110150116-1eb474da","@accounts/module-core":"1.0.0-alpha-20231110150116-1eb474da","@accounts/password":"1.0.0-alpha-20231110150116-1eb474da","@accounts/server":"1.0.0-alpha-20231110150116-1eb474da","@accounts/types":"1.0.0-alpha-20231110150116-1eb474da","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231110150116-1eb474da","@accounts/mikro-orm":"1.0.0-alpha-20231110150116-1eb474da","@accounts/module-core":"1.0.0-alpha-20231110150116-1eb474da","@accounts/password":"1.0.0-alpha-20231110150116-1eb474da","@accounts/server":"1.0.0-alpha-20231110150116-1eb474da","@accounts/types":"1.0.0-alpha-20231110150116-1eb474da","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-F4qtXxwpxkPx9iI1FlbiafYXQIv2PhxfnHjopd0CH5SCnMjlCvjgOMIL8vKpTHloT6AQdkpPD6c1f3lfPbJRlw==","shasum":"b484abeab4fc9b622a257e0f572a95ae6a9a315a","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231110150116-1eb474da.tgz","fileCount":22,"unpackedSize":20752,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCFLCYdTHcy4YNHzl312BJolDi6WwWb69oO4AIaE2wbzwIgYp8/MR113Z3JliOfR5fjIa/Ci8HIDEg02XvLGlZgn1M="}]},"_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-mikro-orm_1.0.0-alpha-20231110150116-1eb474da_1699628837596_0.10687418798226367"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110204039-4238958d":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231110204039-4238958d","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231110204039-4238958d","@accounts/mikro-orm":"1.0.0-alpha-20231110204039-4238958d","@accounts/module-core":"1.0.0-alpha-20231110204039-4238958d","@accounts/password":"1.0.0-alpha-20231110204039-4238958d","@accounts/server":"1.0.0-alpha-20231110204039-4238958d","@accounts/types":"1.0.0-alpha-20231110204039-4238958d","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231110204039-4238958d","@accounts/mikro-orm":"1.0.0-alpha-20231110204039-4238958d","@accounts/module-core":"1.0.0-alpha-20231110204039-4238958d","@accounts/password":"1.0.0-alpha-20231110204039-4238958d","@accounts/server":"1.0.0-alpha-20231110204039-4238958d","@accounts/types":"1.0.0-alpha-20231110204039-4238958d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-kkXFOo1xTn7sLvGhVU1hdDb8XIXb8t9qEEcVdC1a7HHP8un1ORLY3w7gINNM2f7Y3h5dug2jCmTws2Z1BeKb/A==","shasum":"b88eb435dcde830a424b92e02c117c96c10be8c7","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231110204039-4238958d.tgz","fileCount":22,"unpackedSize":20752,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE0/2/H1XpSqscNPMEPBE3ZZApQ9gYD6yES/iwj7SIUnAiEA8decn5iR0CCV/NjtArY2ZnfidSHkhGr3DWL+pRDw3II="}]},"_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-mikro-orm_1.0.0-alpha-20231110204039-4238958d_1699649209398_0.5436856513665829"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111101845-4f997913":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231111101845-4f997913","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231111101845-4f997913","@accounts/mikro-orm":"1.0.0-alpha-20231111101845-4f997913","@accounts/module-core":"1.0.0-alpha-20231111101845-4f997913","@accounts/password":"1.0.0-alpha-20231111101845-4f997913","@accounts/server":"1.0.0-alpha-20231111101845-4f997913","@accounts/types":"1.0.0-alpha-20231111101845-4f997913","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231111101845-4f997913","@accounts/mikro-orm":"1.0.0-alpha-20231111101845-4f997913","@accounts/module-core":"1.0.0-alpha-20231111101845-4f997913","@accounts/password":"1.0.0-alpha-20231111101845-4f997913","@accounts/server":"1.0.0-alpha-20231111101845-4f997913","@accounts/types":"1.0.0-alpha-20231111101845-4f997913","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-X1aZ7efbm2VmGdO9mu3Rut9pMpcOq8sgmsddRLDbIGJHV0HPbflXGYOJ35DLojuyOxYHV+jKCNqMx6NQKG30fg==","shasum":"e39482b192a5529d7d7691545ace2a68bacf389d","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231111101845-4f997913.tgz","fileCount":22,"unpackedSize":20752,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC6lsMC0tJ7xKT5+5kc8SeZ6Qlq4oLGSF4tsZDySqHb/QIhANO9G85GZ3TSZdfRIBE2zY7BkEXJ3pVcUuGAseIKNNv8"}]},"_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-mikro-orm_1.0.0-alpha-20231111101845-4f997913_1699698159060_0.9480304230835177"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111172350-25f6cb1d":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231111172350-25f6cb1d","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/mikro-orm":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/module-core":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/password":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/server":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/types":"1.0.0-alpha-20231111172350-25f6cb1d","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/mikro-orm":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/module-core":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/password":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/server":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/types":"1.0.0-alpha-20231111172350-25f6cb1d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-wE6pZlyF/3vfpleyYKf4ouA0wRJFv0R0vYQ2uIvQwan4zoiK1z6AXhc4KnnAs8kuBBEthYFLc20WZxRaEi9UcQ==","shasum":"3c9ee6a6bf85d103647ab892f67336033c825644","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231111172350-25f6cb1d.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBmvacmSHyuuRwQnPVy3z/83p6dpmxWJw7X5DWBwrMWPAiBAcNrvvb5VYd4AJEGLKoxWw6AwOqbPtaTBwaB5csNrGw=="}]},"_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-mikro-orm_1.0.0-alpha-20231111172350-25f6cb1d_1699723665522_0.5448433240890966"},"_hasShrinkwrap":false},"1.0.0-alpha-20231113142902-7812b73b":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231113142902-7812b73b","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231113142902-7812b73b","@accounts/mikro-orm":"1.0.0-alpha-20231113142902-7812b73b","@accounts/module-core":"1.0.0-alpha-20231113142902-7812b73b","@accounts/password":"1.0.0-alpha-20231113142902-7812b73b","@accounts/server":"1.0.0-alpha-20231113142902-7812b73b","@accounts/types":"1.0.0-alpha-20231113142902-7812b73b","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231113142902-7812b73b","@accounts/mikro-orm":"1.0.0-alpha-20231113142902-7812b73b","@accounts/module-core":"1.0.0-alpha-20231113142902-7812b73b","@accounts/password":"1.0.0-alpha-20231113142902-7812b73b","@accounts/server":"1.0.0-alpha-20231113142902-7812b73b","@accounts/types":"1.0.0-alpha-20231113142902-7812b73b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-RuS4Vn69Sk+kS7imK2mhrj+ri43+tQePpuUW9y32F6Ifu3p9DiJoQ3TW18DpmYFmUGQuDXDhKb6tiFwUrodhjA==","shasum":"a00f02471db15e6797eb454a97e11b11d1127281","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231113142902-7812b73b.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGEuYSuABmgpH18Oa3R5ixAY8brwujw1qzd3orULvFQtAiAULaMRG+DTneiZ84XwoPj0b2vYuvzP0IBwul7oLuipJg=="}]},"_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-mikro-orm_1.0.0-alpha-20231113142902-7812b73b_1699885973097_0.9681227688204299"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115113719-ae2b53a9":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231115113719-ae2b53a9","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/mikro-orm":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/module-core":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/password":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/server":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/types":"1.0.0-alpha-20231115113719-ae2b53a9","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/mikro-orm":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/module-core":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/password":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/server":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/types":"1.0.0-alpha-20231115113719-ae2b53a9","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-kCCNVK/R8r4L/mBSa4ZwcVF54HiIOEPeLl6PLHoqvthLJOVkZyvwyAgdBz1j0PpmXE9iRklgSVr9K90EZwOlTA==","shasum":"5bbc29d15c9d5bac8a90f004a00cd134a194502b","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231115113719-ae2b53a9.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEkeS1JnQPIx9izvL34LVKADekzsHIdbyDT4csTy2jhBAiEAgm64DSLwAtEd4wwO9Q/1D25w4Xsj+IaKqSR+2FSeFuU="}]},"_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-mikro-orm_1.0.0-alpha-20231115113719-ae2b53a9_1700048470597_0.6614363384718491"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115205645-aa630d56":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231115205645-aa630d56","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231115205645-aa630d56","@accounts/mikro-orm":"1.0.0-alpha-20231115205645-aa630d56","@accounts/module-core":"1.0.0-alpha-20231115205645-aa630d56","@accounts/password":"1.0.0-alpha-20231115205645-aa630d56","@accounts/server":"1.0.0-alpha-20231115205645-aa630d56","@accounts/types":"1.0.0-alpha-20231115205645-aa630d56","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231115205645-aa630d56","@accounts/mikro-orm":"1.0.0-alpha-20231115205645-aa630d56","@accounts/module-core":"1.0.0-alpha-20231115205645-aa630d56","@accounts/password":"1.0.0-alpha-20231115205645-aa630d56","@accounts/server":"1.0.0-alpha-20231115205645-aa630d56","@accounts/types":"1.0.0-alpha-20231115205645-aa630d56","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-iUcm0JOBZE3O6GbEwit7mj53kEwbLu12nGVNsDMraAJaXgt31t8SDP/lvYg4xL+eG/8PYQxfcXDJq+8CFq1QxQ==","shasum":"617869c2935b6ad31d2c3c4ffaf5d5277d45b4fb","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231115205645-aa630d56.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFks71nTGK2QDq3WMwbR6CxgQ6ItwmItMOv4iMLWKMbnAiBiemRsrNpU87Z6HwjdIHcashN2x6bwbl0Gxvh9HL3Lzw=="}]},"_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-mikro-orm_1.0.0-alpha-20231115205645-aa630d56_1700082037752_0.7772428289763393"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116130548-67b64a6a":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231116130548-67b64a6a","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/mikro-orm":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/module-core":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/password":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/server":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/types":"1.0.0-alpha-20231116130548-67b64a6a","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/mikro-orm":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/module-core":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/password":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/server":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/types":"1.0.0-alpha-20231116130548-67b64a6a","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-pnqY8Kv3BIIEr//Am+nPU0yntSSa8FffMc+TKsTjrzs7FVaeiERUK5EzFqh4s7fVoFa5tzPBaK3E31urXC6xeA==","shasum":"8d93ad7315d113594df071f2980df078d355902b","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231116130548-67b64a6a.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBmBi4d1wnIrhG9XyU0y4t9k1cAlTw4GOfTZ+ia6ejBBAiEA3PDVq5MtzP1PJhz4MSpyZFrKmTkzHO1yWTcVG5i1bZI="}]},"_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-mikro-orm_1.0.0-alpha-20231116130548-67b64a6a_1700140186401_0.06625127606139669"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116132834-55ee2b96":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231116132834-55ee2b96","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/mikro-orm":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/module-core":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/password":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/server":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/types":"1.0.0-alpha-20231116132834-55ee2b96","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/mikro-orm":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/module-core":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/password":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/server":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/types":"1.0.0-alpha-20231116132834-55ee2b96","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-Rpms5zsQchcARmwaLdoovCyfYHvDYHyLanXOcg/BwrD8RYyC9SDHBJ4nuwqOJaFODVcXQHMtZyOZXuplQ6htPg==","shasum":"37165dfa61e9a8beb429e45465193373db6331c3","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231116132834-55ee2b96.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHDwTmmFr9TWlTg6iZF0L37GPLg2KY1070kUgLdHt/ZSAiEAzQvavmUGFcIUKWaKYbmQO5fFYDRV6f/ziVWRhhxqe2Y="}]},"_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-mikro-orm_1.0.0-alpha-20231116132834-55ee2b96_1700141548031_0.35792420152039894"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119093904-9adfd014":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231119093904-9adfd014","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231119093904-9adfd014","@accounts/mikro-orm":"1.0.0-alpha-20231119093904-9adfd014","@accounts/module-core":"1.0.0-alpha-20231119093904-9adfd014","@accounts/password":"1.0.0-alpha-20231119093904-9adfd014","@accounts/server":"1.0.0-alpha-20231119093904-9adfd014","@accounts/types":"1.0.0-alpha-20231119093904-9adfd014","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231119093904-9adfd014","@accounts/mikro-orm":"1.0.0-alpha-20231119093904-9adfd014","@accounts/module-core":"1.0.0-alpha-20231119093904-9adfd014","@accounts/password":"1.0.0-alpha-20231119093904-9adfd014","@accounts/server":"1.0.0-alpha-20231119093904-9adfd014","@accounts/types":"1.0.0-alpha-20231119093904-9adfd014","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-5gZV346KWZ4c5/Mtc8fJF+n3AiCkHo1WOC6ichv77GyvZq+iiprZgvJT2ONh4oKdgJBqanfYzS40BliLKA9dqQ==","shasum":"06d7482fb81cbace29ca6f6af904c7e8015db164","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231119093904-9adfd014.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAzfPQ9JMqK9whmiFa7spTWHMglUOLK6vnQn3joiuSR8AiAuF7Ghg1vRKJmZSdVdxmhWHpZNzit/TYxt3X5UGCpiHw=="}]},"_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-mikro-orm_1.0.0-alpha-20231119093904-9adfd014_1700386982107_0.823610323118555"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119094526-b1fc68c7":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231119094526-b1fc68c7","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/mikro-orm":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/module-core":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/password":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/server":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/types":"1.0.0-alpha-20231119094526-b1fc68c7","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/mikro-orm":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/module-core":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/password":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/server":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/types":"1.0.0-alpha-20231119094526-b1fc68c7","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-KnbboLDecMqek4qn3Yko3XHtXt/3ffnaYYKtzRk4bxHFql0Kt7CA303dOzUPUUBdDpp70wAJmUU891ii4A7e9w==","shasum":"16598433af98d0762772e1569f3273d6f04eb448","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231119094526-b1fc68c7.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAZwgXYZwaTOSMrwlCHqU4aTqOqeR/1h7ONj8NNm8xc8AiAF6FQSzlIMnwjNxXl44X+/cdSDQOnwwoTQDWVpeJm8+A=="}]},"_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-mikro-orm_1.0.0-alpha-20231119094526-b1fc68c7_1700387355985_0.8409717331037028"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120163547-4a461fcc":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231120163547-4a461fcc","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/mikro-orm":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/module-core":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/password":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/server":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/types":"1.0.0-alpha-20231120163547-4a461fcc","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/mikro-orm":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/module-core":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/password":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/server":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/types":"1.0.0-alpha-20231120163547-4a461fcc","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-1Emm8bSHNf6Ad0WTyq7t9s01CiQj/9PIAoVVMZsl0QjeRS9xrPQwtJCkhOg2hr65V9ZPeAYSHpU2QWwFwaOs9w==","shasum":"33a456fbcffe88f30f84334c4d5cb2d54da09b12","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231120163547-4a461fcc.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCIC4BD6jiFg6Dgw2jo8HmhJ4xGTM3L+oOdA5sIC6uB+L8Ah8MXj+0tCpmzwNV+Ky1hXZy6Xozkvc8n9PDZGqF2yz8"}]},"_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-mikro-orm_1.0.0-alpha-20231120163547-4a461fcc_1700498377656_0.8529708780965906"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120164530-e14d6a81":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231120164530-e14d6a81","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/mikro-orm":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/module-core":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/password":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/server":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/types":"1.0.0-alpha-20231120164530-e14d6a81","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/mikro-orm":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/module-core":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/password":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/server":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/types":"1.0.0-alpha-20231120164530-e14d6a81","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-HpXk/rvWAeikk8Ucbf2tmdvrfLMfkHs9xZfDTFUnPzlTDUiWSp0vUMfy6FfsyZ0uiXd23+V2C7g1/9kmwGloCg==","shasum":"b2c462d7c33beee4296e1e3130eba210178ecda2","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231120164530-e14d6a81.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICbF/u0XnpsNrQCJahDrSl/JIEY7PLYFVi8jZ4R85rsgAiEA2AVvaqmlac6Z4TTOsREKpvLmmK48DLVJpzhgssszTsM="}]},"_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-mikro-orm_1.0.0-alpha-20231120164530-e14d6a81_1700498962196_0.0020966885183002493"},"_hasShrinkwrap":false},"1.0.0-alpha-20231121011122-60a60524":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231121011122-60a60524","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231121011122-60a60524","@accounts/mikro-orm":"1.0.0-alpha-20231121011122-60a60524","@accounts/module-core":"1.0.0-alpha-20231121011122-60a60524","@accounts/password":"1.0.0-alpha-20231121011122-60a60524","@accounts/server":"1.0.0-alpha-20231121011122-60a60524","@accounts/types":"1.0.0-alpha-20231121011122-60a60524","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231121011122-60a60524","@accounts/mikro-orm":"1.0.0-alpha-20231121011122-60a60524","@accounts/module-core":"1.0.0-alpha-20231121011122-60a60524","@accounts/password":"1.0.0-alpha-20231121011122-60a60524","@accounts/server":"1.0.0-alpha-20231121011122-60a60524","@accounts/types":"1.0.0-alpha-20231121011122-60a60524","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.151","@mikro-orm/core":"6.0.0-dev.151","@mikro-orm/entity-generator":"6.0.0-dev.151","@mikro-orm/knex":"6.0.0-dev.151","@mikro-orm/migrations":"6.0.0-dev.151","@mikro-orm/postgresql":"6.0.0-dev.151","@mikro-orm/reflection":"6.0.0-dev.151","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-RaQIsmsunNnaYCDxwK6LZFJNHWPbSAmz0454aXJ+08a7LniZFMqVYLL+8V+Wivx62X2ZOgd3kWT7HM7q7kZRvw==","shasum":"5aa0b52f353fa5209632b560a96aa9f30c3b9fd0","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231121011122-60a60524.tgz","fileCount":22,"unpackedSize":21077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHqe1u5PiI1FMgLkWGBuyM8FshxUMDkXhBBkMvbIKY5yAiEAs8KMcfIXdAUZo2AkYuEn48WFlP2GXnuZ0Klfnqyu/h0="}]},"_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-mikro-orm_1.0.0-alpha-20231121011122-60a60524_1700529320653_0.11848037982452175"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122105229-8edd073f":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231122105229-8edd073f","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231122105229-8edd073f","@accounts/mikro-orm":"1.0.0-alpha-20231122105229-8edd073f","@accounts/module-core":"1.0.0-alpha-20231122105229-8edd073f","@accounts/password":"1.0.0-alpha-20231122105229-8edd073f","@accounts/server":"1.0.0-alpha-20231122105229-8edd073f","@accounts/types":"1.0.0-alpha-20231122105229-8edd073f","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231122105229-8edd073f","@accounts/mikro-orm":"1.0.0-alpha-20231122105229-8edd073f","@accounts/module-core":"1.0.0-alpha-20231122105229-8edd073f","@accounts/password":"1.0.0-alpha-20231122105229-8edd073f","@accounts/server":"1.0.0-alpha-20231122105229-8edd073f","@accounts/types":"1.0.0-alpha-20231122105229-8edd073f","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.195","@mikro-orm/core":"6.0.0-dev.195","@mikro-orm/entity-generator":"6.0.0-dev.195","@mikro-orm/knex":"6.0.0-dev.195","@mikro-orm/migrations":"6.0.0-dev.195","@mikro-orm/postgresql":"6.0.0-dev.195","@mikro-orm/reflection":"6.0.0-dev.195","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-Mu3dCNnqtCMI9sK2RkbK4mFnKvXXLMjtB3aONTWwEZA4jxE+XF5nmaWpGnwp7glk0iIywj97FkAO29651v8TjQ==","shasum":"56d6122941d19e62e8834f22e3f1b7bf6c443dc6","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231122105229-8edd073f.tgz","fileCount":22,"unpackedSize":21087,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC/sy7VmCozPJxYxhGB4YNHk/iumZNwKoV0LMuSqJgByAiBRnX/J78OM150lOO/W6mf3X6Ozia4nBVtKnpXin8NZMw=="}]},"_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-mikro-orm_1.0.0-alpha-20231122105229-8edd073f_1700650589884_0.7232677941044423"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122120807-69a661e3":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231122120807-69a661e3","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/magic-link":"1.0.0-alpha-20231122120807-69a661e3","@accounts/mikro-orm":"1.0.0-alpha-20231122120807-69a661e3","@accounts/module-core":"1.0.0-alpha-20231122120807-69a661e3","@accounts/password":"1.0.0-alpha-20231122120807-69a661e3","@accounts/server":"1.0.0-alpha-20231122120807-69a661e3","@accounts/types":"1.0.0-alpha-20231122120807-69a661e3","@mikro-orm/core":"^6.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/magic-link":"1.0.0-alpha-20231122120807-69a661e3","@accounts/mikro-orm":"1.0.0-alpha-20231122120807-69a661e3","@accounts/module-core":"1.0.0-alpha-20231122120807-69a661e3","@accounts/password":"1.0.0-alpha-20231122120807-69a661e3","@accounts/server":"1.0.0-alpha-20231122120807-69a661e3","@accounts/types":"1.0.0-alpha-20231122120807-69a661e3","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@mikro-orm/cli":"6.0.0-dev.195","@mikro-orm/core":"6.0.0-dev.195","@mikro-orm/entity-generator":"6.0.0-dev.195","@mikro-orm/knex":"6.0.0-dev.195","@mikro-orm/migrations":"6.0.0-dev.195","@mikro-orm/postgresql":"6.0.0-dev.195","@mikro-orm/reflection":"6.0.0-dev.195","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6","reflect-metadata":"0.1.13"},"_id":"@accounts/module-mikro-orm@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-dLi9GifR95myffDd0DvblMcVBu8TmXFTqJhjJaGnUsx5dBCHeDLxrmzlt5/ZED4uYKps3XqVDxh43LqUc18ukw==","shasum":"763c3c59e0cd1d41906b0dfaaa8a209cdaf7da8f","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231122120807-69a661e3.tgz","fileCount":22,"unpackedSize":21281,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCrbjdoJubqxCTm4MweuNqTpMyzYt85Gl/iS6cwSmzHqgIhAJLNcBe9Wkixdyk5WCgdVEiyiXaGhIv6WHvmOPs7lUeA"}]},"_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-mikro-orm_1.0.0-alpha-20231122120807-69a661e3_1700655132134_0.5479552526126727"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122192915-c0243667":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231122192915-c0243667","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231122192915-c0243667","@accounts/module-core":"1.0.0-alpha-20231122192915-c0243667","@accounts/server":"1.0.0-alpha-20231122192915-c0243667","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231122192915-c0243667","@accounts/module-core":"1.0.0-alpha-20231122192915-c0243667","@accounts/server":"1.0.0-alpha-20231122192915-c0243667","@accounts/types":"1.0.0-alpha-20231122192915-c0243667","@mikro-orm/core":"6.0.0-dev.195","@mikro-orm/migrations":"6.0.0-dev.195","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-EJ8MdbJb6H3V6m9NMWTl5bqGOAB6g//YZFfa1Zb+1oyjzZ1YgsS23Tce37Uh/iakaP+qnSrdePE/cSuEcYEV8Q==","shasum":"2ca739981e410b70961b452ac46930fde02fb7c3","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231122192915-c0243667.tgz","fileCount":22,"unpackedSize":20147,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAJQ+Vr5vIHS597QxfuGw5YIdWKsSOFhzux6lDDnyPEFAiEA4WRvm5nrHNjREE9TqcdhL7JlTdCOCg+oP+6BOalsZzc="}]},"_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-mikro-orm_1.0.0-alpha-20231122192915-c0243667_1700681597025_0.4440485746859557"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123103003-4f0c2405":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231123103003-4f0c2405","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/module-core":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/server":"1.0.0-alpha-20231123103003-4f0c2405","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/module-core":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/server":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/types":"1.0.0-alpha-20231123103003-4f0c2405","@mikro-orm/core":"6.0.0-dev.195","@mikro-orm/migrations":"6.0.0-dev.195","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-MKTV+JakNIMaJaw5bIXVs9+b6Y8MCMNLKi3MOk8guBt3Il4ORG6aSinpTJqKWhjthA4jddMHfz9lIu+XYlUuPQ==","shasum":"ea3f6ef50b3547ca37a17cabcd780f5bb25b432d","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231123103003-4f0c2405.tgz","fileCount":22,"unpackedSize":20147,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAftKPpH4LdfXdElsaXc5YN+zLFK27IsPRkChAEhXrKsAiEArSARCwLNcDHFCWQod24wtinXOKOeIjPbLnaXHNDJCPI="}]},"_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-mikro-orm_1.0.0-alpha-20231123103003-4f0c2405_1700735637073_0.3241473662112506"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123122853-0ccafb9d":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231123122853-0ccafb9d","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/module-core":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/server":"1.0.0-alpha-20231123122853-0ccafb9d","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/module-core":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/server":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/types":"1.0.0-alpha-20231123122853-0ccafb9d","@mikro-orm/core":"6.0.0-dev.195","@mikro-orm/migrations":"6.0.0-dev.195","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-ejnqfLeKL3wPpqFrRQRDGaXtmZ1OuL2jlcOLbWjIIuRPTi/xOKDBy9zMxqv0KLnQS9x1p92kmK0AciFOQzFFxw==","shasum":"37053b32a7517d5ba5be36e4399b2a612ec0066a","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231123122853-0ccafb9d.tgz","fileCount":22,"unpackedSize":20147,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD6+buCEC5jULxFiYItQ1EBn3KpQaAtLGAcNzKlStGxIAIhAPTWpR/8DM0y5TE2LCbAoiE2TEmv56I2FU4ZZIZupPOi"}]},"_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-mikro-orm_1.0.0-alpha-20231123122853-0ccafb9d_1700742762050_0.5458595958511996"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123131746-58399dcd":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231123131746-58399dcd","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231123131746-58399dcd","@accounts/module-core":"1.0.0-alpha-20231123131746-58399dcd","@accounts/server":"1.0.0-alpha-20231123131746-58399dcd","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231123131746-58399dcd","@accounts/module-core":"1.0.0-alpha-20231123131746-58399dcd","@accounts/server":"1.0.0-alpha-20231123131746-58399dcd","@accounts/types":"1.0.0-alpha-20231123131746-58399dcd","@mikro-orm/core":"6.0.0-dev.195","@mikro-orm/migrations":"6.0.0-dev.195","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-GG2DQktTBxpeUs/seAraQTnxY0nPXNViGc2ycbGRiABqFWcTyyUq6yEqjcCmoplpcsxPSCA8rRdRwL+pbL9dDg==","shasum":"42dbb9b905de62fb09fcbd3e3b101b55164d533f","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231123131746-58399dcd.tgz","fileCount":22,"unpackedSize":20147,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/IxKJhcX+wAviXj8MnBED/NkHhEB8ylA5qUixFG3RAQIhAMWRD+huWbV/hXPXAFjBCou7Mw88IkTGYXkjq/6LiLYP"}]},"_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-mikro-orm_1.0.0-alpha-20231123131746-58399dcd_1700745701728_0.7990221349630742"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123183707-51335dc2":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231123183707-51335dc2","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231123183707-51335dc2","@accounts/module-core":"1.0.0-alpha-20231123183707-51335dc2","@accounts/server":"1.0.0-alpha-20231123183707-51335dc2","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231123183707-51335dc2","@accounts/module-core":"1.0.0-alpha-20231123183707-51335dc2","@accounts/server":"1.0.0-alpha-20231123183707-51335dc2","@accounts/types":"1.0.0-alpha-20231123183707-51335dc2","@mikro-orm/core":"6.0.0-dev.195","@mikro-orm/migrations":"6.0.0-dev.195","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-UZgt4jlC8obJcqD2SK4iJENgniNxMtH/tyUWDS1XlDql6wgAFAomeXw/QiDS/tq373g/Rie38BYgJ7Z/VQ9KwA==","shasum":"cae821e09f3decfdce6dbe9c9195b0c4052784b6","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231123183707-51335dc2.tgz","fileCount":22,"unpackedSize":20147,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEZK+/y7owAXuEYjEdU1p/Bj2OaKiKESKLmIV9kEAyMwAiAQoNvKMvz1eDozaNygQP1SLp5n96sxyeqGtXBdT2bewQ=="}]},"_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-mikro-orm_1.0.0-alpha-20231123183707-51335dc2_1700764859277_0.18903556611650996"},"_hasShrinkwrap":false},"1.0.0-alpha-20231124142337-45cc4d05":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231124142337-45cc4d05","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/module-core":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/server":"1.0.0-alpha-20231124142337-45cc4d05","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/module-core":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/server":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/types":"1.0.0-alpha-20231124142337-45cc4d05","@mikro-orm/core":"6.0.0-dev.195","@mikro-orm/migrations":"6.0.0-dev.195","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-VTEPg1nzfajYC0glWLz8RlF+BrpRI5xUjNj9S2nHnlgdndysJMrZo6OyNCjmdb3SUjjKYsQTWD2YxuJpOsuZNA==","shasum":"30062615064072cde7411b06612f6d2a0e648699","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231124142337-45cc4d05.tgz","fileCount":22,"unpackedSize":20147,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQClMV4GVN7c9vQK7gvEnEZjmsnU3sCDzP17MHzFkwOkigIgCgHoegFBHeT/olmCfDV71pfR+R9B+cGmEjA+Q6C1q6k="}]},"_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-mikro-orm_1.0.0-alpha-20231124142337-45cc4d05_1700836056009_0.4019356768784883"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127162849-b5b29d3d":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231127162849-b5b29d3d","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/module-core":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/server":"1.0.0-alpha-20231127162849-b5b29d3d","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/module-core":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/server":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/types":"1.0.0-alpha-20231127162849-b5b29d3d","@mikro-orm/core":"6.0.0-dev.220","@mikro-orm/migrations":"6.0.0-dev.220","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-SGL8xNpEWmj9+ABFROZT8MTHcW4EevsllNNIofdf7Cr2vHBM2VbQ+SiAQiHm1e/R68pze7/MIjbMKgltUl+hGA==","shasum":"707ea380518e49d2aa75461a173aa875bbb7c177","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231127162849-b5b29d3d.tgz","fileCount":22,"unpackedSize":20147,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCgVmX6rnvN1NWjYwlNyMUPpxo+3jvABQ8pVHbzsAJpuAIgSCaHWf2ceCZeHF11LGEPbn6/pVPMCDw2msM0XZuG9Lc="}]},"_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-mikro-orm_1.0.0-alpha-20231127162849-b5b29d3d_1701102769452_0.9983865836265362"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127170705-4b0b3391":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231127170705-4b0b3391","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/module-core":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/server":"1.0.0-alpha-20231127170705-4b0b3391","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/module-core":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/server":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/types":"1.0.0-alpha-20231127170705-4b0b3391","@mikro-orm/core":"6.0.0-dev.220","@mikro-orm/migrations":"6.0.0-dev.220","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-iet6BGqp3tnycmGHWZtsD/wvvQ3HPASxp1d6qXMQLnSlQsGSKpu9fx9KE2HFteToR9f585/9GvAjbAC/uSIo/Q==","shasum":"63c64e3d81c68917f8e89d2618d5746d896147d6","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231127170705-4b0b3391.tgz","fileCount":22,"unpackedSize":20193,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCJZlmEPNR2hxn0IXTP7cSFccPd923HqhOne1O2S8hfpwIgL3vNAsFbINy+cxlztJFl8YzKWBRnXTjOcJza4nMPBSc="}]},"_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-mikro-orm_1.0.0-alpha-20231127170705-4b0b3391_1701105063204_0.8979294128490918"},"_hasShrinkwrap":false},"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/module-core":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/server":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/module-core":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/server":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/types":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@mikro-orm/core":"6.0.0-dev.220","@mikro-orm/migrations":"6.0.0-dev.220","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-JiUQr9mTgQfIEYgG/FOtFAZwno32ExacZhQkh1FKoCkulpm3ctGes6Y05m4TFgypOBGVwvXtw6VogexBwm5ZxQ==","shasum":"0b153d35a2f2384943840aa21fca4fa3a740d245","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165.tgz","fileCount":22,"unpackedSize":20449,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFL1gcARHmfKWEOs2IGN6HOFfuVL6t67NrM2dqAFI12FAiEA68aTy9byIRB3rALT2xiSgWiigLpiDCGiupo7bflZgHc="}]},"_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-mikro-orm_1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165_1701341568735_0.6463709756088947"},"_hasShrinkwrap":false},"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/module-core":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/server":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/module-core":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/server":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/types":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@mikro-orm/core":"6.0.0-dev.234","@mikro-orm/migrations":"6.0.0-dev.234","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-4esQP4Wg+ppsH/15kLAAdwnwuHx8NkkTztUnhixCW77M0H2lrq2GlY1ZISX6bDGGtbKE6jyQlabtCn/ZXjfGDA==","shasum":"2bd3c03e1aa547bcdaff4b5b196098dcd69fcefb","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db.tgz","fileCount":22,"unpackedSize":20449,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDHT/8598KpuWWAx3h5ZM2i1/xrls/aZAkgpz5Mj8+0QAIgCLQvBy8f7EnOnP+z9z5ufB+Sq22APYSqU9K1DC1R0JY="}]},"_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-mikro-orm_1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db_1701879298745_0.19488602456065762"},"_hasShrinkwrap":false},"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/module-core":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/server":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/module-core":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/server":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/types":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@mikro-orm/core":"6.0.0-dev.252","@mikro-orm/migrations":"6.0.0-dev.252","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-jssZf6X12stU6hZ7uFUFR55ANwZgdoNyR+GeubTjUrwSbrc89N03NM0bYKCdJ2e9uXCjdknkimQOTZy2tB1NdA==","shasum":"03033ad4b8e817cdfed44d10017d2b7bed445835","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b.tgz","fileCount":22,"unpackedSize":20449,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFkMc5VzNizOWqq5H7MMcK5q55c2qSAHHtq8J5mRLHDqAiA4hLbpO6kgl1qvSPGiiB2PGgUrouIDjKIvMmAc/Zlx4A=="}]},"_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-mikro-orm_1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b_1702469622848_0.639328974710849"},"_hasShrinkwrap":false},"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/module-core":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/server":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/module-core":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/server":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/types":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@mikro-orm/core":"6.0.0-dev.261","@mikro-orm/migrations":"6.0.0-dev.261","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-FxSU6WSYMAFWd6c1L8k3ngeaUXjLtgCK74RmeAJWlPqpN2edz45PpeuZD5lcbvSzruWriMv30WiVuMWiJu2B7Q==","shasum":"c8f12bf3e41b7ef4baa615a93dd65874afe1428e","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd.tgz","fileCount":22,"unpackedSize":20449,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDo8nyhKu77OkevxdCxk9YyKpRwCzsmY2VmzRwIQEPsfAIhAPC/czlWHHvM63fdlGlr9aoGuZBJ8YP290tyd7Ef1EZq"}]},"_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-mikro-orm_1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd_1702550297488_0.762246919228174"},"_hasShrinkwrap":false},"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/module-core":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/server":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/module-core":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/server":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/types":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@mikro-orm/core":"6.0.0-dev.283","@mikro-orm/migrations":"6.0.0-dev.283","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-21HAyKPeID3H2vzPro4zssyW/piDnquY62STuHaf6pcB3+qFCr3jT8BDhZfu3QU98b6tHYWzIr7xXUakKcYDIA==","shasum":"f9ec5ea3d1e3cfa799bdb1146faf11cd58bfee6f","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9.tgz","fileCount":22,"unpackedSize":20449,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIECblRnVOCjtRM2qSb5BSigWAEo+WNAimtVXADaW3NMRAiEAwGPny3rz98vGJu5jtwlcEyemZpKZRgB//31Rgdvj1PU="}]},"_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-mikro-orm_1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9_1702984097217_0.6964650841048317"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/module-core":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/server":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/module-core":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/server":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/types":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@mikro-orm/core":"6.0.0-dev.320","@mikro-orm/migrations":"6.0.0-dev.320","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-pZFV+U3RYylNN0kYg7WAiSu27Pgffe4HcLNuq+Idv+9ZH6oRlxqMrvBpN1ov4wCCgIk/jKhDMKwqYTr/qIBWTw==","shasum":"08ac78c411335832ca018c8ba3dccecacd8e3a06","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b.tgz","fileCount":22,"unpackedSize":20449,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDfoqdE38pZQpg89wMh2rB6UZ3/s7twP5SSnOWexExCrAIhAJc7tr+mWcaB2EghAM4jHJWvqK7Opvc/khM7aCBnSYDv"}]},"_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-mikro-orm_1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b_1704640214524_0.6705521174324245"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/module-core":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/server":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/module-core":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/server":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/types":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@mikro-orm/core":"6.0.0-dev.321","@mikro-orm/migrations":"6.0.0-dev.321","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-AWcVLIjMpuJyN0hHIg7ObzRZkG5QfpR+yHNznQmNpbrLpZ69+G/T/gUsWBF/8+R5Dq/vlOdpbdX7Plnh9Cx0YQ==","shasum":"85d5155b3418891016d95416a8ceb7aa7c49ab1e","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59.tgz","fileCount":22,"unpackedSize":20449,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDb/AWndC5dc8bjcqh5EQFchkEYHDkwa3XPP07FW/0ynAIhAIMvSgltl2TL5H1dfcENLBkY7mEFDAnp/0ZlBto5M9yW"}]},"_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-mikro-orm_1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59_1704644231890_0.4350704710507818"},"_hasShrinkwrap":false},"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/module-core":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/server":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/module-core":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/server":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/types":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@mikro-orm/core":"6.0.1","@mikro-orm/migrations":"6.0.1","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-UCrquPqt6EYZC2FEUzk+s4H5eEB7Pzl+8uqyeTvvQ8C1PW6wIIDNzbi0aZ32a5cRONuV7gaK8wvux0N6MHz0Sg==","shasum":"1a0223c2ccb3d51ddc42864c280104919e376c01","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0.tgz","fileCount":22,"unpackedSize":20433,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/vy8OsqnaY+JDDR9bHaKIYoopDrFzeBJHolmKKaGPxwIhAPFbjWPUiBv1JXGhUUCAddWHmzMtaoTGSbIcbVRsyrZY"}]},"_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-mikro-orm_1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0_1704702344164_0.04052291690140919"},"_hasShrinkwrap":false},"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":{"name":"@accounts/module-mikro-orm","version":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/module-core":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/server":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/module-core":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/server":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/types":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@mikro-orm/core":"6.0.1","@mikro-orm/migrations":"6.0.1","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-oTXfFuUvN5yeY6bHrJnkVwwEZoCzL36+gN/oXWKerAfv/2oXu1ZC9BTfQC9uZH1YE18XEcHd/wH+5FthioJ2Bg==","shasum":"4ec02c7d1506183be151043cbeca5f5bec1bffcd","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45.tgz","fileCount":22,"unpackedSize":20409,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDGRCdC38D7OJ94SQHqg3As27OsMSQ1UXHX+Lf3sftLvAIgbyMjDsas6y9LxGrKEvvhTE/Zsr/ENXlQ1nxvLC/NCDg="}]},"_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-mikro-orm_1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45_1704702850484_0.6428440206600115"},"_hasShrinkwrap":false},"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/module-core":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/server":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/module-core":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/server":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/types":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@mikro-orm/core":"6.0.7","@mikro-orm/migrations":"6.0.7","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-xyibXH7EI4Lp4Y6/DHkmZ9uu4NZ0yb6FO7EK/FQUuPvLRL/swVkFo9xWWr15Ai/44sgfc9/qbJLnmOz4PjEHiQ==","shasum":"486429d9f982f06568b38e10a8b6ba60138c2ff9","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d.tgz","fileCount":22,"unpackedSize":20433,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAxz3MM5xdcPIcMha+BMQGv9nOJSJqNecpWN76K0dOsIAiEAoTR8Q7L2GhgdH1eOg+Xd3ka2Qmz1cCsAVTAfK6Ju08I="}]},"_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-mikro-orm_1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d_1706708492769_0.021985848366369742"},"_hasShrinkwrap":false},"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":{"name":"@accounts/module-mikro-orm","version":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/module-core":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/server":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/module-core":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/server":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/types":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@mikro-orm/core":"6.0.7","@mikro-orm/migrations":"6.0.7","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-7X+yJGZEinoPlKnH+AQJ3kHtEMll5OVpGwMSkGXGFLhXkVK98X8DN4XsFYMXJpoDwQIQ5pect9y00cbDrUuv6A==","shasum":"ac5dc440279980866c9e116f0afbadf0c6afc7a2","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39.tgz","fileCount":22,"unpackedSize":20409,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDma8/vptE+az3Br8qkEWKSfU7ERTPlEqj8gwcmcfk5cQIgEDtDFzfUDhnZycTBstdrSpd/qWyFqHou1zuBWoGfYZg="}]},"_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-mikro-orm_1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39_1706708997600_0.6541067995647027"},"_hasShrinkwrap":false},"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/module-core":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/server":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/module-core":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/server":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/types":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@mikro-orm/core":"6.1.0","@mikro-orm/migrations":"6.1.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-DnTz6uvBDBdtlkkm5OOEJh8HxyjJ4bQRHn8bsq6GaOQp1emvPe9WmAVuNUGYYsvrOtaLnszszN7nzlf8EJBAOA==","shasum":"e2c742bbb6ecc1631bea5a6875027d632a130b49","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a.tgz","fileCount":22,"unpackedSize":20433,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDNnQiJnUbcxMrhy1KJGPIrC5r6iuqLmdT7VRE/KHixbAiEA/t/sh8ZFCeO+2qaYLPLwMi7OMeygOKOQtS3lo0HK4uE="}]},"_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-mikro-orm_1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a_1707394469738_0.1273059208671241"},"_hasShrinkwrap":false},"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":{"name":"@accounts/module-mikro-orm","version":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/module-core":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/server":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/module-core":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/server":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/types":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@mikro-orm/core":"6.1.0","@mikro-orm/migrations":"6.1.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-h6aPoGBico6X9a7LfMP+nzGC28kTw9ScFLFanSJlluECzXjs7BvFMwnRSbvL2oxSi9tl/Mh9IPL8UXmKdBgm7w==","shasum":"3df4ab5f8d4c6098ab21a5680f2d790c3f913462","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf.tgz","fileCount":22,"unpackedSize":20409,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQClh96tSCVaiMVMZ4+p1Q5cnCeWhypGqD7G/Srp9gHkbwIhAO1+h9KoDKV9juJkMPxBbopcNqT8/y0r23qr5ErxL3P6"}]},"_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-mikro-orm_1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf_1707395097219_0.9021839469119113"},"_hasShrinkwrap":false},"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":{"name":"@accounts/module-mikro-orm","version":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/module-core":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/server":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/module-core":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/server":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/types":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@mikro-orm/core":"6.1.8","@mikro-orm/migrations":"6.1.8","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-ZsUU0pVxAAGEtA35w5b45/KzvmqU/QgUkHP9Vp5/2RUCjq5jLKVpYz5DBf9E2G9xSf4ibdKrRxdkwQNedATamA==","shasum":"95f5d00795ff368a837e1905d1ea820f9248072c","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a.tgz","fileCount":22,"unpackedSize":20433,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDkBBw5icF+pZbfn+t9Hc1QvFpux9zmECMxdubdkkGwnQIgSaaDkDVqeJg+uqwFEmVtWSy8Bx+N8SXkVrWrWYKauV4="}]},"_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-mikro-orm_1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a_1709894081696_0.8427427756868302"},"_hasShrinkwrap":false},"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":{"name":"@accounts/module-mikro-orm","version":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","description":"MikroORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","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/mikro-orm":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/module-core":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/server":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@mikro-orm/core":"^6.0.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/mikro-orm":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/module-core":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/server":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/types":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@mikro-orm/core":"6.1.8","@mikro-orm/migrations":"6.1.8","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-mikro-orm@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-csYDWaK39KmlBN/oGNbsNGGFfVBcnICtUGy6LJaCPBsjTMRXiltVq3EiKUSYO3r81BgjaeuJw+uNePQPibGIgA==","shasum":"6620072a136a071713f9b3e3812c8c24e8632738","tarball":"https://registry.npmjs.org/@accounts/module-mikro-orm/-/module-mikro-orm-1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3.tgz","fileCount":22,"unpackedSize":20409,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCW5J0cdsRBkDQHkvfUPPtAGCk10RpiFIpjTztLVU6yNgIgN+d6yDpQ4Pwwuid6+QsaxoUl7leS3Db0CpHfmI+Ay0w="}]},"_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-mikro-orm_1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3_1709894960409_0.8775027357982708"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-13T10:30:50.074Z","0.34.0":"2023-09-13T10:30:50.440Z","modified":"2024-03-08T10:49:21.041Z","1.0.0-alpha-20231022085748-0910b9e1":"2023-10-22T09:04:08.681Z","1.0.0-alpha-20231106132410-d312ae00":"2023-11-06T13:27:58.552Z","1.0.0-alpha-20231106135626-1555665c":"2023-11-06T14:02:50.498Z","1.0.0-alpha-20231109134411-9db5d55b":"2023-11-09T13:48:05.968Z","1.0.0-alpha-20231110150116-1eb474da":"2023-11-10T15:07:17.760Z","1.0.0-alpha-20231110204039-4238958d":"2023-11-10T20:46:49.636Z","1.0.0-alpha-20231111101845-4f997913":"2023-11-11T10:22:39.316Z","1.0.0-alpha-20231111172350-25f6cb1d":"2023-11-11T17:27:45.733Z","1.0.0-alpha-20231113142902-7812b73b":"2023-11-13T14:32:53.290Z","1.0.0-alpha-20231115113719-ae2b53a9":"2023-11-15T11:41:10.742Z","1.0.0-alpha-20231115205645-aa630d56":"2023-11-15T21:00:37.935Z","1.0.0-alpha-20231116130548-67b64a6a":"2023-11-16T13:09:46.674Z","1.0.0-alpha-20231116132834-55ee2b96":"2023-11-16T13:32:28.201Z","1.0.0-alpha-20231119093904-9adfd014":"2023-11-19T09:43:02.325Z","1.0.0-alpha-20231119094526-b1fc68c7":"2023-11-19T09:49:16.182Z","1.0.0-alpha-20231120163547-4a461fcc":"2023-11-20T16:39:37.820Z","1.0.0-alpha-20231120164530-e14d6a81":"2023-11-20T16:49:22.401Z","1.0.0-alpha-20231121011122-60a60524":"2023-11-21T01:15:20.820Z","1.0.0-alpha-20231122105229-8edd073f":"2023-11-22T10:56:30.019Z","1.0.0-alpha-20231122120807-69a661e3":"2023-11-22T12:12:12.277Z","1.0.0-alpha-20231122192915-c0243667":"2023-11-22T19:33:17.181Z","1.0.0-alpha-20231123103003-4f0c2405":"2023-11-23T10:33:57.293Z","1.0.0-alpha-20231123122853-0ccafb9d":"2023-11-23T12:32:42.197Z","1.0.0-alpha-20231123131746-58399dcd":"2023-11-23T13:21:41.899Z","1.0.0-alpha-20231123183707-51335dc2":"2023-11-23T18:40:59.491Z","1.0.0-alpha-20231124142337-45cc4d05":"2023-11-24T14:27:36.175Z","1.0.0-alpha-20231127162849-b5b29d3d":"2023-11-27T16:32:49.610Z","1.0.0-alpha-20231127170705-4b0b3391":"2023-11-27T17:11:03.434Z","1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":"2023-11-30T10:52:48.924Z","1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":"2023-12-06T16:14:58.920Z","1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":"2023-12-13T12:13:43.040Z","1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":"2023-12-14T10:38:17.700Z","1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":"2023-12-19T11:08:17.423Z","1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":"2024-01-07T15:10:14.705Z","1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":"2024-01-07T16:17:12.070Z","1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":"2024-01-08T08:25:44.353Z","1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":"2024-01-08T08:34:10.658Z","1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":"2024-01-31T13:41:32.934Z","1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":"2024-01-31T13:49:57.795Z","1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":"2024-02-08T12:14:29.871Z","1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":"2024-02-08T12:24:57.373Z","1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":"2024-03-08T10:34:41.829Z","1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":"2024-03-08T10:49:20.576Z"},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"description":"MikroORM Database Interface GraphQL Module","homepage":"https://github.com/js-accounts/accounts","repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"license":"MIT","readme":"","readmeFilename":""}