Skip to content

Commit

Permalink
feat: Resolve review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Nov 11, 2022
1 parent f9e520e commit b984ef4
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ export function createSignInputsFromImportableEd25519Key(key: TImportableEd25519
}

export function createKeyPairRaw(seed?: string): KeyPair {
return seed ? generateKeyPairFromSeed(Buffer.from(seed)) : generateKeyPair()
return seed ? generateKeyPairFromSeed(fromString(seed)) : generateKeyPair()
}

export function createKeyPairBase64(seed?: string): IKeyPair {
const keyPair = seed ? generateKeyPairFromSeed(Buffer.from(seed)) : generateKeyPair()
const keyPair = seed ? generateKeyPairFromSeed(fromString(seed)) : generateKeyPair()
return {
publicKey: toString(keyPair.publicKey, 'base64'),
privateKey: toString(keyPair.secretKey, 'base64'),
}
}

export function createKeyPairHex(seed?: string): IKeyPair {
const keyPair = seed ? generateKeyPairFromSeed(Buffer.from(seed)) : generateKeyPair()
const keyPair = createKeyPairRaw(seed)
return {
publicKey: toString(keyPair.publicKey, 'hex'),
privateKey: toString(keyPair.secretKey, 'hex'),
Expand Down Expand Up @@ -199,27 +199,3 @@ export function createSignInputsFromKeyPair(didDocument: IdentifierPayload, keys
const signInputs = keyHexs.map((key)=>createSignInputsFromImportableEd25519Key(key, didDocument.verificationMethod!))
return signInputs
}

export enum DidDocumentOperation {
Set = 'setDidDocument',
Add = 'addToDidDocument',
Remove = 'removeFromDidDocument'
}

export function jsonConcat(o1: any, o2:any) {
for (var key in o2) {
if(Array.isArray(o1[key])) {
o1[key].push(...o2[key])
} else {
o1[key] = o2[key]
}}
return o1
}

export function jsonSubtract(o1: any, o2: any) {
for (var key in o2) {
if(o2[key] == o1[key]) {
delete(o1[key])
}
}
}

0 comments on commit b984ef4

Please sign in to comment.