@clxmedia/credstore-client 1.0.1

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 ADDED
@@ -0,0 +1 @@
1
+ RELEASE 1.0.0
@@ -0,0 +1,31 @@
1
+ # Contributing
2
+
3
+ 1. [Fork it](https://help.github.com/articles/fork-a-repo/)
4
+ 2. Install dependencies (`npm install`)
5
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
6
+ 4. Commit your changes (`git commit -am 'Added some feature'`)
7
+ 5. Test your changes (`npm test`)
8
+ 6. Push to the branch (`git push origin my-new-feature`)
9
+ 7. [Create new Pull Request](https://help.github.com/articles/creating-a-pull-request/)
10
+
11
+ ## Testing
12
+
13
+ We use [Jest](https://github.com/facebook/jest) to write tests. Run our test suite with this command:
14
+
15
+ ```
16
+ npm test
17
+ ```
18
+
19
+ ## Code Style
20
+
21
+ We use [Prettier](https://prettier.io/) and tslint to maintain code style and best practices.
22
+ Please make sure your PR adheres to the guides by running:
23
+
24
+ ```
25
+ npm run format
26
+ ```
27
+
28
+ and
29
+ ```
30
+ npm run lint
31
+ ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 John Biundo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ <h1 align="center"></h1>
2
+
3
+ <div align="center">
4
+ <a href="http://nestjs.com/" target="_blank">
5
+ <img src="https://nestjs.com/img/logo_text.svg" width="150" alt="Nest Logo" />
6
+ </a>
7
+ </div>
8
+
9
+ <h3 align="center">NestJS npm Package Starter</h3>
10
+
11
+ <div align="center">
12
+ <a href="https://nestjs.com" target="_blank">
13
+ <img src="https://img.shields.io/badge/built%20with-NestJs-red.svg" alt="Built with NestJS">
14
+ </a>
15
+ </div>
16
+
17
+ ### Installation
18
+
19
+ 1. Clone the repo
20
+ 2. Run npm/yarn install
21
+
22
+ ```bash
23
+ cd nestjs-package-starter
24
+ npm install
25
+ ```
26
+
27
+ ## Change Log
28
+
29
+ See [Changelog](CHANGELOG.md) for more information.
30
+
31
+ ## Contributing
32
+
33
+ Contributions welcome! See [Contributing](CONTRIBUTING.md).
34
+
35
+ ## Author
36
+
37
+ **John Biundo (Y Prospect on [Discord](https://discord.gg/G7Qnnhy))**
38
+
39
+ ## License
40
+
41
+ Licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,12 @@
1
+ export declare class CredStoreClient {
2
+ private apiServer;
3
+ private apiKey;
4
+ private httpService;
5
+ constructor(apiServer: string, apiKey: string);
6
+ fetchUpdatedCredential(guid: string, master_id: number): Promise<any>;
7
+ createCredential(master_id: number, provider: string, credData: any, name?: string): Promise<any>;
8
+ updateCredential(guid: string, data: any): Promise<any>;
9
+ patchData(url: string, data: any): Promise<any>;
10
+ postData(url: string, data: any): Promise<any>;
11
+ fetchData(url: string): Promise<any>;
12
+ }
package/dist/client.js ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CredStoreClient = void 0;
13
+ const axios_1 = require("@nestjs/axios");
14
+ const rxjs_1 = require("rxjs");
15
+ class CredStoreClient {
16
+ constructor(apiServer, apiKey) {
17
+ this.httpService = new axios_1.HttpService();
18
+ this.apiServer = apiServer;
19
+ this.apiKey = apiKey;
20
+ }
21
+ fetchUpdatedCredential(guid, master_id) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ return yield this.fetchData(`credentials/${master_id}/${guid}`);
24
+ });
25
+ }
26
+ createCredential(master_id, provider, credData, name) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const data = {
29
+ provider,
30
+ name,
31
+ payload: credData
32
+ };
33
+ return yield this.postData(`credentials/${master_id}`, data);
34
+ });
35
+ }
36
+ updateCredential(guid, data) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ return yield this.patchData(`credentials/${guid}`, data);
39
+ });
40
+ }
41
+ patchData(url, data) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const config = {
44
+ headers: { 'x-credstore-admin-key': this.apiKey },
45
+ };
46
+ const requestUrl = `${this.apiServer}/${url}`;
47
+ const response = yield (0, rxjs_1.lastValueFrom)(this.httpService.patch(requestUrl, data, config).pipe((0, rxjs_1.map)((response) => {
48
+ return response.data;
49
+ })));
50
+ return response;
51
+ });
52
+ }
53
+ postData(url, data) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const config = {
56
+ headers: { 'x-credstore-admin-key': this.apiKey },
57
+ };
58
+ const requestUrl = `${this.apiServer}/${url}`;
59
+ const response = yield (0, rxjs_1.lastValueFrom)(this.httpService.post(requestUrl, data, config).pipe((0, rxjs_1.map)((response) => {
60
+ return response.data;
61
+ })));
62
+ return response;
63
+ });
64
+ }
65
+ fetchData(url) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ const config = {
68
+ headers: { 'x-credstore-admin-key': this.apiKey },
69
+ };
70
+ const requestUrl = `${this.apiServer}/${url}`;
71
+ const response = yield (0, rxjs_1.lastValueFrom)(this.httpService.get(requestUrl, config).pipe((0, rxjs_1.map)((response) => {
72
+ return response.data;
73
+ })));
74
+ return response;
75
+ });
76
+ }
77
+ }
78
+ exports.CredStoreClient = CredStoreClient;
@@ -0,0 +1 @@
1
+ export * from './client';
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client"), exports);
@@ -0,0 +1,11 @@
1
+ import { HttpService } from '@nestjs/axios';
2
+ export declare class CredStoreClientService {
3
+ private readonly httpService;
4
+ constructor(httpService: HttpService);
5
+ fetchUpdatedCredential(guid: string, master_id: number): Promise<any>;
6
+ createCredential(master_id: number, provider: string, credData: any, name?: string): Promise<any>;
7
+ updateCredential(guid: string, data: any): Promise<any>;
8
+ patchData(url: string, data: any): Promise<any>;
9
+ postData(url: string, data: any): Promise<any>;
10
+ fetchData(url: string): Promise<any>;
11
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CredStoreClientService = void 0;
13
+ const rxjs_1 = require("rxjs");
14
+ class CredStoreClientService {
15
+ constructor(httpService) {
16
+ this.httpService = httpService;
17
+ }
18
+ fetchUpdatedCredential(guid, master_id) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ return yield this.fetchData(`credentials/${master_id}/${guid}`);
21
+ });
22
+ }
23
+ createCredential(master_id, provider, credData, name) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const data = {
26
+ provider,
27
+ name,
28
+ payload: credData
29
+ };
30
+ return yield this.postData(`credentials/${master_id}`, data);
31
+ });
32
+ }
33
+ updateCredential(guid, data) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ return yield this.patchData(`credentials/${guid}`, data);
36
+ });
37
+ }
38
+ patchData(url, data) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const apiServer = 'this.configService.get<string>(ConfigKeys.credstore.api_server)';
41
+ const apiKey = 'this.configService.get<string>(ConfigKeys.xperience.admin_key)';
42
+ const config = {
43
+ headers: { 'x-credstore-admin-key': apiKey },
44
+ };
45
+ const requestUrl = `${apiServer}/${url}`;
46
+ const response = yield (0, rxjs_1.lastValueFrom)(this.httpService.patch(requestUrl, data, config).pipe((0, rxjs_1.map)((response) => {
47
+ return response.data;
48
+ })));
49
+ return response;
50
+ });
51
+ }
52
+ postData(url, data) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const apiServer = 'this.configService.get<string>(ConfigKeys.credstore.api_server)';
55
+ const apiKey = 'this.configService.get<string>(ConfigKeys.xperience.admin_key)';
56
+ const config = {
57
+ headers: { 'x-credstore-admin-key': apiKey },
58
+ };
59
+ const requestUrl = `${apiServer}/${url}`;
60
+ const response = yield (0, rxjs_1.lastValueFrom)(this.httpService.post(requestUrl, data, config).pipe((0, rxjs_1.map)((response) => {
61
+ return response.data;
62
+ })));
63
+ return response;
64
+ });
65
+ }
66
+ fetchData(url) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const apiServer = 'this.configService.get<string>(ConfigKeys.credstore.api_server)';
69
+ const apiKey = 'this.configService.get<string>(ConfigKeys.xperience.admin_key)';
70
+ const config = {
71
+ headers: { 'x-credstore-admin-key': apiKey },
72
+ };
73
+ const requestUrl = `${apiServer}/${url}`;
74
+ const response = yield (0, rxjs_1.lastValueFrom)(this.httpService.get(requestUrl, config).pipe((0, rxjs_1.map)((response) => {
75
+ return response.data;
76
+ })));
77
+ return response;
78
+ });
79
+ }
80
+ }
81
+ exports.CredStoreClientService = CredStoreClientService;
package/dist/test.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function getHello(): string;
package/dist/test.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHello = void 0;
4
+ function getHello() {
5
+ return 'Hello from the new package!';
6
+ }
7
+ exports.getHello = getHello;
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@clxmedia/credstore-client",
3
+ "version": "1.0.1",
4
+ "description": "CLXperience CredStore Client",
5
+ "author": "Brandon Thompson <brandont@clxmedia.com>",
6
+ "license": "MIT",
7
+ "readmeFilename": "README.md",
8
+ "main": "dist/test.js",
9
+ "files": [
10
+ "dist/**/*",
11
+ "*.md"
12
+ ],
13
+ "scripts": {
14
+ "start:dev": "tsc -w",
15
+ "build": "tsc",
16
+ "prepare": "npm run build",
17
+ "format": "prettier --write \"src/**/*.ts\"",
18
+ "lint": "tslint -p tsconfig.json -c tslint.json",
19
+ "test": "jest",
20
+ "test:watch": "jest --watch",
21
+ "test:cov": "jest --coverage",
22
+ "test:e2e": "jest --config ./test/jest-e2e.json"
23
+ },
24
+ "keywords": [
25
+ "nestjs"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/btaustin/credstore-client"
33
+ },
34
+ "bugs": "https://github.com/btaustin/credstore-client",
35
+ "peerDependencies": {
36
+ "@nestjs/common": "^8.1.1"
37
+ },
38
+ "dependencies": {
39
+ "@nestjs/axios": "^0.1.0"
40
+ },
41
+ "devDependencies": {
42
+ "@nestjs/common": "^8.1.1",
43
+ "@nestjs/core": "^8.1.1",
44
+ "@nestjs/platform-express": "^8.1.1",
45
+ "@nestjs/testing": "8.1.1",
46
+ "@types/jest": "28.1.7",
47
+ "@types/node": "16.11.7",
48
+ "@types/supertest": "2.0.12",
49
+ "jest": "28.1.3",
50
+ "prettier": "2.7.1",
51
+ "supertest": "6.2.4",
52
+ "ts-jest": "28.0.8",
53
+ "ts-node": "10.9.1",
54
+ "tsc-watch": "5.0.3",
55
+ "tsconfig-paths": "4.1.0",
56
+ "tslint": "6.1.3",
57
+ "typescript": "4.7.4"
58
+ },
59
+ "jest": {
60
+ "moduleFileExtensions": [
61
+ "js",
62
+ "json",
63
+ "ts"
64
+ ],
65
+ "rootDir": "src",
66
+ "testRegex": ".spec.ts$",
67
+ "transform": {
68
+ "^.+\\.(t|j)s$": "ts-jest"
69
+ },
70
+ "coverageDirectory": "../coverage",
71
+ "testEnvironment": "node"
72
+ }
73
+ }