Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated #14

Merged
merged 22 commits into from
Jun 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update index.ts
  • Loading branch information
bobslavtriev committed Jun 6, 2024
commit fe49f56705c38bd182d90dcdb8ed9f32722624c7
17 changes: 11 additions & 6 deletions src/Utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { curve } from 'libsignal'
import { randomBytes, randomUUID } from 'crypto'
import { KeyPair, valueReplacer, valueReviver, AppDataSync, Bits } from '../Types'
import { KeyPair, valueReplacer, valueReviver, AppDataSync, Fingerprint, Bits } from '../Types'

const generateKeyPair = () => {
const { pubKey, privKey } = curve.generateKeyPair()
Expand Down Expand Up @@ -58,12 +58,17 @@ const parseTimestamp = (timestamp: Bits | number) => {
}

export const fromObject = (args: AppDataSync) => {
const f: Fingerprint = {
...args.fingerprint,
deviceIndexes: Array.isArray(args.fingerprint.deviceIndexes) ? args.fingerprint.deviceIndexes : []
}

const message = {
keyData: Array.isArray(args.keyData) ? args.keyData : new Uint8Array(),
fingerprint: {
rawId: args.fingerprint.rawId,
currentIndex: args.fingerprint.rawId,
deviceIndexes: Array.isArray(args.fingerprint.deviceIndexes) ? args.fingerprint.deviceIndexes : []
rawId: f.rawId || 0,
currentIndex: f.rawId || 0,
deviceIndexes: f.deviceIndexes
},
timestamp: parseTimestamp(args.timestamp)
}
Expand Down Expand Up @@ -114,9 +119,9 @@ export const initAuthCreds = () => {
identityId: randomBytes(20),
backupToken: randomBytes(20),
registered: false,
registration: {},
registration: {} as never,
pairingCode: undefined,
lastPropHash: undefined,
routingInfo: undefined
routingInfo: undefined
}
}