@azure/attestation 1.0.1-alpha.20250609.1 → 1.0.1-alpha.20250611.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/attestationClient.d.ts +1 -1
- package/dist/browser/attestationClient.js +1 -1
- package/dist/browser/attestationClient.js.map +1 -1
- package/dist/commonjs/attestationClient.d.ts +1 -1
- package/dist/commonjs/attestationClient.js +1 -1
- package/dist/commonjs/attestationClient.js.map +1 -1
- package/dist/esm/attestationClient.d.ts +1 -1
- package/dist/esm/attestationClient.js +1 -1
- package/dist/esm/attestationClient.js.map +1 -1
- package/dist/react-native/attestationClient.d.ts +1 -1
- package/dist/react-native/attestationClient.js +1 -1
- package/dist/react-native/attestationClient.js.map +1 -1
- package/package.json +1 -1
|
@@ -160,7 +160,7 @@ export declare class AttestationClient {
|
|
|
160
160
|
attestSgxEnclave(quote: Uint8Array | Buffer | Blob, options?: AttestSgxEnclaveOptions): Promise<AttestationResponse<AttestationResult>>;
|
|
161
161
|
/** Attest a TPM based enclave.
|
|
162
162
|
|
|
163
|
-
* See the {@link https://learn.microsoft.com/
|
|
163
|
+
* See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.
|
|
164
164
|
*
|
|
165
165
|
* @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.
|
|
166
166
|
* @param options - Pipeline options for TPM attestation request.
|
|
@@ -153,7 +153,7 @@ export class AttestationClient {
|
|
|
153
153
|
}
|
|
154
154
|
/** Attest a TPM based enclave.
|
|
155
155
|
|
|
156
|
-
* See the {@link https://learn.microsoft.com/
|
|
156
|
+
* See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.
|
|
157
157
|
*
|
|
158
158
|
* @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.
|
|
159
159
|
* @param options - Pipeline options for TPM attestation request.
|
|
@@ -1 +1 @@
|
|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I,CAAC,QAAQ,CAAC;QACvB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAwB,IAAI,KAAK,EAAE,CAAC;QACjD,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\n\nimport type {\n AttestationResult,\n AttestationSigner,\n AttestationTokenValidationOptions,\n} from \"./models/index.js\";\n\nimport type {\n GeneratedAttestationResult,\n InitTimeData,\n RuntimeData,\n} from \"./generated/models/index.js\";\nimport { KnownDataType } from \"./generated/models/index.js\";\n\nimport { logger } from \"./logger.js\";\nimport type { GeneratedClientOptionalParams } from \"./generated/models/index.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\nimport type { AttestationResponse } from \"./models/attestationResponse.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\n\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { bytesToString, stringToBytes } from \"./utils/utf8.js\";\nimport { _attestationResultFromGenerated } from \"./models/attestationResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { Uint8ArrayFromInput } from \"./utils/buffer.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationClientOptions extends CommonClientOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Client operations.\n */\nexport interface AttestationClientOperationOptions extends OperationOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service for the individual operation.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Optional parameters for the AttestOpenEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestOpenEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Optional parameters for the AttestSgxEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestSgxEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Operation options for the AttestTpm API.\n */\nexport interface AttestTpmOptions extends AttestationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getOpenIdMetadata\n * - getAttestationSigners\n * - attestSgxEnclave\n * - attestOpenEnclave\n * - attestTpm\n */\nexport class AttestationClient {\n /**\n * Creates an instance of AttestationClient.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_NoCreds\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationClient(endpoint);\n * ```\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param options - Options used to configure the Attestation Client.\n *\n */\n public constructor(endpoint: string, options?: AttestationClientOptions);\n\n /**\n * Creates an instance of AttestationClient with options and credentials.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_Creds\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const credentials = new DefaultAzureCredential();\n * const client = new AttestationClient(endpoint, credentials);\n * ```\n *\n * Note that credentials are required to call the `attestTpm` API.\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param credentials - Credentials used to configure the attestation client.\n *\n */\n public constructor(\n endpoint: string,\n credentials: TokenCredential,\n options?: AttestationClientOptions,\n );\n public constructor(\n endpoint: string,\n credentialsOrOptions?: TokenCredential | AttestationClientOptions,\n clientOptions: AttestationClientOptions = {},\n ) {\n let credentialScopes: string[] | undefined = undefined;\n let credential: TokenCredential | undefined = undefined;\n let options: AttestationClientOptions;\n\n if (credentialsOrOptions && isTokenCredential(credentialsOrOptions)) {\n credential = credentialsOrOptions;\n credentialScopes = [\"https://attest.azure.net/.default\"];\n options = clientOptions;\n } else {\n options = credentialsOrOptions || {};\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credentialScopes: credentialScopes,\n credential: credential,\n loggingOptions: {\n logger: logger.info,\n allowedHeaderNames: [\"x-ms-request-id\", \"x-ms-maa-service-version\"],\n },\n },\n };\n\n this._client = new GeneratedClient(endpoint, internalPipelineOptions);\n this._validationOptions = options.validationOptions;\n }\n\n /** Attests an OpenEnclave report generated from an SGX Enclave using the OpenEnclave SDK.\n *\n * @param report - An OpenEnclave report generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n *\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n * @throws {@link Error} if the `initTimeJson` option is provided and the value of `initTimeJson` is not JSON.\n * @throws {@link Error} if the `runTimeJson` option is provided and the value of `runTimeJson` is not JSON.\n */\n public async attestOpenEnclave(\n report: Uint8Array | Buffer | Blob,\n options: AttestOpenEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestOpenEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestOpenEnclave(\n {\n report: await Uint8ArrayFromInput(report),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attests a quote generated from SGX Enclave using the Intel SDK.\n *\n * @param quote - An SGX quote generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n */\n public async attestSgxEnclave(\n quote: Uint8Array | Buffer | Blob,\n options: AttestSgxEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestSgxEnclave(\n {\n quote: await Uint8ArrayFromInput(quote),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attest a TPM based enclave.\n\n * See the {@link https://learn.microsoft.com/en-us/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.\n * \n * @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.\n * @param options - Pipeline options for TPM attestation request.\n * @returns A structure containing the response from the TPM attestation, Utf8 encoded.\n * \n * @remarks\n * \n * The incoming requests to the TPM attestation API are stringified JSON objects.\n * \n * @example\n * For example, the initial call for a TPM attestation operation is:\n * \n * ```snippet:AttestationClient_AttestTpm\n * const encodedPayload = JSON.stringify({ payload: { type: \"aikcert\" } });\n * const result = await client.attestTpm(encodedPayload);\n * ```\n * \n * where stringToBytes converts the string to UTF8.\n * \n * Note that the attestTpm requires an attestation client which is configured with\n * authentication credentials.\n * \n */\n public async attestTpm(request: string, options: AttestTpmOptions = {}): Promise<string> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n const response = await this._client.attestation.attestTpm(\n { data: stringToBytes(request) },\n updatedOptions,\n );\n if (response.data) {\n return bytesToString(response.data);\n } else {\n throw Error(\"Internal error - response data cannot be undefined.\");\n }\n },\n );\n }\n\n /**\n * Returns the list of attestation signers which can be used to sign attestation\n * service tokens.\n *\n * @param options - Client operation options.\n * @returns the set of AttestationSigners which may be used to sign attestation tokens.\n */\n public async getAttestationSigners(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<AttestationSigner[]> {\n return tracingClient.withSpan(\n \"AttestationClient-getAttestationSigners\",\n options,\n async (updatedOptions) => {\n const signingCertificates = await this._client.signingCertificates.get(updatedOptions);\n const signers: AttestationSigner[] = new Array();\n signingCertificates.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n return signers;\n },\n );\n }\n\n /**\n * Returns the OpenID Metadata discovery document for the attestation service instance.\n * @param options - Client operation options.\n * @returns The OpenID metadata discovery document for the attestation service.\n */\n public async getOpenIdMetadata(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<Record<string, unknown>> {\n return tracingClient.withSpan(\n \"AttestationClient-getOpenIdMetadata\",\n options,\n async (updatedOptions) => {\n const configs = await this._client.metadataConfiguration.get(updatedOptions);\n return configs;\n },\n );\n }\n\n private _client: GeneratedClient;\n private _validationOptions?: AttestationTokenValidationOptions;\n private _signers?: AttestationSigner[];\n\n private async _signingKeys(): Promise<AttestationSigner[]> {\n if (this._signers !== undefined) {\n return this._signers;\n }\n const jwks = await this._client.signingCertificates.get();\n const signers: AttestationSigner[] = new Array();\n jwks.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n this._signers = signers;\n return this._signers;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attestationClient.js","sourceRoot":"","sources":["../../src/attestationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAajE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAC;AAGzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAmGvD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,iBAAiB;IA0C5B,YACE,QAAgB,EAChB,oBAAiE,EACjE,gBAA0C,EAAE;QAE5C,IAAI,gBAAgB,GAAyB,SAAS,CAAC;QACvD,IAAI,UAAU,GAAgC,SAAS,CAAC;QACxD,IAAI,OAAiC,CAAC;QAEtC,IAAI,oBAAoB,IAAI,iBA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qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC7E,OAAO,OAAO,CAAC;QACjB,CAAC,CACF,CAAC;IACJ,CAAC;IAMO,KAAK,CAAC,YAAY;;QACxB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAwB,IAAI,KAAK,EAAE,CAAC;QACjD,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\n\nimport type {\n AttestationResult,\n AttestationSigner,\n AttestationTokenValidationOptions,\n} from \"./models/index.js\";\n\nimport type {\n GeneratedAttestationResult,\n InitTimeData,\n RuntimeData,\n} from \"./generated/models/index.js\";\nimport { KnownDataType } from \"./generated/models/index.js\";\n\nimport { logger } from \"./logger.js\";\nimport type { GeneratedClientOptionalParams } from \"./generated/models/index.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\nimport type { AttestationResponse } from \"./models/attestationResponse.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\n\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { bytesToString, stringToBytes } from \"./utils/utf8.js\";\nimport { _attestationResultFromGenerated } from \"./models/attestationResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { Uint8ArrayFromInput } from \"./utils/buffer.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationClientOptions extends CommonClientOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Client operations.\n */\nexport interface AttestationClientOperationOptions extends OperationOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service for the individual operation.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Optional parameters for the AttestOpenEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestOpenEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Optional parameters for the AttestSgxEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestSgxEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Operation options for the AttestTpm API.\n */\nexport interface AttestTpmOptions extends AttestationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getOpenIdMetadata\n * - getAttestationSigners\n * - attestSgxEnclave\n * - attestOpenEnclave\n * - attestTpm\n */\nexport class AttestationClient {\n /**\n * Creates an instance of AttestationClient.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_NoCreds\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationClient(endpoint);\n * ```\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param options - Options used to configure the Attestation Client.\n *\n */\n public constructor(endpoint: string, options?: AttestationClientOptions);\n\n /**\n * Creates an instance of AttestationClient with options and credentials.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_Creds\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const credentials = new DefaultAzureCredential();\n * const client = new AttestationClient(endpoint, credentials);\n * ```\n *\n * Note that credentials are required to call the `attestTpm` API.\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param credentials - Credentials used to configure the attestation client.\n *\n */\n public constructor(\n endpoint: string,\n credentials: TokenCredential,\n options?: AttestationClientOptions,\n );\n public constructor(\n endpoint: string,\n credentialsOrOptions?: TokenCredential | AttestationClientOptions,\n clientOptions: AttestationClientOptions = {},\n ) {\n let credentialScopes: string[] | undefined = undefined;\n let credential: TokenCredential | undefined = undefined;\n let options: AttestationClientOptions;\n\n if (credentialsOrOptions && isTokenCredential(credentialsOrOptions)) {\n credential = credentialsOrOptions;\n credentialScopes = [\"https://attest.azure.net/.default\"];\n options = clientOptions;\n } else {\n options = credentialsOrOptions || {};\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credentialScopes: credentialScopes,\n credential: credential,\n loggingOptions: {\n logger: logger.info,\n allowedHeaderNames: [\"x-ms-request-id\", \"x-ms-maa-service-version\"],\n },\n },\n };\n\n this._client = new GeneratedClient(endpoint, internalPipelineOptions);\n this._validationOptions = options.validationOptions;\n }\n\n /** Attests an OpenEnclave report generated from an SGX Enclave using the OpenEnclave SDK.\n *\n * @param report - An OpenEnclave report generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n *\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n * @throws {@link Error} if the `initTimeJson` option is provided and the value of `initTimeJson` is not JSON.\n * @throws {@link Error} if the `runTimeJson` option is provided and the value of `runTimeJson` is not JSON.\n */\n public async attestOpenEnclave(\n report: Uint8Array | Buffer | Blob,\n options: AttestOpenEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestOpenEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestOpenEnclave(\n {\n report: await Uint8ArrayFromInput(report),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attests a quote generated from SGX Enclave using the Intel SDK.\n *\n * @param quote - An SGX quote generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n */\n public async attestSgxEnclave(\n quote: Uint8Array | Buffer | Blob,\n options: AttestSgxEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestSgxEnclave(\n {\n quote: await Uint8ArrayFromInput(quote),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attest a TPM based enclave.\n\n * See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.\n * \n * @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.\n * @param options - Pipeline options for TPM attestation request.\n * @returns A structure containing the response from the TPM attestation, Utf8 encoded.\n * \n * @remarks\n * \n * The incoming requests to the TPM attestation API are stringified JSON objects.\n * \n * @example\n * For example, the initial call for a TPM attestation operation is:\n * \n * ```snippet:AttestationClient_AttestTpm\n * const encodedPayload = JSON.stringify({ payload: { type: \"aikcert\" } });\n * const result = await client.attestTpm(encodedPayload);\n * ```\n * \n * where stringToBytes converts the string to UTF8.\n * \n * Note that the attestTpm requires an attestation client which is configured with\n * authentication credentials.\n * \n */\n public async attestTpm(request: string, options: AttestTpmOptions = {}): Promise<string> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n const response = await this._client.attestation.attestTpm(\n { data: stringToBytes(request) },\n updatedOptions,\n );\n if (response.data) {\n return bytesToString(response.data);\n } else {\n throw Error(\"Internal error - response data cannot be undefined.\");\n }\n },\n );\n }\n\n /**\n * Returns the list of attestation signers which can be used to sign attestation\n * service tokens.\n *\n * @param options - Client operation options.\n * @returns the set of AttestationSigners which may be used to sign attestation tokens.\n */\n public async getAttestationSigners(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<AttestationSigner[]> {\n return tracingClient.withSpan(\n \"AttestationClient-getAttestationSigners\",\n options,\n async (updatedOptions) => {\n const signingCertificates = await this._client.signingCertificates.get(updatedOptions);\n const signers: AttestationSigner[] = new Array();\n signingCertificates.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n return signers;\n },\n );\n }\n\n /**\n * Returns the OpenID Metadata discovery document for the attestation service instance.\n * @param options - Client operation options.\n * @returns The OpenID metadata discovery document for the attestation service.\n */\n public async getOpenIdMetadata(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<Record<string, unknown>> {\n return tracingClient.withSpan(\n \"AttestationClient-getOpenIdMetadata\",\n options,\n async (updatedOptions) => {\n const configs = await this._client.metadataConfiguration.get(updatedOptions);\n return configs;\n },\n );\n }\n\n private _client: GeneratedClient;\n private _validationOptions?: AttestationTokenValidationOptions;\n private _signers?: AttestationSigner[];\n\n private async _signingKeys(): Promise<AttestationSigner[]> {\n if (this._signers !== undefined) {\n return this._signers;\n }\n const jwks = await this._client.signingCertificates.get();\n const signers: AttestationSigner[] = new Array();\n jwks.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n this._signers = signers;\n return this._signers;\n }\n}\n"]}
|
|
@@ -160,7 +160,7 @@ export declare class AttestationClient {
|
|
|
160
160
|
attestSgxEnclave(quote: Uint8Array | Buffer | Blob, options?: AttestSgxEnclaveOptions): Promise<AttestationResponse<AttestationResult>>;
|
|
161
161
|
/** Attest a TPM based enclave.
|
|
162
162
|
|
|
163
|
-
* See the {@link https://learn.microsoft.com/
|
|
163
|
+
* See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.
|
|
164
164
|
*
|
|
165
165
|
* @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.
|
|
166
166
|
* @param options - Pipeline options for TPM attestation request.
|
|
@@ -157,7 +157,7 @@ class AttestationClient {
|
|
|
157
157
|
}
|
|
158
158
|
/** Attest a TPM based enclave.
|
|
159
159
|
|
|
160
|
-
* See the {@link https://learn.microsoft.com/
|
|
160
|
+
* See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.
|
|
161
161
|
*
|
|
162
162
|
* @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.
|
|
163
163
|
* @param options - Pipeline options for TPM attestation request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestationClient.js","sourceRoot":"","sources":["../../src/attestationClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAA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licensed under the MIT License.\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\n\nimport type {\n AttestationResult,\n AttestationSigner,\n AttestationTokenValidationOptions,\n} from \"./models/index.js\";\n\nimport type {\n GeneratedAttestationResult,\n InitTimeData,\n RuntimeData,\n} from \"./generated/models/index.js\";\nimport { KnownDataType } from \"./generated/models/index.js\";\n\nimport { logger } from \"./logger.js\";\nimport type { GeneratedClientOptionalParams } from \"./generated/models/index.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\nimport type { AttestationResponse } from \"./models/attestationResponse.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\n\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { bytesToString, stringToBytes } from \"./utils/utf8.js\";\nimport { _attestationResultFromGenerated } from \"./models/attestationResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { Uint8ArrayFromInput } from \"./utils/buffer.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationClientOptions extends CommonClientOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Client operations.\n */\nexport interface AttestationClientOperationOptions extends OperationOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service for the individual operation.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Optional parameters for the AttestOpenEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestOpenEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Optional parameters for the AttestSgxEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestSgxEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Operation options for the AttestTpm API.\n */\nexport interface AttestTpmOptions extends AttestationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getOpenIdMetadata\n * - getAttestationSigners\n * - attestSgxEnclave\n * - attestOpenEnclave\n * - attestTpm\n */\nexport class AttestationClient {\n /**\n * Creates an instance of AttestationClient.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_NoCreds\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationClient(endpoint);\n * ```\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param options - Options used to configure the Attestation Client.\n *\n */\n public constructor(endpoint: string, options?: AttestationClientOptions);\n\n /**\n * Creates an instance of AttestationClient with options and credentials.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_Creds\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const credentials = new DefaultAzureCredential();\n * const client = new AttestationClient(endpoint, credentials);\n * ```\n *\n * Note that credentials are required to call the `attestTpm` API.\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param credentials - Credentials used to configure the attestation client.\n *\n */\n public constructor(\n endpoint: string,\n credentials: TokenCredential,\n options?: AttestationClientOptions,\n );\n public constructor(\n endpoint: string,\n credentialsOrOptions?: TokenCredential | AttestationClientOptions,\n clientOptions: AttestationClientOptions = {},\n ) {\n let credentialScopes: string[] | undefined = undefined;\n let credential: TokenCredential | undefined = undefined;\n let options: AttestationClientOptions;\n\n if (credentialsOrOptions && isTokenCredential(credentialsOrOptions)) {\n credential = credentialsOrOptions;\n credentialScopes = [\"https://attest.azure.net/.default\"];\n options = clientOptions;\n } else {\n options = credentialsOrOptions || {};\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credentialScopes: credentialScopes,\n credential: credential,\n loggingOptions: {\n logger: logger.info,\n allowedHeaderNames: [\"x-ms-request-id\", \"x-ms-maa-service-version\"],\n },\n },\n };\n\n this._client = new GeneratedClient(endpoint, internalPipelineOptions);\n this._validationOptions = options.validationOptions;\n }\n\n /** Attests an OpenEnclave report generated from an SGX Enclave using the OpenEnclave SDK.\n *\n * @param report - An OpenEnclave report generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n *\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n * @throws {@link Error} if the `initTimeJson` option is provided and the value of `initTimeJson` is not JSON.\n * @throws {@link Error} if the `runTimeJson` option is provided and the value of `runTimeJson` is not JSON.\n */\n public async attestOpenEnclave(\n report: Uint8Array | Buffer | Blob,\n options: AttestOpenEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestOpenEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestOpenEnclave(\n {\n report: await Uint8ArrayFromInput(report),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attests a quote generated from SGX Enclave using the Intel SDK.\n *\n * @param quote - An SGX quote generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n */\n public async attestSgxEnclave(\n quote: Uint8Array | Buffer | Blob,\n options: AttestSgxEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestSgxEnclave(\n {\n quote: await Uint8ArrayFromInput(quote),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attest a TPM based enclave.\n\n * See the {@link https://learn.microsoft.com/en-us/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.\n * \n * @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.\n * @param options - Pipeline options for TPM attestation request.\n * @returns A structure containing the response from the TPM attestation, Utf8 encoded.\n * \n * @remarks\n * \n * The incoming requests to the TPM attestation API are stringified JSON objects.\n * \n * @example\n * For example, the initial call for a TPM attestation operation is:\n * \n * ```snippet:AttestationClient_AttestTpm\n * const encodedPayload = JSON.stringify({ payload: { type: \"aikcert\" } });\n * const result = await client.attestTpm(encodedPayload);\n * ```\n * \n * where stringToBytes converts the string to UTF8.\n * \n * Note that the attestTpm requires an attestation client which is configured with\n * authentication credentials.\n * \n */\n public async attestTpm(request: string, options: AttestTpmOptions = {}): Promise<string> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n const response = await this._client.attestation.attestTpm(\n { data: stringToBytes(request) },\n updatedOptions,\n );\n if (response.data) {\n return bytesToString(response.data);\n } else {\n throw Error(\"Internal error - response data cannot be undefined.\");\n }\n },\n );\n }\n\n /**\n * Returns the list of attestation signers which can be used to sign attestation\n * service tokens.\n *\n * @param options - Client operation options.\n * @returns the set of AttestationSigners which may be used to sign attestation tokens.\n */\n public async getAttestationSigners(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<AttestationSigner[]> {\n return tracingClient.withSpan(\n \"AttestationClient-getAttestationSigners\",\n options,\n async (updatedOptions) => {\n const signingCertificates = await this._client.signingCertificates.get(updatedOptions);\n const signers: AttestationSigner[] = new Array();\n signingCertificates.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n return signers;\n },\n );\n }\n\n /**\n * Returns the OpenID Metadata discovery document for the attestation service instance.\n * @param options - Client operation options.\n * @returns The OpenID metadata discovery document for the attestation service.\n */\n public async getOpenIdMetadata(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<Record<string, unknown>> {\n return tracingClient.withSpan(\n \"AttestationClient-getOpenIdMetadata\",\n options,\n async (updatedOptions) => {\n const configs = await this._client.metadataConfiguration.get(updatedOptions);\n return configs;\n },\n );\n }\n\n private _client: GeneratedClient;\n private _validationOptions?: AttestationTokenValidationOptions;\n private _signers?: AttestationSigner[];\n\n private async _signingKeys(): Promise<AttestationSigner[]> {\n if (this._signers !== undefined) {\n return this._signers;\n }\n const jwks = await this._client.signingCertificates.get();\n const signers: AttestationSigner[] = new Array();\n jwks.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n this._signers = signers;\n return this._signers;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attestationClient.js","sourceRoot":"","sources":["../../src/attestationClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,uEAAiE;AAajE,0DAA4D;AAE5D,2CAAqC;AAErC,+EAAyD;AAGzD,4EAA4E;AAE5E,qEAA+D;AAE/D,gDAAqD;AAErD,6CAA+D;AAC/D,wEAAgF;AAChF,wEAAgF;AAChF,s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AAO,CAAC,IAAI,CAAC,IAAA,sDAA+B,EAAC,OAAO,CAAC,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;YACH,OAAO,OAAO,CAAC;QACjB,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,iBAAiB;IAC5B,8DAA8D;IAC9D,UAA6C,EAAE;QAE/C,OAAO,0BAAa,CAAC,QAAQ,CAC3B,qCAAqC,EACrC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC7E,OAAO,OAAO,CAAC;QACjB,CAAC,CACF,CAAC;IACJ,CAAC;IAMO,KAAK,CAAC,YAAY;;QACxB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAwB,IAAI,KAAK,EAAE,CAAC;QACjD,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,IAAA,sDAA+B,EAAC,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAvVD,8CAuVC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\n\nimport type {\n AttestationResult,\n AttestationSigner,\n AttestationTokenValidationOptions,\n} from \"./models/index.js\";\n\nimport type {\n GeneratedAttestationResult,\n InitTimeData,\n RuntimeData,\n} from \"./generated/models/index.js\";\nimport { KnownDataType } from \"./generated/models/index.js\";\n\nimport { logger } from \"./logger.js\";\nimport type { GeneratedClientOptionalParams } from \"./generated/models/index.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\nimport type { AttestationResponse } from \"./models/attestationResponse.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\n\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { bytesToString, stringToBytes } from \"./utils/utf8.js\";\nimport { _attestationResultFromGenerated } from \"./models/attestationResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { Uint8ArrayFromInput } from \"./utils/buffer.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationClientOptions extends CommonClientOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Client operations.\n */\nexport interface AttestationClientOperationOptions extends OperationOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service for the individual operation.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Optional parameters for the AttestOpenEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestOpenEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Optional parameters for the AttestSgxEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestSgxEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Operation options for the AttestTpm API.\n */\nexport interface AttestTpmOptions extends AttestationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getOpenIdMetadata\n * - getAttestationSigners\n * - attestSgxEnclave\n * - attestOpenEnclave\n * - attestTpm\n */\nexport class AttestationClient {\n /**\n * Creates an instance of AttestationClient.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_NoCreds\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationClient(endpoint);\n * ```\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param options - Options used to configure the Attestation Client.\n *\n */\n public constructor(endpoint: string, options?: AttestationClientOptions);\n\n /**\n * Creates an instance of AttestationClient with options and credentials.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_Creds\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const credentials = new DefaultAzureCredential();\n * const client = new AttestationClient(endpoint, credentials);\n * ```\n *\n * Note that credentials are required to call the `attestTpm` API.\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param credentials - Credentials used to configure the attestation client.\n *\n */\n public constructor(\n endpoint: string,\n credentials: TokenCredential,\n options?: AttestationClientOptions,\n );\n public constructor(\n endpoint: string,\n credentialsOrOptions?: TokenCredential | AttestationClientOptions,\n clientOptions: AttestationClientOptions = {},\n ) {\n let credentialScopes: string[] | undefined = undefined;\n let credential: TokenCredential | undefined = undefined;\n let options: AttestationClientOptions;\n\n if (credentialsOrOptions && isTokenCredential(credentialsOrOptions)) {\n credential = credentialsOrOptions;\n credentialScopes = [\"https://attest.azure.net/.default\"];\n options = clientOptions;\n } else {\n options = credentialsOrOptions || {};\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credentialScopes: credentialScopes,\n credential: credential,\n loggingOptions: {\n logger: logger.info,\n allowedHeaderNames: [\"x-ms-request-id\", \"x-ms-maa-service-version\"],\n },\n },\n };\n\n this._client = new GeneratedClient(endpoint, internalPipelineOptions);\n this._validationOptions = options.validationOptions;\n }\n\n /** Attests an OpenEnclave report generated from an SGX Enclave using the OpenEnclave SDK.\n *\n * @param report - An OpenEnclave report generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n *\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n * @throws {@link Error} if the `initTimeJson` option is provided and the value of `initTimeJson` is not JSON.\n * @throws {@link Error} if the `runTimeJson` option is provided and the value of `runTimeJson` is not JSON.\n */\n public async attestOpenEnclave(\n report: Uint8Array | Buffer | Blob,\n options: AttestOpenEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestOpenEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestOpenEnclave(\n {\n report: await Uint8ArrayFromInput(report),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attests a quote generated from SGX Enclave using the Intel SDK.\n *\n * @param quote - An SGX quote generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n */\n public async attestSgxEnclave(\n quote: Uint8Array | Buffer | Blob,\n options: AttestSgxEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestSgxEnclave(\n {\n quote: await Uint8ArrayFromInput(quote),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attest a TPM based enclave.\n\n * See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.\n * \n * @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.\n * @param options - Pipeline options for TPM attestation request.\n * @returns A structure containing the response from the TPM attestation, Utf8 encoded.\n * \n * @remarks\n * \n * The incoming requests to the TPM attestation API are stringified JSON objects.\n * \n * @example\n * For example, the initial call for a TPM attestation operation is:\n * \n * ```snippet:AttestationClient_AttestTpm\n * const encodedPayload = JSON.stringify({ payload: { type: \"aikcert\" } });\n * const result = await client.attestTpm(encodedPayload);\n * ```\n * \n * where stringToBytes converts the string to UTF8.\n * \n * Note that the attestTpm requires an attestation client which is configured with\n * authentication credentials.\n * \n */\n public async attestTpm(request: string, options: AttestTpmOptions = {}): Promise<string> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n const response = await this._client.attestation.attestTpm(\n { data: stringToBytes(request) },\n updatedOptions,\n );\n if (response.data) {\n return bytesToString(response.data);\n } else {\n throw Error(\"Internal error - response data cannot be undefined.\");\n }\n },\n );\n }\n\n /**\n * Returns the list of attestation signers which can be used to sign attestation\n * service tokens.\n *\n * @param options - Client operation options.\n * @returns the set of AttestationSigners which may be used to sign attestation tokens.\n */\n public async getAttestationSigners(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<AttestationSigner[]> {\n return tracingClient.withSpan(\n \"AttestationClient-getAttestationSigners\",\n options,\n async (updatedOptions) => {\n const signingCertificates = await this._client.signingCertificates.get(updatedOptions);\n const signers: AttestationSigner[] = new Array();\n signingCertificates.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n return signers;\n },\n );\n }\n\n /**\n * Returns the OpenID Metadata discovery document for the attestation service instance.\n * @param options - Client operation options.\n * @returns The OpenID metadata discovery document for the attestation service.\n */\n public async getOpenIdMetadata(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<Record<string, unknown>> {\n return tracingClient.withSpan(\n \"AttestationClient-getOpenIdMetadata\",\n options,\n async (updatedOptions) => {\n const configs = await this._client.metadataConfiguration.get(updatedOptions);\n return configs;\n },\n );\n }\n\n private _client: GeneratedClient;\n private _validationOptions?: AttestationTokenValidationOptions;\n private _signers?: AttestationSigner[];\n\n private async _signingKeys(): Promise<AttestationSigner[]> {\n if (this._signers !== undefined) {\n return this._signers;\n }\n const jwks = await this._client.signingCertificates.get();\n const signers: AttestationSigner[] = new Array();\n jwks.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n this._signers = signers;\n return this._signers;\n }\n}\n"]}
|
|
@@ -160,7 +160,7 @@ export declare class AttestationClient {
|
|
|
160
160
|
attestSgxEnclave(quote: Uint8Array | Buffer | Blob, options?: AttestSgxEnclaveOptions): Promise<AttestationResponse<AttestationResult>>;
|
|
161
161
|
/** Attest a TPM based enclave.
|
|
162
162
|
|
|
163
|
-
* See the {@link https://learn.microsoft.com/
|
|
163
|
+
* See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.
|
|
164
164
|
*
|
|
165
165
|
* @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.
|
|
166
166
|
* @param options - Pipeline options for TPM attestation request.
|
|
@@ -153,7 +153,7 @@ export class AttestationClient {
|
|
|
153
153
|
}
|
|
154
154
|
/** Attest a TPM based enclave.
|
|
155
155
|
|
|
156
|
-
* See the {@link https://learn.microsoft.com/
|
|
156
|
+
* See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.
|
|
157
157
|
*
|
|
158
158
|
* @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.
|
|
159
159
|
* @param options - Pipeline options for TPM attestation request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestationClient.js","sourceRoot":"","sources":["../../src/attestationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAajE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAC;AAGzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAmGvD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,iBAAiB;IA0C5B,YACE,QAAgB,EAChB,oBAAiE,EACjE,gBAA0C,EAAE;QAE5C,IAAI,gBAAgB,GAAyB,SAAS,CAAC;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AAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC7E,OAAO,OAAO,CAAC;QACjB,CAAC,CACF,CAAC;IACJ,CAAC;IAMO,KAAK,CAAC,YAAY;;QACxB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAwB,IAAI,KAAK,EAAE,CAAC;QACjD,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\n\nimport type {\n AttestationResult,\n AttestationSigner,\n AttestationTokenValidationOptions,\n} from \"./models/index.js\";\n\nimport type {\n GeneratedAttestationResult,\n InitTimeData,\n RuntimeData,\n} from \"./generated/models/index.js\";\nimport { KnownDataType } from \"./generated/models/index.js\";\n\nimport { logger } from \"./logger.js\";\nimport type { GeneratedClientOptionalParams } from \"./generated/models/index.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\nimport type { AttestationResponse } from \"./models/attestationResponse.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\n\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { bytesToString, stringToBytes } from \"./utils/utf8.js\";\nimport { _attestationResultFromGenerated } from \"./models/attestationResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { Uint8ArrayFromInput } from \"./utils/buffer.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationClientOptions extends CommonClientOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Client operations.\n */\nexport interface AttestationClientOperationOptions extends OperationOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service for the individual operation.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Optional parameters for the AttestOpenEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestOpenEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Optional parameters for the AttestSgxEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestSgxEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Operation options for the AttestTpm API.\n */\nexport interface AttestTpmOptions extends AttestationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getOpenIdMetadata\n * - getAttestationSigners\n * - attestSgxEnclave\n * - attestOpenEnclave\n * - attestTpm\n */\nexport class AttestationClient {\n /**\n * Creates an instance of AttestationClient.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_NoCreds\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationClient(endpoint);\n * ```\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param options - Options used to configure the Attestation Client.\n *\n */\n public constructor(endpoint: string, options?: AttestationClientOptions);\n\n /**\n * Creates an instance of AttestationClient with options and credentials.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_Creds\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const credentials = new DefaultAzureCredential();\n * const client = new AttestationClient(endpoint, credentials);\n * ```\n *\n * Note that credentials are required to call the `attestTpm` API.\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param credentials - Credentials used to configure the attestation client.\n *\n */\n public constructor(\n endpoint: string,\n credentials: TokenCredential,\n options?: AttestationClientOptions,\n );\n public constructor(\n endpoint: string,\n credentialsOrOptions?: TokenCredential | AttestationClientOptions,\n clientOptions: AttestationClientOptions = {},\n ) {\n let credentialScopes: string[] | undefined = undefined;\n let credential: TokenCredential | undefined = undefined;\n let options: AttestationClientOptions;\n\n if (credentialsOrOptions && isTokenCredential(credentialsOrOptions)) {\n credential = credentialsOrOptions;\n credentialScopes = [\"https://attest.azure.net/.default\"];\n options = clientOptions;\n } else {\n options = credentialsOrOptions || {};\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credentialScopes: credentialScopes,\n credential: credential,\n loggingOptions: {\n logger: logger.info,\n allowedHeaderNames: [\"x-ms-request-id\", \"x-ms-maa-service-version\"],\n },\n },\n };\n\n this._client = new GeneratedClient(endpoint, internalPipelineOptions);\n this._validationOptions = options.validationOptions;\n }\n\n /** Attests an OpenEnclave report generated from an SGX Enclave using the OpenEnclave SDK.\n *\n * @param report - An OpenEnclave report generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n *\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n * @throws {@link Error} if the `initTimeJson` option is provided and the value of `initTimeJson` is not JSON.\n * @throws {@link Error} if the `runTimeJson` option is provided and the value of `runTimeJson` is not JSON.\n */\n public async attestOpenEnclave(\n report: Uint8Array | Buffer | Blob,\n options: AttestOpenEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestOpenEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestOpenEnclave(\n {\n report: await Uint8ArrayFromInput(report),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attests a quote generated from SGX Enclave using the Intel SDK.\n *\n * @param quote - An SGX quote generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n */\n public async attestSgxEnclave(\n quote: Uint8Array | Buffer | Blob,\n options: AttestSgxEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestSgxEnclave(\n {\n quote: await Uint8ArrayFromInput(quote),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attest a TPM based enclave.\n\n * See the {@link https://learn.microsoft.com/en-us/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.\n * \n * @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.\n * @param options - Pipeline options for TPM attestation request.\n * @returns A structure containing the response from the TPM attestation, Utf8 encoded.\n * \n * @remarks\n * \n * The incoming requests to the TPM attestation API are stringified JSON objects.\n * \n * @example\n * For example, the initial call for a TPM attestation operation is:\n * \n * ```snippet:AttestationClient_AttestTpm\n * const encodedPayload = JSON.stringify({ payload: { type: \"aikcert\" } });\n * const result = await client.attestTpm(encodedPayload);\n * ```\n * \n * where stringToBytes converts the string to UTF8.\n * \n * Note that the attestTpm requires an attestation client which is configured with\n * authentication credentials.\n * \n */\n public async attestTpm(request: string, options: AttestTpmOptions = {}): Promise<string> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n const response = await this._client.attestation.attestTpm(\n { data: stringToBytes(request) },\n updatedOptions,\n );\n if (response.data) {\n return bytesToString(response.data);\n } else {\n throw Error(\"Internal error - response data cannot be undefined.\");\n }\n },\n );\n }\n\n /**\n * Returns the list of attestation signers which can be used to sign attestation\n * service tokens.\n *\n * @param options - Client operation options.\n * @returns the set of AttestationSigners which may be used to sign attestation tokens.\n */\n public async getAttestationSigners(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<AttestationSigner[]> {\n return tracingClient.withSpan(\n \"AttestationClient-getAttestationSigners\",\n options,\n async (updatedOptions) => {\n const signingCertificates = await this._client.signingCertificates.get(updatedOptions);\n const signers: AttestationSigner[] = new Array();\n signingCertificates.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n return signers;\n },\n );\n }\n\n /**\n * Returns the OpenID Metadata discovery document for the attestation service instance.\n * @param options - Client operation options.\n * @returns The OpenID metadata discovery document for the attestation service.\n */\n public async getOpenIdMetadata(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<Record<string, unknown>> {\n return tracingClient.withSpan(\n \"AttestationClient-getOpenIdMetadata\",\n options,\n async (updatedOptions) => {\n const configs = await this._client.metadataConfiguration.get(updatedOptions);\n return configs;\n },\n );\n }\n\n private _client: GeneratedClient;\n private _validationOptions?: AttestationTokenValidationOptions;\n private _signers?: AttestationSigner[];\n\n private async _signingKeys(): Promise<AttestationSigner[]> {\n if (this._signers !== undefined) {\n return this._signers;\n }\n const jwks = await this._client.signingCertificates.get();\n const signers: AttestationSigner[] = new Array();\n jwks.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n this._signers = signers;\n return this._signers;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attestationClient.js","sourceRoot":"","sources":["../../src/attestationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAajE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAC;AAGzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CA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CAAC,CAAC;YACH,OAAO,OAAO,CAAC;QACjB,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,iBAAiB;IAC5B,8DAA8D;IAC9D,UAA6C,EAAE;QAE/C,OAAO,aAAa,CAAC,QAAQ,CAC3B,qCAAqC,EACrC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC7E,OAAO,OAAO,CAAC;QACjB,CAAC,CACF,CAAC;IACJ,CAAC;IAMO,KAAK,CAAC,YAAY;;QACxB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAwB,IAAI,KAAK,EAAE,CAAC;QACjD,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\n\nimport type {\n AttestationResult,\n AttestationSigner,\n AttestationTokenValidationOptions,\n} from \"./models/index.js\";\n\nimport type {\n GeneratedAttestationResult,\n InitTimeData,\n RuntimeData,\n} from \"./generated/models/index.js\";\nimport { KnownDataType } from \"./generated/models/index.js\";\n\nimport { logger } from \"./logger.js\";\nimport type { GeneratedClientOptionalParams } from \"./generated/models/index.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\nimport type { AttestationResponse } from \"./models/attestationResponse.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\n\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { bytesToString, stringToBytes } from \"./utils/utf8.js\";\nimport { _attestationResultFromGenerated } from \"./models/attestationResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { Uint8ArrayFromInput } from \"./utils/buffer.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationClientOptions extends CommonClientOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Client operations.\n */\nexport interface AttestationClientOperationOptions extends OperationOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service for the individual operation.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Optional parameters for the AttestOpenEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestOpenEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Optional parameters for the AttestSgxEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestSgxEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Operation options for the AttestTpm API.\n */\nexport interface AttestTpmOptions extends AttestationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getOpenIdMetadata\n * - getAttestationSigners\n * - attestSgxEnclave\n * - attestOpenEnclave\n * - attestTpm\n */\nexport class AttestationClient {\n /**\n * Creates an instance of AttestationClient.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_NoCreds\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationClient(endpoint);\n * ```\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param options - Options used to configure the Attestation Client.\n *\n */\n public constructor(endpoint: string, options?: AttestationClientOptions);\n\n /**\n * Creates an instance of AttestationClient with options and credentials.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_Creds\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const credentials = new DefaultAzureCredential();\n * const client = new AttestationClient(endpoint, credentials);\n * ```\n *\n * Note that credentials are required to call the `attestTpm` API.\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param credentials - Credentials used to configure the attestation client.\n *\n */\n public constructor(\n endpoint: string,\n credentials: TokenCredential,\n options?: AttestationClientOptions,\n );\n public constructor(\n endpoint: string,\n credentialsOrOptions?: TokenCredential | AttestationClientOptions,\n clientOptions: AttestationClientOptions = {},\n ) {\n let credentialScopes: string[] | undefined = undefined;\n let credential: TokenCredential | undefined = undefined;\n let options: AttestationClientOptions;\n\n if (credentialsOrOptions && isTokenCredential(credentialsOrOptions)) {\n credential = credentialsOrOptions;\n credentialScopes = [\"https://attest.azure.net/.default\"];\n options = clientOptions;\n } else {\n options = credentialsOrOptions || {};\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credentialScopes: credentialScopes,\n credential: credential,\n loggingOptions: {\n logger: logger.info,\n allowedHeaderNames: [\"x-ms-request-id\", \"x-ms-maa-service-version\"],\n },\n },\n };\n\n this._client = new GeneratedClient(endpoint, internalPipelineOptions);\n this._validationOptions = options.validationOptions;\n }\n\n /** Attests an OpenEnclave report generated from an SGX Enclave using the OpenEnclave SDK.\n *\n * @param report - An OpenEnclave report generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n *\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n * @throws {@link Error} if the `initTimeJson` option is provided and the value of `initTimeJson` is not JSON.\n * @throws {@link Error} if the `runTimeJson` option is provided and the value of `runTimeJson` is not JSON.\n */\n public async attestOpenEnclave(\n report: Uint8Array | Buffer | Blob,\n options: AttestOpenEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestOpenEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestOpenEnclave(\n {\n report: await Uint8ArrayFromInput(report),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attests a quote generated from SGX Enclave using the Intel SDK.\n *\n * @param quote - An SGX quote generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n */\n public async attestSgxEnclave(\n quote: Uint8Array | Buffer | Blob,\n options: AttestSgxEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestSgxEnclave(\n {\n quote: await Uint8ArrayFromInput(quote),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attest a TPM based enclave.\n\n * See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.\n * \n * @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.\n * @param options - Pipeline options for TPM attestation request.\n * @returns A structure containing the response from the TPM attestation, Utf8 encoded.\n * \n * @remarks\n * \n * The incoming requests to the TPM attestation API are stringified JSON objects.\n * \n * @example\n * For example, the initial call for a TPM attestation operation is:\n * \n * ```snippet:AttestationClient_AttestTpm\n * const encodedPayload = JSON.stringify({ payload: { type: \"aikcert\" } });\n * const result = await client.attestTpm(encodedPayload);\n * ```\n * \n * where stringToBytes converts the string to UTF8.\n * \n * Note that the attestTpm requires an attestation client which is configured with\n * authentication credentials.\n * \n */\n public async attestTpm(request: string, options: AttestTpmOptions = {}): Promise<string> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n const response = await this._client.attestation.attestTpm(\n { data: stringToBytes(request) },\n updatedOptions,\n );\n if (response.data) {\n return bytesToString(response.data);\n } else {\n throw Error(\"Internal error - response data cannot be undefined.\");\n }\n },\n );\n }\n\n /**\n * Returns the list of attestation signers which can be used to sign attestation\n * service tokens.\n *\n * @param options - Client operation options.\n * @returns the set of AttestationSigners which may be used to sign attestation tokens.\n */\n public async getAttestationSigners(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<AttestationSigner[]> {\n return tracingClient.withSpan(\n \"AttestationClient-getAttestationSigners\",\n options,\n async (updatedOptions) => {\n const signingCertificates = await this._client.signingCertificates.get(updatedOptions);\n const signers: AttestationSigner[] = new Array();\n signingCertificates.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n return signers;\n },\n );\n }\n\n /**\n * Returns the OpenID Metadata discovery document for the attestation service instance.\n * @param options - Client operation options.\n * @returns The OpenID metadata discovery document for the attestation service.\n */\n public async getOpenIdMetadata(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<Record<string, unknown>> {\n return tracingClient.withSpan(\n \"AttestationClient-getOpenIdMetadata\",\n options,\n async (updatedOptions) => {\n const configs = await this._client.metadataConfiguration.get(updatedOptions);\n return configs;\n },\n );\n }\n\n private _client: GeneratedClient;\n private _validationOptions?: AttestationTokenValidationOptions;\n private _signers?: AttestationSigner[];\n\n private async _signingKeys(): Promise<AttestationSigner[]> {\n if (this._signers !== undefined) {\n return this._signers;\n }\n const jwks = await this._client.signingCertificates.get();\n const signers: AttestationSigner[] = new Array();\n jwks.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n this._signers = signers;\n return this._signers;\n }\n}\n"]}
|
|
@@ -160,7 +160,7 @@ export declare class AttestationClient {
|
|
|
160
160
|
attestSgxEnclave(quote: Uint8Array | Buffer | Blob, options?: AttestSgxEnclaveOptions): Promise<AttestationResponse<AttestationResult>>;
|
|
161
161
|
/** Attest a TPM based enclave.
|
|
162
162
|
|
|
163
|
-
* See the {@link https://learn.microsoft.com/
|
|
163
|
+
* See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.
|
|
164
164
|
*
|
|
165
165
|
* @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.
|
|
166
166
|
* @param options - Pipeline options for TPM attestation request.
|
|
@@ -153,7 +153,7 @@ export class AttestationClient {
|
|
|
153
153
|
}
|
|
154
154
|
/** Attest a TPM based enclave.
|
|
155
155
|
|
|
156
|
-
* See the {@link https://learn.microsoft.com/
|
|
156
|
+
* See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.
|
|
157
157
|
*
|
|
158
158
|
* @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.
|
|
159
159
|
* @param options - Pipeline options for TPM attestation request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestationClient.js","sourceRoot":"","sources":["../../src/attestationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAajE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAC;AAGzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAmGvD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,iBAAiB;IA0C5B,YACE,QAAgB,EAChB,oBAAiE,EACjE,gBAA0C,EAAE;QAE5C,IAAI,gBAAgB,GAAyB,SAAS,CAAC;QACvD,IAAI,UAAU,GAAgC,SAAS,CAAC;QACxD,IAAI,OAAiC,CAAC;QAEtC,IAAI,oBAAoB,IAAI,iBAAiB,CAA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CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC7E,OAAO,OAAO,CAAC;QACjB,CAAC,CACF,CAAC;IACJ,CAAC;IAMO,KAAK,CAAC,YAAY;;QACxB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAwB,IAAI,KAAK,EAAE,CAAC;QACjD,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\n\nimport type {\n AttestationResult,\n AttestationSigner,\n AttestationTokenValidationOptions,\n} from \"./models/index.js\";\n\nimport type {\n GeneratedAttestationResult,\n InitTimeData,\n RuntimeData,\n} from \"./generated/models/index.js\";\nimport { KnownDataType } from \"./generated/models/index.js\";\n\nimport { logger } from \"./logger.js\";\nimport type { GeneratedClientOptionalParams } from \"./generated/models/index.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\nimport type { AttestationResponse } from \"./models/attestationResponse.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\n\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { bytesToString, stringToBytes } from \"./utils/utf8.js\";\nimport { _attestationResultFromGenerated } from \"./models/attestationResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { Uint8ArrayFromInput } from \"./utils/buffer.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationClientOptions extends CommonClientOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Client operations.\n */\nexport interface AttestationClientOperationOptions extends OperationOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service for the individual operation.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Optional parameters for the AttestOpenEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestOpenEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Optional parameters for the AttestSgxEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestSgxEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Operation options for the AttestTpm API.\n */\nexport interface AttestTpmOptions extends AttestationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getOpenIdMetadata\n * - getAttestationSigners\n * - attestSgxEnclave\n * - attestOpenEnclave\n * - attestTpm\n */\nexport class AttestationClient {\n /**\n * Creates an instance of AttestationClient.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_NoCreds\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationClient(endpoint);\n * ```\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param options - Options used to configure the Attestation Client.\n *\n */\n public constructor(endpoint: string, options?: AttestationClientOptions);\n\n /**\n * Creates an instance of AttestationClient with options and credentials.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_Creds\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const credentials = new DefaultAzureCredential();\n * const client = new AttestationClient(endpoint, credentials);\n * ```\n *\n * Note that credentials are required to call the `attestTpm` API.\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param credentials - Credentials used to configure the attestation client.\n *\n */\n public constructor(\n endpoint: string,\n credentials: TokenCredential,\n options?: AttestationClientOptions,\n );\n public constructor(\n endpoint: string,\n credentialsOrOptions?: TokenCredential | AttestationClientOptions,\n clientOptions: AttestationClientOptions = {},\n ) {\n let credentialScopes: string[] | undefined = undefined;\n let credential: TokenCredential | undefined = undefined;\n let options: AttestationClientOptions;\n\n if (credentialsOrOptions && isTokenCredential(credentialsOrOptions)) {\n credential = credentialsOrOptions;\n credentialScopes = [\"https://attest.azure.net/.default\"];\n options = clientOptions;\n } else {\n options = credentialsOrOptions || {};\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credentialScopes: credentialScopes,\n credential: credential,\n loggingOptions: {\n logger: logger.info,\n allowedHeaderNames: [\"x-ms-request-id\", \"x-ms-maa-service-version\"],\n },\n },\n };\n\n this._client = new GeneratedClient(endpoint, internalPipelineOptions);\n this._validationOptions = options.validationOptions;\n }\n\n /** Attests an OpenEnclave report generated from an SGX Enclave using the OpenEnclave SDK.\n *\n * @param report - An OpenEnclave report generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n *\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n * @throws {@link Error} if the `initTimeJson` option is provided and the value of `initTimeJson` is not JSON.\n * @throws {@link Error} if the `runTimeJson` option is provided and the value of `runTimeJson` is not JSON.\n */\n public async attestOpenEnclave(\n report: Uint8Array | Buffer | Blob,\n options: AttestOpenEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestOpenEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestOpenEnclave(\n {\n report: await Uint8ArrayFromInput(report),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attests a quote generated from SGX Enclave using the Intel SDK.\n *\n * @param quote - An SGX quote generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n */\n public async attestSgxEnclave(\n quote: Uint8Array | Buffer | Blob,\n options: AttestSgxEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestSgxEnclave(\n {\n quote: await Uint8ArrayFromInput(quote),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attest a TPM based enclave.\n\n * See the {@link https://learn.microsoft.com/en-us/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.\n * \n * @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.\n * @param options - Pipeline options for TPM attestation request.\n * @returns A structure containing the response from the TPM attestation, Utf8 encoded.\n * \n * @remarks\n * \n * The incoming requests to the TPM attestation API are stringified JSON objects.\n * \n * @example\n * For example, the initial call for a TPM attestation operation is:\n * \n * ```snippet:AttestationClient_AttestTpm\n * const encodedPayload = JSON.stringify({ payload: { type: \"aikcert\" } });\n * const result = await client.attestTpm(encodedPayload);\n * ```\n * \n * where stringToBytes converts the string to UTF8.\n * \n * Note that the attestTpm requires an attestation client which is configured with\n * authentication credentials.\n * \n */\n public async attestTpm(request: string, options: AttestTpmOptions = {}): Promise<string> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n const response = await this._client.attestation.attestTpm(\n { data: stringToBytes(request) },\n updatedOptions,\n );\n if (response.data) {\n return bytesToString(response.data);\n } else {\n throw Error(\"Internal error - response data cannot be undefined.\");\n }\n },\n );\n }\n\n /**\n * Returns the list of attestation signers which can be used to sign attestation\n * service tokens.\n *\n * @param options - Client operation options.\n * @returns the set of AttestationSigners which may be used to sign attestation tokens.\n */\n public async getAttestationSigners(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<AttestationSigner[]> {\n return tracingClient.withSpan(\n \"AttestationClient-getAttestationSigners\",\n options,\n async (updatedOptions) => {\n const signingCertificates = await this._client.signingCertificates.get(updatedOptions);\n const signers: AttestationSigner[] = new Array();\n signingCertificates.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n return signers;\n },\n );\n }\n\n /**\n * Returns the OpenID Metadata discovery document for the attestation service instance.\n * @param options - Client operation options.\n * @returns The OpenID metadata discovery document for the attestation service.\n */\n public async getOpenIdMetadata(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<Record<string, unknown>> {\n return tracingClient.withSpan(\n \"AttestationClient-getOpenIdMetadata\",\n options,\n async (updatedOptions) => {\n const configs = await this._client.metadataConfiguration.get(updatedOptions);\n return configs;\n },\n );\n }\n\n private _client: GeneratedClient;\n private _validationOptions?: AttestationTokenValidationOptions;\n private _signers?: AttestationSigner[];\n\n private async _signingKeys(): Promise<AttestationSigner[]> {\n if (this._signers !== undefined) {\n return this._signers;\n }\n const jwks = await this._client.signingCertificates.get();\n const signers: AttestationSigner[] = new Array();\n jwks.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n this._signers = signers;\n return this._signers;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attestationClient.js","sourceRoot":"","sources":["../../src/attestationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAajE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAC;AAGzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAmGvD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,iBAAi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BAAiB;IAC5B,8DAA8D;IAC9D,UAA6C,EAAE;QAE/C,OAAO,aAAa,CAAC,QAAQ,CAC3B,qCAAqC,EACrC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC7E,OAAO,OAAO,CAAC;QACjB,CAAC,CACF,CAAC;IACJ,CAAC;IAMO,KAAK,CAAC,YAAY;;QACxB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAwB,IAAI,KAAK,EAAE,CAAC;QACjD,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\n\nimport type {\n AttestationResult,\n AttestationSigner,\n AttestationTokenValidationOptions,\n} from \"./models/index.js\";\n\nimport type {\n GeneratedAttestationResult,\n InitTimeData,\n RuntimeData,\n} from \"./generated/models/index.js\";\nimport { KnownDataType } from \"./generated/models/index.js\";\n\nimport { logger } from \"./logger.js\";\nimport type { GeneratedClientOptionalParams } from \"./generated/models/index.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\nimport type { AttestationResponse } from \"./models/attestationResponse.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\n\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { bytesToString, stringToBytes } from \"./utils/utf8.js\";\nimport { _attestationResultFromGenerated } from \"./models/attestationResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { Uint8ArrayFromInput } from \"./utils/buffer.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationClientOptions extends CommonClientOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Client operations.\n */\nexport interface AttestationClientOperationOptions extends OperationOptions {\n /**\n * Validation options to be used to validate attestation tokens received\n * from the attestation service for the individual operation.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Optional parameters for the AttestOpenEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestOpenEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Optional parameters for the AttestSgxEnclave API.\n *\n * @param initTimeData - data provided at the time the enclave was initialized.\n * @param runTimeData - data provided at the time the SGX quote being attested was created.\n * @param draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\nexport interface AttestSgxEnclaveOptions extends AttestationClientOperationOptions {\n /**\n *initTimeData : data provided at the time the enclave was initialized, to be interpreted as binary data.\n *\n */\n initTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * inittimeJson : data provided at the time the enclave was initialized, to be interpreted as JSON data.\n */\n initTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeData - data provided at the time the OpenEnclave report being attested was created to be interpreted as binary data.\n */\n runTimeData?: Uint8Array | Buffer | Blob;\n\n /**\n * runTimeJson - data provided at the time the OpenEnclave report being attested was created to be interpreted as JSON data.\n */\n runTimeJson?: Uint8Array | Buffer | Blob;\n\n /**\n * draftPolicyForAttestation - If specified, the attestation policy to be used during the attestation request.\n */\n draftPolicyForAttestation?: string;\n}\n\n/**\n * Operation options for the AttestTpm API.\n */\nexport interface AttestTpmOptions extends AttestationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getOpenIdMetadata\n * - getAttestationSigners\n * - attestSgxEnclave\n * - attestOpenEnclave\n * - attestTpm\n */\nexport class AttestationClient {\n /**\n * Creates an instance of AttestationClient.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_NoCreds\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationClient(endpoint);\n * ```\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param options - Options used to configure the Attestation Client.\n *\n */\n public constructor(endpoint: string, options?: AttestationClientOptions);\n\n /**\n * Creates an instance of AttestationClient with options and credentials.\n *\n * Example usage:\n * ```ts snippet:Attestation_Constructor_Creds\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { AttestationClient } from \"@azure/attestation\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const credentials = new DefaultAzureCredential();\n * const client = new AttestationClient(endpoint, credentials);\n * ```\n *\n * Note that credentials are required to call the `attestTpm` API.\n *\n * @param endpoint - The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param credentials - Credentials used to configure the attestation client.\n *\n */\n public constructor(\n endpoint: string,\n credentials: TokenCredential,\n options?: AttestationClientOptions,\n );\n public constructor(\n endpoint: string,\n credentialsOrOptions?: TokenCredential | AttestationClientOptions,\n clientOptions: AttestationClientOptions = {},\n ) {\n let credentialScopes: string[] | undefined = undefined;\n let credential: TokenCredential | undefined = undefined;\n let options: AttestationClientOptions;\n\n if (credentialsOrOptions && isTokenCredential(credentialsOrOptions)) {\n credential = credentialsOrOptions;\n credentialScopes = [\"https://attest.azure.net/.default\"];\n options = clientOptions;\n } else {\n options = credentialsOrOptions || {};\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credentialScopes: credentialScopes,\n credential: credential,\n loggingOptions: {\n logger: logger.info,\n allowedHeaderNames: [\"x-ms-request-id\", \"x-ms-maa-service-version\"],\n },\n },\n };\n\n this._client = new GeneratedClient(endpoint, internalPipelineOptions);\n this._validationOptions = options.validationOptions;\n }\n\n /** Attests an OpenEnclave report generated from an SGX Enclave using the OpenEnclave SDK.\n *\n * @param report - An OpenEnclave report generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n *\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n * @throws {@link Error} if the `initTimeJson` option is provided and the value of `initTimeJson` is not JSON.\n * @throws {@link Error} if the `runTimeJson` option is provided and the value of `runTimeJson` is not JSON.\n */\n public async attestOpenEnclave(\n report: Uint8Array | Buffer | Blob,\n options: AttestOpenEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestOpenEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestOpenEnclave(\n {\n report: await Uint8ArrayFromInput(report),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attests a quote generated from SGX Enclave using the Intel SDK.\n *\n * @param quote - An SGX quote generated by an SGX enclave.\n * @param options - Operation options for the attestOpenEnclave API call.\n * @returns Returns an AttestationResponse whose body is an AttestationResult describing\n * the claims returned by the attestation service.\n * @throws {@link Error} if the `initTimeData` option and `initTimeJson` option is provided.\n * @throws {@link Error} if the `runTimeData` option and `runTimeJson` option is provided.\n */\n public async attestSgxEnclave(\n quote: Uint8Array | Buffer | Blob,\n options: AttestSgxEnclaveOptions = {},\n ): Promise<AttestationResponse<AttestationResult>> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {\n throw new Error(\"Cannot provide both initTimeData and initTimeJson.\");\n }\n\n if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {\n throw new Error(\"Cannot provide both runTimeData and runTimeJson.\");\n }\n\n const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);\n\n const initTimeData: InitTimeData | undefined = initData\n ? {\n data: initData,\n dataType:\n options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);\n const runTimeData: RuntimeData | undefined = runData\n ? {\n data: runData,\n dataType:\n options.runTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,\n }\n : undefined;\n\n const attestationResponse = await this._client.attestation.attestSgxEnclave(\n {\n quote: await Uint8ArrayFromInput(quote),\n initTimeData: initTimeData,\n runtimeData: runTimeData,\n draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,\n },\n updatedOptions,\n );\n\n const token = new AttestationTokenImpl(attestationResponse.token);\n const problems = token.getTokenProblems(\n await this._signingKeys(),\n options.validationOptions ?? this._validationOptions,\n );\n if (problems.length) {\n throw new Error(problems.join(\";\"));\n }\n\n const attestationResult = TypeDeserializer.deserialize(\n token.getBody(),\n {\n GeneratedAttestationResult: Mappers.GeneratedAttestationResult,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"GeneratedAttestationResult\",\n ) as GeneratedAttestationResult;\n\n return createAttestationResponse<AttestationResult>(\n token,\n _attestationResultFromGenerated(attestationResult),\n );\n },\n );\n }\n\n /** Attest a TPM based enclave.\n\n * See the {@link https://learn.microsoft.com/azure/attestation/virtualization-based-security-protocol | TPM Attestation Protocol Reference} for more information.\n * \n * @param request - Incoming request to send to the TPM attestation service, Utf8 encoded.\n * @param options - Pipeline options for TPM attestation request.\n * @returns A structure containing the response from the TPM attestation, Utf8 encoded.\n * \n * @remarks\n * \n * The incoming requests to the TPM attestation API are stringified JSON objects.\n * \n * @example\n * For example, the initial call for a TPM attestation operation is:\n * \n * ```snippet:AttestationClient_AttestTpm\n * const encodedPayload = JSON.stringify({ payload: { type: \"aikcert\" } });\n * const result = await client.attestTpm(encodedPayload);\n * ```\n * \n * where stringToBytes converts the string to UTF8.\n * \n * Note that the attestTpm requires an attestation client which is configured with\n * authentication credentials.\n * \n */\n public async attestTpm(request: string, options: AttestTpmOptions = {}): Promise<string> {\n return tracingClient.withSpan(\n \"AttestationClient-attestSgxEnclave\",\n options,\n async (updatedOptions) => {\n const response = await this._client.attestation.attestTpm(\n { data: stringToBytes(request) },\n updatedOptions,\n );\n if (response.data) {\n return bytesToString(response.data);\n } else {\n throw Error(\"Internal error - response data cannot be undefined.\");\n }\n },\n );\n }\n\n /**\n * Returns the list of attestation signers which can be used to sign attestation\n * service tokens.\n *\n * @param options - Client operation options.\n * @returns the set of AttestationSigners which may be used to sign attestation tokens.\n */\n public async getAttestationSigners(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<AttestationSigner[]> {\n return tracingClient.withSpan(\n \"AttestationClient-getAttestationSigners\",\n options,\n async (updatedOptions) => {\n const signingCertificates = await this._client.signingCertificates.get(updatedOptions);\n const signers: AttestationSigner[] = new Array();\n signingCertificates.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n return signers;\n },\n );\n }\n\n /**\n * Returns the OpenID Metadata discovery document for the attestation service instance.\n * @param options - Client operation options.\n * @returns The OpenID metadata discovery document for the attestation service.\n */\n public async getOpenIdMetadata(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: AttestationClientOperationOptions = {},\n ): Promise<Record<string, unknown>> {\n return tracingClient.withSpan(\n \"AttestationClient-getOpenIdMetadata\",\n options,\n async (updatedOptions) => {\n const configs = await this._client.metadataConfiguration.get(updatedOptions);\n return configs;\n },\n );\n }\n\n private _client: GeneratedClient;\n private _validationOptions?: AttestationTokenValidationOptions;\n private _signers?: AttestationSigner[];\n\n private async _signingKeys(): Promise<AttestationSigner[]> {\n if (this._signers !== undefined) {\n return this._signers;\n }\n const jwks = await this._client.signingCertificates.get();\n const signers: AttestationSigner[] = new Array();\n jwks.keys?.forEach((element) => {\n signers.push(_attestationSignerFromGenerated(element));\n });\n this._signers = signers;\n return this._signers;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/attestation",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.20250611.1",
|
|
4
4
|
"description": "Javascript/Typescript client implementation for the Microsoft Azure Attestation service.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "./dist/commonjs/index.js",
|