Skip to content

Commit

Permalink
Add type definition for AthenzX509Config
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsakai committed Dec 7, 2023
1 parent 705c1fe commit d7fa4cb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 14 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class AuthenticationTls {
}

export class AuthenticationAthenz {
constructor(params: string | AthenzConfig);
constructor(params: string | AthenzConfig | AthenzX509Config);
}

export interface AthenzConfig {
Expand All @@ -198,9 +198,22 @@ export interface AthenzConfig {
keyId?: string;
principalHeader?: string;
roleHeader?: string;
caCert?: string;
/**
* @deprecated
*/
tokenExpirationTime?: string;
}

export class AthenzX509Config {
providerDomain: string;
privateKey: string;
x509CertChain: string;
ztsUrl: string;
roleHeader?: string;
caCert?: string;
}

export class AuthenticationToken {
constructor(params: { token: string });
}
Expand Down
10 changes: 10 additions & 0 deletions tstest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ import Pulsar = require('./index');
principalHeader: 'Athenz-Principal-Auth',
roleHeader: 'Athenz-Role-Auth',
tokenExpirationTime: '3600',
caCert: 'file:///path/to/cacert.pem',
});

const authAthenz3: Pulsar.AuthenticationAthenz = new Pulsar.AuthenticationAthenz({
providerDomain: 'athenz.provider.domain',
privateKey: 'file:///path/to/private.key',
ztsUrl: 'https://localhost:8443',
roleHeader: 'Athenz-Role-Auth',
x509CertChain: 'file:///path/to/x509cert.pem',
caCert: 'file:///path/to/cacert.pem',
});

const authOauth2PrivateKey: Pulsar.AuthenticationOauth2 = new Pulsar.AuthenticationOauth2({
Expand Down

0 comments on commit d7fa4cb

Please sign in to comment.