🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@elastic/request-crypto

Package Overview
Dependencies
Maintainers
57
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elastic/request-crypto - npm Package Compare versions

Comparing version

to
1.0.2

1

lib/aes.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
var makeAESCryptoWith = require("@elastic/node-crypto");
exports.makeAESCryptoWith = makeAESCryptoWith;
//# sourceMappingURL=aes.js.map

2

lib/jwk.d.ts

@@ -7,2 +7,2 @@ import * as jose from 'node-jose';

}
export declare function createJWKManager(jwks?: JWKS, jwk?: jose.JWK): Promise<JWKManager>;
export declare function createJWKManager(jwks?: JWKS, jwk?: typeof jose.JWK): Promise<JWKManager>;

@@ -51,3 +51,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
var jose = require("node-jose");

@@ -54,0 +53,0 @@ var jwks_1 = require("./jwks");

@@ -31,6 +31,6 @@ /// <reference types="node" />

JWK: typeof jose.JWK;
JWE: jose.JWE;
constructor(store: any, jwk?: jose.JWK, jwe?: jose.JWE);
JWE: typeof jose.JWE;
constructor(store: any, jwk?: typeof jose.JWK, jwe?: typeof jose.JWE);
addKey(kid: string | undefined, modulus: number, use: KeyUse): Promise<void>;
insertKey(jwk: JWK): Promise<void>;
insertKey(jwk: jose.JWK.Key): Promise<void>;
getPublicJWK(kid?: string): PublicJWK | null;

@@ -42,6 +42,6 @@ getPrivateJWK(kid?: string): PrivateJWK | null;

encrypt(kid: string, input: Buffer): Promise<string>;
decrypt(payload: any, jwks?: PrivateJWKS): Promise<Buffer>;
decrypt(payload: any, jwks?: any): Promise<Buffer>;
protected getKey(kid?: string): any;
}
export declare function createJWKS(jwk: jose.JWK, jwks?: JWKS): Promise<any>;
export declare function createJWKS(jwk: typeof jose.JWK, jwks?: JWKS): Promise<any>;
export declare function createJWKSManager(jwks?: JWKS): Promise<JWKSManager>;

@@ -38,3 +38,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
var jose = require("node-jose");

@@ -105,3 +104,3 @@ exports.RSA_ALGORITHM = 'RSA-OAEP';

return __awaiter(this, void 0, void 0, function () {
var publicJWK, encryptConfig, encrypter;
var publicJWK;
return __generator(this, function (_a) {

@@ -112,8 +111,5 @@ publicJWK = this.getKey(kid);

}
encryptConfig = {
format: 'compact',
zip: true,
};
encrypter = this.JWE.createEncrypt(encryptConfig, publicJWK);
return [2 /*return*/, encrypter.update(input).final()];
return [2 /*return*/, this.JWE.createEncrypt({ format: 'compact', zip: true }, publicJWK)
.update(input)
.final()];
});

@@ -146,6 +142,7 @@ });

return __awaiter(this, void 0, void 0, function () {
var storeMethod;
return __generator(this, function (_a) {
storeMethod = jwks ? 'asKeyStore' : 'createKeyStore';
return [2 /*return*/, jwk[storeMethod](jwks)];
if (jwks) {
return [2 /*return*/, jwk.asKeyStore(jwks)];
}
return [2 /*return*/, jwk.createKeyStore()];
});

@@ -152,0 +149,0 @@ });

{
"name": "@elastic/request-crypto",
"version": "1.0.1",
"version": "1.0.2",
"description": "Request Cryptography",

@@ -42,4 +42,5 @@ "main": "lib/index.js",

"@elastic/node-crypto": "^0.1.2",
"@types/node-jose": "1.1.0",
"node-jose": "1.1.0"
}
}

@@ -1,4 +0,3 @@

// @ts-ignore
import * as makeAESCryptoWith from '@elastic/node-crypto';
export { makeAESCryptoWith };

@@ -1,2 +0,1 @@

// @ts-ignore
import * as jose from 'node-jose';

@@ -3,0 +2,0 @@ import { createJWKS, JWKS, JWKSManager } from './jwks';

@@ -1,2 +0,1 @@

// @ts-ignore
import * as jose from 'node-jose';

@@ -50,3 +49,3 @@

public JWK: typeof jose.JWK;
public JWE: jose.JWE;
public JWE: typeof jose.JWE;
constructor(store: any, jwk = jose.JWK, jwe = jose.JWE) {

@@ -62,3 +61,3 @@ this.store = store;

}
public async insertKey(jwk: JWK): Promise<void> {
public async insertKey(jwk: jose.JWK.Key): Promise<void> {
await this.store.add(jwk);

@@ -94,15 +93,12 @@ }

}
const encryptConfig = {
format: 'compact',
zip: true,
};
const encrypter = this.JWE.createEncrypt(encryptConfig, publicJWK);
return encrypter.update(input).final();
return this.JWE.createEncrypt({ format: 'compact', zip: true }, publicJWK)
.update(input)
.final();
}
public async decrypt(payload: any, jwks: PrivateJWKS = this.store): Promise<Buffer> {
public async decrypt(payload: any, jwks = this.store): Promise<Buffer> {
const decrypter = this.JWE.createDecrypt(jwks);
const decryptedPayload = await decrypter.decrypt(payload);
return decryptedPayload.payload;
return (decryptedPayload as any).payload;
}

@@ -114,5 +110,7 @@ protected getKey(kid?: string): any {

export async function createJWKS(jwk: jose.JWK, jwks?: JWKS): Promise<any> {
const storeMethod = jwks ? 'asKeyStore' : 'createKeyStore';
return jwk[storeMethod](jwks);
export async function createJWKS(jwk: typeof jose.JWK, jwks?: JWKS): Promise<any> {
if (jwks) {
return jwk.asKeyStore(jwks);
}
return jwk.createKeyStore();
}

@@ -119,0 +117,0 @@

@@ -58,5 +58,5 @@ // @ts-ignore

export function unpackBody(packedBody: string) {
const decodedBody: Buffer = util.base64url.decode(packedBody);
const decodedBody = (util.base64url.decode(packedBody) as unknown) as Buffer;
const { encryptedAESKey, encryptedPayload } = JSON.parse(decodedBody.toString('utf8'));
return { encryptedAESKey, encryptedPayload };
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet