[attestation] Migrate to ESM and tshy (#31433)

### Packages impacted by this PR

@azure/attestation

### Issues associated with this PR

#31338 

### Describe the problem that is addressed by this PR

Migrates `@azure/attestation` to ESM and tshy.

Co-authored-by: Deyaaeldeen Almahallawi <dealmaha@microsoft.com>
This commit is contained in:
Maor Leger 2024-10-22 09:39:30 -07:00 коммит произвёл GitHub
Родитель 7c51b1e579
Коммит b3bda3a2f9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
58 изменённых файлов: 352 добавлений и 436 удалений

Просмотреть файл

@ -19813,7 +19813,7 @@ packages:
dev: false
file:projects/attestation.tgz:
resolution: {integrity: sha512-0kI30QHKBXk+W68K+zxIKPJWca0weJVb/pp/HR9iPyiQpzqPYrwbMSUbK2Z1AwmRx6AoWKXW49xwlLybTrkEPg==, tarball: file:projects/attestation.tgz}
resolution: {integrity: sha512-V0CVYGkI+Po3q/CYlVVzbulZu0z2L/BfVeyvXHnK2bRYvPLmk+tjUw1buaNpPv8pblabUQnS3IzgQjApegiRiQ==, tarball: file:projects/attestation.tgz}
name: '@rush-temp/attestation'
version: 0.0.0
dependencies:
@ -19824,6 +19824,8 @@ packages:
'@types/chai-as-promised': 7.1.8
'@types/mocha': 10.0.9
'@types/node': 18.19.57
'@vitest/browser': 2.1.3(playwright@1.48.1)(typescript@5.6.3)(vitest@2.1.3)
'@vitest/coverage-istanbul': 2.1.3(vitest@2.1.3)
buffer: 6.0.3
chai: 4.3.10
chai-as-promised: 7.1.2(chai@4.3.10)
@ -19846,6 +19848,7 @@ packages:
karma-sourcemap-loader: 0.3.8
mocha: 10.7.3
nyc: 17.1.0
playwright: 1.48.1
rimraf: 5.0.10
safe-buffer: 5.2.1
source-map-support: 0.5.21
@ -19853,14 +19856,27 @@ packages:
tslib: 2.8.0
typescript: 5.6.3
util: 0.12.5
vitest: 2.1.3(@types/node@18.19.57)(@vitest/browser@2.1.3)
transitivePeerDependencies:
- '@swc/core'
- '@swc/wasm'
- '@edge-runtime/vm'
- '@vitest/ui'
- bufferutil
- debug
- happy-dom
- jiti
- jsdom
- less
- lightningcss
- msw
- safaridriver
- sass
- sass-embedded
- stylus
- sugarss
- supports-color
- terser
- utf-8-validate
- vite
- webdriverio
dev: false
file:projects/batch.tgz:

Просмотреть файл

@ -85,6 +85,8 @@ export default leafCommand(commandInfo, async ({ "package-name": packageName, br
await prepareFiles(projectFolder, { browser });
await applyCodemods(projectFolder);
log.info("Running `rush update`");
await run(["rush", "update"], { cwd: projectFolder });
log.info("Formatting files");
await run(["rushx", "format"], { cwd: projectFolder });
await commitChanges(projectFolder, "rushx format");
@ -167,7 +169,7 @@ export default mergeConfig(
async function writeBrowserTestConfig(packageFolder: string): Promise<void> {
const testConfig = {
extends: "./.tshy/build.json",
include: ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts"],
include: ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts", "./test/**/*.mts"],
exclude: ["./test/**/node/**/*.ts"],
compilerOptions: {
outDir: "./dist-test/browser",
@ -176,7 +178,7 @@ async function writeBrowserTestConfig(packageFolder: string): Promise<void> {
},
};
await saveJson(resolve(packageFolder, "test.browser.config.json"), testConfig);
await saveJson(resolve(packageFolder, "tsconfig.browser.config.json"), testConfig);
}
async function fixApiExtractorConfig(apiExtractorJsonPath: string): Promise<void> {
@ -266,7 +268,7 @@ function setScriptsSection(scripts: PackageJson["scripts"]): void {
scripts["build"] = "npm run clean && dev-tool run build-package && dev-tool run extract-api";
scripts["unit-test:browser"] =
"npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --no-test-proxy --browser";
"npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser";
scripts["unit-test:node"] = "dev-tool run test:vitest";
for (const script of Object.keys(scripts)) {

Просмотреть файл

@ -13,6 +13,8 @@ Fixed a bug where the client options are ignored when passed along with an AAD c
### Other Changes
- Native ESM support has been added, and this package will now emit both CommonJS and ESM. [#31433](https://github.com/Azure/azure-sdk-for-js/pull/31433)
## 1.0.0 (2021-08-10)
### Features Added

Просмотреть файл

@ -1,6 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/src/index.d.ts",
"mainEntryPointFilePath": "dist/esm/index.d.ts",
"docModel": {
"enabled": true
},
@ -11,7 +11,7 @@
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/latest/attestation.d.ts"
"publicTrimmedFilePath": "dist/attestation.d.ts"
},
"messages": {
"tsdocMessageReporting": {

Просмотреть файл

@ -1,139 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// https://github.com/karma-runner/karma-chrome-launcher
process.env.CHROME_BIN = require("puppeteer").executablePath();
require("dotenv").config();
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "./",
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ["source-map-support", "mocha"],
plugins: [
"karma-mocha",
"karma-mocha-reporter",
"karma-chrome-launcher",
"karma-firefox-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-sourcemap-loader",
"karma-junit-reporter",
"karma-source-map-support",
],
// list of files / patterns to load in the browser
files: [
"dist-test/index.browser.js",
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true },
],
// list of files / patterns to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["env"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
// "dist-test/index.js": ["coverage"]
},
envPreprocessor: [
"TEST_MODE",
"ATTESTATION_AAD_URL",
"ATTESTATION_ISOLATED_URL",
"ATTESTATION_LOCATION_SHORT_NAME",
"policySigningCertificate0",
"policySigningCertificate1",
"policySigningCertificate2",
"isolatedSigningCertificate",
"ATTESTATION_ISOLATED_SIGNING_CERTIFICATE",
"ATTESTATION_ISOLATED_SIGNING_KEY",
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"AZURE_TENANT_ID",
"RECORDINGS_RELATIVE_PATH",
],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "junit"],
coverageReporter: {
// specify a common output directory
dir: "coverage-browser/",
reporters: [
{ type: "json", subdir: ".", file: "coverage.json" },
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
{ type: "html", subdir: "html" },
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
],
},
junitReporter: {
outputDir: "", // results will be saved as $outputDir/$browserName.xml
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
suite: "", // suite will become the package name attribute in xml testsuite element
useBrowserName: false, // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
properties: {}, // key value pair of properties to add to the <properties> section of the report
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// --no-sandbox allows our tests to run in Linux without having to change the system.
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
browsers: ["ChromeHeadlessNoSandbox"],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: "ChromeHeadless",
flags: ["--no-sandbox", "--disable-web-security"],
},
ChromeInteractiveNoSandbox: {
base: "Chrome",
flags: ["--no-sandbox", "--disable-web-security"],
},
},
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 1,
browserNoActivityTimeout: 60000000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
client: {
mocha: {
// change Karma's debug.html to the mocha web reporter
reporter: "html",
timeout: 0,
},
},
});
};

Просмотреть файл

@ -3,17 +3,9 @@
"version": "1.0.1",
"description": "Javascript/Typescript client implementation for the Microsoft Azure Attestation service.",
"sdk-type": "client",
"main": "dist/index.js",
"module": "dist-esm/src/index.js",
"browser": {
"./dist-esm/src/utils/base64.js": "./dist-esm/src/utils/base64.browser.js",
"./dist-esm/src/utils/blobConvert.js": "./dist-esm/src/utils/blobConvert.browser.js",
"./dist-esm/src/utils/textEncoding.js": "./dist-esm/src/utils/textEncoding.browser.js",
"./dist-esm/src/utils/buffer.js": "./dist-esm/src/utils/buffer.browser.js",
"./dist-esm/test/utils/base64url.js": "./dist-esm/test/utils/base64url.browser.js",
"./dist-esm/test/utils/env.js": "./dist-esm/test/utils/env.browser.js",
"./dist-esm/samples-dev/utils/base64url.js": "./dist-esm/samples-dev/utils/base64url.browser.js"
},
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"browser": "./dist/browser/index.js",
"//metadata": {
"constantPaths": [
{
@ -26,24 +18,24 @@
}
]
},
"types": "types/latest/attestation.d.ts",
"types": "./dist/commonjs/index.d.ts",
"scripts": {
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build": "npm run clean && tsc -p . && npm run build:nodebrowser && dev-tool run extract-api",
"build:browser": "tsc -p . && dev-tool run bundle",
"build:node": "tsc -p . && dev-tool run bundle",
"build:nodebrowser": "dev-tool run bundle",
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
"build:browser": "dev-tool run build-package && dev-tool run build-test",
"build:node": "dev-tool run build-package && dev-tool run build-test",
"build:nodebrowser": "dev-tool run build-test",
"build:samples": "echo Obsolete.",
"build:test": "tsc -p . && dev-tool run bundle",
"build:test": "dev-tool run build-package && dev-tool run build-test",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf --glob dist dist-* temp types *.tgz *.log",
"execute:samples": "dev-tool samples run samples-dev",
"extract-api": "tsc -p . && dev-tool run extract-api",
"extract-api": "dev-tool run build-package && dev-tool run extract-api",
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"generate:client": "autorest --typescript ./swagger/README.md",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"integration-test:browser": "dev-tool run test:browser",
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 --exclude 'dist-esm/test/**/browser/*.spec.js' 'dist-esm/test/**/*.spec.js'",
"integration-test:browser": "dev-tool run test:vitest --browser",
"integration-test:node": "dev-tool run test:vitest -- --test-timeout 5000000",
"lint": "eslint package.json api-extractor.json src test",
"lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]",
"pack": "npm pack 2>&1",
@ -51,14 +43,12 @@
"test:browser": "npm run build:test && npm run integration-test:browser",
"test:node": "npm run build:test && npm run integration-test:node",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "dev-tool run test:browser",
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
"unit-test:node": "dev-tool run test:vitest",
"update-snippets": "echo skipped"
},
"files": [
"dist/",
"dist-esm/src/",
"types/latest/",
"README.md",
"LICENSE"
],
@ -92,43 +82,27 @@
"tslib": "^2.2.0"
},
"devDependencies": {
"@azure-tools/test-credential": "^1.0.0",
"@azure-tools/test-recorder": "^3.0.0",
"@azure-tools/test-credential": "^2.0.0",
"@azure-tools/test-recorder": "^4.1.0",
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/identity": "^4.0.1",
"@microsoft/api-extractor": "^7.31.1",
"@types/chai": "^4.1.6",
"@types/chai-as-promised": "^7.1.0",
"@types/mocha": "^10.0.0",
"@types/node": "^18.0.0",
"@vitest/browser": "^2.1.3",
"@vitest/coverage-istanbul": "^2.1.3",
"buffer": "^6.0.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cross-env": "^7.0.2",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"inherits": "^2.0.3",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-json-preprocessor": "^0.3.3",
"karma-json-to-file-reporter": "^1.0.1",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-source-map-support": "~1.4.0",
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"nyc": "^17.0.0",
"playwright": "^1.48.1",
"rimraf": "^5.0.5",
"safe-buffer": "^5.2.1",
"source-map-support": "^0.5.9",
"ts-node": "^10.0.0",
"typescript": "~5.6.2",
"util": "^0.12.1"
"util": "^0.12.1",
"vitest": "^2.1.3"
},
"//sampleConfiguration": {
"skipFolder": false,
@ -137,5 +111,42 @@
"azure-attestation"
],
"requiredResources": {}
},
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"esmDialects": [
"browser",
"react-native"
],
"selfLink": false
},
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"react-native": {
"types": "./dist/react-native/index.d.ts",
"default": "./dist/react-native/index.js"
},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
}
}

