{"_id":"@dwebid/simple-identity-exchange-protocol","_rev":"1-67b87449c666c5a0518ceba08a815d88","name":"@dwebid/simple-identity-exchange-protocol","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dwebid/simple-identity-exchange-protocol","version":"1.0.0","description":"Protocol for giving write access of a dWeb-based identity document from one device to another.","main":"index.js","directories":{"lib":"lib"},"scripts":{"protobuf":"protoc schema.proto -o messages.js"},"repository":{"type":"git","url":"git+https://github.com/dwebprotocol/dwebid-siep.git"},"keywords":["dweb"],"author":{"name":"Jared Rice Sr.","email":"jared@peepsx.com"},"license":"MIT","bugs":{"url":"https://github.com/dwebprotocol/dwebid-siep/issues"},"homepage":"https://dwebx.org","dependencies":{"@ddatabase/crypto":"^1.0.0","noise-protocol":"^3.0.1","simple-handshake":"^3.0.0","simple-message-channels":"^1.2.1","sodium-native":"^3.2.1","varint":"^6.0.0","xsalsa20-universal":"^1.0.0"},"gitHead":"b84f0cee6784c67900cfc228b8df055e04b7d460","_id":"@dwebid/simple-identity-exchange-protocol@1.0.0","_nodeVersion":"14.16.0","_npmVersion":"7.10.0","dist":{"integrity":"sha512-yZIfSS1sFxe5qfeTmY1LD36OxuVSMEmcysrABh8smEF7TBquD6Fdaq6QT9gdD2554ACZjJdrKKYPQW8UiZWOmg==","shasum":"1846023c4367e52ee66b8b2c9769a6c2436e439f","tarball":"https://registry.npmjs.org/@dwebid/simple-identity-exchange-protocol/-/simple-identity-exchange-protocol-1.0.0.tgz","fileCount":7,"unpackedSize":16049,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgmlUGCRA9TVsSAnZWagAA5GMQAIBwLAaXtzuI2F7ytO4P\nVDrlCARc+1uGVsQ2kf7S9wZdrTfO3geSn16SLX3LpVTGv39ToqP+wHoZN0OJ\neGqxxnAqgnj+P3ymlWQCiHWu3L1t2lN5swzts+hGcDf9K92QLUAIjfFeUnwP\nqtlryizQlbAw93k1NGwkheqo9hqbQah+oHJHODMgBw5dmNbCPBAHw8awr1Vq\n8iDE8mrA9Oq9Vl0WKnDCQXpZ0BU2c+s19fkcHQTHEJcMTfV2xhgVsBqVMtUP\nSLsM0g5SSTDVCFly9KOzV1iBfaAKma4zOCa0nHpdjjdmnqwxCYU6aebEguNv\ntx24LbuXw/BifsurcX74NjYgnFNN/mgQbvHes/lH5YhTAAu5yo2uljWO/pPF\njzHWN/lVr7qkMtqjzse5Z+vii4GzsqjKaLrTzD98uJcIYKesnF247MZ5renf\n9T6F7sBdKgbpwm8hP7GY4a1KRj6ruKBvbj5GZiZ+A7KGQxP+vHDy96l6hDYF\noLwXn2uO5CZ7hi5ueHHieX72BBt1+b8/N8YGNn75qKtKEABZHhUHg7juRIHE\n9CyCQRpvnDJd5uAAPOce9dPtSLv+nPwf20ZTzfgcAdozMHB3qgjeRqFIsA6i\niqX73yHMYKQfKWR99pxQe+1GFIh5AK5yJDCd5cJJbIq/dJ3NRLsE+o6RnjkS\naluQ\r\n=gyPv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQChM3aLghWnq8tiN+bymWeri920LMLyxozmINFuyTdxqwIgdGuDP2L/AwZIOpmQ7dBxIfBonj+VS5FWu9lXhbvOZgY="}]},"_npmUser":{"name":"dwebprotocol","email":"shikhar@arisen.network"},"maintainers":[{"name":"dwebprotocol","email":"shikhar@arisen.network"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-identity-exchange-protocol_1.0.0_1620727045560_0.1073197229563807"},"_hasShrinkwrap":false}},"time":{"created":"2021-05-11T09:57:25.193Z","1.0.0":"2021-05-11T09:57:25.788Z","modified":"2022-04-05T06:11:18.304Z"},"maintainers":[{"name":"dwebprotocol","email":"shikhar@arisen.network"}],"description":"Protocol for giving write access of a dWeb-based identity document from one device to another.","homepage":"https://dwebx.org","keywords":["dweb"],"repository":{"type":"git","url":"git+https://github.com/dwebprotocol/dwebid-siep.git"},"author":{"name":"Jared Rice Sr.","email":"jared@peepsx.com"},"bugs":{"url":"https://github.com/dwebprotocol/dwebid-siep/issues"},"license":"MIT","readme":"# @dwebid/simple-identity-exchange-protocol\nA protocol for exchanging diffKeys and a seed to an identity document (multi-writer dTree), between one device and another.\n\n### Install\n```\nnpm install @dwebid/simple-identity-exchange-protocol\n```\n\n## Usage On Device A\n```js\nimport SIEP from '@dwebid/simple-identity-exchange-protocol'\n\nlet seed = null\nlet remoteDiffKey = null\n\n// true means Device A is the initiator\nconst a = new SIEP(true, {\n  // make sure the connection with Device B is encrypted and that there is a NOISE handshake\n  encrypted: true\n  noise: true\n  // listen for the handshake to finalize and react to it\n  onhandshake() {\n    a.open(1, { deviceId: keyHere })\n  }\n  // listen for a verify message and react to it.\n  onverify (channel, message) {\n     // retrieve type from message\n    const verificationType = message.type\n    if (verificationType === \"device-verification\") {\n      // send the secret shown on the screen of Device B\n      a.prove(channel, { secret: 777777 })\n    }\n  }\n  // listen for a releaseseed message and react to it.\n  onreleaseseed (channel, message) {\n    // Extract seed from message sent by Device B\n    seed = message.seed\n  }\n  // listen for a wantkey message and react to it.\n  onwantkey (channel, message) {\n    // save Device A's dTree diffKey into a constant\n    const dMessengerDbDiffKey = db.diffKey\n    // provide the key that Device B asked for in their `wantkey` message\n    a.provideKey(channel, {\n      identifier: \"dmessenger\",\n      diffKey: dMessengerDbDiffKey\n    })    \n  }\n  // listen for a providekey message and react to it\n  onprovidekey (channel, message) {\n    // Extract the diffKey from the message sent by Device B\n    remoteDiffKey = message.diffKey\n  }\n})\n```\n\n## Usage On Device B\n```\nimport SIEP from '@dwebid/simple-identity-exchange-protocol'\n\nlet seed = null\nlet remoteDiffKey = nulll\nlet verified = false\n\n// false means Device B is the receiver\nconst b = new SIEP(false, {\n   // make sure the connection to Device A is encrypted\n  encrypted: true\n   // listen for an open message and react to it\n  onopen (channel, message) {\n    console.log(`Connection opened with deviceID ${message.deviceId} on channel # ${channel}`)\n    // when Device A opens the connection, we send a verify message immediately back to device A, letting it\n    // know which type of verification is required.\n    b.verify(channel, { type: 'device-verification' })\n  }\n  // listen for a \"prove\" message and react to it\n  onproof (channel, message) {\n    const secretCode = 777777\n    // ensure that the secret code sent in the prove message, is the secretCode Device B is expecting.\n    if (message.secret ==== secretCode) {\n      verified = true\n      seed = secretEncryptionSeedHere\n      // since Device A verified the secret, we can now release the seed\n      b.releaseseed(channel, { seed: seed })\n     // while we're at it, lets ask Device B for their diffKey for the database related to \"dmessenger\"\n      b.wantkey(channel, { identifier: 'dmessenger' })\n    } else {\n      b.destroy()\n    }\n  }\n  // listen for a providekey message and react to it\n  onprovidekey (channel, message) {\n    remoteDiffKey = message.diffKey\n  }\n  // listen for a wantkey message and react to it\n  onwantkey (channel, message) {\n    if (verified) {\n      b.providekey(channel, { identifier: 'dmessenger', diffKey: db.diffKey })\n    }\n  }\n})\n```\n\n## API Documentation\nComing soon\n\n## LICENSE \n[MIT](LICENSE.md)","readmeFilename":"README.md"}