@iyio/aws 0.0.10
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/README.md +11 -0
- package/package.json +14 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +8 -0
- package/src/index.js.map +1 -0
- package/src/lib/AwsHttpRequestSigner.d.ts +16 -0
- package/src/lib/AwsHttpRequestSigner.js +65 -0
- package/src/lib/AwsHttpRequestSigner.js.map +1 -0
- package/src/lib/_modules.aws.d.ts +2 -0
- package/src/lib/_modules.aws.js +10 -0
- package/src/lib/_modules.aws.js.map +1 -0
- package/src/lib/_types.aws.d.ts +5 -0
- package/src/lib/_types.aws.js +9 -0
- package/src/lib/_types.aws.js.map +1 -0
- package/src/lib/aws-auth.d.ts +7 -0
- package/src/lib/aws-auth.js +3 -0
- package/src/lib/aws-auth.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iyio/aws",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {},
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"@iyio/common": "0.0.10",
|
|
10
|
+
"rxjs": "^7.5.7",
|
|
11
|
+
"uuid": "^9.0.0",
|
|
12
|
+
"tslib": "^2.3.0"
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./lib/aws-auth"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./lib/AwsHttpRequestSigner"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/_modules.aws"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./lib/_types.aws"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/aws/src/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,qEAA2C;AAC3C,6DAAmC;AACnC,2DAAiC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseHttpRequest, IHttpRequestSigner, Scope, TypeDef } from '@iyio/common';
|
|
2
|
+
import { IAwsAuth } from './aws-auth';
|
|
3
|
+
export interface AwsHttpRequestSignerOptions {
|
|
4
|
+
awsAuthProviders: TypeDef<IAwsAuth>;
|
|
5
|
+
region: string;
|
|
6
|
+
service: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class AwsHttpRequestSigner implements IHttpRequestSigner {
|
|
9
|
+
static optionsFromScope(scope: Scope): AwsHttpRequestSignerOptions;
|
|
10
|
+
static fromScope(scope: Scope): AwsHttpRequestSigner;
|
|
11
|
+
private readonly options;
|
|
12
|
+
private signingPair;
|
|
13
|
+
constructor(options: AwsHttpRequestSignerOptions);
|
|
14
|
+
canSign(): boolean;
|
|
15
|
+
sign(request: BaseHttpRequest): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AwsHttpRequestSigner = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sha256_browser_1 = require("@aws-crypto/sha256-browser");
|
|
6
|
+
const protocol_http_1 = require("@aws-sdk/protocol-http");
|
|
7
|
+
const signature_v4_1 = require("@aws-sdk/signature-v4");
|
|
8
|
+
const _types_aws_1 = require("./_types.aws");
|
|
9
|
+
class AwsHttpRequestSigner {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.signingPair = null;
|
|
12
|
+
this.options = Object.assign({}, options);
|
|
13
|
+
}
|
|
14
|
+
static optionsFromScope(scope) {
|
|
15
|
+
return {
|
|
16
|
+
awsAuthProviders: scope.to(_types_aws_1.IAwsAuthType),
|
|
17
|
+
region: scope.require(_types_aws_1.awsRegionParam),
|
|
18
|
+
service: scope.require(_types_aws_1.awsHttpSignerServiceParam),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
static fromScope(scope) {
|
|
22
|
+
return new AwsHttpRequestSigner(AwsHttpRequestSigner.optionsFromScope(scope));
|
|
23
|
+
}
|
|
24
|
+
canSign() {
|
|
25
|
+
var _a;
|
|
26
|
+
return ((_a = this.options.awsAuthProviders.get()) === null || _a === void 0 ? void 0 : _a.getAuthProvider()) ? true : false;
|
|
27
|
+
}
|
|
28
|
+
sign(request) {
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const authProvider = this.options.awsAuthProviders.get();
|
|
31
|
+
const credentials = authProvider === null || authProvider === void 0 ? void 0 : authProvider.getAuthProvider();
|
|
32
|
+
if (!credentials) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!this.signingPair || credentials !== this.signingPair.creds) {
|
|
36
|
+
this.signingPair = {
|
|
37
|
+
signer: new signature_v4_1.SignatureV4({
|
|
38
|
+
credentials: credentials,
|
|
39
|
+
region: this.options.region,
|
|
40
|
+
service: this.options.service,
|
|
41
|
+
sha256: sha256_browser_1.Sha256
|
|
42
|
+
}),
|
|
43
|
+
creds: credentials
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (!request.headers) {
|
|
47
|
+
request.headers = {};
|
|
48
|
+
}
|
|
49
|
+
const parts = /https?:\/\/([^/]*)/.exec(request.uri);
|
|
50
|
+
if (!parts) {
|
|
51
|
+
throw new Error('url contains no host');
|
|
52
|
+
}
|
|
53
|
+
request.headers['host'] = parts[1];
|
|
54
|
+
const signed = yield this.signingPair.signer.sign(new protocol_http_1.HttpRequest(Object.assign({}, request)));
|
|
55
|
+
if (signed.headers) {
|
|
56
|
+
request.headers = {};
|
|
57
|
+
for (const e in signed.headers) {
|
|
58
|
+
request.headers[e] = signed.headers[e];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.AwsHttpRequestSigner = AwsHttpRequestSigner;
|
|
65
|
+
//# sourceMappingURL=AwsHttpRequestSigner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AwsHttpRequestSigner.js","sourceRoot":"","sources":["../../../../../packages/aws/src/lib/AwsHttpRequestSigner.ts"],"names":[],"mappings":";;;;AAAA,+DAAoD;AACpD,0DAAqD;AACrD,wDAAoD;AAGpD,6CAAuF;AAWvF,MAAa,oBAAoB;IAmB7B,YAAmB,OAAmC;QAF9C,gBAAW,GAAqC,IAAI,CAAC;QAIzD,IAAI,CAAC,OAAO,qBAAK,OAAO,CAAC,CAAA;IAC7B,CAAC;IAnBM,MAAM,CAAC,gBAAgB,CAAC,KAAW;QACtC,OAAO;YACH,gBAAgB,EAAC,KAAK,CAAC,EAAE,CAAC,yBAAY,CAAC;YACvC,MAAM,EAAC,KAAK,CAAC,OAAO,CAAC,2BAAc,CAAC;YACpC,OAAO,EAAC,KAAK,CAAC,OAAO,CAAC,sCAAyB,CAAC;SACnD,CAAA;IACL,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,KAAW;QAC/B,OAAO,IAAI,oBAAoB,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAClF,CAAC;IAWM,OAAO;;QACV,OAAO,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAAE,0CAAE,eAAe,EAAE,EAAA,CAAC,CAAA,IAAI,CAAA,CAAC,CAAA,KAAK,CAAC;IAC7E,CAAC;IAEY,IAAI,CAAC,OAAwB;;YAEtC,MAAM,YAAY,GAAC,I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,CAAC;iBACxC;aACJ;QACL,CAAC;KAAA;CAEJ;AAxED,oDAwEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.awsModule = void 0;
|
|
4
|
+
const common_1 = require("@iyio/common");
|
|
5
|
+
const AwsHttpRequestSigner_1 = require("./AwsHttpRequestSigner");
|
|
6
|
+
const awsModule = (scope) => {
|
|
7
|
+
scope.provideForType(common_1.IHttpRequestSignerType, scope => AwsHttpRequestSigner_1.AwsHttpRequestSigner.fromScope(scope));
|
|
8
|
+
};
|
|
9
|
+
exports.awsModule = awsModule;
|
|
10
|
+
//# sourceMappingURL=_modules.aws.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_modules.aws.js","sourceRoot":"","sources":["../../../../../packages/aws/src/lib/_modules.aws.ts"],"names":[],"mappings":";;;AAAA,yCAAyE;AACzE,iEAA8D;AAEvD,MAAM,SAAS,GAAC,CAAC,KAAuB,EAAC,EAAE;IAC9C,KAAK,CAAC,cAAc,CAAC,+BAAsB,EAAC,KAAK,CAAA,EAAE,CAAA,2CAAoB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9F,CAAC,CAAA;AAFY,QAAA,SAAS,aAErB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IAwsAuth } from "./aws-auth";
|
|
2
|
+
export declare const IAwsAuthType: import("@iyio/common").TypeDef<IAwsAuth>;
|
|
3
|
+
export declare const awsRegionParam: import("@iyio/common").CallableTypeDef<string>;
|
|
4
|
+
export declare const awsProfileParam: import("@iyio/common").CallableTypeDef<string>;
|
|
5
|
+
export declare const awsHttpSignerServiceParam: import("@iyio/common").CallableTypeDef<string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.awsHttpSignerServiceParam = exports.awsProfileParam = exports.awsRegionParam = exports.IAwsAuthType = void 0;
|
|
4
|
+
const common_1 = require("@iyio/common");
|
|
5
|
+
exports.IAwsAuthType = (0, common_1.defineType)("IAwsAuthType");
|
|
6
|
+
exports.awsRegionParam = (0, common_1.defineStringParam)('AWS_REGION');
|
|
7
|
+
exports.awsProfileParam = (0, common_1.defineStringParam)('ASW_PROFILE');
|
|
8
|
+
exports.awsHttpSignerServiceParam = (0, common_1.defineStringParam)('AWS_HTTP_SIGNER_SERVICE', 'lambda');
|
|
9
|
+
//# sourceMappingURL=_types.aws.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_types.aws.js","sourceRoot":"","sources":["../../../../../packages/aws/src/lib/_types.aws.ts"],"names":[],"mappings":";;;AAAA,yCAA6D;AAGhD,QAAA,YAAY,GAAC,IAAA,mBAAU,EAAW,cAAc,CAAC,CAAC;AAElD,QAAA,cAAc,GAAC,IAAA,0BAAiB,EAAC,YAAY,CAAC,CAAC;AAC/C,QAAA,eAAe,GAAC,IAAA,0BAAiB,EAAC,aAAa,CAAC,CAAC;AAEjD,QAAA,yBAAyB,GAAC,IAAA,0BAAiB,EAAC,yBAAyB,EAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-auth.js","sourceRoot":"","sources":["../../../../../packages/aws/src/lib/aws-auth.ts"],"names":[],"mappings":""}
|