Просмотреть файл

@ -28,8 +28,8 @@ import { DefaultAzureCredential } from "@azure/identity";
// Load environment from a .env file if it exists.
import * as dotenv from "dotenv";
import { writeBanner } from "./utils/helpers";
import { decodeString } from "./utils/base64url";
import { writeBanner } from "./utils/helpers.js";
import { decodeString } from "./utils/base64url.js";
dotenv.config();

Просмотреть файл

@ -29,7 +29,7 @@ import { X509 } from "jsrsasign";
// Load environment from a .env file if it exists.
import * as dotenv from "dotenv";
import { writeBanner } from "./utils/helpers";
import { writeBanner } from "./utils/helpers.js";
dotenv.config();
async function getOpenIdMetadata() {

Просмотреть файл

@ -29,7 +29,7 @@ import { DefaultAzureCredential } from "@azure/identity";
// Load environment from a .env file if it exists.
import * as dotenv from "dotenv";
import { writeBanner } from "./utils/helpers";
import { writeBanner } from "./utils/helpers.js";
dotenv.config();
async function getCurrentAttestationPolicyAad() {

Просмотреть файл

@ -31,7 +31,7 @@ import { X509 } from "jsrsasign";
// Load environment from a .env file if it exists.
import * as dotenv from "dotenv";
import { writeBanner } from "./utils/helpers";
import { writeBanner } from "./utils/helpers.js";
dotenv.config();
async function getPolicyManagementCertificates() {

Просмотреть файл

@ -31,13 +31,13 @@
import { AttestationAdministrationClient } from "@azure/attestation";
import { DefaultAzureCredential } from "@azure/identity";
import { createRSAKey, createX509Certificate, generateSha1Hash } from "./utils/cryptoUtils";
import { createRSAKey, createX509Certificate, generateSha1Hash } from "./utils/cryptoUtils.js";
import { X509 } from "jsrsasign";
// Load environment from a .env file if it exists.
import * as dotenv from "dotenv";
import { writeBanner } from "./utils/helpers";
import { byteArrayToHex } from "../src/utils/base64";
import { writeBanner } from "./utils/helpers.js";
import { byteArrayToHex } from "../src/utils/base64.js";
dotenv.config();
async function modifyPolicyManagementCertificates() {

Просмотреть файл

@ -39,8 +39,8 @@ import { DefaultAzureCredential } from "@azure/identity";
// Load environment from a .env file if it exists.
import * as dotenv from "dotenv";
import { writeBanner } from "./utils/helpers";
import { createRSAKey, createX509Certificate, generateSha256Hash } from "./utils/cryptoUtils";
import { writeBanner } from "./utils/helpers.js";
import { createRSAKey, createX509Certificate, generateSha256Hash } from "./utils/cryptoUtils.js";
import { X509 } from "jsrsasign";

Просмотреть файл

@ -5,7 +5,7 @@
/// <reference path="../../src/jsrsasign.d.ts"/>
import * as jsrsasign from "jsrsasign";
import { hexToByteArray } from "../../src/utils/base64";
import { hexToByteArray } from "../../src/utils/base64.js";
export function createECDSKey(): [string, string] {
const keyPair = jsrsasign.KEYUTIL.generateKeypair("EC", "secp256r1");

Просмотреть файл

@ -2,17 +2,17 @@
// Licensed under the MIT License.
/* eslint-disable @azure/azure-sdk/ts-naming-options */
import { GeneratedClient } from "./generated/generatedClient";
import { logger } from "./logger";
import { GeneratedClient } from "./generated/generatedClient.js";
import { logger } from "./logger.js";
import {
AttestationCertificateManagementBody,
GeneratedClientOptionalParams,
JsonWebKey,
PolicyCertificatesResult,
} from "./generated/models";
} from "./generated/models/index.js";
import { bytesToString } from "./utils/utf8";
import { bytesToString } from "./utils/utf8.js";
import {
AttestationResponse,
@ -21,24 +21,24 @@ import {
AttestationType,
PolicyCertificatesModificationResult,
PolicyResult,
} from "./models";
import { StoredAttestationPolicy } from "./models/storedAttestationPolicy";
} from "./models/index.js";
import { StoredAttestationPolicy } from "./models/storedAttestationPolicy.js";
import { CommonClientOptions, OperationOptions } from "@azure/core-client";
import { TokenCredential } from "@azure/core-auth";
import { TypeDeserializer } from "./utils/typeDeserializer";
import * as Mappers from "./generated/models/mappers";
import { TypeDeserializer } from "./utils/typeDeserializer.js";
import * as Mappers from "./generated/models/mappers.js";
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../jsrsasign.d.ts"/>
import * as jsrsasign from "jsrsasign";
import { hexToBase64 } from "./utils/helpers";
import { _policyResultFromGenerated } from "./models/policyResult";
import { _attestationSignerFromGenerated } from "./models/attestationSigner";
import { verifyAttestationSigningKey } from "./utils/helpers";
import { createAttestationResponse } from "./models/attestationResponse";
import { AttestationTokenImpl } from "./models/attestationToken";
import { tracingClient } from "./generated/tracing";
import { hexToBase64 } from "./utils/helpers.js";
import { _policyResultFromGenerated } from "./models/policyResult.js";
import { _attestationSignerFromGenerated } from "./models/attestationSigner.js";
import { verifyAttestationSigningKey } from "./utils/helpers.js";
import { createAttestationResponse } from "./models/attestationResponse.js";
import { AttestationTokenImpl } from "./models/attestationToken.js";
import { tracingClient } from "./generated/tracing.js";
/**
* Attestation Client Construction Options.

Просмотреть файл

@ -1,32 +1,36 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { GeneratedClient } from "./generated/generatedClient";
import { GeneratedClient } from "./generated/generatedClient.js";
import { AttestationResult, AttestationSigner, AttestationTokenValidationOptions } from "./models";
import {
AttestationResult,
AttestationSigner,
AttestationTokenValidationOptions,
} from "./models/index.js";
import {
GeneratedAttestationResult,
InitTimeData,
KnownDataType,
RuntimeData,
} from "./generated/models";
} from "./generated/models/index.js";
import { logger } from "./logger";
import { GeneratedClientOptionalParams } from "./generated/models";
import * as Mappers from "./generated/models/mappers";
import { logger } from "./logger.js";
import { GeneratedClientOptionalParams } from "./generated/models/index.js";
import * as Mappers from "./generated/models/mappers.js";
import { AttestationResponse, createAttestationResponse } from "./models/attestationResponse";
import { AttestationResponse, createAttestationResponse } from "./models/attestationResponse.js";
import { TypeDeserializer } from "./utils/typeDeserializer";
import { TypeDeserializer } from "./utils/typeDeserializer.js";
import { TokenCredential, isTokenCredential } from "@azure/core-auth";
import { CommonClientOptions, OperationOptions } from "@azure/core-client";
import { bytesToString, stringToBytes } from "./utils/utf8";
import { _attestationResultFromGenerated } from "./models/attestationResult";
import { _attestationSignerFromGenerated } from "./models/attestationSigner";
import { AttestationTokenImpl } from "./models/attestationToken";
import { Uint8ArrayFromInput } from "./utils/buffer";
import { tracingClient } from "./generated/tracing";
import { bytesToString, stringToBytes } from "./utils/utf8.js";
import { _attestationResultFromGenerated } from "./models/attestationResult.js";
import { _attestationSignerFromGenerated } from "./models/attestationSigner.js";
import { AttestationTokenImpl } from "./models/attestationToken.js";
import { Uint8ArrayFromInput } from "./utils/buffer.js";
import { tracingClient } from "./generated/tracing.js";
/**
* Attestation Client Construction Options.

Просмотреть файл

@ -18,15 +18,15 @@ import {
AttestationImpl,
SigningCertificatesImpl,
MetadataConfigurationImpl
} from "./operations";
} from "./operations/index.js";
import {
Policy,
PolicyCertificates,
Attestation,
SigningCertificates,
MetadataConfiguration
} from "./operationsInterfaces";
import { GeneratedClientOptionalParams } from "./models";
} from "./operationsInterfaces/index.js";
import { GeneratedClientOptionalParams } from "./models/index.js";
export class GeneratedClient extends coreClient.ServiceClient {
instanceUrl: string;

6
sdk/attestation/attestation/src/generated/index.ts сгенерированный
Просмотреть файл

@ -6,6 +6,6 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./models";
export { GeneratedClient } from "./generatedClient";
export * from "./operationsInterfaces";
export * from "./models/index.js";
export { GeneratedClient } from "./generatedClient.js";
export * from "./operationsInterfaces/index.js";

Просмотреть файл

@ -15,7 +15,7 @@ import {
AttestOpenEnclaveRequest as AttestOpenEnclaveRequestMapper,
AttestSgxEnclaveRequest as AttestSgxEnclaveRequestMapper,
TpmAttestationRequest as TpmAttestationRequestMapper
} from "../models/mappers";
} from "../models/mappers.js";
export const accept: OperationParameter = {
parameterPath: "accept",

Просмотреть файл

@ -6,12 +6,12 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { tracingClient } from "../tracing";
import { Attestation } from "../operationsInterfaces";
import { tracingClient } from "../tracing.js";
import { Attestation } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { GeneratedClient } from "../generatedClient";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { GeneratedClient } from "../generatedClient.js";
import {
AttestOpenEnclaveRequest,
AttestationAttestOpenEnclaveOptionalParams,
@ -22,7 +22,7 @@ import {
TpmAttestationRequest,
AttestationAttestTpmOptionalParams,
AttestationAttestTpmResponse
} from "../models";
} from "../models/index.js";
/** Class containing Attestation operations. */
export class AttestationImpl implements Attestation {

Просмотреть файл

@ -6,8 +6,8 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./policy";
export * from "./policyCertificates";
export * from "./attestation";
export * from "./signingCertificates";
export * from "./metadataConfiguration";
export * from "./policy.js";
export * from "./policyCertificates.js";
export * from "./attestation.js";
export * from "./signingCertificates.js";
export * from "./metadataConfiguration.js";

Просмотреть файл

@ -6,16 +6,16 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { tracingClient } from "../tracing";
import { MetadataConfiguration } from "../operationsInterfaces";
import { tracingClient } from "../tracing.js";
import { MetadataConfiguration } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { GeneratedClient } from "../generatedClient";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { GeneratedClient } from "../generatedClient.js";
import {
MetadataConfigurationGetOptionalParams,
MetadataConfigurationGetResponse
} from "../models";
} from "../models/index.js";
/** Class containing MetadataConfiguration operations. */
export class MetadataConfigurationImpl implements MetadataConfiguration {

Просмотреть файл

@ -6,12 +6,12 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { tracingClient } from "../tracing";
import { Policy } from "../operationsInterfaces";
import { tracingClient } from "../tracing.js";
import { Policy } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { GeneratedClient } from "../generatedClient";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { GeneratedClient } from "../generatedClient.js";
import {
AttestationType,
PolicyGetOptionalParams,
@ -20,7 +20,7 @@ import {
PolicySetModelResponse,
PolicyResetOptionalParams,
PolicyResetResponse
} from "../models";
} from "../models/index.js";
/** Class containing Policy operations. */
export class PolicyImpl implements Policy {

Просмотреть файл

@ -6,12 +6,12 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { tracingClient } from "../tracing";
import { PolicyCertificates } from "../operationsInterfaces";
import { tracingClient } from "../tracing.js";
import { PolicyCertificates } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { GeneratedClient } from "../generatedClient";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { GeneratedClient } from "../generatedClient.js";
import {
PolicyCertificatesGetOptionalParams,
PolicyCertificatesGetResponse,
@ -19,7 +19,7 @@ import {
PolicyCertificatesAddResponse,
PolicyCertificatesRemoveOptionalParams,
PolicyCertificatesRemoveResponse
} from "../models";
} from "../models/index.js";
/** Class containing PolicyCertificates operations. */
export class PolicyCertificatesImpl implements PolicyCertificates {

Просмотреть файл

@ -6,16 +6,16 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { tracingClient } from "../tracing";
import { SigningCertificates } from "../operationsInterfaces";
import { tracingClient } from "../tracing.js";
import { SigningCertificates } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { GeneratedClient } from "../generatedClient";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { GeneratedClient } from "../generatedClient.js";
import {
SigningCertificatesGetOptionalParams,
SigningCertificatesGetResponse
} from "../models";
} from "../models/index.js";
/** Class containing SigningCertificates operations. */
export class SigningCertificatesImpl implements SigningCertificates {

Просмотреть файл

@ -16,7 +16,7 @@ import {
TpmAttestationRequest,
AttestationAttestTpmOptionalParams,
AttestationAttestTpmResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a Attestation. */
export interface Attestation {

Просмотреть файл

@ -6,8 +6,8 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./policy";
export * from "./policyCertificates";
export * from "./attestation";
export * from "./signingCertificates";
export * from "./metadataConfiguration";
export * from "./policy.js";
export * from "./policyCertificates.js";
export * from "./attestation.js";
export * from "./signingCertificates.js";
export * from "./metadataConfiguration.js";

Просмотреть файл

@ -9,7 +9,7 @@
import {
MetadataConfigurationGetOptionalParams,
MetadataConfigurationGetResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a MetadataConfiguration. */
export interface MetadataConfiguration {

Просмотреть файл

@ -14,7 +14,7 @@ import {
PolicySetModelResponse,
PolicyResetOptionalParams,
PolicyResetResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a Policy. */
export interface Policy {

Просмотреть файл

@ -13,7 +13,7 @@ import {
PolicyCertificatesAddResponse,
PolicyCertificatesRemoveOptionalParams,
PolicyCertificatesRemoveResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a PolicyCertificates. */
export interface PolicyCertificates {

Просмотреть файл

@ -9,7 +9,7 @@
import {
SigningCertificatesGetOptionalParams,
SigningCertificatesGetResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a SigningCertificates. */
export interface SigningCertificates {

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export * from "./models";
export * from "./models/index.js";
export {
AttestationClient,
AttestationClientOptions,
@ -8,7 +8,7 @@ export {
AttestSgxEnclaveOptions,
AttestTpmOptions,
AttestationClientOperationOptions,
} from "./attestationClient";
} from "./attestationClient.js";
export {
AttestationAdministrationClient,
@ -16,4 +16,4 @@ export {
AttestationAdministrationClientOperationOptions,
AttestationAdministrationClientPolicyOperationOptions,
AttestationAdministrationClientPolicyCertificateOperationOptions,
} from "./attestationAdministrationClient";
} from "./attestationAdministrationClient.js";

Просмотреть файл

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { StoredAttestationPolicy } from "./storedAttestationPolicy";
import { StoredAttestationPolicy } from "./storedAttestationPolicy.js";
// import { AttestationSigningKey } from "./attestationSigningKey";
import { AttestationToken, AttestationTokenImpl } from "./attestationToken";
import { AttestationToken, AttestationTokenImpl } from "./attestationToken.js";
/**
*

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { AttestationToken } from "./attestationToken";
import { AttestationToken } from "./attestationToken.js";
/**
* An AttestationResponse represents the response from the Microsoft Azure

Просмотреть файл

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { AttestationSigner } from ".";
import { GeneratedAttestationResult } from "../generated";
import { _attestationSignerFromGenerated } from "./attestationSigner";
import { AttestationSigner } from "./index.js";
import { GeneratedAttestationResult } from "../generated/index.js";
import { _attestationSignerFromGenerated } from "./attestationSigner.js";
/**
* Defines the contents of the {@link AttestationResult.sgxCollateral} claim in

Просмотреть файл

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { JsonWebKey } from "../generated/models";
import { pemFromBase64 } from "../utils/helpers";
import { JsonWebKey } from "../generated/models/index.js";
import { pemFromBase64 } from "../utils/helpers.js";
/**
* An AttestationSigner represents a signing certificate chain/Key ID combination

Просмотреть файл

@ -5,14 +5,14 @@
/// <reference path="../jsrsasign.d.ts"/>
import * as jsrsasign from "jsrsasign";
import { JsonWebKey } from "../generated/models";
import { base64UrlDecodeString } from "../utils/base64";
import { bytesToString } from "../utils/utf8";
import { AttestationSigner, _attestationSignerFromGenerated } from "./attestationSigner";
import { JsonWebKey } from "../generated/models/index.js";
import { base64UrlDecodeString } from "../utils/base64.js";
import { bytesToString } from "../utils/utf8.js";
import { AttestationSigner, _attestationSignerFromGenerated } from "./attestationSigner.js";
import * as Mappers from "../generated/models/mappers";
import { TypeDeserializer } from "../utils/typeDeserializer";
import { hexToBase64, verifyAttestationSigningKey } from "../utils/helpers";
import * as Mappers from "../generated/models/mappers.js";
import { TypeDeserializer } from "../utils/typeDeserializer.js";
import { hexToBase64, verifyAttestationSigningKey } from "../utils/helpers.js";
/**
* Options used to validate attestation tokens.

Просмотреть файл

@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export { AttestationSigner } from "./attestationSigner";
export { AttestationToken, AttestationTokenValidationOptions } from "./attestationToken";
export { AttestationResponse } from "./attestationResponse";
export { PolicyResult } from "./policyResult";
export { AttestationResult, AttestationSgxCollateralInfo } from "./attestationResult";
export { AttestationSigner } from "./attestationSigner.js";
export { AttestationToken, AttestationTokenValidationOptions } from "./attestationToken.js";
export { AttestationResponse } from "./attestationResponse.js";
export { PolicyResult } from "./policyResult.js";
export { AttestationResult, AttestationSgxCollateralInfo } from "./attestationResult.js";
export {
KnownAttestationType,
KnownCertificateModification,
@ -14,5 +14,5 @@ export {
CertificateModification,
PolicyModification,
PolicyCertificatesModificationResult,
} from "../generated/models/index";
export { AttestationPolicyToken, createAttestationPolicyToken } from "./attestationPolicyToken";
} from "../generated/models/index.js";
export { AttestationPolicyToken, createAttestationPolicyToken } from "./attestationPolicyToken.js";

Просмотреть файл

@ -7,13 +7,13 @@
*
*/
import { PolicyModification } from "./index";
import * as Mappers from "../generated/models/mappers";
import { PolicyModification } from "./index.js";
import * as Mappers from "../generated/models/mappers.js";
import { PolicyResult as GeneratedPolicyResult } from "../generated/models";
import { PolicyResult as GeneratedPolicyResult } from "../generated/models/index.js";
import { TypeDeserializer } from "../utils/typeDeserializer";
import { AttestationSigner, _attestationSignerFromGenerated } from "./attestationSigner";
import { TypeDeserializer } from "../utils/typeDeserializer.js";
import { AttestationSigner, _attestationSignerFromGenerated } from "./attestationSigner.js";
/**
* The result of a policy certificate modification

Просмотреть файл

@ -7,10 +7,10 @@
*
*/
import { stringToBytes } from "../utils/utf8";
import { TypeDeserializer } from "../utils/typeDeserializer";
import { stringToBytes } from "../utils/utf8.js";
import { TypeDeserializer } from "../utils/typeDeserializer.js";
import * as Mappers from "../generated/models/mappers";
import * as Mappers from "../generated/models/mappers.js";
/**
* Represents a stored attestation policy sent to the attestation service.

Просмотреть файл

@ -4,7 +4,7 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../jsrsasign.d.ts"/>
import * as jsrsasign from "jsrsasign";
import { base64EncodeByteArray, hexToByteArray } from "./base64";
import { base64EncodeByteArray, hexToByteArray } from "./base64.js";
/** Create an AttestationSigningKey from the provided private key and certificate.
*

Просмотреть файл

@ -1,11 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { assert, use as chaiUse, expect } from "chai";
import { Context } from "mocha";
import chaiPromises from "chai-as-promised";
chaiUse(chaiPromises);
import { Recorder } from "@azure-tools/test-recorder";
import {
@ -13,16 +8,17 @@ import {
createRecordedAdminClient,
createRecordedClient,
recorderOptions,
} from "../utils/recordedClient";
import * as base64url from "../utils/base64url";
} from "../utils/recordedClient.js";
import * as base64url from "../utils/base64url.js";
import { KnownAttestationType } from "../../src";
import { KnownAttestationType } from "../../src/index.js";
import { describe, it, assert, expect, beforeEach, afterEach } from "vitest";
describe("AttestationClient in Browser", function () {
let recorder: Recorder;
beforeEach(async function (this: Context) {
recorder = new Recorder(this.currentTest);
beforeEach(async function (ctx) {
recorder = new Recorder(ctx);
await recorder.start(recorderOptions);
});
@ -204,7 +200,7 @@ describe("AttestationClient in Browser", function () {
runTimeData: binaryRuntimeData,
runTimeJson: binaryRuntimeData,
}),
).to.eventually.be.rejectedWith("Cannot provide both runTimeData and runTimeJson");
).rejects.toThrow("Cannot provide both runTimeData and runTimeJson");
}
{
@ -263,7 +259,7 @@ describe("AttestationClient in Browser", function () {
runTimeJson: binaryRuntimeData,
},
),
).to.eventually.be.rejectedWith("Cannot provide both runTimeData and runTimeJson");
).rejects.toThrow("Cannot provide both runTimeData and runTimeJson");
}
{

Просмотреть файл

@ -1,11 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { assert, use as chaiUse, expect } from "chai";
import { Context } from "mocha";
import chaiPromises from "chai-as-promised";
chaiUse(chaiPromises);
import { Recorder } from "@azure-tools/test-recorder";
import {
@ -13,16 +7,17 @@ import {
createRecordedAdminClient,
createRecordedClient,
recorderOptions,
} from "../utils/recordedClient";
import * as base64url from "../utils/base64url";
} from "../utils/recordedClient.js";
import * as base64url from "../utils/base64url.js";
import { KnownAttestationType } from "../../src";
import { KnownAttestationType } from "../../src/index.js";
import { describe, it, assert, expect, beforeEach, afterEach } from "vitest";
describe("[AAD] Attestation Client", function () {
let recorder: Recorder;
beforeEach(async function (this: Context) {
recorder = new Recorder(this.currentTest);
beforeEach(async function (ctx) {
recorder = new Recorder(ctx);
await recorder.start(recorderOptions);
});
@ -198,14 +193,12 @@ describe("[AAD] Attestation Client", function () {
const client = createRecordedClient(recorder, endpointType);
// You can't specify both runtimeData and runtimeJson.
await assert.isRejected(
await expect(
client.attestOpenEnclave(base64url.decodeString(_openEnclaveReport).subarray(0x10), {
runTimeData: binaryRuntimeData,
runTimeJson: binaryRuntimeData,
}),
"Cannot provide both runTimeData and runTimeJson.",
"Expected to throw since you can't specify both runtimeData and runtimeJson",
);
).rejects.toThrow("Cannot provide both runTimeData and runTimeJson.");
{
const attestationResult = await client.attestOpenEnclave(
@ -251,14 +244,12 @@ describe("[AAD] Attestation Client", function () {
const binaryRuntimeData = base64url.decodeString(_runtimeData);
await assert.isRejected(
await expect(
client.attestSgxEnclave(base64url.decodeString(_openEnclaveReport).subarray(0x10), {
runTimeData: binaryRuntimeData,
runTimeJson: binaryRuntimeData,
}),
"Cannot provide both runTimeData and runTimeJson.",
"Expected to throw since you can't specify both runtimeData and runtimeJson",
);
).rejects.toThrow("Cannot provide both runTimeData and runTimeJson.");
{
// An OpenEnclave report has a 16 byte header prepended to an SGX quote.

Просмотреть файл

@ -5,24 +5,20 @@
/// <reference path="../../src/jsrsasign.d.ts"/>
import * as jsrsasign from "jsrsasign";
import { assert, use as chaiUse, expect } from "chai";
import { Context } from "mocha";
import chaiPromises from "chai-as-promised";
chaiUse(chaiPromises);
import { Recorder } from "@azure-tools/test-recorder";
import { bytesToString, stringToBytes } from "../../src/utils/utf8";
import { bytesToString, stringToBytes } from "../../src/utils/utf8.js";
import { createECDSKey, createRSAKey, createX509Certificate } from "../utils/cryptoUtils";
import { verifyAttestationSigningKey } from "../../src/utils/helpers";
import { AttestationTokenImpl } from "../../src/models/attestationToken";
import { recorderOptions } from "../utils/recordedClient";
import { createECDSKey, createRSAKey, createX509Certificate } from "../utils/cryptoUtils.js";
import { verifyAttestationSigningKey } from "../../src/utils/helpers.js";
import { AttestationTokenImpl } from "../../src/models/attestationToken.js";
import { recorderOptions } from "../utils/recordedClient.js";
import { describe, it, assert, expect, beforeEach, afterEach } from "vitest";
describe("AttestationTokenTests", function () {
let recorder: Recorder;
beforeEach(async function (this: Context) {
recorder = new Recorder(this.currentTest);
beforeEach(async function (ctx) {
recorder = new Recorder(ctx);
await recorder.start(recorderOptions);
});

Просмотреть файл

@ -4,14 +4,8 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../../src/jsrsasign.d.ts"/>
import * as jsrsasign from "jsrsasign";
import { assert, use as chaiUse, expect } from "chai";
import { Context } from "mocha";
import chaiAsPromised from "chai-as-promised";
/* eslint-disable @typescript-eslint/no-invalid-this */
chaiUse(chaiAsPromised);
import { Recorder, isLiveMode } from "@azure-tools/test-recorder";
import {
@ -19,17 +13,22 @@ import {
createRecordedAdminClient,
getIsolatedSigningKey,
recorderOptions,
} from "../utils/recordedClient";
import { AttestationType, KnownAttestationType, createAttestationPolicyToken } from "../../src";
import { createRSAKey, createX509Certificate, generateSha256Hash } from "../utils/cryptoUtils";
import { KnownPolicyModification } from "../../src/generated";
import { verifyAttestationSigningKey } from "../../src/utils/helpers";
} from "../utils/recordedClient.js";
import {
AttestationType,
KnownAttestationType,
createAttestationPolicyToken,
} from "../../src/index.js";
import { createRSAKey, createX509Certificate, generateSha256Hash } from "../utils/cryptoUtils.js";
import { KnownPolicyModification } from "../../src/generated/index.js";
import { verifyAttestationSigningKey } from "../../src/utils/helpers.js";
import { describe, it, assert, expect, beforeEach, afterEach } from "vitest";
describe("PolicyGetSetTests ", function () {
let recorder: Recorder;
beforeEach(async function (this: Context) {
recorder = new Recorder(this.currentTest);
beforeEach(async function (ctx) {
recorder = new Recorder(ctx);
await recorder.start(recorderOptions);
});
@ -64,27 +63,27 @@ describe("PolicyGetSetTests ", function () {
await expect(
adminClient.setPolicy(KnownAttestationType.SgxEnclave, minimalPolicy, { privateKey: rsaKey }),
).to.be.rejectedWith("privateKey is specified");
).rejects.toThrow("privateKey is specified");
await expect(
adminClient.setPolicy(KnownAttestationType.SgxEnclave, minimalPolicy, {
certificate: rsaCertificate,
}),
).to.be.rejectedWith("privateKey is specified");
).rejects.toThrow("privateKey is specified");
await expect(
adminClient.setPolicy(KnownAttestationType.SgxEnclave, minimalPolicy, {
privateKey: rsaKey2,
certificate: rsaCertificate,
}),
).to.be.rejectedWith("Key does not match Certificate");
).rejects.toThrow("Key does not match Certificate");
await expect(
adminClient.setPolicy(KnownAttestationType.SgxEnclave, minimalPolicy, {
privateKey: "BogusKey",
certificate: rsaCertificate,
}),
).to.be.rejectedWith("not supported argument");
).rejects.toThrow("not supported argument");
await adminClient.setPolicy(KnownAttestationType.SgxEnclave, minimalPolicy);
@ -100,31 +99,31 @@ describe("PolicyGetSetTests ", function () {
await expect(
adminClient.resetPolicy(KnownAttestationType.SgxEnclave, { privateKey: rsaKey }),
).to.be.rejectedWith("privateKey is specified");
).rejects.toThrow("privateKey is specified");
await expect(
adminClient.resetPolicy(KnownAttestationType.SgxEnclave, { certificate: rsaCertificate }),
).to.be.rejectedWith("privateKey is specified");
).rejects.toThrow("privateKey is specified");
await expect(
adminClient.resetPolicy(KnownAttestationType.SgxEnclave, {
privateKey: "BogusKey",
certificate: rsaCertificate,
}),
).to.be.rejectedWith("not supported argument");
).rejects.toThrow("not supported argument");
await expect(
adminClient.resetPolicy(KnownAttestationType.SgxEnclave, {
privateKey: rsaKey2,
certificate: rsaCertificate,
}),
).to.be.rejectedWith("Key does not match Certificate");
).rejects.toThrow("Key does not match Certificate");
await adminClient.resetPolicy(KnownAttestationType.SgxEnclave);
});
it("Set Policy SGX - AAD Secured", async function () {
if (!isLiveMode()) this.skip(); // "secured APIs cannot match the policy hash because the recorded policy signer won't match the signer in the request"
it("Set Policy SGX - AAD Secured", async function (ctx) {
if (!isLiveMode()) ctx.skip(); // "secured APIs cannot match the policy hash because the recorded policy signer won't match the signer in the request"
const [rsaKey, rsapubKey] = createRSAKey();
const rsaCertificate = createX509Certificate(rsaKey, rsapubKey, "CertificateName");
await testSetPolicy(KnownAttestationType.SgxEnclave, "AAD", {
@ -133,8 +132,8 @@ describe("PolicyGetSetTests ", function () {
});
});
it("Set Policy SGX - Isolated Secured", async function () {
if (!isLiveMode()) this.skip(); // "setPolicy APIs require keys and certificates from the environment, which are not available in playback"
it("Set Policy SGX - Isolated Secured", async function (ctx) {
if (!isLiveMode()) ctx.skip(); // "setPolicy APIs require keys and certificates from the environment, which are not available in playback"
await testSetPolicy(KnownAttestationType.SgxEnclave, "Isolated", getIsolatedSigningKey());
});
@ -142,16 +141,16 @@ describe("PolicyGetSetTests ", function () {
await testResetPolicy(KnownAttestationType.SgxEnclave, "AAD");
});
it("Reset Policy SGX - AAD Secured", async function () {
if (!isLiveMode()) this.skip(); // "secured APIs cannot match the policy hash because the recorded policy signer won't match the signer in the request"
it("Reset Policy SGX - AAD Secured", async function (ctx) {
if (!isLiveMode()) ctx.skip(); // "secured APIs cannot match the policy hash because the recorded policy signer won't match the signer in the request"
const [rsaKey, rsaPubKey] = createRSAKey();
const rsaCertificate = createX509Certificate(rsaKey, rsaPubKey, "CertificateName");
const signingKey = verifyAttestationSigningKey(rsaKey, rsaCertificate);
await testResetPolicy(KnownAttestationType.SgxEnclave, "AAD", signingKey);
});
it("Reset Policy SGX - Isolated Secured", async function () {
if (!isLiveMode()) this.skip(); // "resetPolicy APIs require keys and certificates from the environment, which are not available in playback"
it("Reset Policy SGX - Isolated Secured", async function (ctx) {
if (!isLiveMode()) ctx.skip(); // "resetPolicy APIs require keys and certificates from the environment, which are not available in playback"
const signingKeys = getIsolatedSigningKey();
await testResetPolicy(KnownAttestationType.SgxEnclave, "Isolated", signingKeys);
});

Просмотреть файл

@ -1,10 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { assert, use as chaiUse, expect } from "chai";
import { Context } from "mocha";
import chaiAsPromised from "chai-as-promised";
chaiUse(chaiAsPromised);
/* eslint-disable @typescript-eslint/no-invalid-this */
import { Recorder, isLiveMode } from "@azure-tools/test-recorder";
@ -13,20 +8,21 @@ import {
createRecordedAdminClient,
getIsolatedSigningKey,
recorderOptions,
} from "../utils/recordedClient";
import { createRSAKey, createX509Certificate, generateSha1Hash } from "../utils/cryptoUtils";
import { KnownCertificateModification } from "../../src/generated";
} from "../utils/recordedClient.js";
import { createRSAKey, createX509Certificate, generateSha1Hash } from "../utils/cryptoUtils.js";
import { KnownCertificateModification } from "../../src/generated/index.js";
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../jsrsasign.d.ts"/>
import * as jsrsasign from "jsrsasign";
import { byteArrayToHex } from "../../src/utils/base64";
import { byteArrayToHex } from "../../src/utils/base64.js";
import { describe, it, assert, expect, beforeEach, afterEach } from "vitest";
describe("PolicyManagementTests ", function () {
let recorder: Recorder;
beforeEach(async function (this: Context) {
recorder = new Recorder(this.currentTest);
beforeEach(async function (ctx) {
recorder = new Recorder(ctx);
await recorder.start(recorderOptions);
});
@ -71,11 +67,11 @@ describe("PolicyManagementTests ", function () {
await expect(
adminClient.addPolicyManagementCertificate(rsaCertificate, "Foo", "Bar"),
).to.be.rejectedWith("can't find PEM header");
).rejects.toThrow("can't find PEM header");
await expect(
adminClient.addPolicyManagementCertificate(rsaCertificate, rsaKey2, rsaCertificate),
).to.be.rejectedWith("Key does not match Certificate");
).rejects.toThrow("Key does not match Certificate");
});
it("Remove Policy failure conditions", async function () {
@ -87,15 +83,15 @@ describe("PolicyManagementTests ", function () {
await expect(
adminClient.removePolicyManagementCertificate(rsaCertificate, "Foo", "Bar"),
).to.be.rejectedWith("can't find PEM header");
).rejects.toThrow("can't find PEM header");
await expect(
adminClient.removePolicyManagementCertificate(rsaCertificate, rsaKey2, rsaCertificate),
).to.be.rejectedWith("Key does not match Certificate");
).rejects.toThrow("Key does not match Certificate");
});
it("setPolicyCertificates", async function () {
if (!isLiveMode()) this.skip(); // "setPolicyCertificate APIs require keys and certificates from the environment, which are not available in playback"
it("setPolicyCertificates", async function (ctx) {
if (!isLiveMode()) ctx.skip(); // "setPolicyCertificate APIs require keys and certificates from the environment, which are not available in playback"
const client = createRecordedAdminClient(recorder, "Isolated");

Просмотреть файл

@ -5,20 +5,21 @@
/// <reference path="../../src/jsrsasign.d.ts"/>
import * as jsrsasign from "jsrsasign";
import { assert, use as chaiUse } from "chai";
import { Context } from "mocha";
import chaiPromises from "chai-as-promised";
chaiUse(chaiPromises);
import { Recorder } from "@azure-tools/test-recorder";
import { createRecordedClient, getAttestationUri, recorderOptions } from "../utils/recordedClient";
import { AttestationClient } from "../../src";
import {
createRecordedClient,
getAttestationUri,
recorderOptions,
} from "../utils/recordedClient.js";
import { AttestationClient } from "../../src/index.js";
import { describe, it, assert, beforeEach, afterEach } from "vitest";
describe("TokenCertTests", function () {
let recorder: Recorder;
beforeEach(async function (this: Context) {
recorder = new Recorder(this.currentTest);
beforeEach(async function (ctx) {
recorder = new Recorder(ctx);
await recorder.start(recorderOptions);
});

Просмотреть файл

@ -5,7 +5,7 @@
/// <reference path="../../src/jsrsasign.d.ts"/>
import * as jsrsasign from "jsrsasign";
import { hexToByteArray } from "../../src/utils/base64";
import { hexToByteArray } from "../../src/utils/base64.js";
export function createECDSKey(): [string, string] {
const keyPair = jsrsasign.KEYUTIL.generateKeypair("EC", "secp256r1");

Просмотреть файл

@ -1,2 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

Просмотреть файл

@ -1,6 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import * as dotenv from "dotenv";
dotenv.config();

Просмотреть файл

@ -13,9 +13,8 @@ import {
AttestationAdministrationClient,
AttestationClient,
AttestationClientOptions,
} from "../../src/";
import "./env";
import { pemFromBase64 } from "../utils/helpers";
} from "../../src/index.js";
import { pemFromBase64 } from "../utils/helpers.js";
const envSetupForPlayback: { [k: string]: string } = {
ATTESTATION_LOCATION_SHORT_NAME: "wus",

Просмотреть файл

@ -0,0 +1,10 @@
{
"extends": "./.tshy/build.json",
"include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts", "./test/**/*.mts"],
"exclude": ["./test/**/node/**/*.ts"],
"compilerOptions": {
"outDir": "./dist-test/browser",
"rootDir": ".",
"skipLibCheck": true
}
}

Просмотреть файл

@ -1,11 +1,19 @@
{
"extends": "../../../tsconfig",
"compilerOptions": {
"outDir": "./dist-esm",
"declarationDir": "./types",
"paths": {
"@azure/attestation": ["./src/index"]
}
},
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": "."
},
"include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"]
"include": [
"src/**/*.ts",
"src/**/*.mts",
"src/**/*.cts",
"samples-dev/**/*.ts",
"test/**/*.ts",
"test/**/*.mts"
]
}

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "../../../vitest.browser.shared.config.ts";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
include: [
"dist-test/browser/test/**/*.spec.js",
],
},
}),
);

Просмотреть файл

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "../../../vitest.shared.config.ts";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
include: ["test/**/*.spec.ts"],
},
}),
);