{"name":"prismarine-auth","version":"2.6.0","keywords":["prismarine","template"],"author":{"name":"Romain Beaumont"},"license":"MIT","_id":"prismarine-auth@2.6.0","maintainers":[{"name":"rom1504","email":"romain.rom1@gmail.com"}],"homepage":"https://github.com/PrismarineJS/prismarine-auth#readme","bugs":{"url":"https://github.com/PrismarineJS/prismarine-auth/issues"},"dist":{"shasum":"c6b3e2722fb9dc2b9ee054968cb1368d6e2668b5","tarball":"http://registry-npm.ywwl.com/prismarine-auth/download/prismarine-auth-2.6.0.tgz","fileCount":36,"integrity":"sha512-9XXYtr6rnJ5EZ/pf63HJvvYPh3lSPe/AIZubwj2BXBQBEidoBR3P5MIm/1nukLwnF1xHiNpF5Y20gcHCdigMDg==","signatures":[{"sig":"MEUCIQDsCiKTYe3R3kb/oegxs4iQNs2xhdTZKNleVd9/jjkiowIgB8+Vgmgr4HQnNE72v/mRsW9ENTErxShcNTyfKLtE+Mg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":77470,"size":23557,"noattachment":false,"key":"/prismarine-auth/-/prismarine-auth-2.6.0.tgz"},"main":"index.js","gitHead":"6fb190253aa0bc8ddf8ea7ee9b060cbb3ac6360d","scripts":{"fix":"standard --fix","lint":"standard","test":"npm run mocha","mocha":"mocha test/*.test.js --reporter spec --exit","pretest":"npm run lint"},"_npmUser":{"name":"rom1504","email":"romain.rom1@gmail.com"},"repository":{"url":"git+https://github.com/PrismarineJS/prismarine-auth.git","type":"git"},"_npmVersion":"6.14.4","description":"Authentication library for Microsoft, Xbox Live, and Minecraft with caching support","directories":{},"_nodeVersion":"14.0.0","dependencies":{"debug":"^4.3.3","uuid-1345":"^1.0.2","smart-buffer":"^4.1.0","@azure/msal-node":"^2.0.2","@xboxreplay/xboxlive-auth":"^3.3.3"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.4","mocha":"^11.0.1","standard":"^17.0.0","prismarine-auth":"file:.","chai-as-promised":"^7.1.1"},"_npmOperationalInternal":{"tmp":"tmp/prismarine-auth_2.6.0_1737300397625_0.44637853728221266","host":"s3://npm-registry-packages-npm-production"},"readme":"# prismarine-auth\n[![NPM version](https://img.shields.io/npm/v/prismarine-auth.svg)](http://npmjs.com/package/prismarine-auth)\n[![Build Status](https://github.com/PrismarineJS/prismarine-auth/workflows/CI/badge.svg)](https://github.com/PrismarineJS/prismarine-auth/actions?query=workflow%3A%22CI%22)\n[![Official Discord](https://img.shields.io/static/v1.svg?label=PrismarineJS&message=Discord&color=blue&logo=discord)](https://discord.gg/GsEFRM8)\n[![Try it on gitpod](https://img.shields.io/badge/try-on%20gitpod-brightgreen.svg)](https://gitpod.io/#https://github.com/PrismarineJS/prismarine-auth)\n\nQuickly and easily obtain auth tokens to authenticate with Microsoft/Xbox/Minecraft/Mojang\n\n## Installation\n```shell\nnpm install prismarine-auth\n```\n\n## Usage\n\n### Authflow\n**Parameters**\n- username? {String} - Username for authentication\n- cacheDirectory? {String | Function} - Where we will store your tokens (optional) or a factory function that returns a cache.\n- options {Object?}\n    - [flow] {enum} Required if options is specified - see [API.md](docs/API.md) for options\n    - [forceRefresh] {boolean} - Clear all cached tokens for the specified `username` to get new ones on subsequent token requests\n    - [password] {string} - If passed we will do password based authentication.\n    - [authTitle] {string} - See the [API.md](docs/API.md)\n    - [deviceType] {string} - See the [API.md](docs/API.md)\n- onMsaCode {Function} - (For device code auth) What we should do when we get the code. Useful for passing the code to another function.\n\n### Examples\n\n### getMsaToken\n```js\nconst { Authflow, Titles } = require('prismarine-auth')\n\nconst userIdentifier = 'unique identifier for caching'\nconst cacheDir = './' // You can leave this as undefined unless you want to specify a caching directory\nconst flow = new Authflow(userIdentifier, cacheDir)\n// Get a auth token, then log it\nflow.getMsaToken().then(console.log)\n```\n\n**Note**: By default, this library will authenticate as Minecraft for Nintendo Switch, with a `flow` set to `live`. For non-Minecraft applications you should\nregister for Microsoft Azure Oauth token. See https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app#register-an-application for more information on obtaining an Azure token. You then use it with the `msal` flow like this:\n\n```js\nconst flow = new Authflow(userIdentifier, cacheDir, { flow: 'msal', authTitle: '000-000-000-000' })\n```\n\nIf `flow` is `live`, the default, then you can only specify existing Microsoft client IDs. This library exposes some default Microsoft client IDs under the exported `Titles` object. See the [types](./index.d.ts) for more information.\n\n### getXboxToken\nSee [docs/API.md](docs/API.md)\n\n\n### getMinecraftJavaToken\n```js\nconst { Authflow, Titles } = require('prismarine-auth')\n\nconst userIdentifier = 'any unique identifier'\nconst cacheDir = './' // You can leave this as undefined unless you want to specify a caching directory\nconst flow = new Authflow(userIdentifier, cacheDir)\n// Get a Minecraft Java Edition auth token, then log it\nflow.getMinecraftJavaToken({ fetchProfile: true }).then(console.log)\n```\n\n### Expected Response\n```json\n{\n    \"token\": \"ey....................\",\n    \"entitlements\": {},\n    \"profile\": {\n        \"id\": \"b945b6ed99b548675309473a69661b9a\",\n        \"name\": \"Usname\",\n        \"skins\": [ [Object] ],\n        \"capes\": []\n    }\n}\n```\n\n### getMinecraftBedrockToken\nSee [docs/API.md](docs/API.md) and [example](examples).\nIt returns an object with `{ chain, token }` for Bedrock login.\n\n### getMinecraftBedrockChain\nSee [docs/API.md](docs/API.md).\n\n### getMinecraftBedrockMultiplayerToken\nSee [docs/API.md](docs/API.md).\n\n### getMinecraftBedrockServicesToken\n```js\nconst { Authflow, Titles } = require('prismarine-auth')\n\nconst userIdentifier = 'any unique identifier'\nconst cacheDir = './' // You can leave this as undefined unless you want to specify a caching directory\nconst flow = new Authflow(userIdentifier, cacheDir)\n// Get a Minecraft Services token, then log it\nflow.getMinecraftBedrockServicesToken().then(console.log)\n```\n\n### Expected Response\n```json\n{\n    \"mcToken\": \"MCToken eyJ...\",\n    \"validUntil\": \"1970-01-01T00:00:00.000Z\",\n    \"treatments\": [\n      \"mc-enable-feedback-landing-page\",\n      \"mc-store-enableinbox\",\n      \"mc-nps-freeorpaid-paidaug24\",\n      // and more\n    ],\n    \"configurations\": {\n      \"validation\": {\n        \"id\": \"Validation\",\n        \"parameters\": {\n          \"minecraftnetaatest\": \"false\"\n        }\n      },\n      \"minecraft\": {\n        \"id\": \"Minecraft\",\n        \"parameters\": {\n          \"with-spongebobadd-button-noswitch\": \"true\",\n          \"sfsdfsdfsfss\": \"true\",\n          \"fsdfd\": \"true\",\n          \"mc-maelstrom-disable\": \"true\",\n          // and more\n        }\n      }\n    },\n    \"treatmentContext\": \"mc-sunsetting_5:31118471;mc-...\"\n}\n```\n\n### More\n[View more examples here](https://github.com/PrismarineJS/prismarine-auth/tree/master/examples).\n\nSee the [types](./index.d.ts) to checkout the full API.\n\n## API\n\nSee [docs/API.md](docs/API.md)\n\n## Debugging\n\nYou can enable some debugging output using the `DEBUG` enviroment variable. Through node.js, you can add `process.env.DEBUG = 'prismarine-auth'` at the top of your code.\n\n\n## Testing\n\nSimply run `npm test` or `yarn test`\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1737300397823,"_cnpm_publish_time":1737300397823,"dist-tags":{"latest":"3.1.1"}}