Skip to content

Commit

Permalink
feat(vkp): update vkp dep
Browse files Browse the repository at this point in the history
  • Loading branch information
chunningham committed Aug 20, 2020
1 parent c338517 commit dfaeb3b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
8 changes: 4 additions & 4 deletions js/identityWallet/identityWallet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ISignedCredCreationArgs } from '../credentials/signedCredential/types';
import { CredentialOfferRequest } from '../interactionTokens/credentialOfferRequest';
import { CredentialOfferResponse } from '../interactionTokens/credentialOfferResponse';
import { CredentialOfferRequestAttrs, CredentialOfferResponseAttrs, IAuthenticationAttrs, ICredentialRequestAttrs, ICredentialResponseAttrs, ICredentialsReceiveAttrs } from '../interactionTokens/interactionTokens.types';
import { IKeyRefArgs, PublicKeyInfo } from '@jolocom/vaulted-key-provider';
import { IKeyRefArgs, KeyTypes } from '@jolocom/vaulted-key-provider';
declare type WithExtraOptions<T> = T & {
expires?: Date;
aud?: string;
Expand All @@ -30,11 +30,11 @@ export declare class IdentityWallet {
private makeReq;
private makeRes;
private messageCannonicaliser;
getPublicKeys: (encryptionPass: string) => Promise<PublicKeyInfo[]>;
getPublicKeys: (encryptionPass: string) => Promise<import("@jolocom/vaulted-key-provider").PublicKeyInfo[]>;
private initializeAndSign;
validateJWT<T, R>(receivedJWT: JSONWebToken<T>, sentJWT?: JSONWebToken<R>, resolver?: import("../didMethods/types").IResolver): Promise<void>;
asymEncrypt: (data: Buffer, publicKey: PublicKeyInfo) => Promise<Buffer>;
asymEncryptToDidKey: (data: Buffer, keyRef: string, resolver?: import("../didMethods/types").IResolver) => Promise<any>;
asymEncrypt: (data: Buffer, key: Buffer, type: KeyTypes) => Promise<Buffer>;
asymEncryptToDidKey: (data: Buffer, keyRef: string, resolver?: import("../didMethods/types").IResolver) => Promise<Buffer>;
asymDecrypt: (data: string, keyRefArgs: IKeyRefArgs) => Promise<Buffer>;
create: {
credential: typeof Credential.create;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jolocom-lib",
"version": "5.0.5",
"version": "5.0.8",
"description": "Unified library for interacting with the Jolocom identity solution",
"main": "js/index.js",
"files": [
Expand Down Expand Up @@ -71,7 +71,7 @@
"dependencies": {
"@jolocom/native-utils-node": "^0.6.0",
"@jolocom/protocol-ts": "^0.5.1",
"@jolocom/vaulted-key-provider": "^0.5.0",
"@jolocom/vaulted-key-provider": "^0.6.0",
"base64url": "^3.0.1",
"bip32": "^1.0.2",
"bip39": "^3.0.1",
Expand Down
31 changes: 19 additions & 12 deletions ts/identityWallet/identityWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import {
} from '../interactionTokens/interactionTokens.types'
import { ErrorCodes } from '../errors'
import { JoloDidMethod } from '../didMethods/jolo'
import { IVaultedKeyProvider, IKeyRefArgs, PublicKeyInfo } from '@jolocom/vaulted-key-provider'
import {
IVaultedKeyProvider,
IKeyRefArgs,
KeyTypes,
} from '@jolocom/vaulted-key-provider'
import { getCryptoProvider } from '@jolocom/vaulted-key-provider/js/cryptoProvider'
import { getRandomBytes } from '../utils/crypto'
import { cryptoUtils } from '@jolocom/native-utils-node'
Expand Down Expand Up @@ -366,9 +370,11 @@ export class IdentityWallet {
/**
* Encrypts data asymmetrically
* @param data - The data to encrypt
* @param pubKey - The key to encrypt to
* @param key - The key to encrypt to
* @param type - The type of the key to encrypt to
*/
public asymEncrypt = async (data: Buffer, publicKey: PublicKeyInfo) => getCryptoProvider(cryptoUtils).encrypt(publicKey, data)
public asymEncrypt = async (data: Buffer, key: Buffer, type: KeyTypes) =>
getCryptoProvider(cryptoUtils).encrypt(key, type, data)

/**
* Encrypts data asymmetrically
Expand All @@ -377,22 +383,23 @@ export class IdentityWallet {
* @param resolver - instance of a {@link Resolver} to use for retrieving the target's public keys. If none is provided, the
* default Jolocom contract is used for resolution.
*/

public asymEncryptToDidKey = async (
data: Buffer,
keyRef: string,
resolver = new JoloDidMethod().resolver,
) => this.asymEncrypt(
data,
//@ts-ignore, type: string in our .ts files vs type: KeyTypes in PublicKeyInfo
(await resolver.resolve(
keyIdToDid(keyRef)
)).didDocument.publicKey[0]
)
) =>
await resolver.resolve(keyIdToDid(keyRef)).then(id => {
const pk = id.publicKeySection.find(pk => pk.id === keyRef)
return this.asymEncrypt(
data,
Buffer.from(pk.publicKeyHex, 'hex'),
pk.type as KeyTypes,
)
})

/**
* Decrypts data asymmetrically
* @param data - The data to decrypt
* @param data - The data to decrypt
* @param derivationArgs - The decryption private key derivation arguments
*/
public asymDecrypt = async (
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@
dependencies:
cred-types-jolocom-core "^0.0.11"

"@jolocom/vaulted-key-provider@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@jolocom/vaulted-key-provider/-/vaulted-key-provider-0.5.0.tgz#ba0b2137e926f15486d6f52ea722d885918cfed4"
integrity sha512-oD1w3SY2CZdPYauC+1VVQM0I6q7m8C5DM/GCAorwc4oBXQWHY59Nf/bhAA/PuUuGNns7rM/SX6tbPqyCNh+OZg==
"@jolocom/vaulted-key-provider@^0.6.0":
version "0.6.0"
resolved "https://registry.yarnpkg.com/@jolocom/vaulted-key-provider/-/vaulted-key-provider-0.6.0.tgz#56e67e2393a6b82deb1eea849b2d78798b2bdd10"
integrity sha512-w3pse8rlmwfp3/5aoiu1kuLbXIFxhYFIgaIojsPcOANHhxZIY5hf1LFvgyat/92ekmegEhUxpDPIySE5V85EsQ==
dependencies:
rfc4648 "^1.4.0"

Expand Down

0 comments on commit dfaeb3b

Please sign in to comment.