@secretary/aws-ssm-parameter-store-adapter 4.2.3
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/.mocharc.js +7 -0
- package/README.md +25 -0
- package/dist/Adapter.d.ts +12 -0
- package/dist/Adapter.js +49 -0
- package/dist/Adapter.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/eslint.json +3 -0
- package/package.json +53 -0
package/.mocharc.js
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Secretary - AWS SSM Parameter Store Adapter
|
|
2
|
+
|
|
3
|
+
This is the [AWS SSM Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html) adapter
|
|
4
|
+
for [Secretary](https://github.com/secretary/node)
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
$ npm install @secretary/core @secretary/aws-ssm-parameter-store-adapter
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Creating the manager
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import {Manager} from '@secretary/core';
|
|
18
|
+
import {Adapter} from '@secretary/aws-ssm-parameter-store-adapter';
|
|
19
|
+
import {SSM} from '@aws-sdk/client-ssm';
|
|
20
|
+
|
|
21
|
+
const manager = new Manager({aws: new Adapter(new SSM({region: 'us-east-1'}))});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Secrets are written as `SecureString` parameters by default. Pass `Type: 'String'` (or a
|
|
25
|
+
custom `KeyId`) through the put options to change that.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DeleteParameterRequest, GetParameterRequest, PutParameterRequest, SSM } from '@aws-sdk/client-ssm';
|
|
2
|
+
import { AbstractAdapter, Secret, SecretValueType } from '@secretary/core';
|
|
3
|
+
export type GetSecretOptions = Omit<GetParameterRequest, 'Name'>;
|
|
4
|
+
export type PutSecretOptions = Omit<PutParameterRequest, 'Name' | 'Value'>;
|
|
5
|
+
export type DeleteSecretOptions = Omit<DeleteParameterRequest, 'Name'>;
|
|
6
|
+
export default class Adapter extends AbstractAdapter {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(client: SSM);
|
|
9
|
+
getSecret<V extends SecretValueType = SecretValueType>(key: string, options?: GetSecretOptions): Promise<Secret<V>>;
|
|
10
|
+
putSecret<V extends SecretValueType = SecretValueType>(secret: Secret<V>, options?: PutSecretOptions): Promise<Secret<V>>;
|
|
11
|
+
deleteSecret<V extends SecretValueType = SecretValueType>(secret: Secret<V>, options?: DeleteSecretOptions): Promise<void>;
|
|
12
|
+
}
|
package/dist/Adapter.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@secretary/core");
|
|
4
|
+
const isNotFound = (e) => (e === null || e === void 0 ? void 0 : e.name) === 'ParameterNotFound' || (e === null || e === void 0 ? void 0 : e.__type) === 'ParameterNotFound';
|
|
5
|
+
class Adapter extends core_1.AbstractAdapter {
|
|
6
|
+
constructor(client) {
|
|
7
|
+
super();
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
async getSecret(key, options = {}) {
|
|
11
|
+
var _a;
|
|
12
|
+
const params = Object.assign({ Name: key, WithDecryption: true }, options);
|
|
13
|
+
try {
|
|
14
|
+
const data = await this.client.getParameter(params);
|
|
15
|
+
const value = (_a = data.Parameter) === null || _a === void 0 ? void 0 : _a.Value;
|
|
16
|
+
let secretValue = value;
|
|
17
|
+
try {
|
|
18
|
+
secretValue = JSON.parse(value);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
return new core_1.Secret(key, secretValue);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
if (isNotFound(e)) {
|
|
26
|
+
throw new core_1.SecretNotFoundError(key);
|
|
27
|
+
}
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async putSecret(secret, options = {}) {
|
|
32
|
+
const params = Object.assign({ Name: secret.key, Value: typeof secret.value === 'string' ? secret.value : JSON.stringify(secret.value), Type: 'SecureString', Overwrite: true }, options);
|
|
33
|
+
const response = await this.client.putParameter(params);
|
|
34
|
+
return secret.withMetadata(response.$metadata);
|
|
35
|
+
}
|
|
36
|
+
async deleteSecret(secret, options = {}) {
|
|
37
|
+
try {
|
|
38
|
+
await this.client.deleteParameter(Object.assign(Object.assign({}, options), { Name: secret.key }));
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (isNotFound(e)) {
|
|
42
|
+
throw new core_1.SecretNotFoundError(secret.key);
|
|
43
|
+
}
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.default = Adapter;
|
|
49
|
+
//# sourceMappingURL=Adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Adapter.js","sourceRoot":"","sources":["../src/Adapter.ts"],"names":[],"mappings":";;AAMA,0CAA8F;AAQ9F,MAAM,UAAU,GAAG,CAAC,CAAU,EAAW,EAAE,CACvC,CAAC,CAA6B,aAA7B,CAAC,uBAAD,CAAC,CAA8B,IAAI,MAAK,mBAAmB,IAAI,CAAC,CAA6B,aAA7B,CAAC,uBAAD,CAAC,CAA8B,MAAM,MAAK,mBAAmB,CAAC;AAEnI,MAAqB,OAAQ,SAAQ,sBAAe;IAChD,YAAoC,MAAW;QAC3C,KAAK,EAAE,CAAC;QADwB,WAAM,GAAN,MAAM,CAAK;IAE/C,CAAC;IAEM,KAAK,CAAC,SAAS,CAClB,GAAW,EACX,UAA4B,EAAE;;QAE9B,MAAM,MAAM,mBAAyB,IAAI,EAAE,GAAG,EAAE,cAAc,E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ACrE;QAAC,OAAO,CAAC,EAAE;YACR,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE;gBACf,MAAM,IAAI,0BAAmB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aAC7C;YAED,MAAM,CAAC,CAAC;SACX;IACL,CAAC;CACJ;AA7DD,0BA6DC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Adapter, GetSecretOptions, PutSecretOptions } from './Adapter';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Adapter = void 0;
|
|
4
|
+
var Adapter_1 = require("./Adapter");
|
|
5
|
+
Object.defineProperty(exports, "Adapter", { enumerable: true, get: function () { return Adapter_1.default; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAiF;AAAzE,kGAAA,OAAO,OAAW"}
|
package/eslint.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@secretary/aws-ssm-parameter-store-adapter",
|
|
3
|
+
"description": "AWS SSM Parameter Store adapter for Secretary",
|
|
4
|
+
"version": "4.2.3",
|
|
5
|
+
"author": "Aaron Scherer <aequasi@gmail.com>",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@secretary/core": "^4.2.1"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@aws-sdk/client-ssm": "3.229.0",
|
|
11
|
+
"@types/chai-as-promised": "7.1.5",
|
|
12
|
+
"@types/eslint": "8.4.10",
|
|
13
|
+
"@typescript-eslint/eslint-plugin": "5.46.1",
|
|
14
|
+
"@typescript-eslint/parser": "5.46.1",
|
|
15
|
+
"chai-as-promised": "7.1.1",
|
|
16
|
+
"eslint": "8.29.0",
|
|
17
|
+
"eslint-config-prettier": "8.5.0",
|
|
18
|
+
"eslint-plugin-import": "2.26.0",
|
|
19
|
+
"typemoq": "2.1.0"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"nyc": {
|
|
24
|
+
"extension": [
|
|
25
|
+
".ts"
|
|
26
|
+
],
|
|
27
|
+
"include": [
|
|
28
|
+
"src/**/*.ts"
|
|
29
|
+
],
|
|
30
|
+
"exclude": [
|
|
31
|
+
"src/**/*.spec.ts"
|
|
32
|
+
],
|
|
33
|
+
"reporter": [
|
|
34
|
+
"text"
|
|
35
|
+
],
|
|
36
|
+
"all": true
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@aws-sdk/client-ssm": "^3.229.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"repository": "secretary/node",
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc --project tsconfig.json",
|
|
47
|
+
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && npx codecov",
|
|
48
|
+
"lint": "eslint --fix --config=eslint.json src",
|
|
49
|
+
"prepublishOnly": "npm run build",
|
|
50
|
+
"test": "nyc mocha"
|
|
51
|
+
},
|
|
52
|
+
"types": "dist/index.d.ts"
|
|
53
|
+
}
|