{"_id":"@accounts/module-typeorm","_rev":"43-729ddcfa81a5e52ba1801db72132698c","name":"@accounts/module-typeorm","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-typeorm","version":"0.34.0","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"^0.1.0","@accounts/module-core":"^0.34.0","@accounts/password":"^0.32.0","@accounts/server":"^0.32.0 || ^0.33.0","@accounts/typeorm":"^0.34.0","@accounts/types":"^0.32.0 || ^0.33.0","graphql":"^16.0.0","graphql-modules":"^2.0.0","graphql-tag":"^2.10.0","typeorm":"^0.3.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/password":"^0.32.1","@accounts/server":"^0.33.1","@accounts/typeorm":"^0.34.0","@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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"gitHead":"3153375d7ba666e8bcbbfd28f3e07890cb58d5f3","_id":"@accounts/module-typeorm@0.34.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-rX+yi0ih6PbbT1HkjfkylczbvmmOFUQbIy5cdOPHC+pE5aCuA45g9enbv/vqi0RcIBzxVTPfsL5Fttf4gQR/5Q==","shasum":"c2bb13d32df648c4d8e271b819f55f011771ef8c","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-0.34.0.tgz","fileCount":6,"unpackedSize":15664,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGww2YHJrb1xBJNVKt+/E4uvzfdYGhplWoFwiu27nXGvAiEA4w8MJBLpnGhpr3E3Q86bzsGmjYgLJEnZXDuQ5exZ/eg="}]},"_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-typeorm_0.34.0_1694601049207_0.20431628304177618"},"_hasShrinkwrap":false},"1.0.0-alpha-20231022085748-0910b9e1":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231022085748-0910b9e1","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/module-core":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/password":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/server":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/server":"1.0.0-alpha-20231022085748-0910b9e1","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-3y5bpQcq5hZ5uImv033tmEa8fcSSkKedR9QuMBNHM7SYtIQKBujZmzqW2wu+ZfYoUbwQQZFf7ljKPdlDfjInbQ==","shasum":"e79ba6350d51438959bc9f214d4392e3061d05ce","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231022085748-0910b9e1.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXtZvorq5rVgJLZDG+9GJJlw1JeBujtiNDyaUVmndezAIhAIZZsLkLDS7zQLhbk65ddMj6mt5zYKbYIDsCiCVgtIJb"}]},"_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-typeorm_1.0.0-alpha-20231022085748-0910b9e1_1697965448527_0.724555246769427"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106132410-d312ae00":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231106132410-d312ae00","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231106132410-d312ae00","@accounts/module-core":"1.0.0-alpha-20231106132410-d312ae00","@accounts/password":"1.0.0-alpha-20231106132410-d312ae00","@accounts/server":"1.0.0-alpha-20231106132410-d312ae00","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231106132410-d312ae00","@accounts/server":"1.0.0-alpha-20231106132410-d312ae00","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-aG4/2I2oxZ4DqRY495Ltlg/z725ChcERJwsyNBtkF/sOZi4vXWeYbQk+ONqP7S2mFKrMxFtdT6PPwePJsf+SAQ==","shasum":"b74ceb3b5c4de05183321221498538184bb822e6","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231106132410-d312ae00.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCH5RIs3vWeA/aERjt/ONJYccM5xh3EdvqWg9nkLEBEcAIgPdtsDy7AyZsaUN7f8BCedqU99Fip/tZU2z2bjOwPBqE="}]},"_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-typeorm_1.0.0-alpha-20231106132410-d312ae00_1699277277752_0.7506299965906684"},"_hasShrinkwrap":false},"1.0.0-alpha-20231106135626-1555665c":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231106135626-1555665c","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231106135626-1555665c","@accounts/module-core":"1.0.0-alpha-20231106135626-1555665c","@accounts/password":"1.0.0-alpha-20231106135626-1555665c","@accounts/server":"1.0.0-alpha-20231106135626-1555665c","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231106135626-1555665c","@accounts/server":"1.0.0-alpha-20231106135626-1555665c","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-zeCL0UdS9KWCNItZEYlFQnm5Rq78Ymf3Xgf7//8RxShwDUpEwtUzXUj6Wv37MAE16e2D8Md+HAQlLawouWB3ww==","shasum":"2352c4a908f53116b4ec525e85d3904f297e6138","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231106135626-1555665c.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFBaeYG7DuJyFt6FSweJGtKi/AcQx/AJRM4UvtSFPBT2AiEAqIruT8idengkwVEMu4628YZfzKvrL2bQkVsXpG/rXC4="}]},"_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-typeorm_1.0.0-alpha-20231106135626-1555665c_1699279371546_0.28228405371942533"},"_hasShrinkwrap":false},"1.0.0-alpha-20231109134411-9db5d55b":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231109134411-9db5d55b","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/module-core":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/password":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/server":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/server":"1.0.0-alpha-20231109134411-9db5d55b","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-cQvjZV2CHjDhCYJXqATfZFW+QarIvWsTVZth2TZeIYT3jviDYLdxXk9uw4viuJdZCFC61YQ0GxsQH1VRrd1l7w==","shasum":"8b4e7d8279ca3f30b3cb115f47b94ef3daddc77f","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231109134411-9db5d55b.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDDPpedV7AZi3byevI8xu+pNLdnEQrzmBUoGMWHO9v4jAiB1YfHvJfHu50vTwJIf7a5dRrpIYwOEGjPl21E+RyS1hQ=="}]},"_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-typeorm_1.0.0-alpha-20231109134411-9db5d55b_1699537684976_0.8942384524742304"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110150116-1eb474da":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231110150116-1eb474da","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231110150116-1eb474da","@accounts/module-core":"1.0.0-alpha-20231110150116-1eb474da","@accounts/password":"1.0.0-alpha-20231110150116-1eb474da","@accounts/server":"1.0.0-alpha-20231110150116-1eb474da","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231110150116-1eb474da","@accounts/server":"1.0.0-alpha-20231110150116-1eb474da","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-Eq/zZF1jxxbIUhFCJ/F4JxzQbeRjwtwzmGJGRdbmz7iJ5zOJMLv65i/z032WdVgwZlxBfFFam8Gz4Gok2RufVA==","shasum":"177b4647754b554750ed07d640ee3c314540a6d1","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231110150116-1eb474da.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID5w4AY+x5By8ZDKBntDJOl/IBheWh/VlMd13uclzz6yAiEA5cms4Zor4VaogMbYWf0MXTRJ+lWrGz46zgFPdYKVzIU="}]},"_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-typeorm_1.0.0-alpha-20231110150116-1eb474da_1699628837425_0.055352764250599096"},"_hasShrinkwrap":false},"1.0.0-alpha-20231110204039-4238958d":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231110204039-4238958d","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231110204039-4238958d","@accounts/module-core":"1.0.0-alpha-20231110204039-4238958d","@accounts/password":"1.0.0-alpha-20231110204039-4238958d","@accounts/server":"1.0.0-alpha-20231110204039-4238958d","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231110204039-4238958d","@accounts/server":"1.0.0-alpha-20231110204039-4238958d","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-pfJOQdPhYd20etSmqeMDcQpc2iPTSzx5MgrZ9Bj988U3dIVECvUPqXYQtpwUDZmGX1t+2UKIFh8gQ9EKT6+cog==","shasum":"1801a7617c592dba8fe4a6890e7ad5a337de1361","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231110204039-4238958d.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFfYgnnK6sB0h3Olcy1AQKDKEWisHuCynzBZsrL2yDRhAiB/0LtLsDnEP4SmYFQgGLw0Qr1DCoHzousAKX//NzTXXw=="}]},"_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-typeorm_1.0.0-alpha-20231110204039-4238958d_1699649208624_0.6820280088625836"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111101845-4f997913":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231111101845-4f997913","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231111101845-4f997913","@accounts/module-core":"1.0.0-alpha-20231111101845-4f997913","@accounts/password":"1.0.0-alpha-20231111101845-4f997913","@accounts/server":"1.0.0-alpha-20231111101845-4f997913","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231111101845-4f997913","@accounts/server":"1.0.0-alpha-20231111101845-4f997913","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-KPaDzsTFlyplCf85OS2JpKmJhmUneiSoS3DLmf4EtjdwMoLdWH77tW9k0kPi7633oL/IbTLds9qHuOmHdcFSNQ==","shasum":"6c41b4c5c4e7f97aee62d3caa8127556b5040572","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231111101845-4f997913.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGiEx8ACbo7vtqvY/RCT/Ud1T2Mw1A/AEqfirW9OUyiDAiEAqJvepjSv5O2jta4CqInPBcOKn2wmdetP8Zp+/KXd6i4="}]},"_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-typeorm_1.0.0-alpha-20231111101845-4f997913_1699698158298_0.2781640499386169"},"_hasShrinkwrap":false},"1.0.0-alpha-20231111172350-25f6cb1d":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231111172350-25f6cb1d","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/module-core":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/password":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/server":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/server":"1.0.0-alpha-20231111172350-25f6cb1d","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-d05mu90s+P/XBKGiqnWqEXoBm1TPm9JVcLlXTJpmd2jomm4xPQSXivSVhx3MlsbdbBJfabo04YXKc/DQIfIrFg==","shasum":"a4c9119d153e2957dc7aab62fd362f18c2b08761","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231111172350-25f6cb1d.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDwNkDwvGN0tCCZKKRZVNHEysd2V+KgsT9DZ1PnmXUVJAiEAqNTn9dE5kUijCQMinQ5Z8k0fIozwH5n34Qk+8jDyMPE="}]},"_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-typeorm_1.0.0-alpha-20231111172350-25f6cb1d_1699723664930_0.46710433049003863"},"_hasShrinkwrap":false},"1.0.0-alpha-20231113142902-7812b73b":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231113142902-7812b73b","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231113142902-7812b73b","@accounts/module-core":"1.0.0-alpha-20231113142902-7812b73b","@accounts/password":"1.0.0-alpha-20231113142902-7812b73b","@accounts/server":"1.0.0-alpha-20231113142902-7812b73b","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231113142902-7812b73b","@accounts/server":"1.0.0-alpha-20231113142902-7812b73b","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-9jLVenHc9E3i7m3tTRjwkvCVQXbmYPMUybQNgqKVlbkfG+xQ4E2U9gmM3cy+2J7uNiiORqaKk5On8kOlZ8BZzQ==","shasum":"5437170fd6255639824bfaa8a57affaa5497d829","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231113142902-7812b73b.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCaNiw6UL+0xVwV9dtukoRzGVIDBPi2jd8G4LUVyu6vlAIhAIPyYJdiD4qNtAaxI6SuNZjkkScq70koMF+FX8YxjWdN"}]},"_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-typeorm_1.0.0-alpha-20231113142902-7812b73b_1699885973903_0.6893669863163587"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115113719-ae2b53a9":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231115113719-ae2b53a9","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/module-core":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/password":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/server":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/server":"1.0.0-alpha-20231115113719-ae2b53a9","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-uG3edOxfm6ZxEkRGv06dkNneJ595zZwcViUw94r3K3OszNZGWcrDlX8Y6vCXw25nMABFhIfvh7VGRhXYPCJJnw==","shasum":"1a6e9e2e7d313e4718200c9f72625d536c738a1a","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231115113719-ae2b53a9.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCb5mLzjc9vxyTRYAyr196Po4BTPCV2NdBPvsALfw0amQIgQBr7I1jvgFtGdaDijTwI90oZ+tQKktooLr60RJFL3NU="}]},"_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-typeorm_1.0.0-alpha-20231115113719-ae2b53a9_1700048470556_0.5539698567678168"},"_hasShrinkwrap":false},"1.0.0-alpha-20231115205645-aa630d56":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231115205645-aa630d56","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231115205645-aa630d56","@accounts/module-core":"1.0.0-alpha-20231115205645-aa630d56","@accounts/password":"1.0.0-alpha-20231115205645-aa630d56","@accounts/server":"1.0.0-alpha-20231115205645-aa630d56","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231115205645-aa630d56","@accounts/server":"1.0.0-alpha-20231115205645-aa630d56","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-2yaflWvx5pd/pMlsnTxVjyxb7kkySdsCgueh80iiXj9Kf41svJm81n5lcFx/nTQzZ0TkXIUrDwlTB9bJYNMNVw==","shasum":"1c1cc22d9277ce36d3ef93c9bbd48746d4da2dbe","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231115205645-aa630d56.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEnWLilJJD9JrF0QqvKQjKPVpef7noFBeK7ijVO3IHCiAiBpla/3XN0MZ+4r4n+qeiRpbE+ng/4ggU8xcg/iRaLKAg=="}]},"_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-typeorm_1.0.0-alpha-20231115205645-aa630d56_1700082037701_0.9253112930804979"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116130548-67b64a6a":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231116130548-67b64a6a","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/module-core":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/password":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/server":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/server":"1.0.0-alpha-20231116130548-67b64a6a","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-UU+Z8f+CieJGaxflSICdy4ygt6mlZW7UjQs5cQ3VpulTqFskeEsz5R1Em4lDpww0pRlllwhQxEeGNeQkgvqbEg==","shasum":"5a5746545e15d0e30b0dd37eccc2e978271ed95c","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231116130548-67b64a6a.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4sFhP+GlifatgxCKLangtobkiB4L/aSZRYKxHz47FXwIgCpzmktXtagmrRgVKPx95kYoVyhtngn/3paNQsfv0bu4="}]},"_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-typeorm_1.0.0-alpha-20231116130548-67b64a6a_1700140186347_0.1934501052325781"},"_hasShrinkwrap":false},"1.0.0-alpha-20231116132834-55ee2b96":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231116132834-55ee2b96","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/module-core":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/password":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/server":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/server":"1.0.0-alpha-20231116132834-55ee2b96","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-21ioi0fpjFXpmItYhqc/ZYv5Tnbx5bKaMfQ4N5F0dXmLZdPbS2Xkhnfx0azmdpEl3X1JR1Y8SLQeQ4TbK3MnMA==","shasum":"ec9fbef4817ff402cc6b72b05dd1101d05193469","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231116132834-55ee2b96.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHoqtX5j+r/qQ1uSvLRfau2Zeq9TKdEkdxgRRI8ghYcoAiEAhQqtxLWWjMlkZ1jKObfPJExfvy2JD5QBWDytwKhxbM0="}]},"_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-typeorm_1.0.0-alpha-20231116132834-55ee2b96_1700141548076_0.9063007754458392"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119093904-9adfd014":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231119093904-9adfd014","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231119093904-9adfd014","@accounts/module-core":"1.0.0-alpha-20231119093904-9adfd014","@accounts/password":"1.0.0-alpha-20231119093904-9adfd014","@accounts/server":"1.0.0-alpha-20231119093904-9adfd014","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231119093904-9adfd014","@accounts/server":"1.0.0-alpha-20231119093904-9adfd014","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-JcI5DjVm+ZfLtvtul/78tCsSUoditsdbwoSzzR14WrMR9ljy56DM1m5Vp52PJvVXj7Rba9fzWxdXT5FsdAvIQA==","shasum":"5f1d509a37b7abf21db0844115afe1b40e38b08f","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231119093904-9adfd014.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHmxliXwIg7l8mkKylNz35fEN8AzljvVxZKOH/Oc5p2RAiBHM4JM6VcVoS1i7GEdLwGIeTzjJsFAO8huc9SD0ulzWQ=="}]},"_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-typeorm_1.0.0-alpha-20231119093904-9adfd014_1700386982095_0.554414369704185"},"_hasShrinkwrap":false},"1.0.0-alpha-20231119094526-b1fc68c7":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231119094526-b1fc68c7","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/module-core":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/password":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/server":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/server":"1.0.0-alpha-20231119094526-b1fc68c7","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-pf0gdXC7YNJopckYn/uBmr4eYGr2PeRyFPhakOujDc4RXXx51VsYS07qsZUI8+r+QqIWuMN6rpwl32sC8Ffd/A==","shasum":"a4ae1c003aba1beb4356470adb0d9e8fc09222a6","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231119094526-b1fc68c7.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCtcrS1H/GNiApIygf0y52hPdkFQGm1YrQZHT3JJ0lgUwIhAMtukypWFa0C2s7isgS9sUL2Be7ORT7GlMCXQYIfyRWY"}]},"_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-typeorm_1.0.0-alpha-20231119094526-b1fc68c7_1700387356662_0.24606441009876368"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120163547-4a461fcc":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231120163547-4a461fcc","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/module-core":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/password":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/server":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/server":"1.0.0-alpha-20231120163547-4a461fcc","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-VM0K/+PHJHWftwEnRT7SYH/4b84slvRcOV481DranP1tEDJ+zOfBm+0E8NQa9HGV1PwuWTh26VNiMndpA+/ACg==","shasum":"fa2d521d64a9dbf5de3025070babe4f88e831cda","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231120163547-4a461fcc.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFXX40NT1fQ33YoytV8kdJN7qr1yAAk08xspxDR/JQRRAiAzgu4V5q0C48oJMtO/z2PVwP8F2GD0K5x+R7HU9RTeBg=="}]},"_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-typeorm_1.0.0-alpha-20231120163547-4a461fcc_1700498378667_0.9065004496070743"},"_hasShrinkwrap":false},"1.0.0-alpha-20231120164530-e14d6a81":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231120164530-e14d6a81","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/module-core":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/password":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/server":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/server":"1.0.0-alpha-20231120164530-e14d6a81","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-KyVQhbrKRsyRDdInMo1VD+RxYuTa7D7KBOzD30uTVf/N7VsqPb0fquCTiTz33sk+IS50qXuUWQJEZkw2u6QKZg==","shasum":"0232b0d8d4e543500a192f2baad6b5d510cb33d7","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231120164530-e14d6a81.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGFaZesUHJCzTXq6V5n/DEzDMoUEHbGa5iTLQNneVnCuAiBiIoWr/HzyRCRps4Bibo3UC6g8+eGl9YCRhzWaYcttLA=="}]},"_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-typeorm_1.0.0-alpha-20231120164530-e14d6a81_1700498962452_0.24136140881618395"},"_hasShrinkwrap":false},"1.0.0-alpha-20231121011122-60a60524":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231121011122-60a60524","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231121011122-60a60524","@accounts/module-core":"1.0.0-alpha-20231121011122-60a60524","@accounts/password":"1.0.0-alpha-20231121011122-60a60524","@accounts/server":"1.0.0-alpha-20231121011122-60a60524","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231121011122-60a60524","@accounts/server":"1.0.0-alpha-20231121011122-60a60524","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-KSQ2MOQFJAUwQeOR+n/aWFGTZ1zcVVulxdhX8Joq99VKZBLJS9ql7s+f43vh8lPMRXHV5viEwZ4Xumwl5Tj15w==","shasum":"a80024d01f5cc6c26084a787da28cf6a4c16a3ad","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231121011122-60a60524.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDhlJlB5izFkJfeBbjqQMsU1zjHzgus2Cd36xl0N28OGgIgU4xUQD+B0gX3Kb5oJkLW/oGn7Gjdi/+0cG3gA3eBDgw="}]},"_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-typeorm_1.0.0-alpha-20231121011122-60a60524_1700529320903_0.010009946199855735"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122105229-8edd073f":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231122105229-8edd073f","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231122105229-8edd073f","@accounts/module-core":"1.0.0-alpha-20231122105229-8edd073f","@accounts/password":"1.0.0-alpha-20231122105229-8edd073f","@accounts/server":"1.0.0-alpha-20231122105229-8edd073f","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231122105229-8edd073f","@accounts/server":"1.0.0-alpha-20231122105229-8edd073f","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-z5lB45C8Ef03L+PdZKR14sKVepzRMjYKL3DTU4FPfO1WzMXNQjjHMNmq1wN6j8XWvYRMmB62CfeJs0QCv/Gn/w==","shasum":"ed2caf2a9ec507d31798e112886c3c354d32d404","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231122105229-8edd073f.tgz","fileCount":6,"unpackedSize":16039,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHzlz50oWO4XLD5W11C0r8vKqhG3ocBfLpbQ7P1HQ7XhAiBkMAPjWGv8d0GnCCR39CqZm14eNISXN/boMb/IhZ8g5w=="}]},"_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-typeorm_1.0.0-alpha-20231122105229-8edd073f_1700650589771_0.9119466741563824"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122120807-69a661e3":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231122120807-69a661e3","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/magic-link":"1.0.0-alpha-20231122120807-69a661e3","@accounts/module-core":"1.0.0-alpha-20231122120807-69a661e3","@accounts/password":"1.0.0-alpha-20231122120807-69a661e3","@accounts/server":"1.0.0-alpha-20231122120807-69a661e3","@accounts/typeorm":"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","typeorm":"^0.3.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/password":"1.0.0-alpha-20231122120807-69a661e3","@accounts/server":"1.0.0-alpha-20231122120807-69a661e3","@accounts/typeorm":"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","reflect-metadata":"0.1.13","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-/cMZ3u3obgJgmjNuhTbLQ6ycbHu9332Bv6VC0MmxH5X63E9fXFhf3QML2hh7RR7qJysEfAxs7lw8QBJHM49SJQ==","shasum":"22bf2a24b0b9be2c25d693799e345445c36576a9","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231122120807-69a661e3.tgz","fileCount":6,"unpackedSize":16064,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICm4NOyJ5jx0wzkgzdlQqbXOPZUb6atrLdGXvuB4AcXPAiEAw2PnYxzq1CbzZnZWDa/a532C0XQorZcUK66xi2Vilag="}]},"_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-typeorm_1.0.0-alpha-20231122120807-69a661e3_1700655131488_0.8587071424675825"},"_hasShrinkwrap":false},"1.0.0-alpha-20231122192915-c0243667":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231122192915-c0243667","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231122192915-c0243667","@accounts/typeorm":"1.0.0-alpha-20231122192915-c0243667","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231122192915-c0243667","@accounts/typeorm":"1.0.0-alpha-20231122192915-c0243667","@accounts/types":"1.0.0-alpha-20231122192915-c0243667","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-TZ7aTIneLQ4m4J3wc3IKgkSUSU5HKMVaMOujdf/+ONC71HHoze3cmuZzQ1quYrX/7v8xsWGg6zhJ5dTs0vtRiw==","shasum":"ef56c14a0700e2dae381d4c8f5c9325b32114d42","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231122192915-c0243667.tgz","fileCount":6,"unpackedSize":15017,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICCRLQGRfn2E4aVUIUG7nsTw8i9hlqsYWwAfoY1Lje0yAiAH0Vu+c96mDjLbzuguLNntXNUgjlUdroJvKC+YnZmp5w=="}]},"_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-typeorm_1.0.0-alpha-20231122192915-c0243667_1700681596661_0.7358964894931432"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123103003-4f0c2405":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231123103003-4f0c2405","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/typeorm":"1.0.0-alpha-20231123103003-4f0c2405","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/typeorm":"1.0.0-alpha-20231123103003-4f0c2405","@accounts/types":"1.0.0-alpha-20231123103003-4f0c2405","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-9nCn0bAo+/mg6ZzfGvzfxUYMZO3a5FC8+B28FsUjuwzm+N8DEj6Rqt/FFY+OJ07AqW6oln3kfLcUd8ytuo/9WA==","shasum":"7921e9b53a2acfc1f5e99055bea965ea385b76ef","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231123103003-4f0c2405.tgz","fileCount":6,"unpackedSize":15017,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDBh9hJqtbbWxW+rXEv8G3BibFXnMSKCEaerHSOHHc6lgIhAPU+k5dFr/xogNshvBnooHvkh3t93/SZPxvDUW5Q4h8b"}]},"_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-typeorm_1.0.0-alpha-20231123103003-4f0c2405_1700735637173_0.42043351079774416"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123122853-0ccafb9d":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231123122853-0ccafb9d","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/typeorm":"1.0.0-alpha-20231123122853-0ccafb9d","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/typeorm":"1.0.0-alpha-20231123122853-0ccafb9d","@accounts/types":"1.0.0-alpha-20231123122853-0ccafb9d","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-+ulK3XqI5PzGmYbdq8M3hD1ODyqyq4uMulcn/ulaqsoib3pjSWcMGC4luyI+cN0qy1xQ4/ff6jDGkVwt2GCtOQ==","shasum":"3cdffb87217d55d95819fe3a72e0268bfeb8ee73","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231123122853-0ccafb9d.tgz","fileCount":6,"unpackedSize":15017,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGS6M1DIe48dlE5jIciaX3E8pZKYDvhQO3nJU+YRbIz5AiEA70f7cpqNTSs5/QvVgpxCeBGJD/dwLSKuFqrU8mri81Y="}]},"_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-typeorm_1.0.0-alpha-20231123122853-0ccafb9d_1700742762232_0.18326654549515697"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123131746-58399dcd":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231123131746-58399dcd","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231123131746-58399dcd","@accounts/typeorm":"1.0.0-alpha-20231123131746-58399dcd","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231123131746-58399dcd","@accounts/typeorm":"1.0.0-alpha-20231123131746-58399dcd","@accounts/types":"1.0.0-alpha-20231123131746-58399dcd","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-TQevK4S2SWH566hzIO7xzlHi14AaBOy7YlTVuE/CwFGeuGBLjwNMtKbSYt9hXBycMKi+wFW6t8qLPO+zgYOZCg==","shasum":"4f87731c1e0ab909a4f50f58ced7e34219a755da","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231123131746-58399dcd.tgz","fileCount":6,"unpackedSize":15017,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGbe25q3HZH83XeAiLAr4Sv1RdRcokYfPDn3R8nxAskjAiAVS4SehBD/lGjHLwPRyd8cYBzt5I2U3EjQ+gax1GWkag=="}]},"_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-typeorm_1.0.0-alpha-20231123131746-58399dcd_1700745701695_0.8022596865001956"},"_hasShrinkwrap":false},"1.0.0-alpha-20231123183707-51335dc2":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231123183707-51335dc2","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231123183707-51335dc2","@accounts/typeorm":"1.0.0-alpha-20231123183707-51335dc2","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231123183707-51335dc2","@accounts/typeorm":"1.0.0-alpha-20231123183707-51335dc2","@accounts/types":"1.0.0-alpha-20231123183707-51335dc2","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-PWitO/pq80ZxEw6qZ0I8z6nvUu1zcjIcLSMpbNHJnNKlQO2pfnJBs4YU2VvBED7TCnMqqEU6dpw+Tux0GgCqog==","shasum":"cf7a25b24a8ec416bd576b5f401ef807f0b0e824","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231123183707-51335dc2.tgz","fileCount":6,"unpackedSize":15017,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB0FK+9GlMtmb8KhaIPA9JcTC+hiKw7IatoC6ePxoiqmAiAhTiBZzT1mSTQt2BlICq+J6pS+daAbPydEJxYAkx8y7A=="}]},"_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-typeorm_1.0.0-alpha-20231123183707-51335dc2_1700764858775_0.8928594214107841"},"_hasShrinkwrap":false},"1.0.0-alpha-20231124142337-45cc4d05":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231124142337-45cc4d05","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/typeorm":"1.0.0-alpha-20231124142337-45cc4d05","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/typeorm":"1.0.0-alpha-20231124142337-45cc4d05","@accounts/types":"1.0.0-alpha-20231124142337-45cc4d05","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-17oiY2KWJpepx1bQTh1fwIfor0ru9AHnkARUOihLUm9bhfKEzI9ojRkmei8vWOfEQoBwe8qjKEjnQEfknH+5rQ==","shasum":"0e0c0ce4c96dd5fb271405a7edf9b22dced829c6","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231124142337-45cc4d05.tgz","fileCount":6,"unpackedSize":15017,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCoHQA4MlwO74cShBD0QSINrN5eqsGb7kwprMwCu/dr/QIhAIXNSpfZhoqU7wLFGUw/CcrBJhnKvbYJGap4+nKIZtYt"}]},"_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-typeorm_1.0.0-alpha-20231124142337-45cc4d05_1700836055828_0.6897633003296966"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127162849-b5b29d3d":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231127162849-b5b29d3d","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/typeorm":"1.0.0-alpha-20231127162849-b5b29d3d","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/typeorm":"1.0.0-alpha-20231127162849-b5b29d3d","@accounts/types":"1.0.0-alpha-20231127162849-b5b29d3d","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-J1jinCI80JxK+8SnuceE5BEyOG5s6q4sAGrCODbuU08DHPl9mo6go9nel5n2ClVtFOEJO0oklcaC6aj3c5CS4A==","shasum":"1275854b82ebe19da79bdf5de76fa8b23684f9a1","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231127162849-b5b29d3d.tgz","fileCount":6,"unpackedSize":15017,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzYbbDuZQG2T/4ZCt3JTITBwoZg8ThCqBLChme5xZsYAIgOfR2k6EJMBx4XM/Ys5fFyR2IhQJiQCAklVsVT8EBHOo="}]},"_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-typeorm_1.0.0-alpha-20231127162849-b5b29d3d_1701102768188_0.3850527380626032"},"_hasShrinkwrap":false},"1.0.0-alpha-20231127170705-4b0b3391":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231127170705-4b0b3391","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/typeorm":"1.0.0-alpha-20231127170705-4b0b3391","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/typeorm":"1.0.0-alpha-20231127170705-4b0b3391","@accounts/types":"1.0.0-alpha-20231127170705-4b0b3391","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-j1tx7179sqDWystfCMGYYjpRpNEibtThmhNQ0bT6wmKhHzGIt67p4Zp4PHSfdxl2rPf8PhHm9kY6Edp2ufDhYQ==","shasum":"34c7da973142cd898ee0000a5cc8168088771a2a","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231127170705-4b0b3391.tgz","fileCount":6,"unpackedSize":15063,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAI9imbb1tvH92joHpVIlbfM/IBdC22wqabb9kGh4LPjAiBUD/IBc6Jhnye2pbFEctk2ICNM5IesYJr8NZbqk3m7Mg=="}]},"_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-typeorm_1.0.0-alpha-20231127170705-4b0b3391_1701105063257_0.9580285586119295"},"_hasShrinkwrap":false},"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/typeorm":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/typeorm":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","@accounts/types":"1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-MKcjImrP0N5WM/HJrj9rHGYMTBYmaAwJDrRR72L0KLp380LMK6qNKxV4/JPsOCaqBJHvCDBP+N6hQXTDAvTkFA==","shasum":"ef5c093e4e3d952121faaeb8a9290abe2a0a2af9","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCzsC3QT0LDLE4OZ8DMLhMT6wKLk7VKJnqQ3XmvDI5GYwIhAM82RjZXeml0dKqsH25JDtWWyGDDAFwZos98oLK3LsgK"}]},"_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-typeorm_1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165_1701341567200_0.01709057898645372"},"_hasShrinkwrap":false},"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/typeorm":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/typeorm":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","@accounts/types":"1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-Jt/0WZnTXMukZYyXC+inWE6KMSAORO7MGUF24cSffhfUAcxSwstUghm87UoMzRPQ/C1XSQafO6dYWYOQukg2EA==","shasum":"d49d5fc976500c187508d4914e52e61b7dd42b4c","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAnc5OkvgnboDuDm3X1p6Pn6OQpxgFHJ39qoYU9a191tAiEApBQ57k3wujU+GsLYnQ1uBYpUa+39frkLRUXTnVKDPvA="}]},"_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-typeorm_1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db_1701879297906_0.9191120127098062"},"_hasShrinkwrap":false},"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/typeorm":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/typeorm":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","@accounts/types":"1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-jf+XqyF7bggte+WF+34ueMvCjL6KoKlSAWnfiMgH7fZIdG0OK7lEROF3WKk5cUIVvzXnSa+Yr7hGcriwk7kF4Q==","shasum":"2f1711a4cff7841014177cdc4c193e9e5afb3943","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCeVVYEBGtI5m6v30D2dXCI7Exy0HEcAshWdge/sM/bNQIgd9jMZoJk2uQBauZNyxI69qdFpVL4IXa87A+YHp2hrGc="}]},"_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-typeorm_1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b_1702469622837_0.10453665186896677"},"_hasShrinkwrap":false},"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/typeorm":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/typeorm":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","@accounts/types":"1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-aPbO0sQRo4q7KqT4jNisC591D/85anb/H9SIyjNUXiGR0qk40gnGaMWj/n+zWk3ER6iT0VatpoEtY1FlKQNSlg==","shasum":"916bd04b4729ba240609242dab4fb16ccb59d720","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDa46CMlgabScJe8rVS6hJbeQuFReq5OPyoKV0YcyLgmQIgNEBje72UJN0GpVLSqzVcXOkL6YAwZExbXIZE9spa2Zc="}]},"_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-typeorm_1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd_1702550297287_0.45841491275996993"},"_hasShrinkwrap":false},"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/typeorm":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/typeorm":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","@accounts/types":"1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.17"},"_id":"@accounts/module-typeorm@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-V0KDuv9v7SYoSnXn/E1KCVnPxUs76fvD0/I+Ne42ufhwBHjpOT5GCcQnOVpUoyJqlkALJzSSfStJM0spOc5aEw==","shasum":"f796c5fea10fd83f98c14d2f9db97c62a4ab769c","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCV83ABDOV1yyuTZyrUBZd431Fp8NYhw5Qbn6MMbiFcwgIhAL2riwGGt8Xr4PW59Vh7VKrIMuU3ZRF39/5GYGQf6XRw"}]},"_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-typeorm_1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9_1702984096608_0.9042799025154433"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/typeorm":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/typeorm":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","@accounts/types":"1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.19"},"_id":"@accounts/module-typeorm@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-U2T2btvEcDgJgUWIVvW60r3hvUciOeDO0kDrZtvmqZ1SjNWMccwqSNSelnInG/mqGoH51E/kahtQ9raLOUnR7Q==","shasum":"64975a7ad99eef99e778f15cd0cd38b58256b074","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICdi5JHh2nZAgOKzE9v3Su6+pPKnbzKB9A5Z8YUgsP5mAiBTtzZYYQRLbuIF0rN2ORSIKqXCa37b6ptrIKG1hOCk/g=="}]},"_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-typeorm_1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b_1704640213459_0.6510772850072726"},"_hasShrinkwrap":false},"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/typeorm":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/typeorm":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","@accounts/types":"1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.19"},"_id":"@accounts/module-typeorm@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-o0OJ627bolvIRg2ZzFOr29G65dvL3InvJK7ZwWGdceoU7HZHEaWUohjPDyy78Vta3/kjwXW/zTeu6E5RpLD2jA==","shasum":"ecee95b889b6a3e8d5954c5b3103a9041ba6145e","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDJE2fdUdPVv43F24N2rwCvEaND/MmS5iZumBHCinOfSgIhANf+UbAUxMUkAJxAtDpTqPmph2SOQRPajF+G5Zjg1xeu"}]},"_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-typeorm_1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59_1704644231152_0.4845224587801076"},"_hasShrinkwrap":false},"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/typeorm":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/typeorm":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","@accounts/types":"1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.19"},"_id":"@accounts/module-typeorm@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-0Qjl/eVzQ5PAAUCa3eg6aqD6jYwhNvFE476XG7GzesSuRrpw+B84u010mwRXYZ3xUsugQuKZ9OJMpGED4HG2uA==","shasum":"980dcb2e465a2df90f6986f4633d244d668eb4dc","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGpGyXf+31cr+ZASmMcO59vNZO7r+keyhuF3D+bTOPBgAiALJDmGBMpvqGSklNUeMrhMTFXm/56WcN3arLXtwX/Lww=="}]},"_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-typeorm_1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0_1704702344168_0.9253896856945507"},"_hasShrinkwrap":false},"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":{"name":"@accounts/module-typeorm","version":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/typeorm":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/typeorm":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","@accounts/types":"1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.19"},"_id":"@accounts/module-typeorm@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-8f69EQHtlx2LhomwktOXEc6Gudcg/gW3rpPfZi1ZotRG+j5bNwi9HRLwK3tMF9jcRuMzPpQdnq+j0s1KAULK7g==","shasum":"4c745252e90f2f2d2926ea095bb17e5d7f991050","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45.tgz","fileCount":6,"unpackedSize":15237,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFgQr6+2K+x828yAPV0LUJoYJlXBNBFIG8Mbwf0WvzNWAiEAmD+EjTdnNQiYNDxkkpzmjWMk3WVIo+bDZT7xuci+tnM="}]},"_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-typeorm_1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45_1704702849890_0.784363748031355"},"_hasShrinkwrap":false},"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/typeorm":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/typeorm":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","@accounts/types":"1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.20"},"_id":"@accounts/module-typeorm@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-RTXaTWGuCWE6p6jFmIZUvtmVTwVfW1ziYbyhRlLX360jScQowkI18dYKX82fHf13Ix33nS2eSTzlVfF1RCX76A==","shasum":"1ba5162c6e7a31e55c3bb3918d57e1a6a1f4ab31","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCxdPFS0Z4uDm6SgqSZq8Q14WlUb3RNBEIQfFzvakaUwwIhALgANPB9alQCWd8vMidlPSZWWqEwOe+u4m4jqc7pSg53"}]},"_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-typeorm_1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d_1706708492708_0.8445765424241507"},"_hasShrinkwrap":false},"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":{"name":"@accounts/module-typeorm","version":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/typeorm":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/typeorm":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","@accounts/types":"1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.20"},"_id":"@accounts/module-typeorm@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-466EPb1XcYc+sv1TAFn77YbNgmevGeEqr2VDhSJ7U3ovTkvXZJWpgAQ1geewQ3mGOvWT6v1/+lX/DxFZw5+iow==","shasum":"491bbe8f458db054b42ce813ed172b7498b49fd4","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39.tgz","fileCount":6,"unpackedSize":15237,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEGn6Ek+WQ/1OfSnq7tiQW0ou9sIPAS2Jne00fFn0OxZAiEAiwqG6L7olj/I1NnbnxiBWUqTG7WPL83Z6aGKMv4PbSg="}]},"_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-typeorm_1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39_1706708995371_0.4552691729614129"},"_hasShrinkwrap":false},"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/typeorm":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/typeorm":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","@accounts/types":"1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.20"},"_id":"@accounts/module-typeorm@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-rXpNJWQMp8zBpWN3uQRKJmWR3xl0fI0BTqTtjvEdamZ30YF/2uXJHwJ/tjDKdSlaQXPEc1iYzmrUK3baFyLuTQ==","shasum":"f19d4c9fdddff182a7e89eb7cd08a6ee8b5cfec1","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD8adTb+1HlpdLonUKzD6OfEcMORV2b08UTbsUDsgKnCgIgffT3+f5PO8CNbMNLIgXcIrQvLAqyAS8R5IxMfPf+4Og="}]},"_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-typeorm_1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a_1707394468992_0.1915287383082298"},"_hasShrinkwrap":false},"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":{"name":"@accounts/module-typeorm","version":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/typeorm":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/typeorm":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","@accounts/types":"1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.20"},"_id":"@accounts/module-typeorm@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-4qqD3ewgIGEiIIabBxT/OBXNJXs2UVvgaAyX+DgpNKciaBIeDQrpC5E38EIuNDpZF9GPCy29x6iLQwG5GcOliQ==","shasum":"ebb8c5d6a8eaa29c6dfb0305a2c1c04d24f9e1d6","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf.tgz","fileCount":6,"unpackedSize":15237,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBiTJGUmRHMSZsAOEgIciG494BgqBd04LzO104DyJXnlAiEAyQRO5szsPPXQLAlk3gM9v4mwJN5E8UHJd7LIRTksJ+k="}]},"_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-typeorm_1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf_1707395096296_0.8558726773115231"},"_hasShrinkwrap":false},"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":{"name":"@accounts/module-typeorm","version":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/typeorm":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/typeorm":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","@accounts/types":"1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.20"},"_id":"@accounts/module-typeorm@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-stUcfNXBIWNckabyq6HOkwkknfBTas4OR8GYVA2HymQ1Gm5dLuulzuqM1RJ7tBh7QY1rDZQanzIJ2fc+Bit7KQ==","shasum":"305b99d0a0a0132c7a51f87c9b92d69d68c156ba","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a.tgz","fileCount":6,"unpackedSize":15255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICp1Jwc9WSzFtLwC47UnR5CJB2jSAJgTiMaPGerE++NlAiEAl2PJk1wWFmvD9VOIpJndVB3lMJd+Tf8JFYy1ulO0Z9U="}]},"_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-typeorm_1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a_1709894080793_0.7351719949240092"},"_hasShrinkwrap":false},"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":{"name":"@accounts/module-typeorm","version":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","description":"TypeORM Database Interface GraphQL Module","main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"clean":"yarn run -T rimraf lib","start":"yarn run -T tsc --watch","precompile":"yarn run clean","compile":"yarn run -T tsc","testonly":"yarn run -T jest --passWithNoTests","coverage":"yarn run testonly --coverage","prepublishOnly":"yarn run compile"},"jest":{"testEnvironment":"node","preset":"ts-jest"},"repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"license":"MIT","bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"homepage":"https://github.com/js-accounts/accounts","peerDependencies":{"@accounts/server":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/typeorm":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0","graphql-modules":"^3.0.0","typeorm":"^0.3.0"},"dependencies":{"tslib":"2.6.2"},"devDependencies":{"@accounts/server":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/typeorm":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","@accounts/types":"1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3","graphql":"16.8.1","graphql-modules":"3.0.0-alpha-20231106133212-0b04b56e","typeorm":"0.3.20"},"_id":"@accounts/module-typeorm@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-CnQIS6UlbgsrkmwyTErju+3pES0f8CcowvUrvvTdBSxS2gmRudk66hfebgtPK8whBCZawkvJ0kTt+XhBjh6dzA==","shasum":"c3c7bce9ab883cb3f8826a548d93b53c31440194","tarball":"https://registry.npmjs.org/@accounts/module-typeorm/-/module-typeorm-1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3.tgz","fileCount":6,"unpackedSize":15237,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHKgdDWEIPyoBk7ajN81sHUs1InAYuRKJuscfzbWchruAiAKddtz4AXsO8WJEt0/88aii5Zjg7Lfhy/H6HUkKUoSZA=="}]},"_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-typeorm_1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3_1709894959948_0.8764457488929958"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-13T10:30:49.082Z","0.34.0":"2023-09-13T10:30:49.394Z","modified":"2024-03-08T10:49:20.765Z","1.0.0-alpha-20231022085748-0910b9e1":"2023-10-22T09:04:08.781Z","1.0.0-alpha-20231106132410-d312ae00":"2023-11-06T13:27:57.909Z","1.0.0-alpha-20231106135626-1555665c":"2023-11-06T14:02:51.706Z","1.0.0-alpha-20231109134411-9db5d55b":"2023-11-09T13:48:05.134Z","1.0.0-alpha-20231110150116-1eb474da":"2023-11-10T15:07:17.629Z","1.0.0-alpha-20231110204039-4238958d":"2023-11-10T20:46:48.803Z","1.0.0-alpha-20231111101845-4f997913":"2023-11-11T10:22:38.467Z","1.0.0-alpha-20231111172350-25f6cb1d":"2023-11-11T17:27:45.088Z","1.0.0-alpha-20231113142902-7812b73b":"2023-11-13T14:32:54.072Z","1.0.0-alpha-20231115113719-ae2b53a9":"2023-11-15T11:41:10.792Z","1.0.0-alpha-20231115205645-aa630d56":"2023-11-15T21:00:37.913Z","1.0.0-alpha-20231116130548-67b64a6a":"2023-11-16T13:09:46.564Z","1.0.0-alpha-20231116132834-55ee2b96":"2023-11-16T13:32:28.347Z","1.0.0-alpha-20231119093904-9adfd014":"2023-11-19T09:43:02.335Z","1.0.0-alpha-20231119094526-b1fc68c7":"2023-11-19T09:49:16.832Z","1.0.0-alpha-20231120163547-4a461fcc":"2023-11-20T16:39:38.950Z","1.0.0-alpha-20231120164530-e14d6a81":"2023-11-20T16:49:22.653Z","1.0.0-alpha-20231121011122-60a60524":"2023-11-21T01:15:21.117Z","1.0.0-alpha-20231122105229-8edd073f":"2023-11-22T10:56:29.996Z","1.0.0-alpha-20231122120807-69a661e3":"2023-11-22T12:12:11.644Z","1.0.0-alpha-20231122192915-c0243667":"2023-11-22T19:33:16.881Z","1.0.0-alpha-20231123103003-4f0c2405":"2023-11-23T10:33:57.349Z","1.0.0-alpha-20231123122853-0ccafb9d":"2023-11-23T12:32:42.415Z","1.0.0-alpha-20231123131746-58399dcd":"2023-11-23T13:21:41.887Z","1.0.0-alpha-20231123183707-51335dc2":"2023-11-23T18:40:58.920Z","1.0.0-alpha-20231124142337-45cc4d05":"2023-11-24T14:27:36.073Z","1.0.0-alpha-20231127162849-b5b29d3d":"2023-11-27T16:32:48.412Z","1.0.0-alpha-20231127170705-4b0b3391":"2023-11-27T17:11:03.507Z","1.0.0-alpha-20231130104851-8345fe6cd6d691fbdd62e2128556729886215165":"2023-11-30T10:52:47.359Z","1.0.0-alpha-20231206161100-80de92b5866143888ffa3a9f9a5b859c2cb688db":"2023-12-06T16:14:58.076Z","1.0.0-alpha-20231213120946-d0b25d8c1fb32653d6d38baded85375166296b9b":"2023-12-13T12:13:42.994Z","1.0.0-alpha-20231214103418-1e7f8c6d37f0e6bf957dedb5c9566ef94ee5aabd":"2023-12-14T10:38:17.489Z","1.0.0-alpha-20231219110415-4099195bd5e8ffdc8eb76f0800ac2e48504820b9":"2023-12-19T11:08:16.797Z","1.0.0-alpha-20240107150616-b81459c89ce8a07a4ee8bafdf5b1fe521894f10b":"2024-01-07T15:10:13.672Z","1.0.0-alpha-20240107161311-3b08baff26de149c7ac84dd2fc77c459d7d1cf59":"2024-01-07T16:17:11.375Z","1.0.0-alpha-20240108082143-d74c0d3658792ccbd34fa5aa1573654370caaaf0":"2024-01-08T08:25:44.351Z","1.0.0-rc-20240108083011-511acde0cc05c194e989d0b75b38eb49836c2f45":"2024-01-08T08:34:10.064Z","1.0.0-alpha-20240131133732-7e266d9a0972859f936670670463acde6c27c45d":"2024-01-31T13:41:32.883Z","1.0.0-rc-20240131134559-3b97fdc3ab172c2bb1dea4a0d2ffd849b9f5da39":"2024-01-31T13:49:55.528Z","1.0.0-alpha-20240208121029-7d2c4bb20c8b189e9becbfca91d8414aab36775a":"2024-02-08T12:14:29.142Z","1.0.0-rc-20240208122057-283f2825621f91e014475c969d330ad5c036dadf":"2024-02-08T12:24:56.492Z","1.0.0-alpha-20240308103044-4af4256ffa4b58ff4654fa2e3514291b689b076a":"2024-03-08T10:34:40.967Z","1.0.0-rc-20240308104521-8c44e20d17ded2c8e8b7299c4bd7268b3582deb3":"2024-03-08T10:49:20.095Z"},"maintainers":[{"name":"leopradel","email":"pradel.leo@gmail.com"},{"name":"tmikeladze","email":"tim.mikeladze@gmail.com"},{"name":"dotansimha","email":"dotansimha@gmail.com"}],"description":"TypeORM Database Interface GraphQL Module","homepage":"https://github.com/js-accounts/accounts","repository":{"type":"git","url":"git+https://github.com/js-accounts/accounts.git"},"author":{"name":"Niccolò Belli","email":"niccolo.belli@linuxsystems.it"},"bugs":{"url":"https://github.com/js-accounts/accounts/issues"},"license":"MIT","readme":"","readmeFilename":""}