Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from igoratron/support-temporary-credentials
Browse files Browse the repository at this point in the history
Support temporary credentials
  • Loading branch information
qasim9872 committed May 13, 2020
2 parents b7b83a1 + fe87b61 commit 0c78305
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/AwsTranscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { StreamingClient } from "./StreamingClient"
export class AwsTranscribe {
private accessKeyId!: string
private secretAccessKey!: string
private sessionToken: string | undefined

constructor(config?: ClientConfig) {
// get from environment if config not provided
this.setAccessKeyId(config?.accessKeyId || process.env.AWS_ACCESS_KEY_ID)
this.setSecretAccessKey(config?.secretAccessKey || process.env.AWS_SECRET_ACCESS_KEY)
this.setSessionToken(config?.sessionToken || process.env.AWS_SESSION_TOKEN)
}

private createPreSignedUrl(config: TranscribeStreamConfig) {
Expand All @@ -27,6 +29,7 @@ export class AwsTranscribe {
{
key: this.accessKeyId,
secret: this.secretAccessKey,
sessionToken: this.sessionToken,
protocol: "wss",
expires: 15,
region: region,
Expand All @@ -51,4 +54,8 @@ export class AwsTranscribe {
this.secretAccessKey = secretAccessKey
}
}

setSessionToken(sessionToken: string | undefined) {
this.sessionToken = sessionToken
}
}
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type LANGUAGES = "en-US" | "en-AU" | "en-GB" | "fr-CA" | "fr-FR" | "es-US
export interface ClientConfig {
accessKeyId?: string
secretAccessKey?: string
sessionToken?: string
}

export interface TranscribeStreamConfig {
Expand Down

0 comments on commit 0c78305

Please sign in to comment.