{"_id":"@synonymdev/slashauth","_rev":"28-73e29afcb7b2ed9e18313a39fb44a3ad","name":"@synonymdev/slashauth","dist-tags":{"latest":"1.0.0-alpha.0"},"versions":{"1.0.0-alpha.0":{"name":"@synonymdev/slashauth","version":"1.0.0-alpha.0","keywords":[],"license":"MIT","_id":"@synonymdev/slashauth@1.0.0-alpha.0","maintainers":[{"name":"rbndg","email":"rbandegi@gmail.com"},{"name":"chm-diederichs","email":"christophe.diederichs@googlemail.com"},{"name":"bitcoinerrorlog","email":"john@synonym.to"},{"name":"jayvdb","email":"jayvdb1@gmail.com"},{"name":"coreyphillips","email":"corey.lyle.phillips@gmail.com"},{"name":"gr0kchain","email":"gr0kchain@protonmail.com"},{"name":"nzh","email":"ar.nazeh@gmail.com"}],"homepage":"https://github.com/synonymdev/slashtags/tree/master/packages/auth/#readme","bugs":{"url":"https://github.com/synonymdev/slashtags/issues"},"dist":{"shasum":"a695a623b23923a2224e36221d4c837409de7c3d","tarball":"https://registry.npmjs.org/@synonymdev/slashauth/-/slashauth-1.0.0-alpha.0.tgz","fileCount":19,"integrity":"sha512-CbDi+r7OqHWi92UcbCMbUafPQKl8x02F8FsUwI0qCTqua9w/N5eBJ+uU8Y+RI9m0QwaU+r18+MHvFy6zSuJVSw==","signatures":[{"sig":"MEUCIG2+JlKQm52cGRDXImQfQub94qXrlqYdwBlG2la69zKcAiEA0H0ZDqXqfxsmyIx5DmIE3F2k7ypp/Ii6JysIcKrXv38=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7322361,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJijeGtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr3SQ/5AZ+tG5pn73QDL/O5eZaFWcYNp3dlYgIXW1ZrpCJYNQkrafNu\r\nDNa38J3apTMICfZbndgV/nkkrPQs4mslaiQXsHPUlBO2IuL9x+NYaqG6qc/P\r\nDuRQxG0/dBRD9m2gnI5GJyMVPPgp8qlgHs8WK4R80FUheNOLLwo/WJRRg95i\r\nzL7e51CghWqaPCJyt75rLHWKndEhA864wUtiqar2YaqBSG2rY4xXS1JjK+lM\r\n88TuUKD+xXmUu268Q/norpo8eScjYFj1A0D3UwxDuqNmMi4MMUWrgY1aUQnd\r\nAnQP6mUUPDUFuDhzoROS/s7c7s59MURDYQsaMu1+7tq8xZ4WceU/HRXM7AMR\r\nebYxcpPteEwF+SbzIJX/AC8a96mlEF6mrgum6vJqVgqcS/0PoYoIuMiGNBSC\r\nxztbPrknXcAn6aF5X5XX81CY9yRkvlfkpD5kVw6JO4vH3cJDQ8gbV86eFlqi\r\niMvcPd+WmYda+S4zQ1Yg/G9ss0ZcsAr8b7IFKKqvTw9iW2AcLJM5STSvoc+r\r\ntEIjIbaFtKRFFauB8ivQdP0FWTSM5q0YCMvSS1q4DugBYTJEdme4wPCLjyRx\r\nAdtyTvExiZeJCM4aPItn7o6rMvpaZV/kolg79BaspeiCJ1hPWtCxCHq84yii\r\nitxwMBcdSqODJVPTN5guOyw59HnyahQIZtY=\r\n=UCiQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","type":"module","types":"types/src/index.d.ts","gitHead":"9d6e55d59d48414500b04dc1033dee32f849acf9","scripts":{"lint":"standard -i dist/ --fix","test":"c8 aegir test","build":"aegir build","clean":"rimraf ./dist","depcheck":"aegir dep-check","ts-check":"aegir ts -p check"},"_npmUser":{"name":"nzh","email":"ar.nazeh@gmail.com"},"standard":{"env":["mocha"]},"repository":{"url":"git+https://github.com/synonymdev/slashtags.git","type":"git"},"_npmVersion":"8.5.5","description":"Authorization using slashtags","directories":{},"_nodeVersion":"16.15.0","dependencies":{"debug":"^4.3.4","compact-encoding":"^2.6.1","@synonymdev/slashtag":"^1.0.0-alpha.0","compact-encoding-struct":"^1.2.1"},"typesVersions":{"*":{"*":["types/*","types/src/*"],"types/*":["types/*","types/src/*"]}},"_hasShrinkwrap":false,"devDependencies":{"b4a":"^1.5.0","aegir":"^37.0.15"},"_npmOperationalInternal":{"tmp":"tmp/slashauth_1.0.0-alpha.0_1653465516979_0.6831445487567562","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-05-25T07:58:36.979Z","modified":"2026-09-07T09:46:31.929Z","1.0.0-alpha.0":"2022-05-25T07:58:37.142Z"},"bugs":{"url":"https://github.com/synonymdev/slashtags/issues"},"license":"MIT","homepage":"https://github.com/synonymdev/slashtags/tree/master/packages/auth/#readme","keywords":[],"repository":{"url":"git+https://github.com/synonymdev/slashtags.git","type":"git"},"description":"Authorization using slashtags","maintainers":[{"email":"pavel@synonym.to","name":"thisispav"},{"email":"john@synonym.to","name":"bitcoinerrorlog"},{"email":"corey.lyle.phillips@gmail.com","name":"coreyphillips"},{"email":"philippwalter@pm.me","name":"pwltr"},{"email":"deniszalessky@gmail.com","name":"dzdidi_restored"},{"email":"octrif@gmail.com","name":"ovitrif"},{"email":"crequena2@gmail.com","name":"shacollision"},{"email":"jamesbrowning91@gmail.com","name":"catch-21"},{"email":"oier@synonym.to","name":"tipogi"},{"email":"andrei@synonym.to","name":"andrei-synonym"},{"email":"tomos@synonym.to","name":"86667-tomos"},{"email":"jayvdb1@gmail.com","name":"jayvdb"},{"email":"sevi_buehler@hotmail.com","name":"sebubu"}],"readme":"# SlashAuth\n\nSlashAuth is a Slashtags [protocol](../slashtag/README.md#slashprotocol) for authorization over a Slashtag's connection.\n\nOnce authentication is done both sides share a private encrypted [drives](../drive) dedicated to each other, and can exchange data over, as an asynchronous communication channel.\n\n## Install\n\n```bash\nnpm i @synonymdev/slashtag @synonymdev/slashauth\n```\n\n## Usage\n\n### Initiator's side\n\n```javascript\nimport { Slashtag } from '@synonymdev/slashtag';\nimport { SlashAuth } from '@synonymdev/slashauth';\n\nconst initiator = new Slashtag({\n  keyPair: Slashtag.createKeyPair(),\n  protocols: { SlashAuth },\n});\n// Responder's wallet will have access to the initiator's profile\nawait initiator.setProfile({ name: 'Alice' });\n// Access the protocol instance from anywhere in the application\nconst auth = slashtag.protocol(SlashAuth);\n\n// After getting the slashauth:// url from the Responder,\n// you can use it to read the Responder's profile\nconst responder = sdk.slashtag({ url: slashauthURL });\n// Get the server's profile if it exists, so you can ask\n// user for confirmation to authenticate to that Responder\nconst profile = await serverSlashtag.getProfile();\n\nauth.once('error', errorHandler);\n\n// On success, Initiator will get the details of the Drive that\n// the Responder created for the Initiator\nauth.once('success', ({ drive }) => {\n  // Success handler\n});\n\n// Connect to the server and send the token in the url `?q=<token>`\nauth.request(url);\n```\n\n### Responder's side\n\n```javascript\nimport { Slashtag } from '@synonymdev/slashtag';\nimport { SlashAuth } from '@synonymdev/slashauth';\n\nconst responder = new Slashtag({\n  keyPair: Slashtag.createKeyPair(),\n  protocols: { SlashAuth },\n});\n// Initiator's wallet will have access to the Responder's profile\nawait responder.setProfile({ name: 'Bob' });\nconst auth = slashtag.protocol(SlashAuth);\n\nauth.on('request', async ({ token, peerInfo, drive }, response) => {\n  // Try resolving user's profile from their Slashtag\n  const initiator = request.peerInfo.slashtag;\n\n  // The Responder can send either a success or error message\n  try {\n    authorize(request.token, initiator);\n    response.success();\n  } catch (e) {\n    response.error(e.message);\n  }\n});\n\n// Listen on the Slashtag.key\nawait slashtag.listen();\n\nfunction authorize(token, initiator) {\n  // Check the token against server's sessions, clientIDs, etc.\n  // Check if the user is already registered, blocked, etc.\n}\n\n// Generate a slashauth:// url and pass it to the initiator\n// token can be a random string, or a session token or a clientID, etc.\nSlashAuth.formatURL(slashtag.url, token);\n```\n\n## How it works\n\nBefore any of the SlashAuth's messages are exchanged, the Initiator and Responder are already connected over a secure connection using [Noise Protocol](https://noiseprotocol.org/).\n\nMore about Slashtags connections [here](#await-slashtaglisten).\n\nSo both the Initiator's and Responder's keys are already known and all subsequent communication is trusted.\n\nThis protocol adds two features:\n\n1. The Initiator can pass a session token to the Responder.\n2. Both the Initiator and the Responder creates a dedicated [drive](../drive/) for each other. Enabling further asynchronous communication between both parties.\n\n### Examples\n\n**Contacts**\n\nInitiator 'Alice' wants to establish a connection to Responder 'Bob'.\n\n- Bob creates a url with the protocol `slashauth:`, Bob's base32 encoding publicKey, and a unique token for this session.\n- Alice connects to Bob using the Bob's publicKey parsed from the url, and pass the token, as well as the publicKey and encryptionKey to the drive created by Alice for Bob.\n- If Bob accepts the request, Bob creates a drive dedicated for Alice, and sends it back to Alice.\n- If Bob rejects the request, Bob can send an error message to Alice.\n\nOnce the request is accepted, now both Alice and Bob add each other as contacts, with drives for Incoming and Outgoing asynchronous messages.\n\n![simple p2p authentication protocol diagram](./docs/alice-bob-auth.png)\n\n**Login & Registration**\n\n- Initiator 'Alice' visits a website, which can be a login page, or a 3rd party client.\n- The client formats a url from the Server's publicKey, and a unique token to that client, whether that is a session token or a clientID, etc. That is left to the each application to decide.\n- Alice connects to the server using its publicKey, and passes the token, and the dedicated drive.\n- If the Server accepts the request, Alice will now get the details of the Server's drive, and the Server can now authorize the Client to request resources.\n\n![server, clietn, and wallet authentication diagram](./docs/server-client-wallet-auth.png)\n","readmeFilename":"README.md"}