How to use the gun.SEA function in gun

To help you get started, we’ve selected a few gun examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github irislib / iris-lib / src / chat.js View on Github external
async messageReceived(data, pub, selfAuthored) {
    if (this.onMessage) {
      const decrypted = await Gun.SEA.decrypt(data, (await this.getSecret(pub)));
      if (typeof decrypted !== `object`) {
        // console.log(`chat data received`, decrypted);
        return;
      }
      this.onMessage(decrypted, {selfAuthored});
    } else {
      // console.log(`chat message received`, decrypted);
    }
  }
github irislib / iris-lib / src / key.js View on Github external
static verify(msg, pubKey) {
    return Gun.SEA.verify(msg.slice(1), pubKey);
  }
}
github irislib / iris-lib / src / chat.js View on Github external
static async getOurSecretChatId(gun, pub, pair) {
    const epub = await gun.user(pub).get(`epub`).once().then();
    const secret = await Gun.SEA.secret(epub, pair);
    return Gun.SEA.work(secret + pub, null, null, {name: 'SHA-256'});
  }
github irislib / iris-lib / src / chat.js View on Github external
static async getTheirSecretChatId(gun, pub, pair) {
    const epub = await gun.user(pub).get(`epub`).once().then();
    const secret = await Gun.SEA.secret(epub, pair);
    return Gun.SEA.work(secret + pair.pub, null, null, {name: 'SHA-256'});
  }
github irislib / iris-lib / src / chat.js View on Github external
static async getOurSecretChatId(gun, pub, pair) {
    const epub = await gun.user(pub).get(`epub`).once().then();
    const secret = await Gun.SEA.secret(epub, pair);
    return Gun.SEA.work(secret + pub, null, null, {name: 'SHA-256'});
  }
github irislib / iris-lib / src / chat.js View on Github external
async getSecret(pub) {
    if (!this.secrets[pub]) {
      const epub = await this.gun.user(pub).get(`epub`).once().then();
      this.secrets[pub] = await Gun.SEA.secret(epub, this.key);
    }
    return this.secrets[pub];
  }

gun

A realtime, decentralized, offline-first, graph data synchronization engine.

(Zlib OR MIT OR Apache-2.0)
Latest version published 18 days ago

Package Health Score

83 / 100
Full package analysis