Skip to content

Commit

Permalink
chore: upgrade to TypeScript 2.7 (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Feb 20, 2018
1 parent 80c439a commit 60c5a1e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
12 changes: 9 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"prettier": "^1.10.2",
"source-map-support": "^0.5.3",
"tmp": "0.0.33",
"typescript": "~2.6.2"
"typescript": "~2.7.0"
},
"files": [
"LICENSE",
Expand Down
2 changes: 1 addition & 1 deletion src/auth/authclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {Credentials} from './credentials';

export abstract class AuthClient {
transporter = new DefaultTransporter();
credentials: Credentials;
credentials: Credentials = {};

/**
* Provides an alternative Axios request implementation with auth credentials
Expand Down
6 changes: 3 additions & 3 deletions src/auth/googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface CredentialResult {
}

export class GoogleAuth {
transporter: Transporter;
transporter?: Transporter;

/**
* Caches a value indicating whether the auth layer is running on Google
Expand All @@ -75,8 +75,8 @@ export class GoogleAuth {
return this.checkIsGCE;
}

private _getDefaultProjectIdPromise: Promise<string|null>;
private _cachedProjectId: string|null;
private _getDefaultProjectIdPromise?: Promise<string|null>;
private _cachedProjectId?: string|null;

// To save the contents of the JSON credential file
jsonContent: JWTInput|null = null;
Expand Down
8 changes: 4 additions & 4 deletions src/auth/jwtclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export class JWT extends OAuth2Client {
scopes?: string|string[];
scope?: string;
subject?: string;
gtoken: GoogleToken;
gtoken?: GoogleToken;
additionalClaims?: {};

private access: JWTAccess;
private access?: JWTAccess;

/**
* JWT service account credentials.
Expand Down Expand Up @@ -157,8 +157,8 @@ export class JWT extends OAuth2Client {
}
this.credentials = result.tokens;
this.credentials.refresh_token = 'jwt-placeholder';
this.key = this.gtoken.key;
this.email = this.gtoken.iss;
this.key = this.gtoken!.key;
this.email = this.gtoken!.iss;
return result.tokens;
}

Expand Down
3 changes: 1 addition & 2 deletions src/auth/oauth2client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class OAuth2Client extends AuthClient {
// TODO: refactor tests to make this private
_clientSecret?: string;

apiKey: string;
apiKey?: string;

projectId?: string;

Expand Down Expand Up @@ -284,7 +284,6 @@ export class OAuth2Client extends AuthClient {
this.redirectUri = opts.redirectUri;
this.authBaseUrl = opts.authBaseUrl;
this.tokenUrl = opts.tokenUrl;
this.credentials = {};
this.eagerRefreshThresholdMillis =
opts.eagerRefreshThresholdMillis || 5 * 60 * 1000;
}
Expand Down
10 changes: 5 additions & 5 deletions test/test.jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ describe('JWT auth client', () => {
jwt.authorize((err, creds) => {
assert.equal(err, null);
assert.notEqual(creds, null);
assert.equal('[email protected]', jwt.gtoken.iss);
assert.equal(PEM_PATH, jwt.gtoken.keyFile);
assert.equal(['http://bar', 'http://foo'].join(' '), jwt.gtoken.scope);
assert.equal('[email protected]', jwt.gtoken.sub);
assert.equal('[email protected]', jwt.gtoken!.iss);
assert.equal(PEM_PATH, jwt.gtoken!.keyFile);
assert.equal(['http://bar', 'http://foo'].join(' '), jwt.gtoken!.scope);
assert.equal('[email protected]', jwt.gtoken!.sub);
assert.equal('initial-access-token', jwt.credentials.access_token);
assert.equal(creds!.access_token, jwt.credentials.access_token);
assert.equal(creds!.refresh_token, jwt.credentials.refresh_token);
Expand All @@ -93,7 +93,7 @@ describe('JWT auth client', () => {

createGTokenMock({access_token: 'initial-access-token'});
jwt.authorize((err, creds) => {
assert.equal('http://foo', jwt.gtoken.scope);
assert.equal('http://foo', jwt.gtoken!.scope);
done();
});
});
Expand Down

0 comments on commit 60c5a1e

Please sign in to comment.