@logto/connector-aws-ses 1.1.1 → 1.1.2

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 CHANGED
@@ -52,7 +52,7 @@ the following parameters are optional; parameters description can be found in th
52
52
 
53
53
  You can type in an email address and click on "Send" to see whether the settings work before "Save and Done".
54
54
 
55
- That's it. Don't forget to [Enable connector in sign-in experience](https://docs.logto.io/docs/tutorials/get-started/passwordless-sign-in-by-adding-connectors#enable-sms-or-email-passwordless-sign-in).
55
+ That's it. Don't forget to [Enable connector in sign-in experience](https://docs.logto.io/docs/recipes/configure-connectors/email-connector/enable-email-sign-in/).
56
56
 
57
57
  ### Configure types
58
58
 
@@ -0,0 +1,102 @@
1
+ import { s as strictParseShort, b as strictParseByte, e as strictParseFloat32 } from './index-s7VGoewj.js';
2
+
3
+ const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
4
+ const RFC3339 = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/);
5
+ const parseRfc3339DateTime = (value) => {
6
+ if (value === null || value === undefined) {
7
+ return undefined;
8
+ }
9
+ if (typeof value !== "string") {
10
+ throw new TypeError("RFC-3339 date-times must be expressed as strings");
11
+ }
12
+ const match = RFC3339.exec(value);
13
+ if (!match) {
14
+ throw new TypeError("Invalid RFC-3339 date-time value");
15
+ }
16
+ const [_, yearStr, monthStr, dayStr, hours, minutes, seconds, fractionalMilliseconds] = match;
17
+ const year = strictParseShort(stripLeadingZeroes(yearStr));
18
+ const month = parseDateValue(monthStr, "month", 1, 12);
19
+ const day = parseDateValue(dayStr, "day", 1, 31);
20
+ return buildDate(year, month, day, { hours, minutes, seconds, fractionalMilliseconds });
21
+ };
22
+ const RFC3339_WITH_OFFSET = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(([-+]\d{2}\:\d{2})|[zZ])$/);
23
+ const parseRfc3339DateTimeWithOffset = (value) => {
24
+ if (value === null || value === undefined) {
25
+ return undefined;
26
+ }
27
+ if (typeof value !== "string") {
28
+ throw new TypeError("RFC-3339 date-times must be expressed as strings");
29
+ }
30
+ const match = RFC3339_WITH_OFFSET.exec(value);
31
+ if (!match) {
32
+ throw new TypeError("Invalid RFC-3339 date-time value");
33
+ }
34
+ const [_, yearStr, monthStr, dayStr, hours, minutes, seconds, fractionalMilliseconds, offsetStr] = match;
35
+ const year = strictParseShort(stripLeadingZeroes(yearStr));
36
+ const month = parseDateValue(monthStr, "month", 1, 12);
37
+ const day = parseDateValue(dayStr, "day", 1, 31);
38
+ const date = buildDate(year, month, day, { hours, minutes, seconds, fractionalMilliseconds });
39
+ if (offsetStr.toUpperCase() != "Z") {
40
+ date.setTime(date.getTime() - parseOffsetToMilliseconds(offsetStr));
41
+ }
42
+ return date;
43
+ };
44
+ const buildDate = (year, month, day, time) => {
45
+ const adjustedMonth = month - 1;
46
+ validateDayOfMonth(year, adjustedMonth, day);
47
+ return new Date(Date.UTC(year, adjustedMonth, day, parseDateValue(time.hours, "hour", 0, 23), parseDateValue(time.minutes, "minute", 0, 59), parseDateValue(time.seconds, "seconds", 0, 60), parseMilliseconds(time.fractionalMilliseconds)));
48
+ };
49
+ const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
50
+ const validateDayOfMonth = (year, month, day) => {
51
+ let maxDays = DAYS_IN_MONTH[month];
52
+ if (month === 1 && isLeapYear(year)) {
53
+ maxDays = 29;
54
+ }
55
+ if (day > maxDays) {
56
+ throw new TypeError(`Invalid day for ${MONTHS[month]} in ${year}: ${day}`);
57
+ }
58
+ };
59
+ const isLeapYear = (year) => {
60
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
61
+ };
62
+ const parseDateValue = (value, type, lower, upper) => {
63
+ const dateVal = strictParseByte(stripLeadingZeroes(value));
64
+ if (dateVal < lower || dateVal > upper) {
65
+ throw new TypeError(`${type} must be between ${lower} and ${upper}, inclusive`);
66
+ }
67
+ return dateVal;
68
+ };
69
+ const parseMilliseconds = (value) => {
70
+ if (value === null || value === undefined) {
71
+ return 0;
72
+ }
73
+ return strictParseFloat32("0." + value) * 1000;
74
+ };
75
+ const parseOffsetToMilliseconds = (value) => {
76
+ const directionStr = value[0];
77
+ let direction = 1;
78
+ if (directionStr == "+") {
79
+ direction = 1;
80
+ }
81
+ else if (directionStr == "-") {
82
+ direction = -1;
83
+ }
84
+ else {
85
+ throw new TypeError(`Offset direction, ${directionStr}, must be "+" or "-"`);
86
+ }
87
+ const hour = Number(value.substring(1, 3));
88
+ const minute = Number(value.substring(4, 6));
89
+ return direction * (hour * 60 + minute) * 60 * 1000;
90
+ };
91
+ const stripLeadingZeroes = (value) => {
92
+ let idx = 0;
93
+ while (idx < value.length - 1 && value.charAt(idx) === "0") {
94
+ idx++;
95
+ }
96
+ if (idx === 0) {
97
+ return value;
98
+ }
99
+ return value.slice(idx);
100
+ };
101
+
102
+ export { parseRfc3339DateTimeWithOffset as a, parseRfc3339DateTime as p };