OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / legacy-keet-core-schemas / lib / plugins / private-profile / ops.js

48 lines · javascript ref:
const e = require("compact-encoding"),
  d = {
    TYPE: 1,
    preencode(d, c) {
      ;(e.fixed32.preencode(d, c.devicePublicKey), e.buffer.preencode(d, c.attestation))
    },
    encode(d, c) {
      ;(e.fixed32.encode(d, c.devicePublicKey), e.buffer.encode(d, c.attestation))
    },
    decode: (d) => ({ devicePublicKey: e.fixed32.decode(d), attestation: e.buffer.decode(d) }),
  },
  c = {
    TYPE: 2,
    preencode(d, c) {
      e.fixed32.preencode(d, c.devicePublicKey)
    },
    encode(d, c) {
      e.fixed32.encode(d, c.devicePublicKey)
    },
    decode: (d) => ({ devicePublicKey: e.fixed32.decode(d) }),
  },
  o = {
    TYPE: 3,
    preencode(d, c) {
      e.fixed32.preencode(d, c.key)
    },
    encode(d, c) {
      e.fixed32.encode(d, c.key)
    },
    decode: (d) => ({ key: e.fixed32.decode(d) }),
  },
  i = {
    TYPE: 4,
    preencode(d, c) {
      e.fixed32.preencode(d, c.key)
    },
    encode(d, c) {
      e.fixed32.encode(d, c.key)
    },
    decode: (d) => ({ key: e.fixed32.decode(d) }),
  }
module.exports = {
  AddDeviceAttestationOperation: d,
  AddDeviceKeyOperation: c,
  RemoveRoomOperation: i,
  AddRoomOperation: o,
}