Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Attestation] Adds missing npm scripts and adds tsdoc.json #13162

Merged
7 commits merged into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sdk/attestation/attestation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
28 changes: 18 additions & 10 deletions sdk/attestation/attestation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"azure",
"typescript",
"browser",
"isomorphic"
"isomorphic",
"cloud"
],
"license": "MIT",
"main": "./dist/index.js",
Expand Down Expand Up @@ -59,13 +60,11 @@
"rollup-plugin-sourcemaps": "^0.4.2",
"safe-buffer": "^5.2.1",
"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"
"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",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
Expand All @@ -77,20 +76,29 @@
"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",
"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": "echo skipped",
"lint": "echo skipped",
"prepack": "npm install && npm run build",
"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,
"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",
Expand Down
10 changes: 3 additions & 7 deletions sdk/attestation/attestation/test/public/attestationTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 3 additions & 7 deletions sdk/attestation/attestation/test/public/tokenCertTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions sdk/attestation/attestation/test/utils/base64url.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

/**
* 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);
}

/**
* 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 = "";
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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, "/");
Expand Down
12 changes: 6 additions & 6 deletions sdk/attestation/attestation/test/utils/base64url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

/**
* 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");
}

/**
* 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 <ArrayBuffer> | <SharedArrayBuffer>-- the TypeScript definition is off here
Expand All @@ -22,16 +22,16 @@ 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");
}

/**
* 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);
Expand All @@ -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, "/");
Expand Down
1 change: 1 addition & 0 deletions sdk/attestation/attestation/test/utils/decodeJWT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
4 changes: 4 additions & 0 deletions sdk/attestation/attestation/tsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"extends": ["../../../tsdoc.json"]
}