@onivoro/server-aws-sts 22.0.0

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.
@@ -0,0 +1,3 @@
1
+ export * from './lib/classes/server-aws-sts-config.class';
2
+ export * from './lib/services/sts.service';
3
+ export * from './lib/server-aws-sts.module';
@@ -0,0 +1,19 @@
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("./lib/classes/server-aws-sts-config.class"), exports);
18
+ __exportStar(require("./lib/services/sts.service"), exports);
19
+ __exportStar(require("./lib/server-aws-sts.module"), exports);
@@ -0,0 +1,6 @@
1
+ export declare class ServerAwsStsConfig {
2
+ AWS_ACCESS_KEY_ID: string;
3
+ AWS_REGION: string;
4
+ AWS_SECRET_ACCESS_KEY: string;
5
+ NODE_ENV: string;
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServerAwsStsConfig = void 0;
4
+ class ServerAwsStsConfig {
5
+ AWS_ACCESS_KEY_ID;
6
+ AWS_REGION;
7
+ AWS_SECRET_ACCESS_KEY;
8
+ NODE_ENV;
9
+ }
10
+ exports.ServerAwsStsConfig = ServerAwsStsConfig;
@@ -0,0 +1,4 @@
1
+ import { ServerAwsStsConfig } from './classes/server-aws-sts-config.class';
2
+ export declare class ServerAwsStsModule {
3
+ static configure(config: ServerAwsStsConfig): any;
4
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var ServerAwsStsModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ServerAwsStsModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const server_common_1 = require("@onivoro/server-common");
13
+ const client_sts_1 = require("@aws-sdk/client-sts");
14
+ const sts_service_1 = require("./services/sts.service");
15
+ const server_aws_sts_config_class_1 = require("./classes/server-aws-sts-config.class");
16
+ let stsClient = null;
17
+ let ServerAwsStsModule = ServerAwsStsModule_1 = class ServerAwsStsModule {
18
+ static configure(config) {
19
+ return (0, server_common_1.moduleFactory)({
20
+ module: ServerAwsStsModule_1,
21
+ providers: [
22
+ {
23
+ provide: client_sts_1.STSClient,
24
+ useFactory: () => stsClient
25
+ ? stsClient
26
+ : stsClient = new client_sts_1.STSClient({
27
+ region: config.AWS_REGION,
28
+ logger: console,
29
+ credentials: config.NODE_ENV === 'production'
30
+ ? undefined
31
+ : {
32
+ accessKeyId: config.AWS_ACCESS_KEY_ID,
33
+ secretAccessKey: config.AWS_SECRET_ACCESS_KEY
34
+ }
35
+ })
36
+ },
37
+ { provide: server_aws_sts_config_class_1.ServerAwsStsConfig, useValue: config },
38
+ sts_service_1.StsService
39
+ ]
40
+ });
41
+ }
42
+ };
43
+ exports.ServerAwsStsModule = ServerAwsStsModule;
44
+ exports.ServerAwsStsModule = ServerAwsStsModule = ServerAwsStsModule_1 = __decorate([
45
+ (0, common_1.Module)({})
46
+ ], ServerAwsStsModule);
@@ -0,0 +1,8 @@
1
+ import { STSClient } from '@aws-sdk/client-sts';
2
+ import { ServerAwsStsConfig } from '../classes/server-aws-sts-config.class';
3
+ export declare class StsService {
4
+ readonly stsClient: STSClient;
5
+ private config;
6
+ constructor(stsClient: STSClient, config: ServerAwsStsConfig);
7
+ getAccountId(): Promise<string>;
8
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StsService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const client_sts_1 = require("@aws-sdk/client-sts");
15
+ const server_aws_sts_config_class_1 = require("../classes/server-aws-sts-config.class");
16
+ let StsService = class StsService {
17
+ stsClient;
18
+ config;
19
+ constructor(stsClient, config) {
20
+ this.stsClient = stsClient;
21
+ this.config = config;
22
+ }
23
+ async getAccountId() {
24
+ const response = await this.stsClient.send(new client_sts_1.GetCallerIdentityCommand({}));
25
+ return response.Account;
26
+ }
27
+ };
28
+ exports.StsService = StsService;
29
+ exports.StsService = StsService = __decorate([
30
+ (0, common_1.Injectable)(),
31
+ __metadata("design:paramtypes", [client_sts_1.STSClient, server_aws_sts_config_class_1.ServerAwsStsConfig])
32
+ ], StsService);
@@ -0,0 +1,3 @@
1
+ export * from './lib/classes/server-aws-sts-config.class';
2
+ export * from './lib/services/sts.service';
3
+ export * from './lib/server-aws-sts.module';
@@ -0,0 +1,19 @@
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("./lib/classes/server-aws-sts-config.class"), exports);
18
+ __exportStar(require("./lib/services/sts.service"), exports);
19
+ __exportStar(require("./lib/server-aws-sts.module"), exports);
@@ -0,0 +1,6 @@
1
+ export declare class ServerAwsStsConfig {
2
+ AWS_ACCESS_KEY_ID: string;
3
+ AWS_REGION: string;
4
+ AWS_SECRET_ACCESS_KEY: string;
5
+ NODE_ENV: string;
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServerAwsStsConfig = void 0;
4
+ class ServerAwsStsConfig {
5
+ AWS_ACCESS_KEY_ID;
6
+ AWS_REGION;
7
+ AWS_SECRET_ACCESS_KEY;
8
+ NODE_ENV;
9
+ }
10
+ exports.ServerAwsStsConfig = ServerAwsStsConfig;
@@ -0,0 +1,4 @@
1
+ import { ServerAwsStsConfig } from './classes/server-aws-sts-config.class';
2
+ export declare class ServerAwsStsModule {
3
+ static configure(config: ServerAwsStsConfig): any;
4
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var ServerAwsStsModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ServerAwsStsModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const server_common_1 = require("@onivoro/server-common");
13
+ const client_sts_1 = require("@aws-sdk/client-sts");
14
+ const sts_service_1 = require("./services/sts.service");
15
+ const server_aws_sts_config_class_1 = require("./classes/server-aws-sts-config.class");
16
+ let stsClient = null;
17
+ let ServerAwsStsModule = ServerAwsStsModule_1 = class ServerAwsStsModule {
18
+ static configure(config) {
19
+ return (0, server_common_1.moduleFactory)({
20
+ module: ServerAwsStsModule_1,
21
+ providers: [
22
+ {
23
+ provide: client_sts_1.STSClient,
24
+ useFactory: () => stsClient
25
+ ? stsClient
26
+ : stsClient = new client_sts_1.STSClient({
27
+ region: config.AWS_REGION,
28
+ logger: console,
29
+ credentials: config.NODE_ENV === 'production'
30
+ ? undefined
31
+ : {
32
+ accessKeyId: config.AWS_ACCESS_KEY_ID,
33
+ secretAccessKey: config.AWS_SECRET_ACCESS_KEY
34
+ }
35
+ })
36
+ },
37
+ { provide: server_aws_sts_config_class_1.ServerAwsStsConfig, useValue: config },
38
+ sts_service_1.StsService
39
+ ]
40
+ });
41
+ }
42
+ };
43
+ exports.ServerAwsStsModule = ServerAwsStsModule;
44
+ exports.ServerAwsStsModule = ServerAwsStsModule = ServerAwsStsModule_1 = __decorate([
45
+ (0, common_1.Module)({})
46
+ ], ServerAwsStsModule);
@@ -0,0 +1,8 @@
1
+ import { STSClient } from '@aws-sdk/client-sts';
2
+ import { ServerAwsStsConfig } from '../classes/server-aws-sts-config.class';
3
+ export declare class StsService {
4
+ readonly stsClient: STSClient;
5
+ private config;
6
+ constructor(stsClient: STSClient, config: ServerAwsStsConfig);
7
+ getAccountId(): Promise<string>;
8
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StsService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const client_sts_1 = require("@aws-sdk/client-sts");
15
+ const server_aws_sts_config_class_1 = require("../classes/server-aws-sts-config.class");
16
+ let StsService = class StsService {
17
+ stsClient;
18
+ config;
19
+ constructor(stsClient, config) {
20
+ this.stsClient = stsClient;
21
+ this.config = config;
22
+ }
23
+ async getAccountId() {
24
+ const response = await this.stsClient.send(new client_sts_1.GetCallerIdentityCommand({}));
25
+ return response.Account;
26
+ }
27
+ };
28
+ exports.StsService = StsService;
29
+ exports.StsService = StsService = __decorate([
30
+ (0, common_1.Injectable)(),
31
+ __metadata("design:paramtypes", [client_sts_1.STSClient, server_aws_sts_config_class_1.ServerAwsStsConfig])
32
+ ], StsService);
@@ -0,0 +1,3 @@
1
+ export * from './lib/classes/server-aws-sts-config.class';
2
+ export * from './lib/services/sts.service';
3
+ export * from './lib/server-aws-sts.module';
@@ -0,0 +1,6 @@
1
+ export declare class ServerAwsStsConfig {
2
+ AWS_ACCESS_KEY_ID: string;
3
+ AWS_REGION: string;
4
+ AWS_SECRET_ACCESS_KEY: string;
5
+ NODE_ENV: string;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { ServerAwsStsConfig } from './classes/server-aws-sts-config.class';
2
+ export declare class ServerAwsStsModule {
3
+ static configure(config: ServerAwsStsConfig): any;
4
+ }
@@ -0,0 +1,8 @@
1
+ import { STSClient } from '@aws-sdk/client-sts';
2
+ import { ServerAwsStsConfig } from '../classes/server-aws-sts-config.class';
3
+ export declare class StsService {
4
+ readonly stsClient: STSClient;
5
+ private config;
6
+ constructor(stsClient: STSClient, config: ServerAwsStsConfig);
7
+ getAccountId(): Promise<string>;
8
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@onivoro/server-aws-sts",
3
+ "version": "22.0.0",
4
+ "repository": {
5
+ "url": "git+https://github.com/onivoro/server-aws-sts.git"
6
+ },
7
+ "main": "dist/cjs/index.js",
8
+ "module": "dist/esm/index.js",
9
+ "types": "dist/types/index.d.ts",
10
+ "files": [
11
+ "dist/*"
12
+ ],
13
+ "scripts": {
14
+ "onx": "onx",
15
+ "build": "onx Build",
16
+ "deploy": "onx Publish",
17
+ "test": "onx Test",
18
+ "update": "onx Update"
19
+ },
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/types/index.d.ts",
23
+ "require": "./dist/cjs/index.js",
24
+ "import": "./dist/esm/index.js",
25
+ "default": "./dist/esm/lib.js"
26
+ }
27
+ },
28
+ "onx": {
29
+ "platform": "server",
30
+ "module": "commonjs"
31
+ },
32
+ "devDependencies": {
33
+ "@onivoro/cli": "^22.0.8",
34
+ "@types/jest": "*",
35
+ "@types/node": "22.8.1",
36
+ "typescript": "*"
37
+ },
38
+ "engines": {
39
+ "node": "22.10.0",
40
+ "npm": "10.9.0"
41
+ },
42
+ "dependencies": {
43
+ "@aws-sdk/client-sts": "^3.699.0",
44
+ "@nestjs/common": "^10.4.6",
45
+ "@onivoro/server-common": "^22.0.3"
46
+ }
47
+ }