Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Renamed any types to be unknown #16344

Merged
merged 3 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sdk/attestation/attestation/review/attestation.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class AttestationClient {
attestSgxEnclave(quote: Uint8Array, options?: AttestSgxEnclaveOptions): Promise<AttestationResponse<AttestationResult>>;
attestTpm(request: string, options?: AttestTpmOptions): Promise<string>;
getAttestationSigners(options?: AttestationClientOperationOptions): Promise<AttestationSigner[]>;
getOpenIdMetadata(options?: AttestationClientOperationOptions): Promise<any>;
getOpenIdMetadata(options?: AttestationClientOperationOptions): Promise<Record<string, unknown>>;
}

// @public
Expand All @@ -62,17 +62,17 @@ export interface AttestationResponse<T> {
// @public
export interface AttestationResult {
enclaveHeldData?: Uint8Array;
inittimeClaims: any;
initTimeClaims: unknown;
isDebuggable?: boolean;
issuer: string;
mrEnclave?: string;
mrSigner?: string;
nonce?: string;
policyClaims: any;
policyClaims: unknown;
policyHash: Uint8Array;
policySigner?: AttestationSigner;
productId?: number;
runtimeClaims: any;
runTimeClaims: unknown;
sgxCollateral?: AttestationSgxCollateralInfo;
svn?: number;
uniqueId: string;
Expand Down Expand Up @@ -106,7 +106,7 @@ export interface AttestationToken {
contentType?: string;
critical?: boolean;
expiresOn?: Date;
getBody(): any;
getBody(): unknown;
issuedAt?: Date;
issuer?: string;
keyId?: string;
Expand Down
5 changes: 4 additions & 1 deletion sdk/attestation/attestation/src/attestationClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,16 @@ export class AttestationClient {
* @param options - Client operation options.
* @returns The OpenID metadata discovery document for the attestation service.
*/
public async getOpenIdMetadata(options: AttestationClientOperationOptions = {}): Promise<any> {
public async getOpenIdMetadata(
options: AttestationClientOperationOptions = {}
): Promise<Record<string, unknown>> {
const { span, updatedOptions } = createSpan("AttestationClient-getOpenIdMetadata", options);
try {
const configs = await this._client.metadataConfiguration.get(updatedOptions);
return configs;
} catch (e) {
span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });
throw e;
} finally {
span.end();
}
Expand Down
42 changes: 21 additions & 21 deletions sdk/attestation/attestation/src/models/attestationResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export interface AttestationResult {
* `runtimeJson` parameter to the `Attest` API is specified. It will
* not be populated if the `runtimeData` parameter is specified.
*/
runtimeClaims: any;
runTimeClaims: unknown;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runTime feels odd in comparison to runtime, did someone ask for this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xirzec asked me to change inittimeData to initTimeData. To be consistent in naming convention, I renamed runtimeData to match the pattern.

inittimeData is data which is presented at the time the enclave is initialized, runtimeData is data which is presented at the time that the evidence is created. The naming convention for both of these should be the same, IMHO since they are so closely related.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, initTime and runTime is also consistent with the AttestSgxEnclaveOptions/AttestOpenEnclaveOptions model types.

/**
* Returns the initialization time claims in the token.
* This value will match the input `initTimeJson` property to the
Expand All @@ -116,12 +116,12 @@ export interface AttestationResult {
* parameter to the `Attest` API is specified. It will not be populated if
* the `initTimeData` parameter is specified.
*/
inittimeClaims: any;
initTimeClaims: unknown;

/**
* Returns the set of claims generated by the attestation policy on the instance.
*/
policyClaims: any;
policyClaims: unknown;

/**
* Returns the verifier which generated this attestation token. Normally one of:
Expand Down Expand Up @@ -199,9 +199,9 @@ export class AttestationResultImpl implements AttestationResult {
version: string;
nonce?: string;
uniqueId: string;
runtimeClaims?: any;
inittimeClaims?: any;
policyClaims?: any;
runTimeClaims?: unknown;
initTimeClaims?: unknown;
policyClaims?: unknown;
verifierType: string;
policySigner?: AttestationSigner;
policyHash: Uint8Array;
Expand All @@ -211,14 +211,14 @@ export class AttestationResultImpl implements AttestationResult {
mrSigner?: string;
svn?: number;
enclaveHeldData?: Uint8Array;
sgxCollateral?: any;
sgxCollateral?: AttestationSgxCollateralInfo;
}) {
this._issuer = params.issuer;
this._nonce = params.nonce;
this._version = params.version;
this._uniqueId = params.uniqueId;
this._runtimeClaims = params.runtimeClaims;
this._inittimeClaims = params.inittimeClaims;
this._runTimeClaims = params.runTimeClaims;
this._initTimeClaims = params.initTimeClaims;
this._policyClaims = params.policyClaims;
this._verifierType = params.verifierType;
this._policySigner = params.policySigner;
Expand All @@ -236,9 +236,9 @@ export class AttestationResultImpl implements AttestationResult {
private _version: string;
private _nonce?: string;
private _uniqueId: string;
private _runtimeClaims?: any;
private _inittimeClaims?: any;
private _policyClaims?: any;
private _runTimeClaims?: unknown;
private _initTimeClaims?: unknown;
private _policyClaims?: unknown;
private _verifierType: string;
private _policySigner?: AttestationSigner;
private _policyHash: Uint8Array;
Expand All @@ -248,7 +248,7 @@ export class AttestationResultImpl implements AttestationResult {
private _mrSigner?: string;
private _svn?: number;
private _enclaveHeldData?: Uint8Array;
private _sgxCollateral?: any;
private _sgxCollateral?: AttestationSgxCollateralInfo;

/**
* Unique Identifier for the token
Expand Down Expand Up @@ -283,20 +283,20 @@ export class AttestationResultImpl implements AttestationResult {
/**
* Runtime Claims
*/
get runtimeClaims(): any {
return this._runtimeClaims;
get runTimeClaims(): unknown {
return this._runTimeClaims;
}
/**
* Inittime Claims
*/
get inittimeClaims(): any {
return this._inittimeClaims;
get initTimeClaims(): unknown {
return this._initTimeClaims;
}

/**
* Policy Generated Claims
*/
get policyClaims(): any {
get policyClaims(): unknown {
return this._policyClaims;
}
/**
Expand Down Expand Up @@ -356,7 +356,7 @@ export class AttestationResultImpl implements AttestationResult {
/**
* The SGX SVN value for the enclave.
*/
get sgxCollateral(): any {
get sgxCollateral(): AttestationSgxCollateralInfo | undefined {
return this._sgxCollateral;
}
}
Expand All @@ -379,8 +379,8 @@ export function _attestationResultFromGenerated(
policySigner: generated.policySigner
? _attestationSignerFromGenerated(generated.policySigner)
: undefined,
runtimeClaims: generated.runtimeClaims,
inittimeClaims: generated.inittimeClaims,
runTimeClaims: generated.runtimeClaims,
initTimeClaims: generated.inittimeClaims,
policyClaims: generated.policyClaims,
verifierType: generated.verifierType,
policyHash: generated.policyHash,
Expand Down
4 changes: 2 additions & 2 deletions sdk/attestation/attestation/src/models/attestationToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export interface AttestationToken {
*
* @returns The body of the attestation token as an object.
*/
getBody(): any;
getBody(): unknown;

/**
* the token to a string.
Expand Down Expand Up @@ -258,7 +258,7 @@ export class AttestationTokenImpl implements AttestationToken {
*
* @returns The body of the attestation token as an object.
*/
public getBody(): any {
public getBody(): unknown {
return this._jwsVerifier.payloadObj;
}

Expand Down
23 changes: 12 additions & 11 deletions sdk/attestation/attestation/test/public/attestationTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe("[AAD] Attestation Client", function() {
);

assert.isNotNull(attestationResult.body.sgxCollateral);
assert.isUndefined(attestationResult.body.runtimeClaims);
assert.isUndefined(attestationResult.body.runTimeClaims);
expect(attestationResult.body.enclaveHeldData?.length).is.equal(binaryRuntimeData.length);
expect(attestationResult.body.enclaveHeldData).to.deep.equal(binaryRuntimeData);

Expand All @@ -241,14 +241,15 @@ describe("[AAD] Attestation Client", function() {
);

assert.isNotNull(attestationResult.body.sgxCollateral);
assert.isDefined(attestationResult.body.runtimeClaims);
assert.isDefined(attestationResult.body.runTimeClaims);
assert.isUndefined(attestationResult.body.enclaveHeldData);

// Confirm that the JWK response out of the service makes sense and contains
// the JSON inside the binaryRuntimeData.
assert.isDefined(attestationResult.body.runtimeClaims.jwk);
assert.isDefined(attestationResult.body.runtimeClaims.jwk.crv);
expect(attestationResult.body.runtimeClaims.jwk.crv).is.equal("P-256");
const runtimeClaims = attestationResult.body.runTimeClaims as any;
assert.isDefined(runtimeClaims.jwk);
assert.isDefined(runtimeClaims.jwk.crv);
expect(runtimeClaims.jwk.crv).is.equal("P-256");

assert(attestationResult.token, "Expected a token from the service but did not receive one");
}
Expand Down Expand Up @@ -290,10 +291,9 @@ describe("[AAD] Attestation Client", function() {
);

assert.isNotNull(attestationResult.body.sgxCollateral);
assert.isUndefined(attestationResult.body.runtimeClaims);
assert.isUndefined(attestationResult.body.runTimeClaims);
expect(attestationResult.body.enclaveHeldData?.length).is.equal(binaryRuntimeData.length);
expect(attestationResult.body.enclaveHeldData).to.deep.equal(binaryRuntimeData);

assert(attestationResult.token, "Expected a token from the service but did not receive one");
}

Expand All @@ -309,14 +309,15 @@ describe("[AAD] Attestation Client", function() {
);

assert.isNotNull(attestationResult.body.sgxCollateral);
assert.isDefined(attestationResult.body.runtimeClaims);
assert.isDefined(attestationResult.body.runTimeClaims);
assert.isUndefined(attestationResult.body.enclaveHeldData);

// Confirm that the JWK response out of the service makes sense and contains
// the JSON inside the binaryRuntimeData.
assert.isDefined(attestationResult.body.runtimeClaims.jwk);
assert.isDefined(attestationResult.body.runtimeClaims.jwk.crv);
expect(attestationResult.body.runtimeClaims.jwk.crv).is.equal("P-256");
const runtimeClaims = attestationResult.body.runTimeClaims as any;
assert.isDefined(runtimeClaims.jwk);
assert.isDefined(runtimeClaims.jwk.crv);
expect(runtimeClaims.jwk.crv).is.equal("P-256");

assert(attestationResult.token, "Expected a token from the service but did not receive one");
}
Expand Down