@azure/attestation 1.0.1-alpha.20250620.1 → 1.0.1-alpha.20250730.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/attestationAdministrationClient.js +24 -22
- package/dist/browser/attestationAdministrationClient.js.map +1 -1
- package/dist/browser/attestationClient.js +23 -21
- package/dist/browser/attestationClient.js.map +1 -1
- package/dist/browser/generated/generatedClient.js +14 -3
- package/dist/browser/generated/generatedClient.js.map +1 -1
- package/dist/browser/generated/operations/attestation.js +4 -3
- package/dist/browser/generated/operations/attestation.js.map +1 -1
- package/dist/browser/generated/operations/metadataConfiguration.js +2 -1
- package/dist/browser/generated/operations/metadataConfiguration.js.map +1 -1
- package/dist/browser/generated/operations/policy.js +4 -3
- package/dist/browser/generated/operations/policy.js.map +1 -1
- package/dist/browser/generated/operations/policyCertificates.js +4 -3
- package/dist/browser/generated/operations/policyCertificates.js.map +1 -1
- package/dist/browser/generated/operations/signingCertificates.js +2 -1
- package/dist/browser/generated/operations/signingCertificates.js.map +1 -1
- package/dist/browser/models/attestationResult.js +17 -0
- package/dist/browser/models/attestationResult.js.map +1 -1
- package/dist/browser/models/attestationSigner.js +2 -3
- package/dist/browser/models/attestationSigner.js.map +1 -1
- package/dist/browser/models/attestationToken.js +12 -8
- package/dist/browser/models/attestationToken.js.map +1 -1
- package/dist/browser/models/storedAttestationPolicy.js +4 -0
- package/dist/browser/models/storedAttestationPolicy.js.map +1 -1
- package/dist/commonjs/attestationAdministrationClient.js +24 -22
- package/dist/commonjs/attestationAdministrationClient.js.map +1 -1
- package/dist/commonjs/attestationClient.js +23 -21
- package/dist/commonjs/attestationClient.js.map +1 -1
- package/dist/commonjs/generated/generatedClient.js +14 -3
- package/dist/commonjs/generated/generatedClient.js.map +1 -1
- package/dist/commonjs/generated/operations/attestation.js +4 -3
- package/dist/commonjs/generated/operations/attestation.js.map +1 -1
- package/dist/commonjs/generated/operations/metadataConfiguration.js +2 -1
- package/dist/commonjs/generated/operations/metadataConfiguration.js.map +1 -1
- package/dist/commonjs/generated/operations/policy.js +4 -3
- package/dist/commonjs/generated/operations/policy.js.map +1 -1
- package/dist/commonjs/generated/operations/policyCertificates.js +4 -3
- package/dist/commonjs/generated/operations/policyCertificates.js.map +1 -1
- package/dist/commonjs/generated/operations/signingCertificates.js +2 -1
- package/dist/commonjs/generated/operations/signingCertificates.js.map +1 -1
- package/dist/commonjs/models/attestationResult.js +17 -0
- package/dist/commonjs/models/attestationResult.js.map +1 -1
- package/dist/commonjs/models/attestationSigner.js +2 -3
- package/dist/commonjs/models/attestationSigner.js.map +1 -1
- package/dist/commonjs/models/attestationToken.js +12 -8
- package/dist/commonjs/models/attestationToken.js.map +1 -1
- package/dist/commonjs/models/storedAttestationPolicy.js +4 -0
- package/dist/commonjs/models/storedAttestationPolicy.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/esm/attestationAdministrationClient.js +24 -22
- package/dist/esm/attestationAdministrationClient.js.map +1 -1
- package/dist/esm/attestationClient.js +23 -21
- package/dist/esm/attestationClient.js.map +1 -1
- package/dist/esm/generated/generatedClient.js +14 -3
- package/dist/esm/generated/generatedClient.js.map +1 -1
- package/dist/esm/generated/operations/attestation.js +4 -3
- package/dist/esm/generated/operations/attestation.js.map +1 -1
- package/dist/esm/generated/operations/metadataConfiguration.js +2 -1
- package/dist/esm/generated/operations/metadataConfiguration.js.map +1 -1
- package/dist/esm/generated/operations/policy.js +4 -3
- package/dist/esm/generated/operations/policy.js.map +1 -1
- package/dist/esm/generated/operations/policyCertificates.js +4 -3
- package/dist/esm/generated/operations/policyCertificates.js.map +1 -1
- package/dist/esm/generated/operations/signingCertificates.js +2 -1
- package/dist/esm/generated/operations/signingCertificates.js.map +1 -1
- package/dist/esm/models/attestationResult.js +17 -0
- package/dist/esm/models/attestationResult.js.map +1 -1
- package/dist/esm/models/attestationSigner.js +2 -3
- package/dist/esm/models/attestationSigner.js.map +1 -1
- package/dist/esm/models/attestationToken.js +12 -8
- package/dist/esm/models/attestationToken.js.map +1 -1
- package/dist/esm/models/storedAttestationPolicy.js +4 -0
- package/dist/esm/models/storedAttestationPolicy.js.map +1 -1
- package/dist/esm/utils/textEncoding-browser.d.mts +8 -2
- package/dist/esm/utils/textEncoding-browser.d.mts.map +1 -1
- package/dist/react-native/attestationAdministrationClient.js +24 -22
- package/dist/react-native/attestationAdministrationClient.js.map +1 -1
- package/dist/react-native/attestationClient.js +23 -21
- package/dist/react-native/attestationClient.js.map +1 -1
- package/dist/react-native/generated/generatedClient.js +14 -3
- package/dist/react-native/generated/generatedClient.js.map +1 -1
- package/dist/react-native/generated/operations/attestation.js +4 -3
- package/dist/react-native/generated/operations/attestation.js.map +1 -1
- package/dist/react-native/generated/operations/metadataConfiguration.js +2 -1
- package/dist/react-native/generated/operations/metadataConfiguration.js.map +1 -1
- package/dist/react-native/generated/operations/policy.js +4 -3
- package/dist/react-native/generated/operations/policy.js.map +1 -1
- package/dist/react-native/generated/operations/policyCertificates.js +4 -3
- package/dist/react-native/generated/operations/policyCertificates.js.map +1 -1
- package/dist/react-native/generated/operations/signingCertificates.js +2 -1
- package/dist/react-native/generated/operations/signingCertificates.js.map +1 -1
- package/dist/react-native/models/attestationResult.js +17 -0
- package/dist/react-native/models/attestationResult.js.map +1 -1
- package/dist/react-native/models/attestationSigner.js +2 -3
- package/dist/react-native/models/attestationSigner.js.map +1 -1
- package/dist/react-native/models/attestationToken.js +12 -8
- package/dist/react-native/models/attestationToken.js.map +1 -1
- package/dist/react-native/models/storedAttestationPolicy.js +4 -0
- package/dist/react-native/models/storedAttestationPolicy.js.map +1 -1
- package/dist/react-native/utils/textEncoding-browser.d.mts +8 -2
- package/dist/react-native/utils/textEncoding-browser.d.mts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestationAdministrationClient.js","sourceRoot":"","sources":["../../src/attestationAdministrationClient.ts"],"names":[],"mappings":"AAA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CAAC;YAE1C,OAAO,yBAAyB,CAAuC,KAAK,EAAE,MAAM,CAAC,CAAC;QACxF,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,WAAW;;QACvB,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;CAKF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* eslint-disable @azure/azure-sdk/ts-naming-options */\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\nimport { logger } from \"./logger.js\";\n\nimport type {\n AttestationCertificateManagementBody,\n GeneratedClientOptionalParams,\n JsonWebKey,\n PolicyCertificatesResult,\n} from \"./generated/models/index.js\";\n\nimport { bytesToString } from \"./utils/utf8.js\";\n\nimport type {\n AttestationResponse,\n AttestationSigner,\n AttestationTokenValidationOptions,\n AttestationType,\n PolicyCertificatesModificationResult,\n PolicyResult,\n} from \"./models/index.js\";\nimport { StoredAttestationPolicy } from \"./models/storedAttestationPolicy.js\";\n\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\n/// <reference path=\"../jsrsasign.d.ts\"/>\nimport * as jsrsasign from \"jsrsasign\";\nimport { hexToBase64 } from \"./utils/helpers.js\";\nimport { _policyResultFromGenerated } from \"./models/policyResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { verifyAttestationSigningKey } from \"./utils/helpers.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationAdministrationClientOptions extends CommonClientOptions {\n /**\n * Options to be used globally to validate attestation tokens received from\n * the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Administration Client operations.\n */\nexport interface AttestationAdministrationClientOperationOptions extends OperationOptions {\n /**\n * Options to be used globally to validate attestation tokens received from\n * the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the administration Policy operations.\n */\nexport interface AttestationAdministrationClientPolicyOperationOptions\n extends AttestationAdministrationClientOperationOptions {\n /**\n * Optional Private key used to sign the token sent to the attestation service.\n *\n * Required for Isolated Mode attestation instances.\n */\n privateKey?: string;\n\n /**\n * Optional certificate which can validate the token sent to the attestation service.\n *\n * Required for Isolated Mode attestation instances.\n *\n * If the service instance is in Isolated mode, the certificate *must* be one\n * of the configured policy management certificates.\n */\n certificate?: string;\n}\n\n/**\n * Operation options for the Policy Certificates operations.\n */\nexport interface AttestationAdministrationClientPolicyCertificateOperationOptions\n extends AttestationAdministrationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getPolicy\n * - setPolicy\n * - resetPolicy\n * - getPolicyManagementCertificates\n * - addPolicyManagementCertificate\n * - removePolicyManagementCertificate\n */\nexport class AttestationAdministrationClient {\n /**\n * Creates an instance of AttestationAdministrationClient.\n *\n * Example usage:\n * ```ts snippet:AttestationAdministrationClient_Constructor\n * import { AttestationAdministrationClient } from \"@azure/attestation\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationAdministrationClient(endpoint, new DefaultAzureCredential());\n * ```\n *\n * @param endpoint - The attestation instance endpoint, for example https://mytenant.attest.azure.net.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the Form Recognizer client.\n */\n\n constructor(\n endpoint: string,\n credentials: TokenCredential,\n options: AttestationAdministrationClientOptions = {},\n ) {\n this._validationOptions = options.validationOptions;\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credential: credentials,\n credentialScopes: [\"https://attest.azure.net/.default\"],\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 }\n\n /**\n * Retrieves the attestation policy document from the server, and returns it\n * to the caller.\n *\n * @param attestationType - AttestationType for which to retrieve policy.\n * @param options - Pipeline and client options for the `getPolicy` call.\n * @returns `AttestationResponse<string>` - the `value` property is the\n * attestation policy, the `token` property will be the actual token\n * returned by the attestation service.\n */\n public async getPolicy(\n attestationType: AttestationType,\n options: AttestationAdministrationClientPolicyOperationOptions = {},\n ): Promise<AttestationResponse<string>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-getPolicy\",\n options,\n async (updatedOptions) => {\n const getPolicyResult = await this._client.policy.get(attestationType, updatedOptions);\n\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(getPolicyResult.token);\n\n // Validate the token returned from the service.\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 // Deserialize the PolicyResult object to retrieve the underlying policy\n // token\n const policyResult = _policyResultFromGenerated(token.getBody());\n\n // The policyResult.policy value will be a JSON Web Signature representing\n // the actual policy object being retrieved. Serialize the token to an\n // AttestationToken object so we can access the body properties on the token.\n if (!policyResult.policy) {\n throw Error(\"Server returned an invalid getPolicy response!\");\n }\n\n const policyToken = new AttestationTokenImpl(policyResult.policy);\n\n const storedPolicy = StoredAttestationPolicy.deserialize(policyToken.getBody());\n\n // Finally, retrieve the stored attestationPolicy value and return that\n // as the AttestationResponse to the caller.\n return createAttestationResponse<string>(\n token,\n bytesToString(storedPolicy.attestationPolicy),\n );\n },\n );\n }\n\n /**\n * Sets the attestation policy for the specified {@link attestationType}.\n *\n * @param attestationType - Attestation Type for which to set policy.\n * @param newPolicyDocument - Policy document to be set.\n * @param options - call options.\n * @returns An {@link AttestationResponse} wrapping a {@link PolicyResult}.\n * Clients can use the PolicyResult to validate that the policy was actually\n * set by the attestation service.\n *\n * @remarks\n *\n * Please note that if the attestation service instance is running in \"Isolated\"\n * mode, the {@link signingKey} must be one of the signing keys configured for the\n * service instance.\n *\n * @throws {@link Error} when a private key is specified without a certificate and vice versa.\n * @throws {@link Error} when the key in the certificate provided does not match the private key.\n */\n public async setPolicy(\n attestationType: AttestationType,\n newPolicyDocument: string,\n options: AttestationAdministrationClientPolicyOperationOptions = {},\n ): Promise<AttestationResponse<PolicyResult>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-setPolicy\",\n options,\n async (updatedOptions) => {\n if (\n (!options.privateKey && options.certificate) ||\n (options.privateKey && !options.certificate)\n ) {\n throw new Error(\n \"If privateKey is specified, certificate must also be provided. If certificate is provided, privateKey must also be provided.\",\n );\n }\n\n if (options.privateKey && options.certificate) {\n verifyAttestationSigningKey(options.privateKey, options.certificate);\n }\n\n const storedAttestationPolicy = new StoredAttestationPolicy(newPolicyDocument).serialize();\n const setPolicyToken = AttestationTokenImpl.create({\n body: storedAttestationPolicy,\n ...options,\n });\n\n const setPolicyResult = await this._client.policy.set(\n attestationType,\n setPolicyToken.serialize(),\n updatedOptions,\n );\n\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(setPolicyResult.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 // Deserialize the PolicyResult object to retrieve the underlying policy\n // token\n const policyResult = _policyResultFromGenerated(token.getBody());\n\n // The policyResult.policy value will be a JSON Web Signature representing\n // the actual policy object being retrieved. Serialize the token to an\n // AttestationToken object so we can access the body properties on the token.\n return createAttestationResponse<PolicyResult>(token, policyResult);\n },\n );\n }\n\n /**\n * Resets the attestation policy for the specified {@link attestationType} to\n * the default value.\n *\n * @param attestationType - Attestation Type for which to set policy.\n * @param options - call options.\n * @returns An {@link AttestationResponse} wrapping a {@link PolicyResult}.\n * Clients can use the PolicyResult to validate that the policy was actually\n * reset by the attestation service.\n *\n * @remarks\n *\n * Please note that if the attestation service instance is running in \"Isolated\"\n * mode, the {@link signingKey} must be one of the signing keys configured for the\n * service instance.\n *\n * @throws {@link Error} when a private key is specified without a certificate and vice versa.\n * @throws {@link Error} when the key in the certificate provided does not match the private key.\n */\n\n public async resetPolicy(\n attestationType: AttestationType,\n options: AttestationAdministrationClientPolicyOperationOptions = {},\n ): Promise<AttestationResponse<PolicyResult>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-setPolicy\",\n options,\n async (updatedOptions) => {\n if (\n (!options.privateKey && options.certificate) ||\n (options.privateKey && !options.certificate)\n ) {\n throw new Error(\n \"If privateKey is specified, certificate must also be provided. If certificate is provided, privateKey must also be provided.\",\n );\n }\n\n if (options.privateKey && options.certificate) {\n verifyAttestationSigningKey(options.privateKey, options.certificate);\n }\n\n const resetPolicyToken = AttestationTokenImpl.create({\n privateKey: options.privateKey,\n certificate: options.certificate,\n });\n\n const resetPolicyResult = await this._client.policy.reset(\n attestationType,\n resetPolicyToken.serialize(),\n updatedOptions,\n );\n\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(resetPolicyResult.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 // Deserialize the PolicyResult object to retrieve the underlying policy\n // token\n const policyResult = _policyResultFromGenerated(token.getBody());\n\n // The policyResult.policy value will be a JSON Web Signature representing\n // the actual policy object being retrieved. Serialize the token to an\n // AttestationToken object so we can access the body properties on the token.\n return createAttestationResponse<PolicyResult>(token, policyResult);\n },\n );\n }\n\n /** Returns the set of policy management certificates for this attestation instance.\n *\n * @remarks If the attestation instance is not in `Isolated` mode, this list will\n * always be empty.\n *\n * @param options - Options for the call to the attestation service.\n * @returns AttestationResponse wrapping a list of Attestation Signers.\n */\n public async getPolicyManagementCertificates(\n options: AttestationAdministrationClientPolicyCertificateOperationOptions = {},\n ): Promise<AttestationResponse<AttestationSigner[]>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-getPolicyManagementCertificates\",\n options,\n async (updatedOptions) => {\n const getCertificatesResult = await this._client.policyCertificates.get(updatedOptions);\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(getCertificatesResult.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 // Deserialize the PolicyResult object to retrieve the underlying policy\n // token\n const jwks = TypeDeserializer.deserialize(\n token.getBody(),\n {\n PolicyCertificatesResult: Mappers.PolicyCertificatesResult,\n JsonWebKeySet: Mappers.JsonWebKeySet,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"PolicyCertificatesResult\",\n ) as PolicyCertificatesResult;\n\n const policyCertificates = new Array<AttestationSigner>();\n jwks.policyCertificates.keys.forEach((jwk) => {\n policyCertificates.push(_attestationSignerFromGenerated(jwk));\n });\n\n return createAttestationResponse<AttestationSigner[]>(token, policyCertificates);\n },\n );\n }\n\n /** Add a new certificate chain to the set of policy management certificates.\n *\n * @param pemCertificate - PEM encoded certificate to add to the set of policy management certificates.\n * @param privateKey - Existing attestation private key used to sign the incoming request.\n * @param certificate - Existing attestation certificate used to verify the incoming request.\n * @param options - Options used in the call to the service.\n * @returns An attestation response including a PolicyCertificatesModificationResult\n *\n * @remarks This API is only supported on `isolated` attestation instances.\n *\n * The signing key MUST be one of the existing attestation signing certificates. The\n * new pemCertificate is signed using the signingKey and the service will validate the\n * signature before allowing the addition.\n *\n * @throws {@link Error} when a private key is specified without a certificate and vice versa.\n * @throws {@link Error} when the key in the certificate provided does not match the private key.\n *\n */\n public async addPolicyManagementCertificate(\n pemCertificate: string,\n privateKey: string,\n certificate: string,\n options: AttestationAdministrationClientPolicyCertificateOperationOptions = {},\n ): Promise<AttestationResponse<PolicyCertificatesModificationResult>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-addPolicyManagementCertificate\",\n options,\n async (updatedOptions) => {\n if ((!privateKey && certificate) || (privateKey && !certificate)) {\n throw new Error(\n \"If privateKey is specified, certificate must also be provided. If certificate is provided, privateKey must also be provided.\",\n );\n }\n\n if (privateKey && certificate) {\n verifyAttestationSigningKey(privateKey, certificate);\n }\n\n const cert = new jsrsasign.X509();\n cert.readCertPEM(pemCertificate);\n const kty = this.keyTypeFromCertificate(cert);\n\n const jwk: JsonWebKey = {\n x5C: [hexToBase64(cert.hex)],\n kty: kty,\n };\n\n const addBody: AttestationCertificateManagementBody = {\n policyCertificate: jwk,\n };\n\n const addCertToken = AttestationTokenImpl.create({\n body: TypeDeserializer.serialize(\n addBody,\n {\n AttestationCertificateManagementBody: Mappers.AttestationCertificateManagementBody,\n JsonWebKey: Mappers.JsonWebKey,\n },\n Mappers.AttestationCertificateManagementBody,\n ),\n privateKey: privateKey,\n certificate: certificate,\n });\n\n const addCertificateResult = await this._client.policyCertificates.add(\n addCertToken.serialize(),\n updatedOptions,\n );\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(addCertificateResult.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 // Deserialize the PolicyCertificatesModificationResult object.\n const result = TypeDeserializer.deserialize(\n token.getBody(),\n {\n PolicyCertificatesModificationResult: Mappers.PolicyCertificatesModificationResult,\n JsonWebKeySet: Mappers.JsonWebKeySet,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"PolicyCertificatesModificationResult\",\n ) as PolicyCertificatesModificationResult;\n\n return createAttestationResponse<PolicyCertificatesModificationResult>(token, result);\n },\n );\n }\n\n private keyTypeFromCertificate(cert: any): string {\n let kty: string;\n switch (cert.getSignatureAlgorithmName()) {\n case \"SHA256withRSA\":\n case \"SHA384withRSA\":\n case \"SHA512withRSA\":\n kty = \"RSA\";\n break;\n case \"SHA256withECDSA\":\n case \"SHA384withECDSA\":\n kty = \"EC\";\n break;\n default:\n kty = \"RSA\";\n break;\n }\n return kty;\n }\n\n /** Add a new certificate chain to the set of policy management certificates.\n *\n * @param pemCertificate - PEM encoded certificate to add to the set of policy management certificates.\n * @param privateKey - Existing attestation private key used to sign the incoming request.\n * @param certificate - Existing attestation certificate used to verify the incoming request.\n * @param options - Options used in the call to the service.\n * @returns An attestation response including a PolicyCertificatesModificationResult\n *\n * @remarks This API is only supported on `isolated` attestation instances.\n *\n * The signing key MUST be one of the existing attestation signing certificates. The\n * new pemCertificate is signed using the signingKey and the service will validate the\n * signature before allowing the addition.\n *\n * @throws {@link Error} when a private key is specified without a certificate and vice versa.\n * @throws {@link Error} when the key in the certificate provided does not match the private key.\n */\n public async removePolicyManagementCertificate(\n pemCertificate: string,\n privateKey: string,\n certificate: string,\n options: AttestationAdministrationClientPolicyCertificateOperationOptions = {},\n ): Promise<AttestationResponse<PolicyCertificatesModificationResult>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-removePolicyManagementCertificate\",\n options,\n async (updatedOptions) => {\n if ((!privateKey && certificate) || (privateKey && !certificate)) {\n throw new Error(\n \"If privateKey is specified, certificate must also be provided. If certificate is provided, privateKey must also be provided.\",\n );\n }\n\n if (privateKey && certificate) {\n verifyAttestationSigningKey(privateKey, certificate);\n }\n\n const cert = new jsrsasign.X509();\n cert.readCertPEM(pemCertificate);\n const kty = this.keyTypeFromCertificate(cert);\n\n const jwk: JsonWebKey = {\n x5C: [hexToBase64(cert.hex)],\n kty: kty,\n };\n\n const addBody: AttestationCertificateManagementBody = {\n policyCertificate: jwk,\n };\n\n const removeCertToken = AttestationTokenImpl.create({\n body: TypeDeserializer.serialize(\n addBody,\n {\n AttestationCertificateManagementBody: Mappers.AttestationCertificateManagementBody,\n JsonWebKey: Mappers.JsonWebKey,\n },\n Mappers.AttestationCertificateManagementBody,\n ),\n privateKey: privateKey,\n certificate: certificate,\n });\n\n const removeCertificateResult = await this._client.policyCertificates.remove(\n removeCertToken.serialize(),\n updatedOptions,\n );\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(removeCertificateResult.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 // Deserialize the PolicyCertificatesModificationResult object.\n const result = TypeDeserializer.deserialize(\n token.getBody(),\n {\n PolicyCertificatesModificationResult: Mappers.PolicyCertificatesModificationResult,\n JsonWebKeySet: Mappers.JsonWebKeySet,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"PolicyCertificatesModificationResult\",\n ) as PolicyCertificatesModificationResult;\n\n return createAttestationResponse<PolicyCertificatesModificationResult>(token, result);\n },\n );\n }\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 private _client: GeneratedClient;\n private _signers?: AttestationSigner[];\n private _validationOptions?: AttestationTokenValidationOptions;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attestationAdministrationClient.js","sourceRoot":"","sources":["../../src/attestationAdministrationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,uDAAuD;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAUhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAI9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAC;AAEzD,yCAAyC;AACzC,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAqDvD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,+BAA+B;IAC1C;;;;;;;;;;;;;;;OAeG;IAEH,YACE,QAAgB,EAChB,WAA4B,EAC5B,UAAkD,EAAE;QAEpD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;QAEpD,MAAM,uBAAuB,GAAkC;YAC7D,GAAG,OAAO;YACV,GAAG;gBACD,UAAU,EAAE,WAAW;gBACvB,gBAAgB,EAAE,CAAC,mCAAmC,CAAC;gBACvD,cAAc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EAAE,OAAO,CAAC,oCAAoC;gBAClF,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,EACD,sCAAsC,CACC,CAAC;YAE1C,OAAO,yBAAyB,CAAuC,KAAK,EAAE,MAAM,CAAC,CAAC;QACxF,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,WAAW;QACvB,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,IAAI,CAAC,IAAI,EAAE,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;IAEO,OAAO,CAAkB;IACzB,QAAQ,CAAuB;IAC/B,kBAAkB,CAAqC;CAChE","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* eslint-disable @azure/azure-sdk/ts-naming-options */\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\nimport { logger } from \"./logger.js\";\n\nimport type {\n AttestationCertificateManagementBody,\n GeneratedClientOptionalParams,\n JsonWebKey,\n PolicyCertificatesResult,\n} from \"./generated/models/index.js\";\n\nimport { bytesToString } from \"./utils/utf8.js\";\n\nimport type {\n AttestationResponse,\n AttestationSigner,\n AttestationTokenValidationOptions,\n AttestationType,\n PolicyCertificatesModificationResult,\n PolicyResult,\n} from \"./models/index.js\";\nimport { StoredAttestationPolicy } from \"./models/storedAttestationPolicy.js\";\n\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { TypeDeserializer } from \"./utils/typeDeserializer.js\";\nimport * as Mappers from \"./generated/models/mappers.js\";\n\n/// <reference path=\"../jsrsasign.d.ts\"/>\nimport * as jsrsasign from \"jsrsasign\";\nimport { hexToBase64 } from \"./utils/helpers.js\";\nimport { _policyResultFromGenerated } from \"./models/policyResult.js\";\nimport { _attestationSignerFromGenerated } from \"./models/attestationSigner.js\";\nimport { verifyAttestationSigningKey } from \"./utils/helpers.js\";\nimport { createAttestationResponse } from \"./models/attestationResponse.js\";\nimport { AttestationTokenImpl } from \"./models/attestationToken.js\";\nimport { tracingClient } from \"./generated/tracing.js\";\n\n/**\n * Attestation Client Construction Options.\n */\nexport interface AttestationAdministrationClientOptions extends CommonClientOptions {\n /**\n * Options to be used globally to validate attestation tokens received from\n * the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the Attestation Administration Client operations.\n */\nexport interface AttestationAdministrationClientOperationOptions extends OperationOptions {\n /**\n * Options to be used globally to validate attestation tokens received from\n * the attestation service.\n */\n validationOptions?: AttestationTokenValidationOptions;\n}\n\n/**\n * Operation options for the administration Policy operations.\n */\nexport interface AttestationAdministrationClientPolicyOperationOptions\n extends AttestationAdministrationClientOperationOptions {\n /**\n * Optional Private key used to sign the token sent to the attestation service.\n *\n * Required for Isolated Mode attestation instances.\n */\n privateKey?: string;\n\n /**\n * Optional certificate which can validate the token sent to the attestation service.\n *\n * Required for Isolated Mode attestation instances.\n *\n * If the service instance is in Isolated mode, the certificate *must* be one\n * of the configured policy management certificates.\n */\n certificate?: string;\n}\n\n/**\n * Operation options for the Policy Certificates operations.\n */\nexport interface AttestationAdministrationClientPolicyCertificateOperationOptions\n extends AttestationAdministrationClientOperationOptions {}\n\n/**\n * Attestation Client class.\n *\n * The AttestationClient class enables access to the Attestation related APIs:\n *\n * - getPolicy\n * - setPolicy\n * - resetPolicy\n * - getPolicyManagementCertificates\n * - addPolicyManagementCertificate\n * - removePolicyManagementCertificate\n */\nexport class AttestationAdministrationClient {\n /**\n * Creates an instance of AttestationAdministrationClient.\n *\n * Example usage:\n * ```ts snippet:AttestationAdministrationClient_Constructor\n * import { AttestationAdministrationClient } from \"@azure/attestation\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://<attestation-instance>.<region>.attest.azure.net\";\n * const client = new AttestationAdministrationClient(endpoint, new DefaultAzureCredential());\n * ```\n *\n * @param endpoint - The attestation instance endpoint, for example https://mytenant.attest.azure.net.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the Form Recognizer client.\n */\n\n constructor(\n endpoint: string,\n credentials: TokenCredential,\n options: AttestationAdministrationClientOptions = {},\n ) {\n this._validationOptions = options.validationOptions;\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...options,\n ...{\n credential: credentials,\n credentialScopes: [\"https://attest.azure.net/.default\"],\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 }\n\n /**\n * Retrieves the attestation policy document from the server, and returns it\n * to the caller.\n *\n * @param attestationType - AttestationType for which to retrieve policy.\n * @param options - Pipeline and client options for the `getPolicy` call.\n * @returns `AttestationResponse<string>` - the `value` property is the\n * attestation policy, the `token` property will be the actual token\n * returned by the attestation service.\n */\n public async getPolicy(\n attestationType: AttestationType,\n options: AttestationAdministrationClientPolicyOperationOptions = {},\n ): Promise<AttestationResponse<string>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-getPolicy\",\n options,\n async (updatedOptions) => {\n const getPolicyResult = await this._client.policy.get(attestationType, updatedOptions);\n\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(getPolicyResult.token);\n\n // Validate the token returned from the service.\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 // Deserialize the PolicyResult object to retrieve the underlying policy\n // token\n const policyResult = _policyResultFromGenerated(token.getBody());\n\n // The policyResult.policy value will be a JSON Web Signature representing\n // the actual policy object being retrieved. Serialize the token to an\n // AttestationToken object so we can access the body properties on the token.\n if (!policyResult.policy) {\n throw Error(\"Server returned an invalid getPolicy response!\");\n }\n\n const policyToken = new AttestationTokenImpl(policyResult.policy);\n\n const storedPolicy = StoredAttestationPolicy.deserialize(policyToken.getBody());\n\n // Finally, retrieve the stored attestationPolicy value and return that\n // as the AttestationResponse to the caller.\n return createAttestationResponse<string>(\n token,\n bytesToString(storedPolicy.attestationPolicy),\n );\n },\n );\n }\n\n /**\n * Sets the attestation policy for the specified {@link attestationType}.\n *\n * @param attestationType - Attestation Type for which to set policy.\n * @param newPolicyDocument - Policy document to be set.\n * @param options - call options.\n * @returns An {@link AttestationResponse} wrapping a {@link PolicyResult}.\n * Clients can use the PolicyResult to validate that the policy was actually\n * set by the attestation service.\n *\n * @remarks\n *\n * Please note that if the attestation service instance is running in \"Isolated\"\n * mode, the {@link signingKey} must be one of the signing keys configured for the\n * service instance.\n *\n * @throws {@link Error} when a private key is specified without a certificate and vice versa.\n * @throws {@link Error} when the key in the certificate provided does not match the private key.\n */\n public async setPolicy(\n attestationType: AttestationType,\n newPolicyDocument: string,\n options: AttestationAdministrationClientPolicyOperationOptions = {},\n ): Promise<AttestationResponse<PolicyResult>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-setPolicy\",\n options,\n async (updatedOptions) => {\n if (\n (!options.privateKey && options.certificate) ||\n (options.privateKey && !options.certificate)\n ) {\n throw new Error(\n \"If privateKey is specified, certificate must also be provided. If certificate is provided, privateKey must also be provided.\",\n );\n }\n\n if (options.privateKey && options.certificate) {\n verifyAttestationSigningKey(options.privateKey, options.certificate);\n }\n\n const storedAttestationPolicy = new StoredAttestationPolicy(newPolicyDocument).serialize();\n const setPolicyToken = AttestationTokenImpl.create({\n body: storedAttestationPolicy,\n ...options,\n });\n\n const setPolicyResult = await this._client.policy.set(\n attestationType,\n setPolicyToken.serialize(),\n updatedOptions,\n );\n\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(setPolicyResult.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 // Deserialize the PolicyResult object to retrieve the underlying policy\n // token\n const policyResult = _policyResultFromGenerated(token.getBody());\n\n // The policyResult.policy value will be a JSON Web Signature representing\n // the actual policy object being retrieved. Serialize the token to an\n // AttestationToken object so we can access the body properties on the token.\n return createAttestationResponse<PolicyResult>(token, policyResult);\n },\n );\n }\n\n /**\n * Resets the attestation policy for the specified {@link attestationType} to\n * the default value.\n *\n * @param attestationType - Attestation Type for which to set policy.\n * @param options - call options.\n * @returns An {@link AttestationResponse} wrapping a {@link PolicyResult}.\n * Clients can use the PolicyResult to validate that the policy was actually\n * reset by the attestation service.\n *\n * @remarks\n *\n * Please note that if the attestation service instance is running in \"Isolated\"\n * mode, the {@link signingKey} must be one of the signing keys configured for the\n * service instance.\n *\n * @throws {@link Error} when a private key is specified without a certificate and vice versa.\n * @throws {@link Error} when the key in the certificate provided does not match the private key.\n */\n\n public async resetPolicy(\n attestationType: AttestationType,\n options: AttestationAdministrationClientPolicyOperationOptions = {},\n ): Promise<AttestationResponse<PolicyResult>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-setPolicy\",\n options,\n async (updatedOptions) => {\n if (\n (!options.privateKey && options.certificate) ||\n (options.privateKey && !options.certificate)\n ) {\n throw new Error(\n \"If privateKey is specified, certificate must also be provided. If certificate is provided, privateKey must also be provided.\",\n );\n }\n\n if (options.privateKey && options.certificate) {\n verifyAttestationSigningKey(options.privateKey, options.certificate);\n }\n\n const resetPolicyToken = AttestationTokenImpl.create({\n privateKey: options.privateKey,\n certificate: options.certificate,\n });\n\n const resetPolicyResult = await this._client.policy.reset(\n attestationType,\n resetPolicyToken.serialize(),\n updatedOptions,\n );\n\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(resetPolicyResult.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 // Deserialize the PolicyResult object to retrieve the underlying policy\n // token\n const policyResult = _policyResultFromGenerated(token.getBody());\n\n // The policyResult.policy value will be a JSON Web Signature representing\n // the actual policy object being retrieved. Serialize the token to an\n // AttestationToken object so we can access the body properties on the token.\n return createAttestationResponse<PolicyResult>(token, policyResult);\n },\n );\n }\n\n /** Returns the set of policy management certificates for this attestation instance.\n *\n * @remarks If the attestation instance is not in `Isolated` mode, this list will\n * always be empty.\n *\n * @param options - Options for the call to the attestation service.\n * @returns AttestationResponse wrapping a list of Attestation Signers.\n */\n public async getPolicyManagementCertificates(\n options: AttestationAdministrationClientPolicyCertificateOperationOptions = {},\n ): Promise<AttestationResponse<AttestationSigner[]>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-getPolicyManagementCertificates\",\n options,\n async (updatedOptions) => {\n const getCertificatesResult = await this._client.policyCertificates.get(updatedOptions);\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(getCertificatesResult.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 // Deserialize the PolicyResult object to retrieve the underlying policy\n // token\n const jwks = TypeDeserializer.deserialize(\n token.getBody(),\n {\n PolicyCertificatesResult: Mappers.PolicyCertificatesResult,\n JsonWebKeySet: Mappers.JsonWebKeySet,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"PolicyCertificatesResult\",\n ) as PolicyCertificatesResult;\n\n const policyCertificates = new Array<AttestationSigner>();\n jwks.policyCertificates.keys.forEach((jwk) => {\n policyCertificates.push(_attestationSignerFromGenerated(jwk));\n });\n\n return createAttestationResponse<AttestationSigner[]>(token, policyCertificates);\n },\n );\n }\n\n /** Add a new certificate chain to the set of policy management certificates.\n *\n * @param pemCertificate - PEM encoded certificate to add to the set of policy management certificates.\n * @param privateKey - Existing attestation private key used to sign the incoming request.\n * @param certificate - Existing attestation certificate used to verify the incoming request.\n * @param options - Options used in the call to the service.\n * @returns An attestation response including a PolicyCertificatesModificationResult\n *\n * @remarks This API is only supported on `isolated` attestation instances.\n *\n * The signing key MUST be one of the existing attestation signing certificates. The\n * new pemCertificate is signed using the signingKey and the service will validate the\n * signature before allowing the addition.\n *\n * @throws {@link Error} when a private key is specified without a certificate and vice versa.\n * @throws {@link Error} when the key in the certificate provided does not match the private key.\n *\n */\n public async addPolicyManagementCertificate(\n pemCertificate: string,\n privateKey: string,\n certificate: string,\n options: AttestationAdministrationClientPolicyCertificateOperationOptions = {},\n ): Promise<AttestationResponse<PolicyCertificatesModificationResult>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-addPolicyManagementCertificate\",\n options,\n async (updatedOptions) => {\n if ((!privateKey && certificate) || (privateKey && !certificate)) {\n throw new Error(\n \"If privateKey is specified, certificate must also be provided. If certificate is provided, privateKey must also be provided.\",\n );\n }\n\n if (privateKey && certificate) {\n verifyAttestationSigningKey(privateKey, certificate);\n }\n\n const cert = new jsrsasign.X509();\n cert.readCertPEM(pemCertificate);\n const kty = this.keyTypeFromCertificate(cert);\n\n const jwk: JsonWebKey = {\n x5C: [hexToBase64(cert.hex)],\n kty: kty,\n };\n\n const addBody: AttestationCertificateManagementBody = {\n policyCertificate: jwk,\n };\n\n const addCertToken = AttestationTokenImpl.create({\n body: TypeDeserializer.serialize(\n addBody,\n {\n AttestationCertificateManagementBody: Mappers.AttestationCertificateManagementBody,\n JsonWebKey: Mappers.JsonWebKey,\n },\n Mappers.AttestationCertificateManagementBody,\n ),\n privateKey: privateKey,\n certificate: certificate,\n });\n\n const addCertificateResult = await this._client.policyCertificates.add(\n addCertToken.serialize(),\n updatedOptions,\n );\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(addCertificateResult.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 // Deserialize the PolicyCertificatesModificationResult object.\n const result = TypeDeserializer.deserialize(\n token.getBody(),\n {\n PolicyCertificatesModificationResult: Mappers.PolicyCertificatesModificationResult,\n JsonWebKeySet: Mappers.JsonWebKeySet,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"PolicyCertificatesModificationResult\",\n ) as PolicyCertificatesModificationResult;\n\n return createAttestationResponse<PolicyCertificatesModificationResult>(token, result);\n },\n );\n }\n\n private keyTypeFromCertificate(cert: any): string {\n let kty: string;\n switch (cert.getSignatureAlgorithmName()) {\n case \"SHA256withRSA\":\n case \"SHA384withRSA\":\n case \"SHA512withRSA\":\n kty = \"RSA\";\n break;\n case \"SHA256withECDSA\":\n case \"SHA384withECDSA\":\n kty = \"EC\";\n break;\n default:\n kty = \"RSA\";\n break;\n }\n return kty;\n }\n\n /** Add a new certificate chain to the set of policy management certificates.\n *\n * @param pemCertificate - PEM encoded certificate to add to the set of policy management certificates.\n * @param privateKey - Existing attestation private key used to sign the incoming request.\n * @param certificate - Existing attestation certificate used to verify the incoming request.\n * @param options - Options used in the call to the service.\n * @returns An attestation response including a PolicyCertificatesModificationResult\n *\n * @remarks This API is only supported on `isolated` attestation instances.\n *\n * The signing key MUST be one of the existing attestation signing certificates. The\n * new pemCertificate is signed using the signingKey and the service will validate the\n * signature before allowing the addition.\n *\n * @throws {@link Error} when a private key is specified without a certificate and vice versa.\n * @throws {@link Error} when the key in the certificate provided does not match the private key.\n */\n public async removePolicyManagementCertificate(\n pemCertificate: string,\n privateKey: string,\n certificate: string,\n options: AttestationAdministrationClientPolicyCertificateOperationOptions = {},\n ): Promise<AttestationResponse<PolicyCertificatesModificationResult>> {\n return tracingClient.withSpan(\n \"AttestationAdministrationClient-removePolicyManagementCertificate\",\n options,\n async (updatedOptions) => {\n if ((!privateKey && certificate) || (privateKey && !certificate)) {\n throw new Error(\n \"If privateKey is specified, certificate must also be provided. If certificate is provided, privateKey must also be provided.\",\n );\n }\n\n if (privateKey && certificate) {\n verifyAttestationSigningKey(privateKey, certificate);\n }\n\n const cert = new jsrsasign.X509();\n cert.readCertPEM(pemCertificate);\n const kty = this.keyTypeFromCertificate(cert);\n\n const jwk: JsonWebKey = {\n x5C: [hexToBase64(cert.hex)],\n kty: kty,\n };\n\n const addBody: AttestationCertificateManagementBody = {\n policyCertificate: jwk,\n };\n\n const removeCertToken = AttestationTokenImpl.create({\n body: TypeDeserializer.serialize(\n addBody,\n {\n AttestationCertificateManagementBody: Mappers.AttestationCertificateManagementBody,\n JsonWebKey: Mappers.JsonWebKey,\n },\n Mappers.AttestationCertificateManagementBody,\n ),\n privateKey: privateKey,\n certificate: certificate,\n });\n\n const removeCertificateResult = await this._client.policyCertificates.remove(\n removeCertToken.serialize(),\n updatedOptions,\n );\n // The attestation token returned from the service has a PolicyResult\n // object as the body.\n const token = new AttestationTokenImpl(removeCertificateResult.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 // Deserialize the PolicyCertificatesModificationResult object.\n const result = TypeDeserializer.deserialize(\n token.getBody(),\n {\n PolicyCertificatesModificationResult: Mappers.PolicyCertificatesModificationResult,\n JsonWebKeySet: Mappers.JsonWebKeySet,\n JsonWebKey: Mappers.JsonWebKey,\n },\n \"PolicyCertificatesModificationResult\",\n ) as PolicyCertificatesModificationResult;\n\n return createAttestationResponse<PolicyCertificatesModificationResult>(token, result);\n },\n );\n }\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 private _client: GeneratedClient;\n private _signers?: AttestationSigner[];\n private _validationOptions?: AttestationTokenValidationOptions;\n}\n"]}
|
|
@@ -37,14 +37,17 @@ export class AttestationClient {
|
|
|
37
37
|
else {
|
|
38
38
|
options = credentialsOrOptions || {};
|
|
39
39
|
}
|
|
40
|
-
const internalPipelineOptions =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const internalPipelineOptions = {
|
|
41
|
+
...options,
|
|
42
|
+
...{
|
|
43
|
+
credentialScopes: credentialScopes,
|
|
44
|
+
credential: credential,
|
|
45
|
+
loggingOptions: {
|
|
46
|
+
logger: logger.info,
|
|
47
|
+
allowedHeaderNames: ["x-ms-request-id", "x-ms-maa-service-version"],
|
|
48
|
+
},
|
|
46
49
|
},
|
|
47
|
-
}
|
|
50
|
+
};
|
|
48
51
|
this._client = new GeneratedClient(endpoint, internalPipelineOptions);
|
|
49
52
|
this._validationOptions = options.validationOptions;
|
|
50
53
|
}
|
|
@@ -62,21 +65,20 @@ export class AttestationClient {
|
|
|
62
65
|
*/
|
|
63
66
|
async attestOpenEnclave(report, options = {}) {
|
|
64
67
|
return tracingClient.withSpan("AttestationClient-attestOpenEnclave", options, async (updatedOptions) => {
|
|
65
|
-
var _a, _b, _c, _d;
|
|
66
68
|
if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {
|
|
67
69
|
throw new Error("Cannot provide both initTimeData and initTimeJson.");
|
|
68
70
|
}
|
|
69
71
|
if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {
|
|
70
72
|
throw new Error("Cannot provide both runTimeData and runTimeJson.");
|
|
71
73
|
}
|
|
72
|
-
const initData = await Uint8ArrayFromInput(
|
|
74
|
+
const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);
|
|
73
75
|
const initTimeData = initData
|
|
74
76
|
? {
|
|
75
77
|
data: initData,
|
|
76
78
|
dataType: options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,
|
|
77
79
|
}
|
|
78
80
|
: undefined;
|
|
79
|
-
const runData = await Uint8ArrayFromInput(
|
|
81
|
+
const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);
|
|
80
82
|
const runTimeData = runData
|
|
81
83
|
? {
|
|
82
84
|
data: runData,
|
|
@@ -87,10 +89,10 @@ export class AttestationClient {
|
|
|
87
89
|
report: await Uint8ArrayFromInput(report),
|
|
88
90
|
initTimeData: initTimeData,
|
|
89
91
|
runtimeData: runTimeData,
|
|
90
|
-
draftPolicyForAttestation:
|
|
92
|
+
draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,
|
|
91
93
|
}, updatedOptions);
|
|
92
94
|
const token = new AttestationTokenImpl(attestationResponse.token);
|
|
93
|
-
const problems = token.getTokenProblems(await this._signingKeys(),
|
|
95
|
+
const problems = token.getTokenProblems(await this._signingKeys(), options.validationOptions ?? this._validationOptions);
|
|
94
96
|
if (problems.length) {
|
|
95
97
|
throw new Error(problems.join(";"));
|
|
96
98
|
}
|
|
@@ -112,21 +114,20 @@ export class AttestationClient {
|
|
|
112
114
|
*/
|
|
113
115
|
async attestSgxEnclave(quote, options = {}) {
|
|
114
116
|
return tracingClient.withSpan("AttestationClient-attestSgxEnclave", options, async (updatedOptions) => {
|
|
115
|
-
var _a, _b, _c, _d;
|
|
116
117
|
if (options.initTimeData !== undefined && options.initTimeJson !== undefined) {
|
|
117
118
|
throw new Error("Cannot provide both initTimeData and initTimeJson.");
|
|
118
119
|
}
|
|
119
120
|
if (options.runTimeData !== undefined && options.runTimeJson !== undefined) {
|
|
120
121
|
throw new Error("Cannot provide both runTimeData and runTimeJson.");
|
|
121
122
|
}
|
|
122
|
-
const initData = await Uint8ArrayFromInput(
|
|
123
|
+
const initData = await Uint8ArrayFromInput(options.initTimeData ?? options.initTimeJson);
|
|
123
124
|
const initTimeData = initData
|
|
124
125
|
? {
|
|
125
126
|
data: initData,
|
|
126
127
|
dataType: options.initTimeJson !== undefined ? KnownDataType.Json : KnownDataType.Binary,
|
|
127
128
|
}
|
|
128
129
|
: undefined;
|
|
129
|
-
const runData = await Uint8ArrayFromInput(
|
|
130
|
+
const runData = await Uint8ArrayFromInput(options.runTimeData ?? options.runTimeJson);
|
|
130
131
|
const runTimeData = runData
|
|
131
132
|
? {
|
|
132
133
|
data: runData,
|
|
@@ -137,10 +138,10 @@ export class AttestationClient {
|
|
|
137
138
|
quote: await Uint8ArrayFromInput(quote),
|
|
138
139
|
initTimeData: initTimeData,
|
|
139
140
|
runtimeData: runTimeData,
|
|
140
|
-
draftPolicyForAttestation:
|
|
141
|
+
draftPolicyForAttestation: options.draftPolicyForAttestation ?? undefined,
|
|
141
142
|
}, updatedOptions);
|
|
142
143
|
const token = new AttestationTokenImpl(attestationResponse.token);
|
|
143
|
-
const problems = token.getTokenProblems(await this._signingKeys(),
|
|
144
|
+
const problems = token.getTokenProblems(await this._signingKeys(), options.validationOptions ?? this._validationOptions);
|
|
144
145
|
if (problems.length) {
|
|
145
146
|
throw new Error(problems.join(";"));
|
|
146
147
|
}
|
|
@@ -199,10 +200,9 @@ export class AttestationClient {
|
|
|
199
200
|
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
|
|
200
201
|
options = {}) {
|
|
201
202
|
return tracingClient.withSpan("AttestationClient-getAttestationSigners", options, async (updatedOptions) => {
|
|
202
|
-
var _a;
|
|
203
203
|
const signingCertificates = await this._client.signingCertificates.get(updatedOptions);
|
|
204
204
|
const signers = new Array();
|
|
205
|
-
|
|
205
|
+
signingCertificates.keys?.forEach((element) => {
|
|
206
206
|
signers.push(_attestationSignerFromGenerated(element));
|
|
207
207
|
});
|
|
208
208
|
return signers;
|
|
@@ -221,14 +221,16 @@ export class AttestationClient {
|
|
|
221
221
|
return configs;
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
+
_client;
|
|
225
|
+
_validationOptions;
|
|
226
|
+
_signers;
|
|
224
227
|
async _signingKeys() {
|
|
225
|
-
var _a;
|
|
226
228
|
if (this._signers !== undefined) {
|
|
227
229
|
return this._signers;
|
|
228
230
|
}
|
|
229
231
|
const jwks = await this._client.signingCertificates.get();
|
|
230
232
|
const signers = new Array();
|
|
231
|
-
|
|
233
|
+
jwks.keys?.forEach((element) => {
|
|
232
234
|
signers.push(_attestationSignerFromGenerated(element));
|
|
233
235
|
});
|
|
234
236
|
this._signers = signers;
|
|
@@ -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,i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AC,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"]}
|
|
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;AACh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AC,+BAA+B,CAAC,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,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;IAEO,OAAO,CAAkB;IACzB,kBAAkB,CAAqC;IACvD,QAAQ,CAAuB;IAE/B,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,IAAI,CAAC,IAAI,EAAE,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"]}
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
import * as coreClient from "@azure/core-client";
|
|
9
9
|
import { PolicyImpl, PolicyCertificatesImpl, AttestationImpl, SigningCertificatesImpl, MetadataConfigurationImpl } from "./operations/index.js";
|
|
10
10
|
export class GeneratedClient extends coreClient.ServiceClient {
|
|
11
|
+
instanceUrl;
|
|
12
|
+
apiVersion;
|
|
11
13
|
/**
|
|
12
14
|
* Initializes a new instance of the GeneratedClient class.
|
|
13
15
|
* @param instanceUrl The attestation instance base URI, for example https://mytenant.attest.azure.net.
|
|
14
16
|
* @param options The parameter options
|
|
15
17
|
*/
|
|
16
18
|
constructor(instanceUrl, options) {
|
|
17
|
-
var _a, _b;
|
|
18
19
|
if (instanceUrl === undefined) {
|
|
19
20
|
throw new Error("'instanceUrl' cannot be null");
|
|
20
21
|
}
|
|
@@ -29,9 +30,14 @@ export class GeneratedClient extends coreClient.ServiceClient {
|
|
|
29
30
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
30
31
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
31
32
|
: `${packageDetails}`;
|
|
32
|
-
const optionsWithDefaults =
|
|
33
|
+
const optionsWithDefaults = {
|
|
34
|
+
...defaults,
|
|
35
|
+
...options,
|
|
36
|
+
userAgentOptions: {
|
|
33
37
|
userAgentPrefix
|
|
34
|
-
},
|
|
38
|
+
},
|
|
39
|
+
baseUri: options.endpoint ?? options.baseUri ?? "{instanceUrl}"
|
|
40
|
+
};
|
|
35
41
|
super(optionsWithDefaults);
|
|
36
42
|
// Parameter assignments
|
|
37
43
|
this.instanceUrl = instanceUrl;
|
|
@@ -69,5 +75,10 @@ export class GeneratedClient extends coreClient.ServiceClient {
|
|
|
69
75
|
};
|
|
70
76
|
this.pipeline.addPolicy(apiVersionPolicy);
|
|
71
77
|
}
|
|
78
|
+
policy;
|
|
79
|
+
policyCertificates;
|
|
80
|
+
attestation;
|
|
81
|
+
signingCertificates;
|
|
82
|
+
metadataConfiguration;
|
|
72
83
|
}
|
|
73
84
|
//# sourceMappingURL=generatedClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatedClient.js","sourceRoot":"","sources":["../../../src/generated/generatedClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,uBAAuB,CAAC;AAU/B,MAAM,OAAO,eAAgB,SAAQ,UAAU,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"generatedClient.js","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O,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAS;IACf,kBAAkB,CAAqB;IACvC,WAAW,CAAc;IACzB,mBAAmB,CAAsB;IACzC,qBAAqB,CAAwB;CAC9C","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport {\n PipelineRequest,\n PipelineResponse,\n SendRequest\n} from \"@azure/core-rest-pipeline\";\nimport {\n PolicyImpl,\n PolicyCertificatesImpl,\n AttestationImpl,\n SigningCertificatesImpl,\n MetadataConfigurationImpl\n} from \"./operations/index.js\";\nimport {\n Policy,\n PolicyCertificates,\n Attestation,\n SigningCertificates,\n MetadataConfiguration\n} from \"./operationsInterfaces/index.js\";\nimport { GeneratedClientOptionalParams } from \"./models/index.js\";\n\nexport class GeneratedClient extends coreClient.ServiceClient {\n instanceUrl: string;\n apiVersion: string;\n\n /**\n * Initializes a new instance of the GeneratedClient class.\n * @param instanceUrl The attestation instance base URI, for example https://mytenant.attest.azure.net.\n * @param options The parameter options\n */\n constructor(instanceUrl: string, options?: GeneratedClientOptionalParams) {\n if (instanceUrl === undefined) {\n throw new Error(\"'instanceUrl' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-attestation/1.0.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint ?? options.baseUri ?? \"{instanceUrl}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.instanceUrl = instanceUrl;\n\n // Assigning values to Constant parameters\n this.apiVersion = options.apiVersion || \"2020-10-01\";\n this.policy = new PolicyImpl(this);\n this.policyCertificates = new PolicyCertificatesImpl(this);\n this.attestation = new AttestationImpl(this);\n this.signingCertificates = new SigningCertificatesImpl(this);\n this.metadataConfiguration = new MetadataConfigurationImpl(this);\n this.addCustomApiVersionPolicy(options.apiVersion);\n }\n\n /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */\n private addCustomApiVersionPolicy(apiVersion?: string) {\n if (!apiVersion) {\n return;\n }\n const apiVersionPolicy = {\n name: \"CustomApiVersionPolicy\",\n async sendRequest(\n request: PipelineRequest,\n next: SendRequest\n ): Promise<PipelineResponse> {\n const param = request.url.split(\"?\");\n if (param.length > 1) {\n const newParams = param[1].split(\"&\").map((item) => {\n if (item.indexOf(\"api-version\") > -1) {\n return \"api-version=\" + apiVersion;\n } else {\n return item;\n }\n });\n request.url = param[0] + \"?\" + newParams.join(\"&\");\n }\n return next(request);\n }\n };\n this.pipeline.addPolicy(apiVersionPolicy);\n }\n\n policy: Policy;\n policyCertificates: PolicyCertificates;\n attestation: Attestation;\n signingCertificates: SigningCertificates;\n metadataConfiguration: MetadataConfiguration;\n}\n"]}
|
|
@@ -11,6 +11,7 @@ import * as Mappers from "../models/mappers.js";
|
|
|
11
11
|
import * as Parameters from "../models/parameters.js";
|
|
12
12
|
/** Class containing Attestation operations. */
|
|
13
13
|
export class AttestationImpl {
|
|
14
|
+
client;
|
|
14
15
|
/**
|
|
15
16
|
* Initialize a new instance of the class Attestation class.
|
|
16
17
|
* @param client Reference to the service client
|
|
@@ -25,7 +26,7 @@ export class AttestationImpl {
|
|
|
25
26
|
* @param options The options parameters.
|
|
26
27
|
*/
|
|
27
28
|
async attestOpenEnclave(request, options) {
|
|
28
|
-
return tracingClient.withSpan("GeneratedClient.attestOpenEnclave", options
|
|
29
|
+
return tracingClient.withSpan("GeneratedClient.attestOpenEnclave", options ?? {}, async (options) => {
|
|
29
30
|
return this.client.sendOperationRequest({ request, options }, attestOpenEnclaveOperationSpec);
|
|
30
31
|
});
|
|
31
32
|
}
|
|
@@ -36,7 +37,7 @@ export class AttestationImpl {
|
|
|
36
37
|
* @param options The options parameters.
|
|
37
38
|
*/
|
|
38
39
|
async attestSgxEnclave(request, options) {
|
|
39
|
-
return tracingClient.withSpan("GeneratedClient.attestSgxEnclave", options
|
|
40
|
+
return tracingClient.withSpan("GeneratedClient.attestSgxEnclave", options ?? {}, async (options) => {
|
|
40
41
|
return this.client.sendOperationRequest({ request, options }, attestSgxEnclaveOperationSpec);
|
|
41
42
|
});
|
|
42
43
|
}
|
|
@@ -47,7 +48,7 @@ export class AttestationImpl {
|
|
|
47
48
|
* @param options The options parameters.
|
|
48
49
|
*/
|
|
49
50
|
async attestTpm(request, options) {
|
|
50
|
-
return tracingClient.withSpan("GeneratedClient.attestTpm", options
|
|
51
|
+
return tracingClient.withSpan("GeneratedClient.attestTpm", options ?? {}, async (options) => {
|
|
51
52
|
return this.client.sendOperationRequest({ request, options }, attestTpmOperationSpec);
|
|
52
53
|
});
|
|
53
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestation.js","sourceRoot":"","sources":["../../../../src/generated/operations/attestation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC;AActD,+CAA+C;AAC/C,MAAM,OAAO,eAAe;
|
|
1
|
+
{"version":3,"file":"attestation.js","sourceRoot":"","sources":["../../../../src/generated/operations/attestation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAA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AC3C;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B;KACF;IACD,WAAW,EAAE,UAAU,CAAC,QAAQ;IAChC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;IACvC,gBAAgB,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC;IAC9D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { tracingClient } from \"../tracing.js\";\nimport { Attestation } from \"../operationsInterfaces/index.js\";\nimport * as coreClient from \"@azure/core-client\";\nimport * as Mappers from \"../models/mappers.js\";\nimport * as Parameters from \"../models/parameters.js\";\nimport { GeneratedClient } from \"../generatedClient.js\";\nimport {\n AttestOpenEnclaveRequest,\n AttestationAttestOpenEnclaveOptionalParams,\n AttestationAttestOpenEnclaveResponse,\n AttestSgxEnclaveRequest,\n AttestationAttestSgxEnclaveOptionalParams,\n AttestationAttestSgxEnclaveResponse,\n TpmAttestationRequest,\n AttestationAttestTpmOptionalParams,\n AttestationAttestTpmResponse\n} from \"../models/index.js\";\n\n/** Class containing Attestation operations. */\nexport class AttestationImpl implements Attestation {\n private readonly client: GeneratedClient;\n\n /**\n * Initialize a new instance of the class Attestation class.\n * @param client Reference to the service client\n */\n constructor(client: GeneratedClient) {\n this.client = client;\n }\n\n /**\n * Processes an OpenEnclave report , producing an artifact. The type of artifact produced is dependent\n * upon attestation policy.\n * @param request Request object containing the quote\n * @param options The options parameters.\n */\n async attestOpenEnclave(\n request: AttestOpenEnclaveRequest,\n options?: AttestationAttestOpenEnclaveOptionalParams\n ): Promise<AttestationAttestOpenEnclaveResponse> {\n return tracingClient.withSpan(\n \"GeneratedClient.attestOpenEnclave\",\n options ?? {},\n async (options) => {\n return this.client.sendOperationRequest(\n { request, options },\n attestOpenEnclaveOperationSpec\n ) as Promise<AttestationAttestOpenEnclaveResponse>;\n }\n );\n }\n\n /**\n * Processes an SGX enclave quote, producing an artifact. The type of artifact produced is dependent\n * upon attestation policy.\n * @param request Request object containing the quote\n * @param options The options parameters.\n */\n async attestSgxEnclave(\n request: AttestSgxEnclaveRequest,\n options?: AttestationAttestSgxEnclaveOptionalParams\n ): Promise<AttestationAttestSgxEnclaveResponse> {\n return tracingClient.withSpan(\n \"GeneratedClient.attestSgxEnclave\",\n options ?? {},\n async (options) => {\n return this.client.sendOperationRequest(\n { request, options },\n attestSgxEnclaveOperationSpec\n ) as Promise<AttestationAttestSgxEnclaveResponse>;\n }\n );\n }\n\n /**\n * Processes attestation evidence from a VBS enclave, producing an attestation result. The attestation\n * result produced is dependent upon the attestation policy.\n * @param request Request object\n * @param options The options parameters.\n */\n async attestTpm(\n request: TpmAttestationRequest,\n options?: AttestationAttestTpmOptionalParams\n ): Promise<AttestationAttestTpmResponse> {\n return tracingClient.withSpan(\n \"GeneratedClient.attestTpm\",\n options ?? {},\n async (options) => {\n return this.client.sendOperationRequest(\n { request, options },\n attestTpmOperationSpec\n ) as Promise<AttestationAttestTpmResponse>;\n }\n );\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst attestOpenEnclaveOperationSpec: coreClient.OperationSpec = {\n path: \"/attest/OpenEnclave\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.AttestationResponse\n },\n default: {\n bodyMapper: Mappers.CloudError\n }\n },\n requestBody: Parameters.request,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.instanceUrl],\n headerParameters: [Parameters.accept, Parameters.contentType1],\n mediaType: \"json\",\n serializer\n};\nconst attestSgxEnclaveOperationSpec: coreClient.OperationSpec = {\n path: \"/attest/SgxEnclave\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.AttestationResponse\n },\n default: {\n bodyMapper: Mappers.CloudError\n }\n },\n requestBody: Parameters.request1,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.instanceUrl],\n headerParameters: [Parameters.accept, Parameters.contentType1],\n mediaType: \"json\",\n serializer\n};\nconst attestTpmOperationSpec: coreClient.OperationSpec = {\n path: \"/attest/Tpm\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.TpmAttestationResponse\n },\n default: {\n bodyMapper: Mappers.CloudError\n }\n },\n requestBody: Parameters.request2,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.instanceUrl],\n headerParameters: [Parameters.accept, Parameters.contentType1],\n mediaType: \"json\",\n serializer\n};\n"]}
|
|
@@ -11,6 +11,7 @@ import * as Mappers from "../models/mappers.js";
|
|
|
11
11
|
import * as Parameters from "../models/parameters.js";
|
|
12
12
|
/** Class containing MetadataConfiguration operations. */
|
|
13
13
|
export class MetadataConfigurationImpl {
|
|
14
|
+
client;
|
|
14
15
|
/**
|
|
15
16
|
* Initialize a new instance of the class MetadataConfiguration class.
|
|
16
17
|
* @param client Reference to the service client
|
|
@@ -23,7 +24,7 @@ export class MetadataConfigurationImpl {
|
|
|
23
24
|
* @param options The options parameters.
|
|
24
25
|
*/
|
|
25
26
|
async get(options) {
|
|
26
|
-
return tracingClient.withSpan("GeneratedClient.get", options
|
|
27
|
+
return tracingClient.withSpan("GeneratedClient.get", options ?? {}, async (options) => {
|
|
27
28
|
return this.client.sendOperationRequest({ options }, getOperationSpec);
|
|
28
29
|
});
|
|
29
30
|
}
|