@streetcred.id/service-clients
Advanced tools
Comparing version 1.0.1 to 1.0.2
import { AgencyServiceClient, AgencyServiceModels } from "./agencyServiceClient" | ||
import { StreetcredClientCredentials } from "./streetcredClientCredentials" | ||
import { ServiceClientOptions } from "./serviceClientOptions" | ||
@@ -8,4 +7,3 @@ export { | ||
AgencyServiceModels as Models, | ||
StreetcredClientCredentials as Credentials, | ||
ServiceClientOptions as Options | ||
StreetcredClientCredentials as Credentials | ||
}; |
import { ServiceClientCredentials, WebResource } from "@azure/ms-rest-js"; | ||
import { ServiceClientOptions } from "./serviceClientOptions" | ||
export class StreetcredClientCredentials implements ServiceClientCredentials { | ||
options: ServiceClientOptions; | ||
accessToken: string | ||
subscriptionKey: string; | ||
constructor (options: ServiceClientOptions) { | ||
this.options = options; | ||
constructor(accessToken: string, subscriptionKey: string) { | ||
this.accessToken = accessToken; | ||
this.subscriptionKey = subscriptionKey; | ||
} | ||
signRequest(webResource: WebResource): Promise<WebResource> { | ||
webResource.headers.set("Authorization", `Bearer ${this.options.accessToken}`); | ||
webResource.headers.set("X-Streetcred-Subscription-Key", this.options.subscriptionKey); | ||
webResource.headers.set("Authorization", `Bearer ${this.accessToken}`); | ||
webResource.headers.set("X-Streetcred-Subscription-Key", this.subscriptionKey); | ||
return Promise.resolve(webResource); | ||
} | ||
} |
{ | ||
"name": "@streetcred.id/service-clients", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "lib/index.ts", |
101525
9
3561