@evervault/sdk
Advanced tools
Comparing version 5.1.4 to 5.1.5
@@ -57,2 +57,4 @@ const RepeatedTimer = require('./repeatedTimer'); | ||
} | ||
return this.polling; | ||
}; | ||
@@ -59,0 +61,0 @@ |
@@ -117,2 +117,4 @@ const RepeatedTimer = require('./repeatedTimer'); | ||
} | ||
return this.polling; | ||
}; | ||
@@ -119,0 +121,0 @@ |
@@ -52,2 +52,3 @@ const RepeatedTimer = require('./repeatedTimer'); | ||
} | ||
return polling; | ||
}; | ||
@@ -54,0 +55,0 @@ |
module.exports = (defaultInterval, cb) => { | ||
const createInterval = () => { | ||
return setInterval(async () => { | ||
const initializedInterval = setInterval(async () => { | ||
try { | ||
@@ -10,2 +10,4 @@ await cb(); | ||
}, interval * 1000); | ||
initializedInterval.unref(); | ||
return initializedInterval; | ||
}; | ||
@@ -12,0 +14,0 @@ |
declare module '@evervault/sdk' { | ||
type PCRs = { pcr0?: string; pcr1?: string; pcr2?: string; pcr8?: string }; | ||
type AttestationData = Record<string, PCRs | PCRs[]>; | ||
type AttestationCallback = () => Promise<PCRs | PCRs[]>; | ||
type AttestationData = PCRs | PCRs[]; | ||
type AttestationCallback = () => Promise<AttestationData>; | ||
@@ -27,2 +27,3 @@ export default class Evervault { | ||
}) => Promise<void>; | ||
disableOutboundRelay: () => void; | ||
/** | ||
@@ -52,3 +53,4 @@ * @deprecated use enableCages instead | ||
) => Promise<void>; | ||
disableEnclaves: () => void; | ||
} | ||
} |
@@ -41,2 +41,5 @@ const crypto = require('crypto'); | ||
/** @typedef {ReturnType<import('./core/repeatedTimer')>} Timer */ | ||
/** @type {{ enclaves: Timer[] | null, relayOutbound: Timer | null}} */ | ||
_backgroundJobs; | ||
constructor(appId, apiKey, options = {}) { | ||
@@ -78,2 +81,6 @@ if ( | ||
this.appId = appId; | ||
this._backgroundJobs = { | ||
relayOutbound: null, | ||
enclaves: null, | ||
}; | ||
@@ -115,3 +122,4 @@ this.defineHiddenProperty( | ||
await attestationCache.init(); | ||
const attestationCachePollingRef = await attestationCache.init(); | ||
this._backgroundJobs.enclaves = [attestationCachePollingRef]; | ||
@@ -121,3 +129,4 @@ //Store client PCR providers to periodically pull new PCRs | ||
await pcrManager.init(); | ||
const pollingRef = await pcrManager.init(); | ||
this._backgroundJobs.enclaves.push(pollingRef); | ||
@@ -152,3 +161,4 @@ attest.addAttestationListener( | ||
await attestationCache.init(); | ||
const attestationCachePollingRef = await attestationCache.init(); | ||
this._backgroundJobs.enclaves = [attestationCachePollingRef]; | ||
@@ -158,3 +168,4 @@ //Store client PCR providers to periodically pull new PCRs | ||
await pcrManager.init(); | ||
const pcrManagerPollingRef = await pcrManager.init(); | ||
this._backgroundJobs.enclaves.push(pcrManagerPollingRef); | ||
@@ -173,2 +184,10 @@ attest.addAttestationListener( | ||
disableEnclaves() { | ||
if (Array.isArray(this._backgroundJobs.enclaves)) { | ||
this._backgroundJobs.enclaves.forEach((enclaveTimer) => { | ||
enclaveTimer.stop(); | ||
}); | ||
} | ||
} | ||
async generateNonce() { | ||
@@ -384,3 +403,7 @@ const nonce = await this.crypto.generateBytes(16); | ||
} | ||
await RelayOutboundConfig.init(this.config, this.http); | ||
const relayOutboundPollingRef = await RelayOutboundConfig.init( | ||
this.config, | ||
this.http | ||
); | ||
this._backgroundJobs.relayOutbound = relayOutboundPollingRef; | ||
await this.httpsHelper.overloadHttpsModule( | ||
@@ -408,2 +431,9 @@ this.apiKey, | ||
} | ||
disableOutboundRelay() { | ||
if (this._backgroundJobs.relayOutbound != null) { | ||
this._backgroundJobs.relayOutbound.stop(); | ||
} | ||
} | ||
/** | ||
@@ -410,0 +440,0 @@ * @returns {HttpsProxyAgent} |
@@ -194,2 +194,4 @@ const certHelper = require('./certHelper'); | ||
const isFunction = (val) => typeof val === 'function'; | ||
if (!isObject(providedAttestationData)) { | ||
@@ -203,7 +205,10 @@ throw new MalformedAttestationData( | ||
const containsOnlyObjects = Object.values(providedAttestationData).every( | ||
(pcrs) => isObject(pcrs) || (Array.isArray(pcrs) && pcrs.every(isObject)) | ||
(pcrs) => | ||
isObject(pcrs) || | ||
(Array.isArray(pcrs) && pcrs.every(isObject)) || | ||
isFunction(pcrs) | ||
); | ||
if (!containsOnlyObjects) { | ||
throw new MalformedAttestationData( | ||
'Expected only objects or lists of objects as values in the attestation data map' | ||
'Expected only objects, lists of objects, or functions as values in the attestation data map' | ||
); | ||
@@ -210,0 +215,0 @@ } |
{ | ||
"name": "@evervault/sdk", | ||
"version": "5.1.4", | ||
"version": "5.1.5", | ||
"description": "Node.js SDK for Evervault", | ||
@@ -10,3 +10,3 @@ "main": "lib/index.js", | ||
"lint": "prettier --check \"./**/*.js\"", | ||
"test": "mocha 'tests/**/*.test.js'", | ||
"test": "mocha 'tests/**/*.test.js' --timeout 30000", | ||
"test:e2e": "mocha 'e2e/**/*.test.js' --timeout 5000 --exit", | ||
@@ -13,0 +13,0 @@ "test:filter": "mocha 'tests/**/*.test.js' --grep", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78297
2494