{"_id":"@accounts/module-magic-link","_rev":"43-892d1c712c069e61d7dda7c3f279c0f3","name":"@accounts/module-magic-link","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-magic-link","version":"0.34.0","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"^0.1.0","@accounts/module-core":"^0.34.0","@accounts/server":"^0.32.0 || ^0.33.0","@accounts/types":"^0.32.0 || ^0.33.0","graphql":"^16.0.0","graphql-modules":"^2.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.6","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"^0.1.1","@accounts/module-core":"^0.34.0","@accounts/server":"^0.33.1","@accounts/types":"^0.33.2","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"2.3.6","@types/request-ip":"0.0.38","graphql":"16.8.0","graphql-modules":"2.2.0","graphql-tag":"2.12.6"},"gitHead":"3153375d7ba666e8bcbbfd28f3e07890cb58d5f3","_id":"@accounts/module-magic-link@0.34.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-bS7gKwNfoEBHm4ShDkGa6QuGV3qzN3C1+FNqdg28G62hQvp0HUcFG6zAVtMtn3WhVbHKESrQ4Y7wi2KOuwYrLA==","shasum":"cef1107784e2240a305e4d3182aac8b19e718d27","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-0.34.0.tgz","fileCount":22,"unpackedSize":41989,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCLHvMzjuKnP+iCN6+E8361pBnebbxjc5gYC96C54HHjAIhALCAIBFp/26zs3V21O+VnbruOB4hWBIgmNKyTbVDdqZw"}]},"_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-magic-link_0.34.0_1694601057307_0.20349549111124277"},"_hasShrinkwrap":false},"1.0.0-alpha-20231022085748-0910b9e1":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231022085748-0910b9e1","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/module-core":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/server":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/types":"1.0.0-alpha-20231022085748-0910b9e1","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.7","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/module-core":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/server":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/types":"1.0.0-alpha-20231022085748-0910b9e1","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231018163544-36199b68","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-SCSOO8CFkICIqVWsuLF4gw2OwStSJbYu/FutDVbdvu8SNVGIujaBH3WDsEjdYRJdQeaOKF7hMQytXLA/bxGEWA==","shasum":"1ae5a6353e0c5954ac0275cefa0311b061b5781e","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231022085748-0910b9e1.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCq5p/nGUBjs5AxqDaNK69pXgD9DIOi4lG+NhpZOHDCOQIgNne7z6oIFdRjKPXlv1MKYcqtPQcuzlOUxQzC8wSBG4g="}]},"_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-magic-link_1.0.0-alpha-20231022085748-0910b9e1_1697965471141_0.636185265890697"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106132410-d312ae00":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231106132410-d312ae00","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231106132410-d312ae00","@accounts/module-core":"1.0.0-alpha-20231106132410-d312ae00","@accounts/server":"1.0.0-alpha-20231106132410-d312ae00","@accounts/types":"1.0.0-alpha-20231106132410-d312ae00","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231106132410-d312ae00","@accounts/module-core":"1.0.0-alpha-20231106132410-d312ae00","@accounts/server":"1.0.0-alpha-20231106132410-d312ae00","@accounts/types":"1.0.0-alpha-20231106132410-d312ae00","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231018163544-36199b68","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-szIutSnxfEnJlAoNwiJL+qsL66IE/Kz7jvz+Y//gEiOQJepvw/j/G/9WoxcwLUprnjpfU15kfDlRZnhKoWU0ZQ==","shasum":"5b18398c1cd73ee08f9a51c71e9e48f0b146e2b8","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231106132410-d312ae00.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICd7ld65j8pFM51bPAAmzE0bFd+yy5hp6LxxXJWUyOgXAiBOY9qr8vYhpiucTud/sU+Y9f/btMe6TmFaX4A9RqgLww=="}]},"_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-magic-link_1.0.0-alpha-20231106132410-d312ae00_1699277290395_0.8497071582139779"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106135626-1555665c":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231106135626-1555665c","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231106135626-1555665c","@accounts/module-core":"1.0.0-alpha-20231106135626-1555665c","@accounts/server":"1.0.0-alpha-20231106135626-1555665c","@accounts/types":"1.0.0-alpha-20231106135626-1555665c","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231106135626-1555665c","@accounts/module-core":"1.0.0-alpha-20231106135626-1555665c","@accounts/server":"1.0.0-alpha-20231106135626-1555665c","@accounts/types":"1.0.0-alpha-20231106135626-1555665c","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.40","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-mVLseYWMkimGUjp/qC+LhhCqF5onCaM8AIDTvRkejc2KAYAm8W51Oo5ZQNbydo6jSC22BRyB0OiN3W1vrPmyQQ==","shasum":"02f0727745c4e6116e67a0add268b4f7aa046bf7","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231106135626-1555665c.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDLHHQTRtC8yNGQ+YkgsVGtz4smQz3yvoQItSDttZ3D0wIhALVJt/Z/Udv7BoWQblpQKHjEmuivOd+/Id1eCEpLqM0A"}]},"_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-magic-link_1.0.0-alpha-20231106135626-1555665c_1699279396321_0.011802943342182237"},"_hasShrinkwrap":false},"1.0.0-alpha-20231109134411-9db5d55b":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231109134411-9db5d55b","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/module-core":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/server":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/types":"1.0.0-alpha-20231109134411-9db5d55b","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/module-core":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/server":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/types":"1.0.0-alpha-20231109134411-9db5d55b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-EP6WhpdIGuKk/GdKngnUdwpQHaUhtJyoiwIwxST2sMqg4iSZkYQsbbdQhV+be8mBV8mkVSToa0JwLyaD1rofIA==","shasum":"4f8bc60fc75119b9180b1b999ea2526e5ebeccd4","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231109134411-9db5d55b.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDticRT02UdSdDEAx94QyRawULT48CoSugTBCOjPPKI4QIhAPp/5xiyYZuxXk4WWJS0SS4kptk0mzd5T/VuTdwUTnz6"}]},"_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-magic-link_1.0.0-alpha-20231109134411-9db5d55b_1699537695457_0.7343256217463048"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110150116-1eb474da":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231110150116-1eb474da","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231110150116-1eb474da","@accounts/module-core":"1.0.0-alpha-20231110150116-1eb474da","@accounts/server":"1.0.0-alpha-20231110150116-1eb474da","@accounts/types":"1.0.0-alpha-20231110150116-1eb474da","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231110150116-1eb474da","@accounts/module-core":"1.0.0-alpha-20231110150116-1eb474da","@accounts/server":"1.0.0-alpha-20231110150116-1eb474da","@accounts/types":"1.0.0-alpha-20231110150116-1eb474da","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-fI17xuZm/Q7ixqkxgIB+TwgRCdKGniy/U+SwyApkeN/eixYjv82nCfsjpAXUcsDO7wn+AU3d1cd5nWaucQ2chw==","shasum":"86f1f382337d699a7656e4a218dcef98b9def9b7","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231110150116-1eb474da.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDjXxL0jvMWusHGxIU2IMzWh413o3/ew6mDidMZiFtKhwIhAM4v05NnbqKXGQPtnAWxiFbYzf963Y1k6YLX/+1F/Asj"}]},"_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-magic-link_1.0.0-alpha-20231110150116-1eb474da_1699628860793_0.09057674946111627"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110204039-4238958d":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231110204039-4238958d","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231110204039-4238958d","@accounts/module-core":"1.0.0-alpha-20231110204039-4238958d","@accounts/server":"1.0.0-alpha-20231110204039-4238958d","@accounts/types":"1.0.0-alpha-20231110204039-4238958d","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231110204039-4238958d","@accounts/module-core":"1.0.0-alpha-20231110204039-4238958d","@accounts/server":"1.0.0-alpha-20231110204039-4238958d","@accounts/types":"1.0.0-alpha-20231110204039-4238958d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-oCRkAnx8Mfqjw5zxLPfl6U+IhoidFRDo2p8pDuPg8N51YXq3wQkkIlf+OViI4dXh7toNp20s4ZEjsOAs2fdTlQ==","shasum":"36699bbe1e440d0251c63d039fbca4735a5a1bf2","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231110204039-4238958d.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCRDK4jNqODrys4SA+8o/1nDH1Ooff6z0TAXH0g/wZW5wIgd+LkTsIUViLkqRn35FKHIOJgOMs792yG1/NsRv2aQZE="}]},"_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-magic-link_1.0.0-alpha-20231110204039-4238958d_1699649227778_0.37278734654079404"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111101845-4f997913":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231111101845-4f997913","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231111101845-4f997913","@accounts/module-core":"1.0.0-alpha-20231111101845-4f997913","@accounts/server":"1.0.0-alpha-20231111101845-4f997913","@accounts/types":"1.0.0-alpha-20231111101845-4f997913","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231111101845-4f997913","@accounts/module-core":"1.0.0-alpha-20231111101845-4f997913","@accounts/server":"1.0.0-alpha-20231111101845-4f997913","@accounts/types":"1.0.0-alpha-20231111101845-4f997913","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-UDgLXZSIzo6lgk87HOfs4ojSoLCsjIGEQFSmsoBEuMF+lLQDJWl6aZpZLuqK4lX9bMaiZQ6bRsQtBLvWgIvgFQ==","shasum":"470085bdfe2b2780eb4bf511f6c14cfaa40b794a","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231111101845-4f997913.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCp28VShOHvVRMvv10Sua1RN+UXTBTKAMzkCZRXAGQlRgIgJDljaz4J9XLalNCiYnhcgheB8AjDb03Ps66J/7cvWxA="}]},"_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-magic-link_1.0.0-alpha-20231111101845-4f997913_1699698168869_0.2917597163078478"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111172350-25f6cb1d":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231111172350-25f6cb1d","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/module-core":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/server":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/types":"1.0.0-alpha-20231111172350-25f6cb1d","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/module-core":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/server":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/types":"1.0.0-alpha-20231111172350-25f6cb1d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-CQYVIXkvSu0X91c8GPzzajHwhAQzf594PFs8pd7MiNSuawSBQWNcKIVUn8Z8Pyw5GCHncGWRd/pK3Vh3iwUjkg==","shasum":"5de162a205b0b8a5a72bed61926a2f5b900843ef","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231111172350-25f6cb1d.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICe6M9fvI/9WBXn0xN0Dx1orglcLOPJUyzg3h/Ak/4QfAiBtNhmlbw5qJdp+msMGGdOKAxcC9rwElvRg1DKstsNUzA=="}]},"_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-magic-link_1.0.0-alpha-20231111172350-25f6cb1d_1699723676251_0.9480020485851377"},"_hasShrinkwrap":false},"1.0.0-alpha-20231113142902-7812b73b":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231113142902-7812b73b","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231113142902-7812b73b","@accounts/module-core":"1.0.0-alpha-20231113142902-7812b73b","@accounts/server":"1.0.0-alpha-20231113142902-7812b73b","@accounts/types":"1.0.0-alpha-20231113142902-7812b73b","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231113142902-7812b73b","@accounts/module-core":"1.0.0-alpha-20231113142902-7812b73b","@accounts/server":"1.0.0-alpha-20231113142902-7812b73b","@accounts/types":"1.0.0-alpha-20231113142902-7812b73b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-Dp1gE9/Z4xIVFMuqGweCWjrsp0yU3UkueBuCrNQd5SHeYAwBn6a5D0WzJQ7u3PZm57YiNq+eXjeA6H0xS/v2Hg==","shasum":"e427313b64c832c07804181e5dd2665bb4d2d70c","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231113142902-7812b73b.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGQ8YYN/8KJwMyqC6fHtktZpXt4N4jOHtBpqIi3vVMuOAiACJ3B45MuEOqyJt7jEfnVmCnSm4AyjHP66+sGlCNWMsg=="}]},"_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-magic-link_1.0.0-alpha-20231113142902-7812b73b_1699885984184_0.8964686581108718"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115113719-ae2b53a9":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231115113719-ae2b53a9","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/module-core":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/server":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/types":"1.0.0-alpha-20231115113719-ae2b53a9","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/module-core":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/server":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/types":"1.0.0-alpha-20231115113719-ae2b53a9","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-RqNvDzBojAGk+8CxkKgzK13HPPZcWpj5GoHWL4trPcZiCL7NOLOSnV+5pWOy7J9HydefKIc4qS7p/1QczUd9MQ==","shasum":"d4bbf8b8fbb6edd4aee559b890866d1d52221fbd","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231115113719-ae2b53a9.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCcTHvYxpmXVe6u//QHoHCcKbRfz9X2tnuTlzQLKW0qrQIhAPJ1ZIN4Na/hS4aLJ02osv3gcCe/R0nqMcVk2LrOAQym"}]},"_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-magic-link_1.0.0-alpha-20231115113719-ae2b53a9_1700048482775_0.024806641858343914"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115205645-aa630d56":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231115205645-aa630d56","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231115205645-aa630d56","@accounts/module-core":"1.0.0-alpha-20231115205645-aa630d56","@accounts/server":"1.0.0-alpha-20231115205645-aa630d56","@accounts/types":"1.0.0-alpha-20231115205645-aa630d56","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231115205645-aa630d56","@accounts/module-core":"1.0.0-alpha-20231115205645-aa630d56","@accounts/server":"1.0.0-alpha-20231115205645-aa630d56","@accounts/types":"1.0.0-alpha-20231115205645-aa630d56","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-tkhJQR0F8mtMB+PLGumj7XGGCQwCVF4v5lkKX+z3A2ki2AYD/3rv+vd4zaSjy0xacyfLl+vnV8myKa+rnKLnnw==","shasum":"8ce386a17c30832213e6cb5e682a7ff618af8798","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231115205645-aa630d56.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDMnfGskL6o9AmAIfgA9mqWRLDedO1uMFgx/P24vqwc+QIgOi0lSBmDIwRMyHM+IrSiTrw8RZb/MZ9AAT8hQAaQtcE="}]},"_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-magic-link_1.0.0-alpha-20231115205645-aa630d56_1700082047526_0.7755155117916988"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116130548-67b64a6a":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231116130548-67b64a6a","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/module-core":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/server":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/types":"1.0.0-alpha-20231116130548-67b64a6a","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/module-core":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/server":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/types":"1.0.0-alpha-20231116130548-67b64a6a","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-v5cBNdFon4aiIhqEXA17RcqkR7fQCGATQSDfBqDdc9iXzwe3xstH62chO20MtZGzzGbzRkkVZ5WmwyaU3kR43w==","shasum":"3729ce065e7040f0c6f4ebeaaa2231177e35595b","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231116130548-67b64a6a.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDEAKBYsjzpQECTS8AO9ATmis0NC4JPUPVn3PkcQ1LQLAIhALXNJmt6+xeYvb7lVFHk1c5vuSwcspWTfCTLFAgKaGl2"}]},"_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-magic-link_1.0.0-alpha-20231116130548-67b64a6a_1700140199151_0.7911561854013462"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116132834-55ee2b96":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231116132834-55ee2b96","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/module-core":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/server":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/types":"1.0.0-alpha-20231116132834-55ee2b96","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/module-core":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/server":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/types":"1.0.0-alpha-20231116132834-55ee2b96","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-JzTkj1VIdoA0dMolsDT33hUtfGEiNuJcTcM1pW6OLrFhB77L+74TZCbh7Vt+xCh9zOoSYwVq6/5wRHIamezwOg==","shasum":"0258f45bfca2ee0b63560e908af486210ef1ceaf","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231116132834-55ee2b96.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHrbN8V37UCuOkbXqwd66w9qvJ7ppQUdbD/RldgpUrfLAiEA2pA1tMRDRUpm70D7yHO2kkAnah8fKWNb+5UutfEyUMo="}]},"_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-magic-link_1.0.0-alpha-20231116132834-55ee2b96_1700141558244_0.46085995635122545"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119093904-9adfd014":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231119093904-9adfd014","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231119093904-9adfd014","@accounts/module-core":"1.0.0-alpha-20231119093904-9adfd014","@accounts/server":"1.0.0-alpha-20231119093904-9adfd014","@accounts/types":"1.0.0-alpha-20231119093904-9adfd014","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231119093904-9adfd014","@accounts/module-core":"1.0.0-alpha-20231119093904-9adfd014","@accounts/server":"1.0.0-alpha-20231119093904-9adfd014","@accounts/types":"1.0.0-alpha-20231119093904-9adfd014","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-Ic+1n2hz2FmeO7BvyKcODfJVW4UfOYrTwUgzHUfGEA0RLNsW5CisektpKqynYRsrVJmHBBl5KjZ2zDpXoPe2qA==","shasum":"96b9a25695f810008e5972b95c2842a1f5dff03d","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231119093904-9adfd014.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFibJu8CrrJ+RJTJp8LhkiMxN9hZv5UR4Vdb5mRv03JwIhAPh6EveDdCgTADXxouVDMgCS6PTSAmL++KClP5+aVa+B"}]},"_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-magic-link_1.0.0-alpha-20231119093904-9adfd014_1700386992614_0.9943907007047867"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119094526-b1fc68c7":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231119094526-b1fc68c7","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/module-core":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/server":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/types":"1.0.0-alpha-20231119094526-b1fc68c7","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/module-core":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/server":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/types":"1.0.0-alpha-20231119094526-b1fc68c7","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-1sj2GAIcD+3QxGM+Ba3yicR7/Vc5v3/tRFwkdgBzthkF/+k75SeL/A9Q8e+3Q+VaqpJb/WMcZi+8zkm/B7DflQ==","shasum":"7d29dcfbe8101226676e1ac900b8a8377dbf0b8a","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231119094526-b1fc68c7.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCMIMGFuK5E9AbW+vWdeqovw+Xb6eYdmnr6pIs16td3WgIhAKrxhhNfPQ37uMD2PU95u2s85ySa0PEWFJUWDgDpl6+U"}]},"_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-magic-link_1.0.0-alpha-20231119094526-b1fc68c7_1700387368059_0.13238057079359788"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120163547-4a461fcc":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231120163547-4a461fcc","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/module-core":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/server":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/types":"1.0.0-alpha-20231120163547-4a461fcc","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/module-core":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/server":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/types":"1.0.0-alpha-20231120163547-4a461fcc","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-ezMIXSrobPVdauZlB0evn9/PvYq+3vrAulKVx68DsDm8+ffzFb5eI0cV2YX15LEaJ2WACGSQVEcJQY/TVlP1PQ==","shasum":"014cf6463beb8217b25a2670fed5a736bccd3714","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231120163547-4a461fcc.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCj6ANKUE8UyPjv1zolTeaI1OHEqWz8s6b+dmyrxD3E3wIgIHB82fDkTttM3SGLcAgIKACZP5OBtqvBsaffTbHUsg0="}]},"_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-magic-link_1.0.0-alpha-20231120163547-4a461fcc_1700498389664_0.7677457623944401"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120164530-e14d6a81":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231120164530-e14d6a81","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/module-core":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/server":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/types":"1.0.0-alpha-20231120164530-e14d6a81","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/module-core":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/server":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/types":"1.0.0-alpha-20231120164530-e14d6a81","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-mvfQf7KKusvJTMjjSBUrdBinGWNxwtsWvmQn3d9R2SrmpTDbpcVPHLGpK086UC2OrfECQkRATUFdSfZn34EljQ==","shasum":"451ba08324c3f71fe530d3cb2bdaf6616bf4c35f","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231120164530-e14d6a81.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBtNWthCY73byw3f1bfvkKtvISbYHtrbAtVVUr7mNfU/AiB681JA4M4F5zQ8nbObnNIxGDooM6GzdYJ6bfU1JyGu3g=="}]},"_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-magic-link_1.0.0-alpha-20231120164530-e14d6a81_1700498977538_0.9013557799101646"},"_hasShrinkwrap":false},"1.0.0-alpha-20231121011122-60a60524":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231121011122-60a60524","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231121011122-60a60524","@accounts/module-core":"1.0.0-alpha-20231121011122-60a60524","@accounts/server":"1.0.0-alpha-20231121011122-60a60524","@accounts/types":"1.0.0-alpha-20231121011122-60a60524","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231121011122-60a60524","@accounts/module-core":"1.0.0-alpha-20231121011122-60a60524","@accounts/server":"1.0.0-alpha-20231121011122-60a60524","@accounts/types":"1.0.0-alpha-20231121011122-60a60524","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-V3tGrDq71wJBiPjqkezKBsNwm1WmbdsqP6cddegFtOE8pbSxXPzDutVijsu2Dd/1WEA6odjn+0LkwGVbpLkeEg==","shasum":"1db0a5caaf3114632110d002b793ab777c748985","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231121011122-60a60524.tgz","fileCount":22,"unpackedSize":41827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA/IFlbLyGbuRT7wimA4zACUiILxHbVBVhN1Js7T9RUYAiEAvUtJNYQwWvXG7B8DM5B0iVLoX87r4KrvVDCNAtLFc98="}]},"_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-magic-link_1.0.0-alpha-20231121011122-60a60524_1700529330197_0.03693364245437625"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122105229-8edd073f":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231122105229-8edd073f","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231122105229-8edd073f","@accounts/module-core":"1.0.0-alpha-20231122105229-8edd073f","@accounts/server":"1.0.0-alpha-20231122105229-8edd073f","@accounts/types":"1.0.0-alpha-20231122105229-8edd073f","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231122105229-8edd073f","@accounts/module-core":"1.0.0-alpha-20231122105229-8edd073f","@accounts/server":"1.0.0-alpha-20231122105229-8edd073f","@accounts/types":"1.0.0-alpha-20231122105229-8edd073f","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-vIZKWdD6yAwdkThf/ejEvxPfTXPrbbyinDp2pLzxWytZgnAfAJfU8Rfg5ahepoJ07RMtfsHyUTs/wxTozeLlTQ==","shasum":"05b006320e6954a4b1d80c0f043c889dd9f3dff0","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231122105229-8edd073f.tgz","fileCount":22,"unpackedSize":41857,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC3V1vXOPnLdH3IgA40nSQPs6/RRbdG+kwpTxRmLOFUwgIgHc38C3nqyj3YMz8kFVJN+JVcfxPD5+jtJGOMCS6palc="}]},"_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-magic-link_1.0.0-alpha-20231122105229-8edd073f_1700650600526_0.8730329403492456"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122120807-69a661e3":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231122120807-69a661e3","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231122120807-69a661e3","@accounts/module-core":"1.0.0-alpha-20231122120807-69a661e3","@accounts/server":"1.0.0-alpha-20231122120807-69a661e3","@accounts/types":"1.0.0-alpha-20231122120807-69a661e3","graphql":"^16.0.0","graphql-modules":"^3.0.0","graphql-tag":"^2.10.0"},"dependencies":{"@graphql-tools/merge":"9.0.0","@graphql-tools/utils":"10.0.8","request-ip":"3.3.0","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231122120807-69a661e3","@accounts/module-core":"1.0.0-alpha-20231122120807-69a661e3","@accounts/server":"1.0.0-alpha-20231122120807-69a661e3","@accounts/types":"1.0.0-alpha-20231122120807-69a661e3","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","@types/request-ip":"0.0.41","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","graphql-tag":"2.12.6"},"_id":"@accounts/module-magic-link@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-EDZgRK5BjxKsiqbOh8/BWcPaYq1153uGpDxziEVGTpd6zKQDicYuR3TS9nkRt1CD/WwXWbZoWsaXM5d1scEH0A==","shasum":"c33289cbc4982d955fd6328895941b8715481e62","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231122120807-69a661e3.tgz","fileCount":22,"unpackedSize":41877,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF5fwgGcCB4h6Cejc/kiaPSrqdz8mTcYKHpAJClAGk58AiBARAlSc4cBDKIifpFiywY8Z/nY58nnqh+vCNOYElDleg=="}]},"_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-magic-link_1.0.0-alpha-20231122120807-69a661e3_1700655143818_0.047141112287839126"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122192915-c0243667":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231122192915-c0243667","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231122192915-c0243667","@accounts/module-core":"1.0.0-alpha-20231122192915-c0243667","@accounts/server":"1.0.0-alpha-20231122192915-c0243667","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231122192915-c0243667","@accounts/module-core":"1.0.0-alpha-20231122192915-c0243667","@accounts/server":"1.0.0-alpha-20231122192915-c0243667","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-1e/wp2dQvv3TvRYDk/OOxexs2PS7OUW6oxgSGmJSL0+RxWGEXdji6iWZI8nfXPSI6p5rDpbohPxpitsMWar/TQ==","shasum":"ce8ac058fa0305ab5096a39712cd45aca0d13fed","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231122192915-c0243667.tgz","fileCount":22,"unpackedSize":41538,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFxi57wEObJXBTP/PeGY7+VCrarnTGBT9sH6LBSNg6XzAiBiqDkVHqvBnriuVs23KzuLIiZFmoLpDR2w99EBl3X0JQ=="}]},"_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-magic-link_1.0.0-alpha-20231122192915-c0243667_1700681608520_0.763210423552461"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123103003-4f0c2405":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231123103003-4f0c2405","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/module-core":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/server":"1.0.0-alpha-20231123103003-4f0c2405","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/module-core":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/server":"1.0.0-alpha-20231123103003-4f0c2405","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-W1iqgF/oG6XzDIgvxDk54ewGeLnFsfYld4tgFzl0+G9wwF43Q6AohCKH33ThYqdAg+5zfexffNNS3gIKx+h5Dg==","shasum":"bf9a59c62dee4c663768f930a0b76b45d42e8425","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231123103003-4f0c2405.tgz","fileCount":22,"unpackedSize":41538,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHsJXlorXTyyp3/GSxoJxgWxLHwbU32MmVMoDg7ddac1AiB0K8ArNJEzd55trS4PhNIP4kZ0AFTOT5ZLtVpHgSGLcg=="}]},"_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-magic-link_1.0.0-alpha-20231123103003-4f0c2405_1700735649075_0.930986878301058"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123122853-0ccafb9d":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231123122853-0ccafb9d","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/module-core":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/server":"1.0.0-alpha-20231123122853-0ccafb9d","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/module-core":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/server":"1.0.0-alpha-20231123122853-0ccafb9d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-Upv+PeGuxVtJ1DbG10ZmTGP8FXySwWOKDD8QISRnV0cH1Fd0RF5jA4POTvD3J/i0cBjuSwDkzPi9ZOkgTIcTVg==","shasum":"befffacd22abb8f01edd9b5753b18bdea896e212","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231123122853-0ccafb9d.tgz","fileCount":22,"unpackedSize":41538,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICHFu297ozSgFQxp4PeceD38cbigMnyP1n6gJx44CCDQAiEA03kDYrtJ7wFkXOZmacFoff/RkAYrGwuWsCFBFDloV18="}]},"_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-magic-link_1.0.0-alpha-20231123122853-0ccafb9d_1700742776130_0.06117114457868156"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123131746-58399dcd":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231123131746-58399dcd","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231123131746-58399dcd","@accounts/module-core":"1.0.0-alpha-20231123131746-58399dcd","@accounts/server":"1.0.0-alpha-20231123131746-58399dcd","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231123131746-58399dcd","@accounts/module-core":"1.0.0-alpha-20231123131746-58399dcd","@accounts/server":"1.0.0-alpha-20231123131746-58399dcd","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-mO7xIiL/b9fXfqqoLodpwr7ELjauAA40yjNthlkBQl4Vci9fj6MyS9K/V9D2OWAOH7zzOGOQfsJkZg69sA9UBA==","shasum":"f45f131e71b7fdba7746264a7c7cc633fff315e8","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231123131746-58399dcd.tgz","fileCount":22,"unpackedSize":41538,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBPSZ8GznwhweeQkf6mHnxniuQoKIO0LVDPLjhwxLu3NAiEAgZqdOMi6seRjJvh6ptRD8qQDEXPPJubSNopQJMlc1bY="}]},"_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-magic-link_1.0.0-alpha-20231123131746-58399dcd_1700745701719_0.25081946279210565"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123183707-51335dc2":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231123183707-51335dc2","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231123183707-51335dc2","@accounts/module-core":"1.0.0-alpha-20231123183707-51335dc2","@accounts/server":"1.0.0-alpha-20231123183707-51335dc2","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231123183707-51335dc2","@accounts/module-core":"1.0.0-alpha-20231123183707-51335dc2","@accounts/server":"1.0.0-alpha-20231123183707-51335dc2","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-x9h7nMfaqyM9RaiDFrU7zWRrfHzGWxi8FT94qOqkrJCHKrnPrdBnOTzZ4EFE7Kshk9topbIDCFwcJNSsvP6dRw==","shasum":"5414970ae04a87cb7913031390ab81f03a120e7c","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231123183707-51335dc2.tgz","fileCount":22,"unpackedSize":41538,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHdWTg/VFLoAOizLxwQCXX8ZcK7GLW/RcAxZNX1OAx8BAiEAvo82qz2dqYs4Eck41kEV0xxp9qwICkBNXK4HarS0UJo="}]},"_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-magic-link_1.0.0-alpha-20231123183707-51335dc2_1700764872360_0.7785646314497678"},"_hasShrinkwrap":false},"1.0.0-alpha-20231124142337-45cc4d05":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231124142337-45cc4d05","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/module-core":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/server":"1.0.0-alpha-20231124142337-45cc4d05","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/module-core":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/server":"1.0.0-alpha-20231124142337-45cc4d05","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-lTLsVlXfwG/Z68PABV4hdDo7ghWbAWwV0td4nXzYWutmMN5DeoUWQemXpPKlDN37Hkylfkoa/T0iX7GBFI1oIg==","shasum":"f45b4af1518d8924983644db5d743102e8f8c05b","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231124142337-45cc4d05.tgz","fileCount":22,"unpackedSize":41538,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/xM/LA0ttpnwWfwCIfYY71Dg1EzFAlqGrklbUZ8iv7QIhANOB9AQvhbeDVGJPRvYvUcB3yMTAAilSMA2K+lPOuoTg"}]},"_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-magic-link_1.0.0-alpha-20231124142337-45cc4d05_1700836066683_0.9599225597907628"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127162849-b5b29d3d":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231127162849-b5b29d3d","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/module-core":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/server":"1.0.0-alpha-20231127162849-b5b29d3d","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/module-core":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/server":"1.0.0-alpha-20231127162849-b5b29d3d","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-LTDQ0cbD2gilFV5zEW9CSS6cjTfCRr4WGBE81lo9yR4wWzwpsGcCll9gul6fA0vFQdeKk1kfzFkqW4E9FyS+jA==","shasum":"d886f1e9fb4b1a3c95042202b3861315b6c36506","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231127162849-b5b29d3d.tgz","fileCount":22,"unpackedSize":41538,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD+YAzdIADlENjkyCJhbuEeHaRMGLIGaB/CCwneaZLG1AIgCz0ccKv1P5U8NYinLCwUdZsusiKoTWIWlGRWeZkQUuI="}]},"_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-magic-link_1.0.0-alpha-20231127162849-b5b29d3d_1701102779137_0.2896604469460613"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127170705-4b0b3391":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231127170705-4b0b3391","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/module-core":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/server":"1.0.0-alpha-20231127170705-4b0b3391","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/module-core":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/server":"1.0.0-alpha-20231127170705-4b0b3391","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-hvz3sOOdABqHBLG7GrPMM5GtlWze/luf7/rxXNS1ma+1ruj7nIHax2RvvhHMlQA445XqVy91tp6GEuofV7B7zg==","shasum":"374e47a1056ce8b36dd5f495a174399b6f39b762","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231127170705-4b0b3391.tgz","fileCount":22,"unpackedSize":41560,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC1tWB9EzDXNKBreY83eE3OY6DMqKritvDjI/yPuJWyGQIhAPogdSeWihFaKa0m1InMXaQRpeUfnszNH7i9UvEpZwmP"}]},"_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-magic-link_1.0.0-alpha-20231127170705-4b0b3391_1701105073280_0.4310378754173716"},"_hasShrinkwrap":false},"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/module-core":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/server":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/module-core":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/server":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-my2gVlGWQNVYnOpy2waCd4SZ751sopDeUPzgdgxlnQJXjayoVJCsP18w3fZhGS6xCTYNN4fl+rVjy+E7F1sd9Q==","shasum":"33b58d3cbb21b5324f1baab858a4f75631468d3b","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCegbJ6N5P8tsokB7IMFfWYK6KO4dRdwwj/9qbmT1c1kAIhALMa66VgXaxMIR827cE668wBzze8KKAOH1KntoAi6uP+"}]},"_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-magic-link_1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165_1701341579456_0.42648541978857724"},"_hasShrinkwrap":false},"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/module-core":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/server":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/module-core":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/server":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-/odveYncH77rpY/wLi53sdkayRVynRk7H/Bmjfp7wXewYCa2eYC4G+fj4FzIJb6XvV6R8rC/v/MGhevvHRF8+Q==","shasum":"d88c43e8861fb5b70805dade1b7d372b41f0807f","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDHTGhZJXGrfqCUMeOjrp4qEYjLxUlhvCPdCfS8bULfPAIhAJqj/vkG/mJmx333CGw+UCRtftY4p/YYFK0WG9bL0uHx"}]},"_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-magic-link_1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db_1701879309899_0.6178804474341884"},"_hasShrinkwrap":false},"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/module-core":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/server":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/module-core":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/server":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-iNzutiK7Tp9zkG5j71zx+NUvMy+Jmq1CPF6vPThW7nCybQaEfAJtIMPv1p3VgUptpAXt/al5fHLVQ382Klj0dw==","shasum":"245db3ae9979ff997cc38f2ea10fce593ddddb18","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHoSRaLXZQIjkGbOXd4mwZXBiXaf/UF9YtronWoq0tOpAiBEzjBGIgGKF368tKbiBhCwasCIMDN6UGoYCRn1P7acHg=="}]},"_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-magic-link_1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b_1702469634262_0.013433950501622327"},"_hasShrinkwrap":false},"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/module-core":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/server":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/module-core":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/server":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-2ZOwykA5zwGS5382X7WCA3EEngmFiuzhPVXXY/4Mr3RyG6avT7PwIILjyzzS4XZi57+e0PDBXxCBhe9JVFubxg==","shasum":"6c7d9c890be55f7f1d0f49f14f37ef7173670efb","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDhx8YX7mI/p+s0ItBWMqbCHRhLqW1V4AefLNAN5Ffs5AiAnMLvEsgU2UsUI6QVmRf+7OXq7snVwpXgLIlG11PiVCw=="}]},"_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-magic-link_1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd_1702550308217_0.7479509597048821"},"_hasShrinkwrap":false},"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/module-core":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/server":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/module-core":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/server":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-VrnxAnGqyiQeDDiN6Ls0gevIgwoi3PuGUZ6v0Qo8JCiHLpbKHzzKmixmm6a7VDgRHekZU59+9L0o8x0b/L0h9w==","shasum":"7d4961b25ddfb05e1f98877c871ceea59e89d2b7","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDmN4KyQ5/3ktfJlajv0ftN/N/zL68Hh9e+tLZRbl2krgIhALB/pBQVObJpXKBpkbuvFkobIJfTPtNe57sQ5xXkNCS8"}]},"_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-magic-link_1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9_1702984109095_0.9307178822688449"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/module-core":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/server":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/module-core":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/server":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-+ioD5+IG2jkfgYAGn8kUa0gRPjk7DrvM2WaV+0foH2dAu3HyuQa1f0FL37h9+skyBaxCF6Zpaq8cUtWbsk3cQg==","shasum":"29ef513597e0cff8c6fbdd33325fb9591988a039","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDFAW+Lv+srAgNlWjTwPDDSuWnaQ8tuanuXjfhZIIo8/gIhAPA5Ir2BxN1iLnB+iaRpDGPajmpMKBrdOdGmy1e9QKY4"}]},"_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-magic-link_1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b_1704640224897_0.7317580024941508"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/module-core":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/server":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/module-core":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/server":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-FX+R0bZJeKSfAESoHzy94v48pzWGIFUOBpPn/sHGG69tpAicV2wt4a7ebG3WpxVMZ6z99wanpLKPDlpxO6M6XA==","shasum":"7e8e36173470b1efd548fad5d43cc245da73402d","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDXJkgxDlibhERe7PPVowMQovxtpGJcH6QCDfdMkiSxHQIgJOPz/MUtBjQiJJ5QsoS4eebYy33hWm+WvsJU9s8jfEU="}]},"_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-magic-link_1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59_1704644244273_0.10821564378340742"},"_hasShrinkwrap":false},"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/module-core":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/server":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/module-core":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/server":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-y+tkRYRftqJpmxM613paZKktPKMdfaZg98Pz6zjmvdXZnT2oi9wF0oHoncNaD3gfZyoOujpMx2rjWm46z7JMng==","shasum":"89bef65f4098547719b74bcc8d8e009b9282c0b9","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDh0KUWHVRbUF5pWpkGdC2l+ezI8SlJzOPzEpcxXM1uvAIgNJHughBVMSKmR74S1BP8zEd9H0lpPLKgSpT5+DDwOLo="}]},"_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-magic-link_1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0_1704702355318_0.7230204189240224"},"_hasShrinkwrap":false},"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":{"name":"@accounts/module-magic-link","version":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/module-core":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/server":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/module-core":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/server":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@graphql-codegen/add":"5.0.0","@graphql-codegen/cli":"5.0.0","@graphql-codegen/introspection":"4.0.0","@graphql-codegen/typescript":"4.0.1","@graphql-codegen/typescript-operations":"4.0.1","@graphql-codegen/typescript-resolvers":"4.0.1","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-qcNvsiAEKhI2QmT7qs4g7knMfHgm0LVWNeeMwQAegupbpWZK57pEjmQsNW30punD33IM3RylxKOEvn634fx6Xg==","shasum":"2a67700bd3a31aaef8bace5b286bbc98cd3dd4ad","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45.tgz","fileCount":22,"unpackedSize":41763,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBuMBXHFu5WuvPrSbP9v4/PIKaUtxfrmAqKREvOK3V4rAiEA4uwLMyvZYW8I4F0c5zDVnSgDnUt8IRqInA21NJ9POhk="}]},"_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-magic-link_1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45_1704702862844_0.4607269740171469"},"_hasShrinkwrap":false},"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/module-core":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/server":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/module-core":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/server":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@graphql-codegen/add":"5.0.1","@graphql-codegen/cli":"5.0.1","@graphql-codegen/introspection":"4.0.1","@graphql-codegen/typescript":"4.0.2","@graphql-codegen/typescript-operations":"4.1.0","@graphql-codegen/typescript-resolvers":"4.0.2","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-cY2IXlToq0YVd2ti15Aak5HxbxPpPv+lAxRLwcDrYu2TRH7wPwKV8CqefnQmNZzvkjK1JaTz4xoLkG4UgcFqVQ==","shasum":"53834a2116b09a0f9f33860479f65d485d802d02","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBgQLe12SKsRWmyDKvsBDYww++g+mssE5QZ4+74/7ZqIAiEAqnj+9g6mI53PHy2el3w/bY+vM/xP+CZUjg2jsnnEgbo="}]},"_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-magic-link_1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d_1706708499623_0.7651074589104572"},"_hasShrinkwrap":false},"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":{"name":"@accounts/module-magic-link","version":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/module-core":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/server":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/module-core":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/server":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@graphql-codegen/add":"5.0.1","@graphql-codegen/cli":"5.0.1","@graphql-codegen/introspection":"4.0.1","@graphql-codegen/typescript":"4.0.2","@graphql-codegen/typescript-operations":"4.1.0","@graphql-codegen/typescript-resolvers":"4.0.2","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-WLh3EdwBTaqesCh7d7pKmrNvTo6rjVhbUwl96rK+Ndk2ay5KsxgZkmog3G0/BHRT/vcfSmTng6T1TBWwoy0UwA==","shasum":"7ebf33cec4e91f685c4281d95fad38c8b3f9cc74","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39.tgz","fileCount":22,"unpackedSize":41763,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFFWvno0vwv5mvPEkPxBRasX3y0DZBNu+KvNpwEmI4+BAiEA+/kgBIWyVUFia8LdNtmtdY33w290FFrw8F//2V7bKE4="}]},"_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-magic-link_1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39_1706709006884_0.3590739014162574"},"_hasShrinkwrap":false},"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/module-core":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/server":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/module-core":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/server":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@graphql-codegen/add":"5.0.2","@graphql-codegen/cli":"5.0.2","@graphql-codegen/introspection":"4.0.2","@graphql-codegen/typescript":"4.0.4","@graphql-codegen/typescript-operations":"4.1.2","@graphql-codegen/typescript-resolvers":"4.0.4","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-WymM/IQdKQk0F5l3ItY0EXqBGq9RuOGm9Px8ME0RMih0aWPv6yctPBv6XFZgLvL75O+7623wKZ2+/QY4ufq1+g==","shasum":"d8f9505dad848cd6f8bf088ab0c5baa2a1a1b0f8","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCa5ZJoZBP9SDkJ38TvyHq/zGINKvZ7i0+WrXEbmOSnmgIgULs6qULGce4ytBwATThBOaMsxW6gdy6AgIvBszbD8eg="}]},"_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-magic-link_1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a_1707394478568_0.6097337899744804"},"_hasShrinkwrap":false},"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":{"name":"@accounts/module-magic-link","version":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/module-core":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/server":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/module-core":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/server":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@graphql-codegen/add":"5.0.2","@graphql-codegen/cli":"5.0.2","@graphql-codegen/introspection":"4.0.2","@graphql-codegen/typescript":"4.0.4","@graphql-codegen/typescript-operations":"4.1.2","@graphql-codegen/typescript-resolvers":"4.0.4","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-5HsXw8vZZJjeOfBDMQBBN1TAMcf+ZUj5OGDRKdrAsa0ORTrher4Deo0LMCvyC2f6ht+pMfM/JrrJ2N8dGTxALg==","shasum":"e87d04ef8ef4f3a04a54cf2ca2330bcb4be2a918","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf.tgz","fileCount":22,"unpackedSize":41763,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDRRdeuAo9Uwv1b4lK/5RQSrDbtczR6QFaNyF+EN7NnmwIhAJYPUk2W/IysPvrXbXL3hlugtjRqvP1SOX/n121SrXri"}]},"_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-magic-link_1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf_1707395109789_0.29711184540288493"},"_hasShrinkwrap":false},"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":{"name":"@accounts/module-magic-link","version":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/module-core":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/server":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/module-core":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/server":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@graphql-codegen/add":"5.0.2","@graphql-codegen/cli":"5.0.2","@graphql-codegen/introspection":"4.0.3","@graphql-codegen/typescript":"4.0.6","@graphql-codegen/typescript-operations":"4.2.0","@graphql-codegen/typescript-resolvers":"4.0.6","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-oKYSWHDpg/ma2qJMtoT9Yb1QHgzEE7+khyKZNsPALKU5VHD7d4tm6ivd6sO90Fq35w7wP7mHgxgtwe4BoIvbLw==","shasum":"1fbc25b51ec4d023fdbf3c33b9d40e539c646821","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a.tgz","fileCount":22,"unpackedSize":41784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAH0P8WykTtzdleOd7IygYwySYEmLe4fQHBF1x3XY5rRAiEAhwKQ9PcRJlETb4n3UokH2JNGwFJiJKGh9bd0mEtUzB0="}]},"_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-magic-link_1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a_1709894091407_0.7360841327332786"},"_hasShrinkwrap":false},"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":{"name":"@accounts/module-magic-link","version":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","description":"Magic link module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run generate:graphql && yarn run -T tsc","testonly":"yarn run -T jest","coverage":"yarn run testonly --coverage","generate:graphql":"yarn run gql-gen","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/module-core":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/server":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","graphql-modules":"^3.0.0"},"dependencies":{"graphql-tag":"2.12.6","tslib":"2.6.2"},"devDependencies":{"@accounts/magic-link":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/module-core":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/server":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@graphql-codegen/add":"5.0.2","@graphql-codegen/cli":"5.0.2","@graphql-codegen/introspection":"4.0.3","@graphql-codegen/typescript":"4.0.6","@graphql-codegen/typescript-operations":"4.2.0","@graphql-codegen/typescript-resolvers":"4.0.6","@graphql-codegen/typescript-type-graphql":"3.0.0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e"},"_id":"@accounts/module-magic-link@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-K3PRrWCG34f8aCRq5Id4lD1MAnRg1dzZVkf32eDzeTWGTDJjTEm0Q2W/wQInAesSklSpb5o46R5PQZMlzhPoMw==","shasum":"fe75fd480f6db1c8eb2a0ef87c1aff2236473dbe","tarball":"https://registry.npmjs.org/@accounts/module-magic-link/-/module-magic-link-1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3.tgz","fileCount":22,"unpackedSize":41763,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHj9Fi8TcvjaAiQcCLPhSMFWnONx4WPmaT/J/trlaAq6AiEA9QMqJPt1hYL++yqgqCKGn0Cq0H0eCeQeHgSqf7pfKrc="}]},"_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-magic-link_1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3_1709894963143_0.4391609178007905"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-13T10:30:57.184Z","0.34.0":"2023-09-13T10:30:57.570Z","modified":"2024-03-08T10:49:23.772Z","1.0.0-alpha-20231022085748-0910b9e1":"2023-10-22T09:04:31.451Z","1.0.0-alpha-20231106132410-d312ae00":"2023-11-06T13:28:10.668Z","1.0.0-alpha-20231106135626-1555665c":"2023-11-06T14:03:16.488Z","1.0.0-alpha-20231109134411-9db5d55b":"2023-11-09T13:48:15.705Z","1.0.0-alpha-20231110150116-1eb474da":"2023-11-10T15:07:40.971Z","1.0.0-alpha-20231110204039-4238958d":"2023-11-10T20:47:07.947Z","1.0.0-alpha-20231111101845-4f997913":"2023-11-11T10:22:49.064Z","1.0.0-alpha-20231111172350-25f6cb1d":"2023-11-11T17:27:56.455Z","1.0.0-alpha-20231113142902-7812b73b":"2023-11-13T14:33:04.394Z","1.0.0-alpha-20231115113719-ae2b53a9":"2023-11-15T11:41:23.009Z","1.0.0-alpha-20231115205645-aa630d56":"2023-11-15T21:00:47.722Z","1.0.0-alpha-20231116130548-67b64a6a":"2023-11-16T13:09:59.433Z","1.0.0-alpha-20231116132834-55ee2b96":"2023-11-16T13:32:38.440Z","1.0.0-alpha-20231119093904-9adfd014":"2023-11-19T09:43:12.874Z","1.0.0-alpha-20231119094526-b1fc68c7":"2023-11-19T09:49:28.217Z","1.0.0-alpha-20231120163547-4a461fcc":"2023-11-20T16:39:49.838Z","1.0.0-alpha-20231120164530-e14d6a81":"2023-11-20T16:49:37.732Z","1.0.0-alpha-20231121011122-60a60524":"2023-11-21T01:15:30.441Z","1.0.0-alpha-20231122105229-8edd073f":"2023-11-22T10:56:40.678Z","1.0.0-alpha-20231122120807-69a661e3":"2023-11-22T12:12:23.956Z","1.0.0-alpha-20231122192915-c0243667":"2023-11-22T19:33:28.700Z","1.0.0-alpha-20231123103003-4f0c2405":"2023-11-23T10:34:09.265Z","1.0.0-alpha-20231123122853-0ccafb9d":"2023-11-23T12:32:56.314Z","1.0.0-alpha-20231123131746-58399dcd":"2023-11-23T13:21:41.913Z","1.0.0-alpha-20231123183707-51335dc2":"2023-11-23T18:41:12.533Z","1.0.0-alpha-20231124142337-45cc4d05":"2023-11-24T14:27:46.832Z","1.0.0-alpha-20231127162849-b5b29d3d":"2023-11-27T16:32:59.329Z","1.0.0-alpha-20231127170705-4b0b3391":"2023-11-27T17:11:13.540Z","1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":"2023-11-30T10:52:59.761Z","1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":"2023-12-06T16:15:10.063Z","1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":"2023-12-13T12:13:54.420Z","1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":"2023-12-14T10:38:28.382Z","1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":"2023-12-19T11:08:29.328Z","1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":"2024-01-07T15:10:25.051Z","1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":"2024-01-07T16:17:24.458Z","1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":"2024-01-08T08:25:55.494Z","1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":"2024-01-08T08:34:23.023Z","1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":"2024-01-31T13:41:39.832Z","1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":"2024-01-31T13:50:07.037Z","1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":"2024-02-08T12:14:38.732Z","1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":"2024-02-08T12:25:09.928Z","1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":"2024-03-08T10:34:51.567Z","1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":"2024-03-08T10:49:23.279Z"},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"description":"Magic link 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":""}