quidproquo-actionprocessor-awslambda 0.1.9 → 0.1.11
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/lib/commonjs/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +2 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js.map +1 -1
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectoryRevokeRefreshTokenActionProcessor.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectoryRevokeRefreshTokenActionProcessor.js +41 -0
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectoryRevokeRefreshTokenActionProcessor.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectorySignOutUserActionProcessor.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectorySignOutUserActionProcessor.js +37 -0
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectorySignOutUserActionProcessor.js.map +1 -0
- package/lib/commonjs/getActionProcessor/core/userDirectory/index.js +3 -1
- package/lib/commonjs/getActionProcessor/core/userDirectory/index.js.map +1 -1
- package/lib/commonjs/getActionProcessor/webserver/email/getEmailSendEmailActionProcessor.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/webserver/email/getEmailSendEmailActionProcessor.js +43 -0
- package/lib/commonjs/getActionProcessor/webserver/email/getEmailSendEmailActionProcessor.js.map +1 -0
- package/lib/commonjs/getActionProcessor/webserver/email/getEmailSetDeliveryStatusActionProcessor.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/webserver/email/getEmailSetDeliveryStatusActionProcessor.js +26 -0
- package/lib/commonjs/getActionProcessor/webserver/email/getEmailSetDeliveryStatusActionProcessor.js.map +1 -0
- package/lib/commonjs/getActionProcessor/webserver/email/index.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/webserver/email/index.js +19 -0
- package/lib/commonjs/getActionProcessor/webserver/email/index.js.map +1 -0
- package/lib/commonjs/getActionProcessor/webserver/index.d.ts +1 -0
- package/lib/commonjs/getActionProcessor/webserver/index.js +3 -1
- package/lib/commonjs/getActionProcessor/webserver/index.js.map +1 -1
- package/lib/commonjs/logic/cognito/globalSignOut.d.ts +1 -0
- package/lib/commonjs/logic/cognito/globalSignOut.js +28 -0
- package/lib/commonjs/logic/cognito/globalSignOut.js.map +1 -0
- package/lib/commonjs/logic/cognito/index.d.ts +2 -0
- package/lib/commonjs/logic/cognito/index.js +2 -0
- package/lib/commonjs/logic/cognito/index.js.map +1 -1
- package/lib/commonjs/logic/cognito/refreshToken.js +10 -1
- package/lib/commonjs/logic/cognito/refreshToken.js.map +1 -1
- package/lib/commonjs/logic/cognito/revokeRefreshToken.d.ts +1 -0
- package/lib/commonjs/logic/cognito/revokeRefreshToken.js +33 -0
- package/lib/commonjs/logic/cognito/revokeRefreshToken.js.map +1 -0
- package/lib/commonjs/logic/s3/generatePresignedUploadUrl.d.ts +1 -1
- package/lib/commonjs/logic/s3/generatePresignedUploadUrl.js +4 -1
- package/lib/commonjs/logic/s3/generatePresignedUploadUrl.js.map +1 -1
- package/lib/commonjs/logic/sesV2/buildRawMimeMessage.d.ts +2 -0
- package/lib/commonjs/logic/sesV2/buildRawMimeMessage.js +79 -0
- package/lib/commonjs/logic/sesV2/buildRawMimeMessage.js.map +1 -0
- package/lib/commonjs/logic/sesV2/sendEmail.d.ts +2 -0
- package/lib/commonjs/logic/sesV2/sendEmail.js +48 -0
- package/lib/commonjs/logic/sesV2/sendEmail.js.map +1 -0
- package/lib/esm/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +2 -2
- package/lib/esm/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js.map +1 -1
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectoryRevokeRefreshTokenActionProcessor.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectoryRevokeRefreshTokenActionProcessor.js +26 -0
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectoryRevokeRefreshTokenActionProcessor.js.map +1 -0
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectorySignOutUserActionProcessor.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectorySignOutUserActionProcessor.js +22 -0
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectorySignOutUserActionProcessor.js.map +1 -0
- package/lib/esm/getActionProcessor/core/userDirectory/index.js +4 -0
- package/lib/esm/getActionProcessor/core/userDirectory/index.js.map +1 -1
- package/lib/esm/getActionProcessor/webserver/email/getEmailSendEmailActionProcessor.d.ts +2 -0
- package/lib/esm/getActionProcessor/webserver/email/getEmailSendEmailActionProcessor.js +28 -0
- package/lib/esm/getActionProcessor/webserver/email/getEmailSendEmailActionProcessor.js.map +1 -0
- package/lib/esm/getActionProcessor/webserver/email/getEmailSetDeliveryStatusActionProcessor.d.ts +2 -0
- package/lib/esm/getActionProcessor/webserver/email/getEmailSetDeliveryStatusActionProcessor.js +11 -0
- package/lib/esm/getActionProcessor/webserver/email/getEmailSetDeliveryStatusActionProcessor.js.map +1 -0
- package/lib/esm/getActionProcessor/webserver/email/index.d.ts +2 -0
- package/lib/esm/getActionProcessor/webserver/email/index.js +7 -0
- package/lib/esm/getActionProcessor/webserver/email/index.js.map +1 -0
- package/lib/esm/getActionProcessor/webserver/index.d.ts +1 -0
- package/lib/esm/getActionProcessor/webserver/index.js +3 -0
- package/lib/esm/getActionProcessor/webserver/index.js.map +1 -1
- package/lib/esm/logic/cognito/globalSignOut.d.ts +1 -0
- package/lib/esm/logic/cognito/globalSignOut.js +15 -0
- package/lib/esm/logic/cognito/globalSignOut.js.map +1 -0
- package/lib/esm/logic/cognito/index.d.ts +2 -0
- package/lib/esm/logic/cognito/index.js +2 -0
- package/lib/esm/logic/cognito/index.js.map +1 -1
- package/lib/esm/logic/cognito/refreshToken.js +10 -1
- package/lib/esm/logic/cognito/refreshToken.js.map +1 -1
- package/lib/esm/logic/cognito/revokeRefreshToken.d.ts +1 -0
- package/lib/esm/logic/cognito/revokeRefreshToken.js +20 -0
- package/lib/esm/logic/cognito/revokeRefreshToken.js.map +1 -0
- package/lib/esm/logic/s3/generatePresignedUploadUrl.d.ts +1 -1
- package/lib/esm/logic/s3/generatePresignedUploadUrl.js +4 -1
- package/lib/esm/logic/s3/generatePresignedUploadUrl.js.map +1 -1
- package/lib/esm/logic/sesV2/buildRawMimeMessage.d.ts +2 -0
- package/lib/esm/logic/sesV2/buildRawMimeMessage.js +74 -0
- package/lib/esm/logic/sesV2/buildRawMimeMessage.js.map +1 -0
- package/lib/esm/logic/sesV2/sendEmail.d.ts +2 -0
- package/lib/esm/logic/sesV2/sendEmail.js +37 -0
- package/lib/esm/logic/sesV2/sendEmail.js.map +1 -0
- package/lib/extension-layer/qpq-log-extension/index.js +22 -22
- package/package.json +25 -24
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildRawMimeMessage = void 0;
|
|
4
|
+
const CRLF = '\r\n';
|
|
5
|
+
// Header values must never contain CR/LF, or a caller-supplied string could inject extra headers
|
|
6
|
+
const sanitizeHeaderValue = (value) => value.replace(/[\r\n]+/g, ' ').trim();
|
|
7
|
+
// RFC 2047 encoded-word for header text that isn't printable ascii (e.g. subjects with emoji)
|
|
8
|
+
const encodeHeaderText = (value) => {
|
|
9
|
+
const sanitized = sanitizeHeaderValue(value);
|
|
10
|
+
if (/^[\x20-\x7e]*$/.test(sanitized)) {
|
|
11
|
+
return sanitized;
|
|
12
|
+
}
|
|
13
|
+
return `=?UTF-8?B?${Buffer.from(sanitized, 'utf8').toString('base64')}?=`;
|
|
14
|
+
};
|
|
15
|
+
// RFC 2045 requires base64 body lines of at most 76 characters
|
|
16
|
+
const wrapBase64 = (base64Data) => {
|
|
17
|
+
const lines = base64Data.match(/.{1,76}/g) || [];
|
|
18
|
+
return lines.join(CRLF);
|
|
19
|
+
};
|
|
20
|
+
const buildBodyPart = (contentType, content, boundary) => [
|
|
21
|
+
`--${boundary}`,
|
|
22
|
+
`Content-Type: ${contentType}; charset=UTF-8`,
|
|
23
|
+
'Content-Transfer-Encoding: base64',
|
|
24
|
+
'',
|
|
25
|
+
wrapBase64(Buffer.from(content, 'utf8').toString('base64')),
|
|
26
|
+
];
|
|
27
|
+
const buildAttachmentPart = (attachment, boundary) => {
|
|
28
|
+
const filename = encodeHeaderText(attachment.filename);
|
|
29
|
+
const contentDisposition = attachment.contentDisposition
|
|
30
|
+
? sanitizeHeaderValue(attachment.contentDisposition)
|
|
31
|
+
: `attachment; filename="${filename}"`;
|
|
32
|
+
return [
|
|
33
|
+
`--${boundary}`,
|
|
34
|
+
`Content-Type: ${sanitizeHeaderValue(attachment.mimetype || 'application/octet-stream')}; name="${filename}"`,
|
|
35
|
+
'Content-Transfer-Encoding: base64',
|
|
36
|
+
`Content-Disposition: ${contentDisposition}`,
|
|
37
|
+
'',
|
|
38
|
+
wrapBase64(attachment.base64Data),
|
|
39
|
+
];
|
|
40
|
+
};
|
|
41
|
+
// Builds an RFC 5322 message: multipart/mixed wrapping a multipart/alternative body plus one
|
|
42
|
+
// part per attachment. Bcc recipients are deliberately never written into the headers; they
|
|
43
|
+
// travel only in the SES Destination so other recipients can't see them. boundarySeed exists
|
|
44
|
+
// so tests get deterministic output.
|
|
45
|
+
const buildRawMimeMessage = (payload, boundarySeed = 'qpq') => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
const mixedBoundary = `----=_${boundarySeed}_mixed`;
|
|
48
|
+
const alternativeBoundary = `----=_${boundarySeed}_alternative`;
|
|
49
|
+
const headers = [
|
|
50
|
+
`From: ${encodeHeaderText(payload.from)}`,
|
|
51
|
+
`To: ${payload.to.map(encodeHeaderText).join(', ')}`,
|
|
52
|
+
...(((_a = payload.cc) === null || _a === void 0 ? void 0 : _a.length) ? [`Cc: ${payload.cc.map(encodeHeaderText).join(', ')}`] : []),
|
|
53
|
+
...(((_b = payload.replyTo) === null || _b === void 0 ? void 0 : _b.length) ? [`Reply-To: ${payload.replyTo.map(encodeHeaderText).join(', ')}`] : []),
|
|
54
|
+
`Subject: ${encodeHeaderText(payload.subject)}`,
|
|
55
|
+
'MIME-Version: 1.0',
|
|
56
|
+
`Content-Type: multipart/mixed; boundary="${mixedBoundary}"`,
|
|
57
|
+
];
|
|
58
|
+
const bodyParts = [
|
|
59
|
+
...(payload.bodyText ? buildBodyPart('text/plain', payload.bodyText, alternativeBoundary) : []),
|
|
60
|
+
...(payload.bodyHtml ? buildBodyPart('text/html', payload.bodyHtml, alternativeBoundary) : []),
|
|
61
|
+
];
|
|
62
|
+
const attachmentParts = (payload.attachments || []).flatMap((attachment) => buildAttachmentPart(attachment, mixedBoundary));
|
|
63
|
+
const lines = [
|
|
64
|
+
...headers,
|
|
65
|
+
'',
|
|
66
|
+
`--${mixedBoundary}`,
|
|
67
|
+
`Content-Type: multipart/alternative; boundary="${alternativeBoundary}"`,
|
|
68
|
+
'',
|
|
69
|
+
...bodyParts,
|
|
70
|
+
`--${alternativeBoundary}--`,
|
|
71
|
+
'',
|
|
72
|
+
...attachmentParts,
|
|
73
|
+
`--${mixedBoundary}--`,
|
|
74
|
+
'',
|
|
75
|
+
];
|
|
76
|
+
return lines.join(CRLF);
|
|
77
|
+
};
|
|
78
|
+
exports.buildRawMimeMessage = buildRawMimeMessage;
|
|
79
|
+
//# sourceMappingURL=buildRawMimeMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildRawMimeMessage.js","sourceRoot":"","sources":["../../../../src/logic/sesV2/buildRawMimeMessage.ts"],"names":[],"mappings":";;;AAGA,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,iGAAiG;AACjG,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,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,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/F,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/F,CAAC;IAEF,MAAM,eAAe,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,mBAAmB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAE5H,MAAM,KAAK,GAAG;QACZ,GAAG,OAAO;QACV,EAAE;QACF,KAAK,aAAa,EAAE;QACpB,kDAAkD,mBAAmB,GAAG;QACxE,EAAE;QACF,GAAG,SAAS;QACZ,KAAK,mBAAmB,IAAI;QAC5B,EAAE;QACF,GAAG,eAAe;QAClB,KAAK,aAAa,IAAI;QACtB,EAAE;KACH,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AApCW,QAAA,mBAAmB,uBAoC9B","sourcesContent":["import { QPQBinaryData } from 'quidproquo-core';\nimport { EmailSendEmailActionPayload } from 'quidproquo-webserver';\n\nconst CRLF = '\\r\\n';\n\n// Header values must never contain CR/LF, or a caller-supplied string could inject extra headers\nconst sanitizeHeaderValue = (value: string): string => value.replace(/[\\r\\n]+/g, ' ').trim();\n\n// RFC 2047 encoded-word for header text that isn't printable ascii (e.g. subjects with emoji)\nconst encodeHeaderText = (value: string): string => {\n const sanitized = sanitizeHeaderValue(value);\n\n if (/^[\\x20-\\x7e]*$/.test(sanitized)) {\n return sanitized;\n }\n\n return `=?UTF-8?B?${Buffer.from(sanitized, 'utf8').toString('base64')}?=`;\n};\n\n// RFC 2045 requires base64 body lines of at most 76 characters\nconst wrapBase64 = (base64Data: string): string => {\n const lines = base64Data.match(/.{1,76}/g) || [];\n\n return lines.join(CRLF);\n};\n\nconst buildBodyPart = (contentType: string, content: string, boundary: string): string[] => [\n `--${boundary}`,\n `Content-Type: ${contentType}; charset=UTF-8`,\n 'Content-Transfer-Encoding: base64',\n '',\n wrapBase64(Buffer.from(content, 'utf8').toString('base64')),\n];\n\nconst buildAttachmentPart = (attachment: QPQBinaryData, boundary: string): string[] => {\n const filename = encodeHeaderText(attachment.filename);\n const contentDisposition = attachment.contentDisposition\n ? sanitizeHeaderValue(attachment.contentDisposition)\n : `attachment; filename=\"${filename}\"`;\n\n return [\n `--${boundary}`,\n `Content-Type: ${sanitizeHeaderValue(attachment.mimetype || 'application/octet-stream')}; name=\"${filename}\"`,\n 'Content-Transfer-Encoding: base64',\n `Content-Disposition: ${contentDisposition}`,\n '',\n wrapBase64(attachment.base64Data),\n ];\n};\n\n// Builds an RFC 5322 message: multipart/mixed wrapping a multipart/alternative body plus one\n// part per attachment. Bcc recipients are deliberately never written into the headers; they\n// travel only in the SES Destination so other recipients can't see them. boundarySeed exists\n// so tests get deterministic output.\nexport const buildRawMimeMessage = (payload: EmailSendEmailActionPayload, boundarySeed: string = 'qpq'): string => {\n const mixedBoundary = `----=_${boundarySeed}_mixed`;\n const alternativeBoundary = `----=_${boundarySeed}_alternative`;\n\n const headers = [\n `From: ${encodeHeaderText(payload.from)}`,\n `To: ${payload.to.map(encodeHeaderText).join(', ')}`,\n ...(payload.cc?.length ? [`Cc: ${payload.cc.map(encodeHeaderText).join(', ')}`] : []),\n ...(payload.replyTo?.length ? [`Reply-To: ${payload.replyTo.map(encodeHeaderText).join(', ')}`] : []),\n `Subject: ${encodeHeaderText(payload.subject)}`,\n 'MIME-Version: 1.0',\n `Content-Type: multipart/mixed; boundary=\"${mixedBoundary}\"`,\n ];\n\n const bodyParts = [\n ...(payload.bodyText ? buildBodyPart('text/plain', payload.bodyText, alternativeBoundary) : []),\n ...(payload.bodyHtml ? buildBodyPart('text/html', payload.bodyHtml, alternativeBoundary) : []),\n ];\n\n const attachmentParts = (payload.attachments || []).flatMap((attachment) => buildAttachmentPart(attachment, mixedBoundary));\n\n const lines = [\n ...headers,\n '',\n `--${mixedBoundary}`,\n `Content-Type: multipart/alternative; boundary=\"${alternativeBoundary}\"`,\n '',\n ...bodyParts,\n `--${alternativeBoundary}--`,\n '',\n ...attachmentParts,\n `--${mixedBoundary}--`,\n '',\n ];\n\n return lines.join(CRLF);\n};\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
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.sendEmail = void 0;
|
|
13
|
+
const client_sesv2_1 = require("@aws-sdk/client-sesv2");
|
|
14
|
+
const createAwsClient_1 = require("../createAwsClient");
|
|
15
|
+
const buildRawMimeMessage_1 = require("./buildRawMimeMessage");
|
|
16
|
+
// SES Simple content can't carry attachments, so those emails go through the raw MIME path.
|
|
17
|
+
// Either way the recipients come from Destination below, which is what keeps bcc addresses
|
|
18
|
+
// out of the message the recipients see.
|
|
19
|
+
const getEmailContent = (payload) => {
|
|
20
|
+
var _a;
|
|
21
|
+
if ((_a = payload.attachments) === null || _a === void 0 ? void 0 : _a.length) {
|
|
22
|
+
return {
|
|
23
|
+
Raw: { Data: new TextEncoder().encode((0, buildRawMimeMessage_1.buildRawMimeMessage)(payload)) },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
Simple: {
|
|
28
|
+
Subject: { Data: payload.subject, Charset: 'UTF-8' },
|
|
29
|
+
Body: Object.assign(Object.assign({}, (payload.bodyText ? { Text: { Data: payload.bodyText, Charset: 'UTF-8' } } : {})), (payload.bodyHtml ? { Html: { Data: payload.bodyHtml, Charset: 'UTF-8' } } : {})),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const sendEmail = (payload, region) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const sesClient = (0, createAwsClient_1.createAwsClient)(client_sesv2_1.SESv2Client, { region });
|
|
35
|
+
const response = yield sesClient.send(new client_sesv2_1.SendEmailCommand({
|
|
36
|
+
FromEmailAddress: payload.from,
|
|
37
|
+
Destination: {
|
|
38
|
+
ToAddresses: payload.to,
|
|
39
|
+
CcAddresses: payload.cc,
|
|
40
|
+
BccAddresses: payload.bcc,
|
|
41
|
+
},
|
|
42
|
+
ReplyToAddresses: payload.replyTo,
|
|
43
|
+
Content: getEmailContent(payload),
|
|
44
|
+
}));
|
|
45
|
+
return response.MessageId || '';
|
|
46
|
+
});
|
|
47
|
+
exports.sendEmail = sendEmail;
|
|
48
|
+
//# sourceMappingURL=sendEmail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendEmail.js","sourceRoot":"","sources":["../../../../src/logic/sesV2/sendEmail.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,wDAAoF;AAEpF,wDAAqD;AACrD,+DAA4D;AAE5D,4FAA4F;AAC5F,2FAA2F;AAC3F,yCAAyC;AACzC,MAAM,eAAe,GAAG,CAAC,OAAoC,EAAgB,EAAE;;IAC7E,IAAI,MAAA,OAAO,CAAC,WAAW,0CAAE,MAAM,EAAE,CAAC;QAChC,OAAO;YACL,GAAG,EAAE,EAAE,IA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EmailSendEmailActionPayload } from 'quidproquo-webserver';\n\nimport { EmailContent, SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\n\nimport { createAwsClient } from '../createAwsClient';\nimport { buildRawMimeMessage } from './buildRawMimeMessage';\n\n// SES Simple content can't carry attachments, so those emails go through the raw MIME path.\n// Either way the recipients come from Destination below, which is what keeps bcc addresses\n// out of the message the recipients see.\nconst getEmailContent = (payload: EmailSendEmailActionPayload): EmailContent => {\n if (payload.attachments?.length) {\n return {\n Raw: { Data: new TextEncoder().encode(buildRawMimeMessage(payload)) },\n };\n }\n\n return {\n Simple: {\n Subject: { Data: payload.subject, Charset: 'UTF-8' },\n Body: {\n ...(payload.bodyText ? { Text: { Data: payload.bodyText, Charset: 'UTF-8' } } : {}),\n ...(payload.bodyHtml ? { Html: { Data: payload.bodyHtml, Charset: 'UTF-8' } } : {}),\n },\n },\n };\n};\n\nexport const sendEmail = async (payload: EmailSendEmailActionPayload, region: string): Promise<string> => {\n const sesClient = createAwsClient(SESv2Client, { region });\n\n const response = await sesClient.send(\n new SendEmailCommand({\n FromEmailAddress: payload.from,\n Destination: {\n ToAddresses: payload.to,\n CcAddresses: payload.cc,\n BccAddresses: payload.bcc,\n },\n ReplyToAddresses: payload.replyTo,\n Content: getEmailContent(payload),\n }),\n );\n\n return response.MessageId || '';\n};\n"]}
|
|
@@ -6,13 +6,13 @@ import { resolveStorageDriveBucketName } from './utils';
|
|
|
6
6
|
// SigV4 presigned URLs cannot expire more than 7 days in the future
|
|
7
7
|
const maxExpirationMs = 7 * 24 * 60 * 60 * 1000;
|
|
8
8
|
const getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig) => {
|
|
9
|
-
return async ({ drive, filepath, expirationMs, contentType, scope }, session) => {
|
|
9
|
+
return async ({ drive, filepath, expirationMs, contentType, contentDisposition, scope }, session) => {
|
|
10
10
|
if (expirationMs > maxExpirationMs) {
|
|
11
11
|
return actionResultError(FileGenerateTemporaryUploadSecureUrlErrorTypeEnum.ExpirationTooLong, 'Expiration exceeds the 7 day maximum for presigned URLs');
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);
|
|
15
|
-
const url = await generatePresignedUploadUrl(s3BucketName, composeScopedFilePath(scope, filepath), qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), expirationMs, session.correlation, contentType);
|
|
15
|
+
const url = await generatePresignedUploadUrl(s3BucketName, composeScopedFilePath(scope, filepath), qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), expirationMs, session.correlation, contentType, contentDisposition);
|
|
16
16
|
return actionResult(url);
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileGenerateTemporaryUploadSecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAoD,iBAAiB,EAAE,gCAAgC,EAAa,MAAM,iBAAiB,CAAC;AACnJ,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EAEd,iDAAiD,GAClD,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,oEAAoE;AACpE,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,MAAM,8CAA8C,GAAG,CAAC,SAAoB,EAAuD,EAAE;IACnI,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"getFileGenerateTemporaryUploadSecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAoD,iBAAiB,EAAE,gCAAgC,EAAa,MAAM,iBAAiB,CAAC;AACnJ,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EAEd,iDAAiD,GAClD,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,oEAAoE;AACpE,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,MAAM,8CAA8C,GAAG,CAAC,SAAoB,EAAuD,EAAE;IACnI,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE;QAClG,IAAI,YAAY,GAAG,eAAe,EAAE,CAAC;YACnC,OAAO,iBAAiB,CACtB,iDAAiD,CAAC,iBAAiB,EACnE,yDAAyD,CAC1D,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,6BAA6B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACrE,MAAM,GAAG,GAAG,MAAM,0BAA0B,CAC1C,YAAY,EACZ,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,EACtC,iBAAiB,CAAC,gCAAgC,CAAC,SAAS,CAAC,EAC7D,YAAY,EACZ,OAAO,CAAC,WAAW,EACnB,WAAW,EACX,kBAAkB,CACnB,CAAC;YAEF,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,qEAAqE;YACrE,uDAAuD;YACvD,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,iDAAiD,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;aAC/H,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sDAAsD,GAAgC,KAAK,EACtG,SAAoB,EACU,EAAE,CAAC,CAAC;IAClC,CAAC,cAAc,CAAC,gCAAgC,CAAC,EAAE,8CAA8C,CAAC,SAAS,CAAC;CAC7G,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport { ActionProcessorList, ActionProcessorListResolver, actionResultError, actionResultErrorFromCaughtError, QPQConfig } from 'quidproquo-core';\nimport {\n actionResult,\n composeScopedFilePath,\n FileActionType,\n FileGenerateTemporaryUploadSecureUrlActionProcessor,\n FileGenerateTemporaryUploadSecureUrlErrorTypeEnum,\n} from 'quidproquo-core';\n\nimport { generatePresignedUploadUrl } from '../../../logic/s3/generatePresignedUploadUrl';\nimport { resolveStorageDriveBucketName } from './utils';\n\n// SigV4 presigned URLs cannot expire more than 7 days in the future\nconst maxExpirationMs = 7 * 24 * 60 * 60 * 1000;\n\nconst getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig: QPQConfig): FileGenerateTemporaryUploadSecureUrlActionProcessor => {\n return async ({ drive, filepath, expirationMs, contentType, contentDisposition, scope }, session) => {\n if (expirationMs > maxExpirationMs) {\n return actionResultError(\n FileGenerateTemporaryUploadSecureUrlErrorTypeEnum.ExpirationTooLong,\n 'Expiration exceeds the 7 day maximum for presigned URLs',\n );\n }\n\n try {\n const s3BucketName = resolveStorageDriveBucketName(drive, qpqConfig);\n const url = await generatePresignedUploadUrl(\n s3BucketName,\n composeScopedFilePath(scope, filepath),\n qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig),\n expirationMs,\n session.correlation,\n contentType,\n contentDisposition,\n );\n\n return actionResult(url);\n } catch (error: unknown) {\n // Name-keyed, not instanceof: under npm link / module federation the\n // error can come from another copy of quidproquo-core.\n return actionResultErrorFromCaughtError(error, {\n InvalidScopeError: (error) => actionResultError(FileGenerateTemporaryUploadSecureUrlErrorTypeEnum.InvalidScope, error.message),\n });\n }\n };\n};\n\nexport const getFileGenerateTemporaryUploadSecureUrlActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n): Promise<ActionProcessorList> => ({\n [FileActionType.GenerateTemporaryUploadSecureUrl]: getProcessFileGenerateTemporaryUploadSecureUrl(qpqConfig),\n});\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, UserDirectoryActionType, UserDirectoryRevokeRefreshTokenErrorTypeEnum, } from 'quidproquo-core';
|
|
3
|
+
import { getCFExportNameUserPoolClientIdFromConfig, getCFExportNameUserPoolIdFromConfig } from '../../../awsNamingUtils';
|
|
4
|
+
import { getExportedValue } from '../../../logic/cloudformation/getExportedValue';
|
|
5
|
+
import { revokeRefreshToken } from '../../../logic/cognito/revokeRefreshToken';
|
|
6
|
+
const getProcessRevokeRefreshToken = (qpqConfig) => {
|
|
7
|
+
return async ({ userDirectoryName, refreshToken }) => {
|
|
8
|
+
const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
9
|
+
const userPoolId = await getExportedValue(getCFExportNameUserPoolIdFromConfig(userDirectoryName, qpqConfig), region);
|
|
10
|
+
const userPoolClientId = await getExportedValue(getCFExportNameUserPoolClientIdFromConfig(userDirectoryName, qpqConfig), region);
|
|
11
|
+
try {
|
|
12
|
+
await revokeRefreshToken(userPoolId, userPoolClientId, region, refreshToken);
|
|
13
|
+
return actionResult(void 0);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
return actionResultErrorFromCaughtError(error, {
|
|
17
|
+
NotAuthorizedException: () => actionResultError(UserDirectoryRevokeRefreshTokenErrorTypeEnum.Unauthorized, 'Refresh token is invalid or already revoked'),
|
|
18
|
+
TooManyRequestsException: () => actionResultError(UserDirectoryRevokeRefreshTokenErrorTypeEnum.LimitExceeded, 'Too many attempts, please try again later'),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export const getUserDirectoryRevokeRefreshTokenActionProcessor = async (qpqConfig) => ({
|
|
24
|
+
[UserDirectoryActionType.RevokeRefreshToken]: getProcessRevokeRefreshToken(qpqConfig),
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=getUserDirectoryRevokeRefreshTokenActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserDirectoryRevokeRefreshTokenActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/userDirectory/getUserDirectoryRevokeRefreshTokenActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAEhC,uBAAuB,EAEvB,4CAA4C,GAC7C,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,yCAAyC,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC;AACzH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E,MAAM,4BAA4B,GAAG,CAAC,SAAoB,EAAkD,EAAE;IAC5G,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE,EAAE,EAAE;QACnD,MAAM,MAAM,GAAG,iBAAiB,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC;QAE7E,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,mCAAmC,CAAC,iBAAiB,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;QAErH,MAAM,gBAAgB,GAAG,MAAM,gBAAgB,CAAC,yCAAyC,CAAC,iBAAiB,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;QAEjI,IAAI,CAAC;YACH,MAAM,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;YAE7E,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,sBAAsB,EAAE,GAAG,EAAE,CAC3B,iBAAiB,CAAC,4CAA4C,CAAC,YAAY,EAAE,6CAA6C,CAAC;gBAC7H,wBAAwB,EAAE,GAAG,EAAE,CAC7B,iBAAiB,CAAC,4CAA4C,CAAC,aAAa,EAAE,2CAA2C,CAAC;aAC7H,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iDAAiD,GAAgC,KAAK,EACjG,SAAoB,EACU,EAAE,CAAC,CAAC;IAClC,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,EAAE,4BAA4B,CAAC,SAAS,CAAC;CACtF,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n QPQConfig,\n UserDirectoryActionType,\n UserDirectoryRevokeRefreshTokenActionProcessor,\n UserDirectoryRevokeRefreshTokenErrorTypeEnum,\n} from 'quidproquo-core';\n\nimport { getCFExportNameUserPoolClientIdFromConfig, getCFExportNameUserPoolIdFromConfig } from '../../../awsNamingUtils';\nimport { getExportedValue } from '../../../logic/cloudformation/getExportedValue';\nimport { revokeRefreshToken } from '../../../logic/cognito/revokeRefreshToken';\n\nconst getProcessRevokeRefreshToken = (qpqConfig: QPQConfig): UserDirectoryRevokeRefreshTokenActionProcessor => {\n return async ({ userDirectoryName, refreshToken }) => {\n const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);\n\n const userPoolId = await getExportedValue(getCFExportNameUserPoolIdFromConfig(userDirectoryName, qpqConfig), region);\n\n const userPoolClientId = await getExportedValue(getCFExportNameUserPoolClientIdFromConfig(userDirectoryName, qpqConfig), region);\n\n try {\n await revokeRefreshToken(userPoolId, userPoolClientId, region, refreshToken);\n\n return actionResult(void 0);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n NotAuthorizedException: () =>\n actionResultError(UserDirectoryRevokeRefreshTokenErrorTypeEnum.Unauthorized, 'Refresh token is invalid or already revoked'),\n TooManyRequestsException: () =>\n actionResultError(UserDirectoryRevokeRefreshTokenErrorTypeEnum.LimitExceeded, 'Too many attempts, please try again later'),\n });\n }\n };\n};\n\nexport const getUserDirectoryRevokeRefreshTokenActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n): Promise<ActionProcessorList> => ({\n [UserDirectoryActionType.RevokeRefreshToken]: getProcessRevokeRefreshToken(qpqConfig),\n});\n"]}
|
package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectorySignOutUserActionProcessor.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, UserDirectoryActionType, UserDirectorySignOutUserErrorTypeEnum, } from 'quidproquo-core';
|
|
3
|
+
import { globalSignOut } from '../../../logic/cognito/globalSignOut';
|
|
4
|
+
const getProcessSignOutUser = (qpqConfig) => {
|
|
5
|
+
return async ({ accessToken }) => {
|
|
6
|
+
const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
7
|
+
try {
|
|
8
|
+
await globalSignOut(accessToken, region);
|
|
9
|
+
return actionResult(void 0);
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
return actionResultErrorFromCaughtError(error, {
|
|
13
|
+
NotAuthorizedException: () => actionResultError(UserDirectorySignOutUserErrorTypeEnum.Unauthorized, 'Access token is invalid or has expired'),
|
|
14
|
+
TooManyRequestsException: () => actionResultError(UserDirectorySignOutUserErrorTypeEnum.LimitExceeded, 'Too many attempts, please try again later'),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export const getUserDirectorySignOutUserActionProcessor = async (qpqConfig) => ({
|
|
20
|
+
[UserDirectoryActionType.SignOutUser]: getProcessSignOutUser(qpqConfig),
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=getUserDirectorySignOutUserActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserDirectorySignOutUserActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/userDirectory/getUserDirectorySignOutUserActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAEhC,uBAAuB,EAEvB,qCAAqC,GACtC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,qBAAqB,GAAG,CAAC,SAAoB,EAA2C,EAAE;IAC9F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;QAC/B,MAAM,MAAM,GAAG,iBAAiB,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC;QAE7E,IAAI,CAAC;YACH,MAAM,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;YAEzC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,sBAAsB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,qCAAqC,CAAC,YAAY,EAAE,wCAAwC,CAAC;gBAC7I,wBAAwB,EAAE,GAAG,EAAE,CAC7B,iBAAiB,CAAC,qCAAqC,CAAC,aAAa,EAAE,2CAA2C,CAAC;aACtH,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0CAA0C,GAAgC,KAAK,EAC1F,SAAoB,EACU,EAAE,CAAC,CAAC;IAClC,CAAC,uBAAuB,CAAC,WAAW,CAAC,EAAE,qBAAqB,CAAC,SAAS,CAAC;CACxE,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n QPQConfig,\n UserDirectoryActionType,\n UserDirectorySignOutUserActionProcessor,\n UserDirectorySignOutUserErrorTypeEnum,\n} from 'quidproquo-core';\n\nimport { globalSignOut } from '../../../logic/cognito/globalSignOut';\n\nconst getProcessSignOutUser = (qpqConfig: QPQConfig): UserDirectorySignOutUserActionProcessor => {\n return async ({ accessToken }) => {\n const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);\n\n try {\n await globalSignOut(accessToken, region);\n\n return actionResult(void 0);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n NotAuthorizedException: () => actionResultError(UserDirectorySignOutUserErrorTypeEnum.Unauthorized, 'Access token is invalid or has expired'),\n TooManyRequestsException: () =>\n actionResultError(UserDirectorySignOutUserErrorTypeEnum.LimitExceeded, 'Too many attempts, please try again later'),\n });\n }\n };\n};\n\nexport const getUserDirectorySignOutUserActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n): Promise<ActionProcessorList> => ({\n [UserDirectoryActionType.SignOutUser]: getProcessSignOutUser(qpqConfig),\n});\n"]}
|
|
@@ -14,9 +14,11 @@ import { getUserDirectoryReadAccessTokenActionProcessor } from './getUserDirecto
|
|
|
14
14
|
import { getUserDirectoryRefreshTokenActionProcessor } from './getUserDirectoryRefreshTokenActionProcessor';
|
|
15
15
|
import { getUserDirectoryRequestEmailVerificationActionProcessor } from './getUserDirectoryRequestEmailVerificationActionProcessor';
|
|
16
16
|
import { getUserDirectoryRespondToAuthChallengeActionProcessor } from './getUserDirectoryRespondToAuthChallengeActionProcessor';
|
|
17
|
+
import { getUserDirectoryRevokeRefreshTokenActionProcessor } from './getUserDirectoryRevokeRefreshTokenActionProcessor';
|
|
17
18
|
import { getUserDirectorySetAccessTokenActionProcessor } from './getUserDirectorySetAccessTokenActionProcessor';
|
|
18
19
|
import { getUserDirectorySetPasswordActionProcessor } from './getUserDirectorySetPasswordActionProcessor';
|
|
19
20
|
import { getUserDirectorySetUserAttributesActionProcessor } from './getUserDirectorySetUserAttributesActionProcessor';
|
|
21
|
+
import { getUserDirectorySignOutUserActionProcessor } from './getUserDirectorySignOutUserActionProcessor';
|
|
20
22
|
export const getUserDirectoryActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
21
23
|
...(await getUserDirectoryAssociateSoftwareTokenActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
22
24
|
...(await getUserDirectoryAuthenticateUserActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
@@ -32,10 +34,12 @@ export const getUserDirectoryActionProcessor = async (qpqConfig, dynamicModuleLo
|
|
|
32
34
|
...(await getUserDirectoryGetUsersByAttributeActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
33
35
|
...(await getUserDirectoryReadAccessTokenActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
34
36
|
...(await getUserDirectoryRefreshTokenActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
37
|
+
...(await getUserDirectoryRevokeRefreshTokenActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
35
38
|
...(await getUserDirectoryRequestEmailVerificationActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
36
39
|
...(await getUserDirectoryRespondToAuthChallengeActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
37
40
|
...(await getUserDirectorySetAccessTokenActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
38
41
|
...(await getUserDirectorySetPasswordActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
39
42
|
...(await getUserDirectorySetUserAttributesActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
43
|
+
...(await getUserDirectorySignOutUserActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
40
44
|
});
|
|
41
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/core/userDirectory/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qDAAqD,EAAE,MAAM,yDAAyD,CAAC;AAChI,OAAO,EAAE,+CAA+C,EAAE,MAAM,mDAAmD,CAAC;AACpH,OAAO,EAAE,6CAA6C,EAAE,MAAM,iDAAiD,CAAC;AAChH,OAAO,EAAE,uDAAuD,EAAE,MAAM,2DAA2D,CAAC;AACpI,OAAO,EAAE,oDAAoD,EAAE,MAAM,wDAAwD,CAAC;AAC9H,OAAO,EAAE,yCAAyC,EAAE,MAAM,6CAA6C,CAAC;AACxG,OAAO,EAAE,gDAAgD,EAAE,MAAM,oDAAoD,CAAC;AACtH,OAAO,EAAE,6CAA6C,EAAE,MAAM,iDAAiD,CAAC;AAChH,OAAO,EAAE,gDAAgD,EAAE,MAAM,oDAAoD,CAAC;AACtH,OAAO,EAAE,wDAAwD,EAAE,MAAM,4DAA4D,CAAC;AACtI,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AACpG,OAAO,EAAE,kDAAkD,EAAE,MAAM,sDAAsD,CAAC;AAC1H,OAAO,EAA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CAAC,MAAM,kDAAkD,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC7F,GAAG,CAAC,MAAM,8CAA8C,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACzF,GAAG,CAAC,MAAM,2CAA2C,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACtF,GAAG,CAAC,MAAM,iDAAiD,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC5F,GAAG,CAAC,MAAM,uDAAuD,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAClG,GAAG,CAAC,MAAM,qDAAqD,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAChG,GAAG,CAAC,MAAM,6CAA6C,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACxF,GAAG,CAAC,MAAM,0CAA0C,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACrF,GAAG,CAAC,MAAM,gDAAgD,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC3F,GAAG,CAAC,MAAM,0CAA0C,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CACtF,CAAC,CAAC","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nimport { getUserDirectoryAssociateSoftwareTokenActionProcessor } from './getUserDirectoryAssociateSoftwareTokenActionProcessor';\nimport { getUserDirectoryAuthenticateUserActionProcessor } from './getUserDirectoryAuthenticateUserActionProcessor';\nimport { getUserDirectoryChangePasswordActionProcessor } from './getUserDirectoryChangePasswordActionProcessor';\nimport { getUserDirectoryConfirmEmailVerificationActionProcessor } from './getUserDirectoryConfirmEmailVerificationActionProcessor';\nimport { getUserDirectoryConfirmForgotPasswordActionProcessor } from './getUserDirectoryConfirmForgotPasswordActionProcessor';\nimport { getUserDirectoryCreateUserActionProcessor } from './getUserDirectoryCreateUserActionProcessor';\nimport { getUserDirectoryDecodeAccessTokenActionProcessor } from './getUserDirectoryDecodeAccessTokenActionProcessor';\nimport { getUserDirectoryForgotPasswordActionProcessor } from './getUserDirectoryForgotPasswordActionProcessor';\nimport { getUserDirectoryGetUserAttributesActionProcessor } from './getUserDirectoryGetUserAttributesActionProcessor';\nimport { getUserDirectoryGetUserAttributesByUserIdActionProcessor } from './getUserDirectoryGetUserAttributesByUserIdActionProcessor';\nimport { getUserDirectoryGetUsersActionProcessor } from './getUserDirectoryGetUsersActionProcessor';\nimport { getUserDirectoryGetUsersByAttributeActionProcessor } from './getUserDirectoryGetUsersByAttributeActionProcessor';\nimport { getUserDirectoryReadAccessTokenActionProcessor } from './getUserDirectoryReadAccessTokenActionProcessor';\nimport { getUserDirectoryRefreshTokenActionProcessor } from './getUserDirectoryRefreshTokenActionProcessor';\nimport { getUserDirectoryRequestEmailVerificationActionProcessor } from './getUserDirectoryRequestEmailVerificationActionProcessor';\nimport { getUserDirectoryRespondToAuthChallengeActionProcessor } from './getUserDirectoryRespondToAuthChallengeActionProcessor';\nimport { getUserDirectoryRevokeRefreshTokenActionProcessor } from './getUserDirectoryRevokeRefreshTokenActionProcessor';\nimport { getUserDirectorySetAccessTokenActionProcessor } from './getUserDirectorySetAccessTokenActionProcessor';\nimport { getUserDirectorySetPasswordActionProcessor } from './getUserDirectorySetPasswordActionProcessor';\nimport { getUserDirectorySetUserAttributesActionProcessor } from './getUserDirectorySetUserAttributesActionProcessor';\nimport { getUserDirectorySignOutUserActionProcessor } from './getUserDirectorySignOutUserActionProcessor';\n\nexport const getUserDirectoryActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getUserDirectoryAssociateSoftwareTokenActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryAuthenticateUserActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryChangePasswordActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryConfirmEmailVerificationActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryConfirmForgotPasswordActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryCreateUserActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryDecodeAccessTokenActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryForgotPasswordActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryGetUserAttributesActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryGetUserAttributesByUserIdActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryGetUsersActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryGetUsersByAttributeActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryReadAccessTokenActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryRefreshTokenActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryRevokeRefreshTokenActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryRequestEmailVerificationActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectoryRespondToAuthChallengeActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectorySetAccessTokenActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectorySetPasswordActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectorySetUserAttributesActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getUserDirectorySignOutUserActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
+
import { actionResult, actionResultError, actionResultErrorFromCaughtError, } from 'quidproquo-core';
|
|
3
|
+
import { EmailActionType, EmailSendEmailErrorTypeEnum } from 'quidproquo-webserver';
|
|
4
|
+
import { sendEmail } from '../../../logic/sesV2/sendEmail';
|
|
5
|
+
const getProcessSendEmail = (qpqConfig) => {
|
|
6
|
+
return async (payload) => {
|
|
7
|
+
const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
8
|
+
try {
|
|
9
|
+
const messageId = await sendEmail(payload, region);
|
|
10
|
+
return actionResult(messageId);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
return actionResultErrorFromCaughtError(error, {
|
|
14
|
+
MessageRejected: () => actionResultError(EmailSendEmailErrorTypeEnum.MessageRejected, 'Message rejected'),
|
|
15
|
+
MailFromDomainNotVerifiedException: () => actionResultError(EmailSendEmailErrorTypeEnum.SenderNotVerified, 'Sender domain not verified'),
|
|
16
|
+
AccountSuspendedException: () => actionResultError(EmailSendEmailErrorTypeEnum.AccountSuspended, 'Email sending account suspended'),
|
|
17
|
+
SendingPausedException: () => actionResultError(EmailSendEmailErrorTypeEnum.SendingPaused, 'Email sending is paused'),
|
|
18
|
+
TooManyRequestsException: () => actionResultError(EmailSendEmailErrorTypeEnum.Throttled, 'Rate exceeded'),
|
|
19
|
+
LimitExceededException: () => actionResultError(EmailSendEmailErrorTypeEnum.LimitExceeded, 'Sending limit exceeded'),
|
|
20
|
+
BadRequestException: () => actionResultError(EmailSendEmailErrorTypeEnum.BadRequest, 'Invalid email request'),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export const getEmailSendEmailActionProcessor = async (qpqConfig) => ({
|
|
26
|
+
[EmailActionType.SendEmail]: getProcessSendEmail(qpqConfig),
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=getEmailSendEmailActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEmailSendEmailActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/webserver/email/getEmailSendEmailActionProcessor.ts"],"names":[],"mappings":"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EAAE,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,UAAU,EAAE,uBAAuB,CAAC;aAC9G,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC1I,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC;CAC5D,CAAC,CAAC","sourcesContent":["import { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n QPQConfig,\n} from 'quidproquo-core';\nimport { EmailActionType, EmailSendEmailActionProcessor, EmailSendEmailErrorTypeEnum } from 'quidproquo-webserver';\n\nimport { sendEmail } from '../../../logic/sesV2/sendEmail';\n\nconst getProcessSendEmail = (qpqConfig: QPQConfig): EmailSendEmailActionProcessor => {\n return async (payload) => {\n const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);\n\n try {\n const messageId = await sendEmail(payload, region);\n\n return actionResult(messageId);\n } catch (error) {\n return actionResultErrorFromCaughtError(error, {\n MessageRejected: () => actionResultError(EmailSendEmailErrorTypeEnum.MessageRejected, 'Message rejected'),\n MailFromDomainNotVerifiedException: () => actionResultError(EmailSendEmailErrorTypeEnum.SenderNotVerified, 'Sender domain not verified'),\n AccountSuspendedException: () => actionResultError(EmailSendEmailErrorTypeEnum.AccountSuspended, 'Email sending account suspended'),\n SendingPausedException: () => actionResultError(EmailSendEmailErrorTypeEnum.SendingPaused, 'Email sending is paused'),\n TooManyRequestsException: () => actionResultError(EmailSendEmailErrorTypeEnum.Throttled, 'Rate exceeded'),\n LimitExceededException: () => actionResultError(EmailSendEmailErrorTypeEnum.LimitExceeded, 'Sending limit exceeded'),\n BadRequestException: () => actionResultError(EmailSendEmailErrorTypeEnum.BadRequest, 'Invalid email request'),\n });\n }\n };\n};\n\nexport const getEmailSendEmailActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [EmailActionType.SendEmail]: getProcessSendEmail(qpqConfig),\n});\n"]}
|
package/lib/esm/getActionProcessor/webserver/email/getEmailSetDeliveryStatusActionProcessor.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { actionResult } from 'quidproquo-core';
|
|
2
|
+
import { EmailActionType } from 'quidproquo-webserver';
|
|
3
|
+
// Deliberately a no-op: the action's meaning is its log entry, which the admin
|
|
4
|
+
// action search folds into the email's entity via the messageId link key.
|
|
5
|
+
const getProcessSetDeliveryStatus = () => {
|
|
6
|
+
return async () => actionResult(undefined);
|
|
7
|
+
};
|
|
8
|
+
export const getEmailSetDeliveryStatusActionProcessor = async (qpqConfig) => ({
|
|
9
|
+
[EmailActionType.SetDeliveryStatus]: getProcessSetDeliveryStatus(),
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=getEmailSetDeliveryStatusActionProcessor.js.map
|
package/lib/esm/getActionProcessor/webserver/email/getEmailSetDeliveryStatusActionProcessor.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEmailSetDeliveryStatusActionProcessor.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/webserver/email/getEmailSetDeliveryStatusActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,YAAY,EAAa,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAyC,MAAM,sBAAsB,CAAC;AAE9F,+EAA+E;AAC/E,0EAA0E;AAC1E,MAAM,2BAA2B,GAAG,GAA0C,EAAE;IAC9E,OAAO,KAAK,IAAI,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wCAAwC,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAClJ,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,2BAA2B,EAAE;CACnE,CAAC,CAAC","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, actionResult, QPQConfig } from 'quidproquo-core';\nimport { EmailActionType, EmailSetDeliveryStatusActionProcessor } from 'quidproquo-webserver';\n\n// Deliberately a no-op: the action's meaning is its log entry, which the admin\n// action search folds into the email's entity via the messageId link key.\nconst getProcessSetDeliveryStatus = (): EmailSetDeliveryStatusActionProcessor => {\n return async () => actionResult(undefined);\n};\n\nexport const getEmailSetDeliveryStatusActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [EmailActionType.SetDeliveryStatus]: getProcessSetDeliveryStatus(),\n});\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getEmailSendEmailActionProcessor } from './getEmailSendEmailActionProcessor';
|
|
2
|
+
import { getEmailSetDeliveryStatusActionProcessor } from './getEmailSetDeliveryStatusActionProcessor';
|
|
3
|
+
export const getEmailActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
4
|
+
...(await getEmailSendEmailActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
5
|
+
...(await getEmailSetDeliveryStatusActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
6
|
+
});
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/getActionProcessor/webserver/email/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AAEtG,MAAM,CAAC,MAAM,uBAAuB,GAAgC,KAAK,EACvE,SAAoB,EACpB,mBAAwC,EACV,EAAE,CAAC,CAAC;IAClC,GAAG,CAAC,MAAM,gCAAgC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC3E,GAAG,CAAC,MAAM,wCAAwC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CACpF,CAAC,CAAC","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nimport { getEmailSendEmailActionProcessor } from './getEmailSendEmailActionProcessor';\nimport { getEmailSetDeliveryStatusActionProcessor } from './getEmailSetDeliveryStatusActionProcessor';\n\nexport const getEmailActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getEmailSendEmailActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getEmailSetDeliveryStatusActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { getEmailActionProcessor } from './email';
|
|
1
2
|
import { getServiceFunctionActionProcessor } from './serviceFunction';
|
|
2
3
|
import { getWebEntryActionProcessor } from './webEntry';
|
|
3
4
|
import { getWebsocketActionProcessor } from './websocket';
|
|
5
|
+
export * from './email';
|
|
4
6
|
export * from './serviceFunction';
|
|
5
7
|
export * from './webEntry';
|
|
6
8
|
export * from './websocket';
|
|
7
9
|
export const getWebserverActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
10
|
+
...(await getEmailActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
8
11
|
...(await getWebEntryActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
9
12
|
...(await getServiceFunctionActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
10
13
|
...(await getWebsocketActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/getActionProcessor/webserver/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAI5B,MAAM,CAAC,MAAM,2BAA2B,GAAgC,KAAK,EAC3E,SAAoB,EACpB,mBAAwC,EACV,EAAE,CAAC,CAAC;IAClC,GAAG,CAAC,MAAM,0BAA0B,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACrE,GAAG,CAAC,MAAM,iCAAiC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC5E,GAAG,CAAC,MAAM,2BAA2B,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CACvE,CAAC,CAAC","sourcesContent":["import { getServiceFunctionActionProcessor } from './serviceFunction';\nimport { getWebEntryActionProcessor } from './webEntry';\nimport { getWebsocketActionProcessor } from './websocket';\n\nexport * from './serviceFunction';\nexport * from './webEntry';\nexport * from './websocket';\n\nimport { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nexport const getWebserverActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getWebEntryActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getServiceFunctionActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getWebsocketActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/getActionProcessor/webserver/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAI5B,MAAM,CAAC,MAAM,2BAA2B,GAAgC,KAAK,EAC3E,SAAoB,EACpB,mBAAwC,EACV,EAAE,CAAC,CAAC;IAClC,GAAG,CAAC,MAAM,uBAAuB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAClE,GAAG,CAAC,MAAM,0BAA0B,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACrE,GAAG,CAAC,MAAM,iCAAiC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC5E,GAAG,CAAC,MAAM,2BAA2B,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CACvE,CAAC,CAAC","sourcesContent":["import { getEmailActionProcessor } from './email';\nimport { getServiceFunctionActionProcessor } from './serviceFunction';\nimport { getWebEntryActionProcessor } from './webEntry';\nimport { getWebsocketActionProcessor } from './websocket';\n\nexport * from './email';\nexport * from './serviceFunction';\nexport * from './webEntry';\nexport * from './websocket';\n\nimport { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nexport const getWebserverActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getEmailActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getWebEntryActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getServiceFunctionActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getWebsocketActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const globalSignOut: (accessToken: string, region: string) => Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CognitoIdentityProviderClient, GlobalSignOutCommand } from '@aws-sdk/client-cognito-identity-provider';
|
|
2
|
+
import { createAwsClient } from '../createAwsClient';
|
|
3
|
+
// Revokes EVERY refresh token issued to the user who owns this access token. Authorized by
|
|
4
|
+
// the access token itself (no IAM needed, like ChangePassword). Access tokens already minted
|
|
5
|
+
// stay valid until they expire (stateless JWTs), so keep the access-token validity short.
|
|
6
|
+
export const globalSignOut = async (accessToken, region) => {
|
|
7
|
+
const cognitoClient = createAwsClient(CognitoIdentityProviderClient, {
|
|
8
|
+
region,
|
|
9
|
+
});
|
|
10
|
+
const params = {
|
|
11
|
+
AccessToken: accessToken,
|
|
12
|
+
};
|
|
13
|
+
await cognitoClient.send(new GlobalSignOutCommand(params));
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=globalSignOut.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalSignOut.js","sourceRoot":"","sources":["../../../../src/logic/cognito/globalSignOut.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAA6B,MAAM,2CAA2C,CAAC;AAE3I,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,2FAA2F;AAC3F,6FAA6F;AAC7F,0FAA0F;AAC1F,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,WAAmB,EAAE,MAAc,EAAiB,EAAE;IACxF,MAAM,aAAa,GAAG,eAAe,CAAC,6BAA6B,EAAE;QACnE,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,MAAM,GAA8B;QACxC,WAAW,EAAE,WAAW;KACzB,CAAC;IAEF,MAAM,aAAa,CAAC,IAAI,CAAC,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC","sourcesContent":["import { CognitoIdentityProviderClient, GlobalSignOutCommand, GlobalSignOutCommandInput } from '@aws-sdk/client-cognito-identity-provider';\n\nimport { createAwsClient } from '../createAwsClient';\n\n// Revokes EVERY refresh token issued to the user who owns this access token. Authorized by\n// the access token itself (no IAM needed, like ChangePassword). Access tokens already minted\n// stay valid until they expire (stateless JWTs), so keep the access-token validity short.\nexport const globalSignOut = async (accessToken: string, region: string): Promise<void> => {\n const cognitoClient = createAwsClient(CognitoIdentityProviderClient, {\n region,\n });\n\n const params: GlobalSignOutCommandInput = {\n AccessToken: accessToken,\n };\n\n await cognitoClient.send(new GlobalSignOutCommand(params));\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/logic/cognito/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './decodeAccessToken';\nexport * from './decodeValidJwt';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/logic/cognito/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './decodeAccessToken';\nexport * from './decodeValidJwt';\nexport * from './globalSignOut';\nexport * from './revokeRefreshToken';\n"]}
|
|
@@ -21,6 +21,15 @@ export const refreshToken = async (userPoolId, clientId, region, username, refre
|
|
|
21
21
|
// Time we issued the request
|
|
22
22
|
const issueDateTime = new Date().toISOString();
|
|
23
23
|
const response = await cognitoClient.send(new AdminInitiateAuthCommand(params));
|
|
24
|
-
|
|
24
|
+
const authResponse = cognitoAdminInitiateAuthResponseToQpqAuthenticationInfo(response, issueDateTime);
|
|
25
|
+
// Cognito's REFRESH_TOKEN_AUTH flow does NOT return a refresh token — the existing one stays
|
|
26
|
+
// valid and is reused — so AuthenticationResult.RefreshToken is undefined here. Carry the
|
|
27
|
+
// caller's refresh token forward so the client keeps a usable session; without this it's
|
|
28
|
+
// dropped after the first refresh and the session can never refresh again. (If refresh-token
|
|
29
|
+
// rotation is ever enabled, Cognito DOES return a new one — then we keep that instead.)
|
|
30
|
+
if (authResponse.authenticationInfo && !authResponse.authenticationInfo.refreshToken) {
|
|
31
|
+
authResponse.authenticationInfo.refreshToken = refreshToken;
|
|
32
|
+
}
|
|
33
|
+
return authResponse;
|
|
25
34
|
};
|
|
26
35
|
//# sourceMappingURL=refreshToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refreshToken.js","sourceRoot":"","sources":["../../../../src/logic/cognito/refreshToken.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EAExB,YAAY,EACZ,6BAA6B,GAC9B,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,uDAAuD,EAAE,MAAM,kCAAkC,CAAC;AAC3G,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,UAAkB,EAClB,QAAgB,EAChB,MAAc,EACd,QAAgB,EAChB,YAAoB,EACe,EAAE;IACrC,MAAM,aAAa,GAAG,eAAe,CAAC,6BAA6B,EAAE;QACnE,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,uBAAuB,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjF,MAAM,UAAU,GAAG,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IAEzE,MAAM,MAAM,GAAkC;QAC5C,QAAQ,EAAE,YAAY,CAAC,kBAAkB;QACzC,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,QAAQ;QAElB,cAAc,EAAE;YACd,aAAa,EAAE,YAAY;YAC3B,WAAW,EAAE,UAAU;SACxB;KACF,CAAC;IAEF,6BAA6B;IAC7B,MAAM,aAAa,GAAG,IAAI,IAAI,EAAE,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AAwB,CAAC,MAAM,CAAC,CAAC,CAAC;IAEhF,MAAM,YAAY,GAAG,uDAAuD,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAEtG,6FAA6F;IAC7F,0FAA0F;IAC1F,yFAAyF;IACzF,6FAA6F;IAC7F,wFAAwF;IACxF,IAAI,YAAY,CAAC,kBAAkB,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,YAAY,EAAE,CAAC;QACrF,YAAY,CAAC,kBAAkB,CAAC,YAAY,GAAG,YAAY,CAAC;IAC9D,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import { AuthenticateUserResponse } from 'quidproquo-core';\n\nimport {\n AdminInitiateAuthCommand,\n AdminInitiateAuthCommandInput,\n AuthFlowType,\n CognitoIdentityProviderClient,\n} from '@aws-sdk/client-cognito-identity-provider';\n\nimport { createAwsClient } from '../createAwsClient';\nimport { calculateSecretHash } from './utils/calculateSecretHash';\nimport { cognitoAdminInitiateAuthResponseToQpqAuthenticationInfo } from './utils/transformCognitoResponse';\nimport { getUserPoolClientSecret } from './getUserPoolClientSecret';\n\nexport const refreshToken = async (\n userPoolId: string,\n clientId: string,\n region: string,\n username: string,\n refreshToken: string,\n): Promise<AuthenticateUserResponse> => {\n const cognitoClient = createAwsClient(CognitoIdentityProviderClient, {\n region,\n });\n\n const clientSecret = await getUserPoolClientSecret(userPoolId, clientId, region);\n const secretHash = calculateSecretHash(username, clientId, clientSecret);\n\n const params: AdminInitiateAuthCommandInput = {\n AuthFlow: AuthFlowType.REFRESH_TOKEN_AUTH,\n UserPoolId: userPoolId,\n ClientId: clientId,\n\n AuthParameters: {\n REFRESH_TOKEN: refreshToken,\n SECRET_HASH: secretHash,\n },\n };\n\n // Time we issued the request\n const issueDateTime = new Date().toISOString();\n const response = await cognitoClient.send(new AdminInitiateAuthCommand(params));\n\n const authResponse = cognitoAdminInitiateAuthResponseToQpqAuthenticationInfo(response, issueDateTime);\n\n // Cognito's REFRESH_TOKEN_AUTH flow does NOT return a refresh token — the existing one stays\n // valid and is reused — so AuthenticationResult.RefreshToken is undefined here. Carry the\n // caller's refresh token forward so the client keeps a usable session; without this it's\n // dropped after the first refresh and the session can never refresh again. (If refresh-token\n // rotation is ever enabled, Cognito DOES return a new one — then we keep that instead.)\n if (authResponse.authenticationInfo && !authResponse.authenticationInfo.refreshToken) {\n authResponse.authenticationInfo.refreshToken = refreshToken;\n }\n\n return authResponse;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const revokeRefreshToken: (userPoolId: string, clientId: string, region: string, refreshToken: string) => Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CognitoIdentityProviderClient, RevokeTokenCommand } from '@aws-sdk/client-cognito-identity-provider';
|
|
2
|
+
import { createAwsClient } from '../createAwsClient';
|
|
3
|
+
import { getUserPoolClientSecret } from './getUserPoolClientSecret';
|
|
4
|
+
// Revokes a single refresh token (and its access-token lineage) via Cognito RevokeToken.
|
|
5
|
+
// The app client has a secret (same one the refresh flow uses), so it must be supplied.
|
|
6
|
+
// Requires token revocation to be enabled on the app client (the CDK default) — a disabled
|
|
7
|
+
// client surfaces as UnsupportedOperationException/UnsupportedTokenTypeException.
|
|
8
|
+
export const revokeRefreshToken = async (userPoolId, clientId, region, refreshToken) => {
|
|
9
|
+
const cognitoClient = createAwsClient(CognitoIdentityProviderClient, {
|
|
10
|
+
region,
|
|
11
|
+
});
|
|
12
|
+
const clientSecret = await getUserPoolClientSecret(userPoolId, clientId, region);
|
|
13
|
+
const params = {
|
|
14
|
+
Token: refreshToken,
|
|
15
|
+
ClientId: clientId,
|
|
16
|
+
ClientSecret: clientSecret,
|
|
17
|
+
};
|
|
18
|
+
await cognitoClient.send(new RevokeTokenCommand(params));
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=revokeRefreshToken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revokeRefreshToken.js","sourceRoot":"","sources":["../../../../src/logic/cognito/revokeRefreshToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,kBAAkB,EAA2B,MAAM,2CAA2C,CAAC;AAEvI,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,yFAAyF;AACzF,wFAAwF;AACxF,2FAA2F;AAC3F,kFAAkF;AAClF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAkB,EAAE,QAAgB,EAAE,MAAc,EAAE,YAAoB,EAAiB,EAAE;IACpI,MAAM,aAAa,GAAG,eAAe,CAAC,6BAA6B,EAAE;QACnE,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,uBAAuB,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEjF,MAAM,MAAM,GAA4B;QACtC,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,YAAY;KAC3B,CAAC;IAEF,MAAM,aAAa,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3D,CAAC,CAAC","sourcesContent":["import { CognitoIdentityProviderClient, RevokeTokenCommand, RevokeTokenCommandInput } from '@aws-sdk/client-cognito-identity-provider';\n\nimport { createAwsClient } from '../createAwsClient';\nimport { getUserPoolClientSecret } from './getUserPoolClientSecret';\n\n// Revokes a single refresh token (and its access-token lineage) via Cognito RevokeToken.\n// The app client has a secret (same one the refresh flow uses), so it must be supplied.\n// Requires token revocation to be enabled on the app client (the CDK default) — a disabled\n// client surfaces as UnsupportedOperationException/UnsupportedTokenTypeException.\nexport const revokeRefreshToken = async (userPoolId: string, clientId: string, region: string, refreshToken: string): Promise<void> => {\n const cognitoClient = createAwsClient(CognitoIdentityProviderClient, {\n region,\n });\n\n const clientSecret = await getUserPoolClientSecret(userPoolId, clientId, region);\n\n const params: RevokeTokenCommandInput = {\n Token: refreshToken,\n ClientId: clientId,\n ClientSecret: clientSecret,\n };\n\n await cognitoClient.send(new RevokeTokenCommand(params));\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const generatePresignedUploadUrl: (bucketName: string, objectKey: string, region: string, expirationMs: number, correlationId?: string, contentType?: string) => Promise<string>;
|
|
1
|
+
export declare const generatePresignedUploadUrl: (bucketName: string, objectKey: string, region: string, expirationMs: number, correlationId?: string, contentType?: string, contentDisposition?: string) => Promise<string>;
|