@clxmedia/credstore-client 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
1
  RELEASE 1.0.14
2
2
 
3
3
  - Adds MailJet as new credential type
4
- - Adds ability to tell CredStore to forcibly skip the cache and grab latest credential from db
4
+ - Adds ability to tell CredStore to forcibly skip the cache and grab latest credential from db
5
+
6
+ RELEASE 1.0.15
7
+
8
+ - Adds guid secrets to client interface
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export interface CredStoreConfig {
2
2
  api_server: string;
3
- api_key: string;
3
+ api_key?: string;
4
4
  }
5
5
  export declare enum CredentialProvider {
6
6
  generic = "generic",
@@ -66,15 +66,25 @@ export interface YardiCredential extends BaseCredential {
66
66
  interfaceEntity: string;
67
67
  interfaceLicense: string;
68
68
  }
69
- export interface FetchOptions {
69
+ export interface FetchOptions extends OptionsBase {
70
70
  skipCache?: boolean;
71
71
  }
72
+ export interface UpdateOptions extends OptionsBase {
73
+ }
74
+ export interface OptionsBase {
75
+ guidSecret?: string;
76
+ }
72
77
  export declare class CredStoreClient {
73
78
  private apiServer;
74
- private headerConfig;
79
+ private apiKey?;
75
80
  private httpService;
76
81
  constructor(config: CredStoreConfig);
82
+ buildHeaders(guidSecret?: string, skipCache?: boolean): {
83
+ 'x-credstore-skip-cache': string;
84
+ 'x-credstore-secret': string;
85
+ 'x-credstore-admin-key': string;
86
+ };
77
87
  fetchCredential(guid: string, fetchOptions?: FetchOptions): Promise<CredStoreBundle>;
78
88
  createCredential(provider: CredentialProvider, credData: EntrataCredential | RealPageCredential | YardiCredential | GenericCredential | MailJetCredential): Promise<any>;
79
- updateCredential(guid: string, data: any): Promise<any>;
89
+ updateCredential(guid: string, data: any, updateOptions?: UpdateOptions): Promise<any>;
80
90
  }
package/dist/client.js CHANGED
@@ -25,28 +25,34 @@ class CredStoreClient {
25
25
  constructor(config) {
26
26
  this.httpService = new axios_1.HttpService();
27
27
  this.apiServer = config.api_server;
28
- this.headerConfig = {
29
- headers: { 'x-credstore-admin-key': config.api_key },
28
+ this.apiKey = config.api_key;
29
+ }
30
+ buildHeaders(guidSecret, skipCache) {
31
+ return {
32
+ 'x-credstore-skip-cache': `${skipCache}`,
33
+ 'x-credstore-secret': guidSecret,
34
+ 'x-credstore-admin-key': this.apiKey
30
35
  };
31
36
  }
32
37
  fetchCredential(guid, fetchOptions) {
33
38
  return __awaiter(this, void 0, void 0, function* () {
34
- const skipCache = fetchOptions && fetchOptions.skipCache;
35
- return yield (0, rxjs_1.lastValueFrom)(this.httpService.get(`${this.apiServer}/credentials/${guid}`, { headers: Object.assign(Object.assign({}, this.headerConfig.headers), { 'x-credstore-skip-cache': `${skipCache}` }) }).pipe((0, rxjs_1.map)((response) => {
39
+ const { guidSecret, skipCache } = fetchOptions;
40
+ return yield (0, rxjs_1.lastValueFrom)(this.httpService.get(`${this.apiServer}/credentials/${guid}`, { headers: this.buildHeaders(guidSecret, skipCache) }).pipe((0, rxjs_1.map)((response) => {
36
41
  return response.data;
37
42
  })));
38
43
  });
39
44
  }
40
45
  createCredential(provider, credData) {
41
46
  return __awaiter(this, void 0, void 0, function* () {
42
- return yield (0, rxjs_1.lastValueFrom)(this.httpService.post(`${this.apiServer}/credentials/${provider}`, credData, this.headerConfig).pipe((0, rxjs_1.map)((response) => {
47
+ return yield (0, rxjs_1.lastValueFrom)(this.httpService.post(`${this.apiServer}/credentials/${provider}`, credData, { headers: this.buildHeaders() }).pipe((0, rxjs_1.map)((response) => {
43
48
  return response.data;
44
49
  })));
45
50
  });
46
51
  }
47
- updateCredential(guid, data) {
52
+ updateCredential(guid, data, updateOptions) {
48
53
  return __awaiter(this, void 0, void 0, function* () {
49
- return yield (0, rxjs_1.lastValueFrom)(this.httpService.patch(`${this.apiServer}/credentials/${guid}`, data, this.headerConfig).pipe((0, rxjs_1.map)((response) => {
54
+ const { guidSecret } = updateOptions;
55
+ return yield (0, rxjs_1.lastValueFrom)(this.httpService.patch(`${this.apiServer}/credentials/${guid}`, data, { headers: this.buildHeaders(guidSecret) }).pipe((0, rxjs_1.map)((response) => {
50
56
  return response.data;
51
57
  })));
52
58
  });
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { CredStoreClient, CredStoreConfig, CredentialAttribute, BaseCredential, EntrataCredential, RealPageCredential, YardiCredential, MailJetCredential, GenericCredential, CredStoreBundle, EntrataCredStoreBundle, RealPageCredStoreBundle, YardiCredStoreBundle, MailJetCredStoreBundle, CredentialProvider, FetchOptions } from './client';
1
+ export { CredStoreClient, CredStoreConfig, CredentialAttribute, BaseCredential, EntrataCredential, RealPageCredential, YardiCredential, MailJetCredential, GenericCredential, CredStoreBundle, EntrataCredStoreBundle, RealPageCredStoreBundle, YardiCredStoreBundle, MailJetCredStoreBundle, CredentialProvider, FetchOptions, UpdateOptions, OptionsBase } from './client';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clxmedia/credstore-client",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "CLXperience CredStore Client",
5
5
  "author": "Brandon Thompson <brandont@clxmedia.com>",
6
6
  "license": "MIT",