diff --git a/.gitignore b/.gitignore index 61dbfc1f9..e6e17e1e3 100644 --- a/.gitignore +++ b/.gitignore @@ -221,6 +221,9 @@ provisioning/transport/http/lib/ provisioning/transport/mqtt/lib/ provisioning/device/lib/ +security/x509/lib +security/tpm/lib + service/lib ts-e2e/lib diff --git a/build/build_parallel/config.json b/build/build_parallel/config.json index 513990380..781d0783b 100644 --- a/build/build_parallel/config.json +++ b/build/build_parallel/config.json @@ -79,6 +79,12 @@ "skip_build": true, "skip_test": true, "skip_ci": true + }, + { + "directory": "security/x509" + }, + { + "directory": "security/tpm" } ] } \ No newline at end of file diff --git a/security/tpm/.npmignore b/security/tpm/.npmignore new file mode 100644 index 000000000..ceee25702 --- /dev/null +++ b/security/tpm/.npmignore @@ -0,0 +1,6 @@ +coverage/ +devdoc/ +test/ +samples/ +src/ +lib/**/*.map \ No newline at end of file diff --git a/security/tpm/index.d.ts b/security/tpm/index.d.ts new file mode 100644 index 000000000..74426fc92 --- /dev/null +++ b/security/tpm/index.d.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +export { TpmSecurityClient } from './lib/tpm'; diff --git a/security/tpm/index.js b/security/tpm/index.js new file mode 100644 index 000000000..d48d413cf --- /dev/null +++ b/security/tpm/index.js @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +'use strict'; + +module.exports = { + TpmSecurityClient : require('lib/tpm').TpmSecurityClient +}; \ No newline at end of file diff --git a/security/tpm/package.json b/security/tpm/package.json new file mode 100644 index 000000000..3750ced1b --- /dev/null +++ b/security/tpm/package.json @@ -0,0 +1,45 @@ +{ + "name": "azure-iot-security-tpm", + "version": "0.0.1", + "description": "Azure IoT TPM security client", + "author": "Microsoft Corporation", + "license": "MIT", + "main": "index.js", + "typings": "index.d.ts", + "dependencies": { + "azure-iot-common": "1.2.2", + "debug": "^3.0.1" + }, + "devDependencies": { + "chai": "^3.5.0", + "istanbul": "^0.4.4", + "jshint": "^2.9.2", + "mocha": "^3.0.1", + "sinon": "^1.17.5", + "tslint": "^5.1.0", + "typescript": "2.2.2", + "@types/node": "^7.0.5" + }, + "scripts": { + "lint": "tslint --project . -c ../../tslint.json", + "build": "tsc", + "unittest-min": "istanbul cover --report none node_modules/mocha/bin/_mocha -- --reporter dot test/_*_test.js", + "alltest-min": "istanbul cover --report none node_modules/mocha/bin/_mocha -- --reporter dot test/_*_test*.js", + "unittest": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec test/_*_test.js", + "alltest": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec test/_*_test*.js", + "ci": "npm -s run lint && npm -s run build && npm -s run alltest-min && npm -s run check-cover", + "test": "npm -s run lint && npm -s run build && npm -s run unittest", + "check-cover": "istanbul check-coverage --statements 50 --branches 50 --lines 50 --functions 50" + }, + "engines": { + "node": ">= 0.10" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-iot-sdk-node.git" + }, + "bugs": { + "url": "https://github.com/Azure/azure-iot-sdk-node/issues" + }, + "homepage": "https://github.com/Azure/azure-iot-sdk-node#readme" +} \ No newline at end of file diff --git a/security/tpm/readme.md b/security/tpm/readme.md new file mode 100644 index 000000000..5c70ed6e5 --- /dev/null +++ b/security/tpm/readme.md @@ -0,0 +1,13 @@ +#azure-iot-security-tpm +Security module for Azure IoT TPM security + +[![npm version](https://badge.fury.io/js/azure-iot-security-tpm.svg)](https://badge.fury.io/js/azure-iot-security-tpm) + +## Install + +`npm install -g azure-iot-security-tpm@latest` to get the latest (pre-release) version. + +## Getting Started + + + diff --git a/security/tpm/src/tpm.ts b/security/tpm/src/tpm.ts new file mode 100644 index 000000000..87c46047c --- /dev/null +++ b/security/tpm/src/tpm.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +'use strict'; +import { errors } from 'azure-iot-common'; + +export class TpmSecurityClient { + getEndorsementKey(callback: (err?: Error) => void): void { + throw new errors.NotImplementedError(); + } + + getStorageRootKey(callback: (err?: Error) => void): void { + throw new errors.NotImplementedError(); + } + + signWithIdentity(callback: (err?: Error) => void): void { + throw new errors.NotImplementedError(); + } + + activateSymmetricIdentity(callback: (err?: Error) => void): void { + throw new errors.NotImplementedError(); + } +} + diff --git a/security/tpm/test/_tpm_test.js b/security/tpm/test/_tpm_test.js new file mode 100644 index 000000000..46f5b9943 --- /dev/null +++ b/security/tpm/test/_tpm_test.js @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +'use strict'; + +var TpmSecurityClient = require('../lib/tpm').TpmSecurityClient ; +var assert = require('chai').assert; + +describe('tpm', function () { + this.timeout(1000); + + var obj = new TpmSecurityClient (); + + describe('getEndorsementKey', function() { + it ('throws', function() { + assert.throws(function() { + obj.getEndorsementKey(); + }); + }); + }); + + describe('getStorageRootKey', function() { + it ('throws', function() { + assert.throws(function() { + obj.getStorageRootKey(); + }); + }); + }); + + describe('signWithIdentity', function() { + it ('throws', function() { + assert.throws(function() { + obj.signWithIdentity(); + }); + }); + }); + + describe('activateSymmetricIdentity', function() { + it ('throws', function() { + assert.throws(function() { + obj.activateSymmetricIdentity(); + }); + }); + }); + +}); + diff --git a/security/tpm/tsconfig.json b/security/tpm/tsconfig.json new file mode 100644 index 000000000..e08f5320f --- /dev/null +++ b/security/tpm/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "outDir": "./lib", + "target":"es5", + "sourceMap": true, + "declaration": true + }, + "include": [ + "./src/**/*.ts" + ] +} \ No newline at end of file diff --git a/security/x509/.npmignore b/security/x509/.npmignore new file mode 100644 index 000000000..ceee25702 --- /dev/null +++ b/security/x509/.npmignore @@ -0,0 +1,6 @@ +coverage/ +devdoc/ +test/ +samples/ +src/ +lib/**/*.map \ No newline at end of file diff --git a/security/x509/index.d.ts b/security/x509/index.d.ts new file mode 100644 index 000000000..dec4f8c84 --- /dev/null +++ b/security/x509/index.d.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +export { X509SecurityClient } from './lib/x509'; diff --git a/security/x509/index.js b/security/x509/index.js new file mode 100644 index 000000000..4dd484dee --- /dev/null +++ b/security/x509/index.js @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +'use strict'; + +module.exports = { + X509SecurityClient: require('lib/x509').X509SecurityClient +}; \ No newline at end of file diff --git a/security/x509/package.json b/security/x509/package.json new file mode 100644 index 000000000..ea866487b --- /dev/null +++ b/security/x509/package.json @@ -0,0 +1,45 @@ +{ + "name": "azure-iot-security-x509", + "version": "0.0.1", + "description": "Azure IoT x509 security client", + "author": "Microsoft Corporation", + "license": "MIT", + "main": "index.js", + "typings": "index.d.ts", + "dependencies": { + "azure-iot-common": "1.2.2", + "debug": "^3.0.1" + }, + "devDependencies": { + "chai": "^3.5.0", + "istanbul": "^0.4.4", + "jshint": "^2.9.2", + "mocha": "^3.0.1", + "sinon": "^1.17.5", + "tslint": "^5.1.0", + "typescript": "2.2.2", + "@types/node": "^7.0.5" + }, + "scripts": { + "lint": "tslint --project . -c ../../tslint.json", + "build": "tsc", + "unittest-min": "istanbul cover --report none node_modules/mocha/bin/_mocha -- --reporter dot test/_*_test.js", + "alltest-min": "istanbul cover --report none node_modules/mocha/bin/_mocha -- --reporter dot test/_*_test*.js", + "unittest": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec test/_*_test.js", + "alltest": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec test/_*_test*.js", + "ci": "npm -s run lint && npm -s run build && npm -s run alltest-min && npm -s run check-cover", + "test": "npm -s run lint && npm -s run build && npm -s run unittest", + "check-cover": "istanbul check-coverage --statements 50 --branches 50 --lines 50 --functions 50" + }, + "engines": { + "node": ">= 0.10" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-iot-sdk-node.git" + }, + "bugs": { + "url": "https://github.com/Azure/azure-iot-sdk-node/issues" + }, + "homepage": "https://github.com/Azure/azure-iot-sdk-node#readme" +} \ No newline at end of file diff --git a/security/x509/readme.md b/security/x509/readme.md new file mode 100644 index 000000000..410cba868 --- /dev/null +++ b/security/x509/readme.md @@ -0,0 +1,13 @@ +#azure-iot-security-x509 +Security module for Azure IoT x509 security + +[![npm version](https://badge.fury.io/js/azure-iot-security-x509.svg)](https://badge.fury.io/js/azure-iot-security-x509) + +## Install + +`npm install -g azure-iot-security-x509@latest` to get the latest (pre-release) version. + +## Getting Started + + + diff --git a/security/x509/src/x509.ts b/security/x509/src/x509.ts new file mode 100644 index 000000000..8e4494f0d --- /dev/null +++ b/security/x509/src/x509.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +'use strict'; +import { errors } from 'azure-iot-common'; + +export class X509SecurityClient { + getCertificate(callback: (err?: Error, cert?: string) => void): void { + throw new errors.NotImplementedError(); + } + + getCertificateChain(callback: (err?: Error, cert?: string) => void): void { + throw new errors.NotImplementedError(); + } +} + diff --git a/security/x509/test/_x509_test.js b/security/x509/test/_x509_test.js new file mode 100644 index 000000000..382c2ace3 --- /dev/null +++ b/security/x509/test/_x509_test.js @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +'use strict'; + +var X509SecurityClient = require('../lib/x509').X509SecurityClient; +var assert = require('chai').assert; + +describe('x509', function () { + this.timeout(1000); + + var obj = new X509SecurityClient(); + + describe('getCertificate', function() { + it ('throws', function() { + assert.throws(function() { + obj.getCertificate(); + }); + }); + }); + + describe('getCertificateChain', function() { + it ('throws', function() { + assert.throws(function() { + obj.getCertificateChain(); + }); + }); + }); + +}); + diff --git a/security/x509/tsconfig.json b/security/x509/tsconfig.json new file mode 100644 index 000000000..e08f5320f --- /dev/null +++ b/security/x509/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "outDir": "./lib", + "target":"es5", + "sourceMap": true, + "declaration": true + }, + "include": [ + "./src/**/*.ts" + ] +} \ No newline at end of file