From 3000ac1016bc820f8e37b5de9e619bf32a7b6de2 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 12 Jan 2021 16:27:06 +0000 Subject: [PATCH 1/7] [Attestation] add missing npm scripts --- sdk/attestation/attestation/package.json | 28 +++++++++++++------ .../test/public/attestationTests.spec.ts | 10 ++----- .../test/public/policyGetSetTests.spec.ts | 11 +++----- .../policyManagementGetSetTests.spec.ts | 10 ++----- .../test/public/tokenCertTests.spec.ts | 10 ++----- .../test/utils/base64url.browser.ts | 12 ++++---- .../attestation/test/utils/base64url.ts | 12 ++++---- .../attestation/test/utils/decodeJWT.ts | 1 + 8 files changed, 45 insertions(+), 49 deletions(-) diff --git a/sdk/attestation/attestation/package.json b/sdk/attestation/attestation/package.json index 5caf2e52df01..5cde5625cdd2 100644 --- a/sdk/attestation/attestation/package.json +++ b/sdk/attestation/attestation/package.json @@ -13,7 +13,8 @@ "azure", "typescript", "browser", - "isomorphic" + "isomorphic", + "cloud" ], "license": "MIT", "main": "./dist/index.js", @@ -24,6 +25,7 @@ }, "devDependencies": { "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", "@azure/test-utils-recorder": "^1.0.0", "@microsoft/api-extractor": "7.7.11", "@opentelemetry/api": "^0.10.2", @@ -36,6 +38,7 @@ "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "dotenv": "^8.2.0", + "eslint": "^7.15.0", "jsrsasign": "^10.1.4", "karma": "^5.1.0", "karma-chrome-launcher": "^3.0.0", @@ -61,11 +64,8 @@ "ts-node": "^8.3.0", "typescript": "4.1.2" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js", - "repository": { - "type": "git", - "url": "https://github.com/Azure/azure-sdk-for-js.git" - }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/attestation/attestation/README.md", + "repository": "github:Azure/azure-sdk-for-js", "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, @@ -77,17 +77,27 @@ "LICENSE" ], "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", "build": "tsc -p . && rollup -c 2>&1 && api-extractor run --local", "build:samples": "echo skipped", "build:test": "tsc -p . && rollup -c 2>&1", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", "clean": "rimraf dist dist-esm dist-test temp types *.tgz *.log", + "execute:samples": "echo skipped", "extract-api": "api-extractor run --local", - "lint": "echo skipped", - "prepack": "npm install && npm run build", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "integration-test:browser": "karma start --single-run", + "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace \"dist-esm/test/{,!(browser)/**/}*.spec.js\"", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint:fix": "eslint package.json api-extractor.json test --ext .ts --fix --fix-type [problem,suggestion]", + "lint": "eslint package.json api-extractor.json test --ext .ts", + "pack": "npm pack 2>&1", + "prebuild": "npm run clean", "test": "npm run clean && npm run build:test && npm run unit-test", "unit-test:browser": "karma start --single-run", "unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"", - "unit-test": "npm run unit-test:node && npm run unit-test:browser" + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --mode file --out ./dist/docs ./src" }, "sideEffects": false, "autoPublish": true, diff --git a/sdk/attestation/attestation/test/public/attestationTests.spec.ts b/sdk/attestation/attestation/test/public/attestationTests.spec.ts index a79f99cac563..a98319589dd2 100644 --- a/sdk/attestation/attestation/test/public/attestationTests.spec.ts +++ b/sdk/attestation/attestation/test/public/attestationTests.spec.ts @@ -8,7 +8,6 @@ chaiUse(chaiPromises); import { isPlaybackMode, Recorder } from "@azure/test-utils-recorder"; import { createRecordedClient, createRecorder } from "../utils/recordedClient"; -import { AttestationClient } from "../../src"; import * as base64url from "../utils/base64url"; import { verifyAttestationToken } from "../utils/helpers"; @@ -119,8 +118,7 @@ describe("[AAD] Attestation Client", function() { "PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCgA"; it("#AttestSgxShared", async () => { - let client: AttestationClient; - client = createRecordedClient("Shared"); + const client = createRecordedClient("Shared"); const binaryRuntimeData = base64url.decodeString(_runtimeData); const attestationResult = await client.attestation.attestSgxEnclave({ quote: base64url.decodeString(_sgxQuote), @@ -137,8 +135,7 @@ describe("[AAD] Attestation Client", function() { } }); it("#AttestSgxAad", async () => { - let client: AttestationClient; - client = createRecordedClient("AAD"); + const client = createRecordedClient("AAD"); const binaryRuntimeData = base64url.decodeString(_runtimeData); const attestationResult = await client.attestation.attestSgxEnclave({ quote: base64url.decodeString(_sgxQuote), @@ -156,8 +153,7 @@ describe("[AAD] Attestation Client", function() { }); it("#AttestSgxIsolated", async () => { - let client: AttestationClient; - client = createRecordedClient("AAD"); + const client = createRecordedClient("AAD"); const binaryRuntimeData = base64url.decodeString(_runtimeData); const attestationResult = await client.attestation.attestSgxEnclave({ quote: base64url.decodeString(_sgxQuote), diff --git a/sdk/attestation/attestation/test/public/policyGetSetTests.spec.ts b/sdk/attestation/attestation/test/public/policyGetSetTests.spec.ts index 46b13cb7e1eb..cb26556db09a 100644 --- a/sdk/attestation/attestation/test/public/policyGetSetTests.spec.ts +++ b/sdk/attestation/attestation/test/public/policyGetSetTests.spec.ts @@ -8,7 +8,7 @@ chaiUse(chaiPromises); import { isPlaybackMode, Recorder } from "@azure/test-utils-recorder"; import { createRecordedClient, createRecorder } from "../utils/recordedClient"; -import { AttestationClient, KnownAttestationType } from "../../src"; +import { KnownAttestationType } from "../../src"; import { verifyAttestationToken } from "../utils/helpers"; describe("PolicyGetSetTests ", function() { @@ -24,8 +24,7 @@ describe("PolicyGetSetTests ", function() { }); it("#GetPolicyAad", async () => { - let client: AttestationClient; - client = createRecordedClient("AAD"); + const client = createRecordedClient("AAD"); const policyResult = await client.policy.get(KnownAttestationType.SgxEnclave); const result = policyResult.token; assert(result, "Expected a token from the service but did not receive one"); @@ -35,8 +34,7 @@ describe("PolicyGetSetTests ", function() { }); it("#GetPolicyIsolated", async () => { - let client: AttestationClient; - client = createRecordedClient("Isolated"); + const client = createRecordedClient("Isolated"); const policyResult = await client.policy.get(KnownAttestationType.SgxEnclave); const result = policyResult.token; assert(result, "Expected a token from the service but did not receive one"); @@ -46,8 +44,7 @@ describe("PolicyGetSetTests ", function() { }); it("#GetPolicyShared", async () => { - let client: AttestationClient; - client = createRecordedClient("Shared"); + const client = createRecordedClient("Shared"); const policyResult = await client.policy.get(KnownAttestationType.SgxEnclave); const result = policyResult.token; assert(result, "Expected a token from the service but did not receive one"); diff --git a/sdk/attestation/attestation/test/public/policyManagementGetSetTests.spec.ts b/sdk/attestation/attestation/test/public/policyManagementGetSetTests.spec.ts index cf3bc329a257..fa9e9081aac7 100644 --- a/sdk/attestation/attestation/test/public/policyManagementGetSetTests.spec.ts +++ b/sdk/attestation/attestation/test/public/policyManagementGetSetTests.spec.ts @@ -8,7 +8,6 @@ chaiUse(chaiPromises); import { isPlaybackMode, Recorder } from "@azure/test-utils-recorder"; import { createRecordedClient, createRecorder } from "../utils/recordedClient"; -import { AttestationClient } from "../../src"; import { verifyAttestationToken } from "../utils/helpers"; describe("PolicyManagementTests ", function() { @@ -24,8 +23,7 @@ describe("PolicyManagementTests ", function() { }); it("#GetPolicyManagementCertificatesAad", async () => { - let client: AttestationClient; - client = createRecordedClient("AAD"); + const client = createRecordedClient("AAD"); const policyResult = await client.policyCertificates.get(); const result = policyResult.token; @@ -41,8 +39,7 @@ describe("PolicyManagementTests ", function() { }); it("#GetPolicyShared", async () => { - let client: AttestationClient; - client = createRecordedClient("Shared"); + const client = createRecordedClient("Shared"); const policyResult = await client.policyCertificates.get(); const result = policyResult.token; @@ -58,8 +55,7 @@ describe("PolicyManagementTests ", function() { }); it("#GetPolicyIsolated", async () => { - let client: AttestationClient; - client = createRecordedClient("Isolated"); + const client = createRecordedClient("Isolated"); const policyResult = await client.policyCertificates.get(); const result = policyResult.token; diff --git a/sdk/attestation/attestation/test/public/tokenCertTests.spec.ts b/sdk/attestation/attestation/test/public/tokenCertTests.spec.ts index ed27fb14db29..c2b0ad00e2d6 100644 --- a/sdk/attestation/attestation/test/public/tokenCertTests.spec.ts +++ b/sdk/attestation/attestation/test/public/tokenCertTests.spec.ts @@ -8,7 +8,6 @@ chaiUse(chaiPromises); import { Recorder } from "@azure/test-utils-recorder"; import { createRecordedClient, createRecorder } from "../utils/recordedClient"; -import { AttestationClient } from "../../src"; import { Buffer } from "../utils/Buffer"; describe("TokenCertTests", function() { @@ -24,8 +23,7 @@ describe("TokenCertTests", function() { }); it("#GetCertificatesAAD", async () => { - let client: AttestationClient; - client = createRecordedClient("AAD"); + const client = createRecordedClient("AAD"); const signingCertificates = await client.signingCertificates.get(); const certs = signingCertificates.keys!; assert(certs.length > 0); @@ -38,8 +36,7 @@ describe("TokenCertTests", function() { } }); it("#GetCertificatesIsolated", async () => { - let client: AttestationClient; - client = createRecordedClient("Isolated"); + const client = createRecordedClient("Isolated"); const signingCertificates = await client.signingCertificates.get(); const certs = signingCertificates.keys!; assert(certs.length > 0); @@ -53,8 +50,7 @@ describe("TokenCertTests", function() { }); it("#GetCertificatesShared", async () => { - let client: AttestationClient; - client = createRecordedClient("Shared"); + const client = createRecordedClient("Shared"); const signingCertificates = await client.signingCertificates.get(); const certs = signingCertificates.keys!; assert(certs.length > 0); diff --git a/sdk/attestation/attestation/test/utils/base64url.browser.ts b/sdk/attestation/attestation/test/utils/base64url.browser.ts index f8302c32a493..ff8ce79bedfa 100644 --- a/sdk/attestation/attestation/test/utils/base64url.browser.ts +++ b/sdk/attestation/attestation/test/utils/base64url.browser.ts @@ -5,7 +5,7 @@ /** * Encodes a string in base64 format. - * @param value the string to encode + * @param value - the string to encode */ export function encodeString(value: string): string { return btoa(value); @@ -13,7 +13,7 @@ export function encodeString(value: string): string { /** * Encodes a byte array in base64 format. - * @param value the Uint8Array to encode + * @param value - the Uint8Array to encode */ export function encodeByteArray(value: Uint8Array): string { let str = ""; @@ -25,7 +25,7 @@ export function encodeByteArray(value: Uint8Array): string { /** * Decodes a base64 string into a byte array. - * @param value the base64 string to decode + * @param value - the base64 string to decode */ function decodeStringFromBase64(value: string): Uint8Array { const byteString = atob(value); @@ -38,8 +38,8 @@ function decodeStringFromBase64(value: string): Uint8Array { /** * Adds missing padding to a Base64 encoded string - * @param unpadded The unpadded input string - * @return The padded string + * @param unpadded - The unpadded input string + * @returns The padded string */ function fixPadding(unpadded: string): string { const count = 3 - ((unpadded.length + 3) % 4); @@ -48,7 +48,7 @@ function fixPadding(unpadded: string): string { /** * Decodes a base64url string into a byte array. - * @param value the base64url string to decode + * @param value - the base64url string to decode */ export function decodeString(value: string): Uint8Array { const encoded = value.replace(/-/g, "+").replace(/_/g, "/"); diff --git a/sdk/attestation/attestation/test/utils/base64url.ts b/sdk/attestation/attestation/test/utils/base64url.ts index 8f68c813f809..7c87929d0264 100644 --- a/sdk/attestation/attestation/test/utils/base64url.ts +++ b/sdk/attestation/attestation/test/utils/base64url.ts @@ -3,7 +3,7 @@ /** * Encodes a string in base64 format. - * @param value the string to encode + * @param value - the string to encode */ export function encodeString(value: string): string { return Buffer.from(value).toString("base64"); @@ -11,7 +11,7 @@ export function encodeString(value: string): string { /** * Encodes a byte array in base64 format. - * @param value the Uint8Array to encode + * @param value - the Uint8Array to encode */ export function encodeByteArray(value: Uint8Array): string { // Buffer.from accepts | -- the TypeScript definition is off here @@ -22,7 +22,7 @@ export function encodeByteArray(value: Uint8Array): string { /** * Decodes a base64 string into a byte array. - * @param value the base64 string to decode + * @param value - the base64 string to decode */ function decodeStringFromBase64(value: string): Uint8Array { return Buffer.from(value, "base64"); @@ -30,8 +30,8 @@ function decodeStringFromBase64(value: string): Uint8Array { /** * Adds missing padding to a Base64 encoded string - * @param unpadded The unpadded input string - * @return The padded string + * @param unpadded - The unpadded input string + * @returns The padded string */ function fixPadding(unpadded: string): string { const count = 3 - ((unpadded.length + 3) % 4); @@ -40,7 +40,7 @@ function fixPadding(unpadded: string): string { /** * Decodes a base64url string into a byte array. - * @param value the base64url string to decode + * @param value - the base64url string to decode */ export function decodeString(value: string): Uint8Array { const encoded = value.replace(/-/g, "+").replace(/_/g, "/"); diff --git a/sdk/attestation/attestation/test/utils/decodeJWT.ts b/sdk/attestation/attestation/test/utils/decodeJWT.ts index 1ab5ac719e48..e787f3b468e9 100644 --- a/sdk/attestation/attestation/test/utils/decodeJWT.ts +++ b/sdk/attestation/attestation/test/utils/decodeJWT.ts @@ -2,6 +2,7 @@ // Licensed under the MIT license. // typed implementation of jwsDecode, copied from here: https://github.com/auth0/node-jws/blob/master/lib/verify-stream.js +/* eslint-disable */ import { Buffer } from "./Buffer"; From b7a824b48e43b8b2ad77676db766bce29ea4bea6 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 12 Jan 2021 16:28:43 +0000 Subject: [PATCH 2/7] adding tsdoc.json --- sdk/attestation/attestation/tsdoc.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 sdk/attestation/attestation/tsdoc.json diff --git a/sdk/attestation/attestation/tsdoc.json b/sdk/attestation/attestation/tsdoc.json new file mode 100644 index 000000000000..81c5a8a2aa2f --- /dev/null +++ b/sdk/attestation/attestation/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": ["../../../tsdoc.json"] +} From 114dc714d08a018535a635a9a5769cb659b09095 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 12 Jan 2021 19:18:34 +0000 Subject: [PATCH 3/7] adding a CHANGELOG.md --- sdk/attestation/attestation/CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 sdk/attestation/attestation/CHANGELOG.md diff --git a/sdk/attestation/attestation/CHANGELOG.md b/sdk/attestation/attestation/CHANGELOG.md new file mode 100644 index 000000000000..a51ed0221df2 --- /dev/null +++ b/sdk/attestation/attestation/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 1.0.0-beta.1 (unreleased) + +Initial early preview release for MAA Data Plane SDK Demonstrates use of the machine generated MAA APIs. + +- Initial Release From 33c757ab25b7987d95350207f2b03a86571cc2bb Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Wed, 13 Jan 2021 20:04:25 +0000 Subject: [PATCH 4/7] remove the lint plugin because of issues with node8 --- sdk/attestation/attestation/package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sdk/attestation/attestation/package.json b/sdk/attestation/attestation/package.json index 5cde5625cdd2..24636676e44c 100644 --- a/sdk/attestation/attestation/package.json +++ b/sdk/attestation/attestation/package.json @@ -25,7 +25,6 @@ }, "devDependencies": { "@azure/dev-tool": "^1.0.0", - "@azure/eslint-plugin-azure-sdk": "^3.0.0", "@azure/test-utils-recorder": "^1.0.0", "@microsoft/api-extractor": "7.7.11", "@opentelemetry/api": "^0.10.2", @@ -89,8 +88,8 @@ "integration-test:browser": "karma start --single-run", "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace \"dist-esm/test/{,!(browser)/**/}*.spec.js\"", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "lint:fix": "eslint package.json api-extractor.json test --ext .ts --fix --fix-type [problem,suggestion]", - "lint": "eslint package.json api-extractor.json test --ext .ts", + "lint:fix": "echo skipped", + "lint": "echo skipped", "pack": "npm pack 2>&1", "prebuild": "npm run clean", "test": "npm run clean && npm run build:test && npm run unit-test", From 39541acc4832ed07351de5ef3ba84e40f5f9cc66 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Wed, 13 Jan 2021 21:17:07 +0000 Subject: [PATCH 5/7] edit --- sdk/attestation/attestation/package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sdk/attestation/attestation/package.json b/sdk/attestation/attestation/package.json index 24636676e44c..b18137a713d3 100644 --- a/sdk/attestation/attestation/package.json +++ b/sdk/attestation/attestation/package.json @@ -37,7 +37,6 @@ "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "dotenv": "^8.2.0", - "eslint": "^7.15.0", "jsrsasign": "^10.1.4", "karma": "^5.1.0", "karma-chrome-launcher": "^3.0.0", @@ -61,7 +60,8 @@ "rollup-plugin-sourcemaps": "^0.4.2", "safe-buffer": "^5.2.1", "ts-node": "^8.3.0", - "typescript": "4.1.2" + "typescript": "4.1.2", + "typedoc": "0.15.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/attestation/attestation/README.md", "repository": "github:Azure/azure-sdk-for-js", @@ -99,7 +99,6 @@ "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --mode file --out ./dist/docs ./src" }, "sideEffects": false, - "autoPublish": true, "browser": { "./dist-esm/test/utils/base64url.js": "./dist-esm/test/utils/base64url.browser.js", "./dist-esm/test/utils/Buffer.js": "./dist-esm/test/utils/Buffer.browser.js", From 4c6af40c4bdfe1cdfe99cb3e846c474538914f43 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Wed, 13 Jan 2021 21:38:24 +0000 Subject: [PATCH 6/7] remove dev-tool --- sdk/attestation/attestation/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/attestation/attestation/package.json b/sdk/attestation/attestation/package.json index b18137a713d3..7aef1d1965de 100644 --- a/sdk/attestation/attestation/package.json +++ b/sdk/attestation/attestation/package.json @@ -24,7 +24,6 @@ "node": ">=8.0.0" }, "devDependencies": { - "@azure/dev-tool": "^1.0.0", "@azure/test-utils-recorder": "^1.0.0", "@microsoft/api-extractor": "7.7.11", "@opentelemetry/api": "^0.10.2", From f5e2837cec7da770ff3a38c72cf2c0e646784309 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Thu, 14 Jan 2021 00:37:10 +0000 Subject: [PATCH 7/7] we need dev-tool for rollup --- sdk/attestation/attestation/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/attestation/attestation/package.json b/sdk/attestation/attestation/package.json index 7aef1d1965de..b18137a713d3 100644 --- a/sdk/attestation/attestation/package.json +++ b/sdk/attestation/attestation/package.json @@ -24,6 +24,7 @@ "node": ">=8.0.0" }, "devDependencies": { + "@azure/dev-tool": "^1.0.0", "@azure/test-utils-recorder": "^1.0.0", "@microsoft/api-extractor": "7.7.11", "@opentelemetry/api": "^0.10.2",