@overturo/js 0.0.0-stage → 1.5.1
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/LICENSE +201 -0
- package/README.md +391 -2
- package/dist/field/index.cjs +1286 -0
- package/dist/field/index.cjs.map +1 -0
- package/dist/field/index.d.cts +174 -0
- package/dist/field/index.d.ts +174 -0
- package/dist/field/index.js +1247 -0
- package/dist/field/index.js.map +1 -0
- package/dist/index.cjs +4621 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1364 -0
- package/dist/index.d.ts +1364 -0
- package/dist/index.js +4579 -0
- package/dist/index.js.map +1 -0
- package/dist/overturo-field.global.js +2 -0
- package/dist/overturo.global.js +2 -0
- package/package.json +80 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,4579 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
6
|
+
try {
|
|
7
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw mod = 0, e;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
13
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
14
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
15
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
16
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
17
|
+
|
|
18
|
+
// node_modules/ajv-formats/dist/formats.js
|
|
19
|
+
var require_formats = __commonJS({
|
|
20
|
+
"node_modules/ajv-formats/dist/formats.js"(exports) {
|
|
21
|
+
"use strict";
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
|
|
24
|
+
function fmtDef(validate2, compare) {
|
|
25
|
+
return { validate: validate2, compare };
|
|
26
|
+
}
|
|
27
|
+
exports.fullFormats = {
|
|
28
|
+
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
29
|
+
date: fmtDef(date, compareDate),
|
|
30
|
+
// date-time: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
31
|
+
time: fmtDef(getTime(true), compareTime),
|
|
32
|
+
"date-time": fmtDef(getDateTime(true), compareDateTime),
|
|
33
|
+
"iso-time": fmtDef(getTime(), compareIsoTime),
|
|
34
|
+
"iso-date-time": fmtDef(getDateTime(), compareIsoDateTime),
|
|
35
|
+
// duration: https://tools.ietf.org/html/rfc3339#appendix-A
|
|
36
|
+
duration: /^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,
|
|
37
|
+
uri,
|
|
38
|
+
"uri-reference": /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,
|
|
39
|
+
// uri-template: https://tools.ietf.org/html/rfc6570
|
|
40
|
+
"uri-template": /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,
|
|
41
|
+
// For the source: https://gist.github.com/dperini/729294
|
|
42
|
+
// For test cases: https://mathiasbynens.be/demo/url-regex
|
|
43
|
+
url: /^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,
|
|
44
|
+
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
|
|
45
|
+
hostname: /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,
|
|
46
|
+
// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
|
|
47
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,
|
|
48
|
+
ipv6: /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,
|
|
49
|
+
regex,
|
|
50
|
+
// uuid: http://tools.ietf.org/html/rfc4122
|
|
51
|
+
uuid: /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,
|
|
52
|
+
// JSON-pointer: https://tools.ietf.org/html/rfc6901
|
|
53
|
+
// uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
|
|
54
|
+
"json-pointer": /^(?:\/(?:[^~/]|~0|~1)*)*$/,
|
|
55
|
+
"json-pointer-uri-fragment": /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,
|
|
56
|
+
// relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
|
|
57
|
+
"relative-json-pointer": /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,
|
|
58
|
+
// the following formats are used by the openapi specification: https://spec.openapis.org/oas/v3.0.0#data-types
|
|
59
|
+
// byte: https://github.com/miguelmota/is-base64
|
|
60
|
+
byte,
|
|
61
|
+
// signed 32 bit integer
|
|
62
|
+
int32: { type: "number", validate: validateInt32 },
|
|
63
|
+
// signed 64 bit integer
|
|
64
|
+
int64: { type: "number", validate: validateInt64 },
|
|
65
|
+
// C-type float
|
|
66
|
+
float: { type: "number", validate: validateNumber },
|
|
67
|
+
// C-type double
|
|
68
|
+
double: { type: "number", validate: validateNumber },
|
|
69
|
+
// hint to the UI to hide input strings
|
|
70
|
+
password: true,
|
|
71
|
+
// unchecked string payload
|
|
72
|
+
binary: true
|
|
73
|
+
};
|
|
74
|
+
exports.fastFormats = {
|
|
75
|
+
...exports.fullFormats,
|
|
76
|
+
date: fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d$/, compareDate),
|
|
77
|
+
time: fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareTime),
|
|
78
|
+
"date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareDateTime),
|
|
79
|
+
"iso-time": fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoTime),
|
|
80
|
+
"iso-date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoDateTime),
|
|
81
|
+
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
|
|
82
|
+
uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
|
|
83
|
+
"uri-reference": /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
|
|
84
|
+
// email (sources from jsen validator):
|
|
85
|
+
// http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
|
|
86
|
+
// http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'wilful violation')
|
|
87
|
+
email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i
|
|
88
|
+
};
|
|
89
|
+
exports.formatNames = Object.keys(exports.fullFormats);
|
|
90
|
+
function isLeapYear(year) {
|
|
91
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
92
|
+
}
|
|
93
|
+
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
94
|
+
var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
95
|
+
function date(str) {
|
|
96
|
+
const matches = DATE.exec(str);
|
|
97
|
+
if (!matches)
|
|
98
|
+
return false;
|
|
99
|
+
const year = +matches[1];
|
|
100
|
+
const month = +matches[2];
|
|
101
|
+
const day = +matches[3];
|
|
102
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month]);
|
|
103
|
+
}
|
|
104
|
+
function compareDate(d1, d2) {
|
|
105
|
+
if (!(d1 && d2))
|
|
106
|
+
return void 0;
|
|
107
|
+
if (d1 > d2)
|
|
108
|
+
return 1;
|
|
109
|
+
if (d1 < d2)
|
|
110
|
+
return -1;
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
|
|
114
|
+
function getTime(strictTimeZone) {
|
|
115
|
+
return function time(str) {
|
|
116
|
+
const matches = TIME.exec(str);
|
|
117
|
+
if (!matches)
|
|
118
|
+
return false;
|
|
119
|
+
const hr = +matches[1];
|
|
120
|
+
const min = +matches[2];
|
|
121
|
+
const sec = +matches[3];
|
|
122
|
+
const tz = matches[4];
|
|
123
|
+
const tzSign = matches[5] === "-" ? -1 : 1;
|
|
124
|
+
const tzH = +(matches[6] || 0);
|
|
125
|
+
const tzM = +(matches[7] || 0);
|
|
126
|
+
if (tzH > 23 || tzM > 59 || strictTimeZone && !tz)
|
|
127
|
+
return false;
|
|
128
|
+
if (hr <= 23 && min <= 59 && sec < 60)
|
|
129
|
+
return true;
|
|
130
|
+
const utcMin = min - tzM * tzSign;
|
|
131
|
+
const utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0);
|
|
132
|
+
return (utcHr === 23 || utcHr === -1) && (utcMin === 59 || utcMin === -1) && sec < 61;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function compareTime(s1, s2) {
|
|
136
|
+
if (!(s1 && s2))
|
|
137
|
+
return void 0;
|
|
138
|
+
const t1 = (/* @__PURE__ */ new Date("2020-01-01T" + s1)).valueOf();
|
|
139
|
+
const t2 = (/* @__PURE__ */ new Date("2020-01-01T" + s2)).valueOf();
|
|
140
|
+
if (!(t1 && t2))
|
|
141
|
+
return void 0;
|
|
142
|
+
return t1 - t2;
|
|
143
|
+
}
|
|
144
|
+
function compareIsoTime(t1, t2) {
|
|
145
|
+
if (!(t1 && t2))
|
|
146
|
+
return void 0;
|
|
147
|
+
const a1 = TIME.exec(t1);
|
|
148
|
+
const a2 = TIME.exec(t2);
|
|
149
|
+
if (!(a1 && a2))
|
|
150
|
+
return void 0;
|
|
151
|
+
t1 = a1[1] + a1[2] + a1[3];
|
|
152
|
+
t2 = a2[1] + a2[2] + a2[3];
|
|
153
|
+
if (t1 > t2)
|
|
154
|
+
return 1;
|
|
155
|
+
if (t1 < t2)
|
|
156
|
+
return -1;
|
|
157
|
+
return 0;
|
|
158
|
+
}
|
|
159
|
+
var DATE_TIME_SEPARATOR = /t|\s/i;
|
|
160
|
+
function getDateTime(strictTimeZone) {
|
|
161
|
+
const time = getTime(strictTimeZone);
|
|
162
|
+
return function date_time(str) {
|
|
163
|
+
const dateTime = str.split(DATE_TIME_SEPARATOR);
|
|
164
|
+
return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1]);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function compareDateTime(dt1, dt2) {
|
|
168
|
+
if (!(dt1 && dt2))
|
|
169
|
+
return void 0;
|
|
170
|
+
const d1 = new Date(dt1).valueOf();
|
|
171
|
+
const d2 = new Date(dt2).valueOf();
|
|
172
|
+
if (!(d1 && d2))
|
|
173
|
+
return void 0;
|
|
174
|
+
return d1 - d2;
|
|
175
|
+
}
|
|
176
|
+
function compareIsoDateTime(dt1, dt2) {
|
|
177
|
+
if (!(dt1 && dt2))
|
|
178
|
+
return void 0;
|
|
179
|
+
const [d1, t1] = dt1.split(DATE_TIME_SEPARATOR);
|
|
180
|
+
const [d2, t2] = dt2.split(DATE_TIME_SEPARATOR);
|
|
181
|
+
const res = compareDate(d1, d2);
|
|
182
|
+
if (res === void 0)
|
|
183
|
+
return void 0;
|
|
184
|
+
return res || compareTime(t1, t2);
|
|
185
|
+
}
|
|
186
|
+
var NOT_URI_FRAGMENT = /\/|:/;
|
|
187
|
+
var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
188
|
+
function uri(str) {
|
|
189
|
+
return NOT_URI_FRAGMENT.test(str) && URI.test(str);
|
|
190
|
+
}
|
|
191
|
+
var BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
|
|
192
|
+
function byte(str) {
|
|
193
|
+
BYTE.lastIndex = 0;
|
|
194
|
+
return BYTE.test(str);
|
|
195
|
+
}
|
|
196
|
+
var MIN_INT32 = -(2 ** 31);
|
|
197
|
+
var MAX_INT32 = 2 ** 31 - 1;
|
|
198
|
+
function validateInt32(value) {
|
|
199
|
+
return Number.isInteger(value) && value <= MAX_INT32 && value >= MIN_INT32;
|
|
200
|
+
}
|
|
201
|
+
function validateInt64(value) {
|
|
202
|
+
return Number.isInteger(value);
|
|
203
|
+
}
|
|
204
|
+
function validateNumber() {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
var Z_ANCHOR = /[^\\]\\Z/;
|
|
208
|
+
function regex(str) {
|
|
209
|
+
if (Z_ANCHOR.test(str))
|
|
210
|
+
return false;
|
|
211
|
+
try {
|
|
212
|
+
new RegExp(str);
|
|
213
|
+
return true;
|
|
214
|
+
} catch (e) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// node_modules/ajv/dist/runtime/ucs2length.js
|
|
222
|
+
var require_ucs2length = __commonJS({
|
|
223
|
+
"node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
|
|
224
|
+
"use strict";
|
|
225
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
226
|
+
function ucs2length(str) {
|
|
227
|
+
const len = str.length;
|
|
228
|
+
let length = 0;
|
|
229
|
+
let pos = 0;
|
|
230
|
+
let value;
|
|
231
|
+
while (pos < len) {
|
|
232
|
+
length++;
|
|
233
|
+
value = str.charCodeAt(pos++);
|
|
234
|
+
if (value >= 55296 && value <= 56319 && pos < len) {
|
|
235
|
+
value = str.charCodeAt(pos);
|
|
236
|
+
if ((value & 64512) === 56320)
|
|
237
|
+
pos++;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return length;
|
|
241
|
+
}
|
|
242
|
+
exports.default = ucs2length;
|
|
243
|
+
ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default';
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// src/constants.ts
|
|
248
|
+
var MESSAGE_TYPES_V2 = {
|
|
249
|
+
READY: "overturo:ready",
|
|
250
|
+
STATE: "overturo:state",
|
|
251
|
+
COMPLETE: "overturo:complete",
|
|
252
|
+
CANCEL: "overturo:cancel",
|
|
253
|
+
ERROR: "overturo:error",
|
|
254
|
+
RESIZE: "overturo:resize",
|
|
255
|
+
DEADLINE: "overturo:deadline"
|
|
256
|
+
};
|
|
257
|
+
var EMBED_DEFAULTS = {
|
|
258
|
+
width: "100%",
|
|
259
|
+
minHeight: "400px",
|
|
260
|
+
maxHeight: "none",
|
|
261
|
+
border: "none",
|
|
262
|
+
borderRadius: "0",
|
|
263
|
+
background: "transparent"
|
|
264
|
+
};
|
|
265
|
+
var EMBED_STYLE_KEYS = Object.keys(EMBED_DEFAULTS);
|
|
266
|
+
var POPUP_DEFAULTS = {
|
|
267
|
+
width: 500,
|
|
268
|
+
height: 700
|
|
269
|
+
};
|
|
270
|
+
var SETUP_MESSAGE_TYPES = {
|
|
271
|
+
READY: "overturoid:ready",
|
|
272
|
+
RESIZE: "overturoid:resize",
|
|
273
|
+
STEP: "overturoid:setup:step",
|
|
274
|
+
CREATED: "overturoid:setup:created",
|
|
275
|
+
CANCEL: "overturoid:cancel",
|
|
276
|
+
ERROR: "overturoid:error",
|
|
277
|
+
PING: "overturoid:ping",
|
|
278
|
+
HEARTBEAT: "overturoid:heartbeat"
|
|
279
|
+
};
|
|
280
|
+
var SETUP_POPUP_DEFAULTS = {
|
|
281
|
+
width: 600,
|
|
282
|
+
height: 800
|
|
283
|
+
};
|
|
284
|
+
var API_PATH = "/api/v1/consent_sessions";
|
|
285
|
+
var DECISIONS_API_PATH = "/api/v1/decisions";
|
|
286
|
+
var DECISIONS_FLOW_PATH = "/decisions";
|
|
287
|
+
var MEETING_CONSENTS_API_PATH = "/api/v1/meeting_consents";
|
|
288
|
+
var SETUP_API_PATH = "/api/v1/accord_setup_sessions";
|
|
289
|
+
var PREVIEW_TOKENS_PATH = "/api/v1/preview_tokens";
|
|
290
|
+
var DEFAULT_BASE_URL = "https://overturo.com";
|
|
291
|
+
var MESSAGE_PREFIX_V2 = "overturo:";
|
|
292
|
+
function isForeignEnvelope(data) {
|
|
293
|
+
const type = data?.type;
|
|
294
|
+
return typeof type === "string" && !type.startsWith(MESSAGE_PREFIX_V2);
|
|
295
|
+
}
|
|
296
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
297
|
+
var CONSENT_FIELD_ELEMENT_NAME = "overturo-consent-field";
|
|
298
|
+
|
|
299
|
+
// src/errors.ts
|
|
300
|
+
var OverturoError = class extends Error {
|
|
301
|
+
constructor(message) {
|
|
302
|
+
super(message);
|
|
303
|
+
this.name = "OverturoError";
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
var OverturoValidationError = class extends OverturoError {
|
|
307
|
+
constructor(message) {
|
|
308
|
+
super(message);
|
|
309
|
+
this.name = "OverturoValidationError";
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
var OverturoApiError = class extends OverturoError {
|
|
313
|
+
constructor(message, status, body) {
|
|
314
|
+
super(message);
|
|
315
|
+
this.name = "OverturoApiError";
|
|
316
|
+
this.status = status;
|
|
317
|
+
this.body = body;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
var OverturoNetworkError = class extends OverturoError {
|
|
321
|
+
constructor(message, cause) {
|
|
322
|
+
super(message);
|
|
323
|
+
this.name = "OverturoNetworkError";
|
|
324
|
+
this.cause = cause;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
var OverturoTimeoutError = class extends OverturoError {
|
|
328
|
+
constructor(message = "Operation timed out") {
|
|
329
|
+
super(message);
|
|
330
|
+
this.name = "OverturoTimeoutError";
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
var OapDenied = class _OapDenied extends OverturoApiError {
|
|
334
|
+
constructor(envelope, status, body) {
|
|
335
|
+
super(envelope.message, status, body);
|
|
336
|
+
this.name = "OapDenied";
|
|
337
|
+
this.reason_code = envelope.reason_code;
|
|
338
|
+
this.failed_bound = envelope.failed_bound;
|
|
339
|
+
this.denial_category = envelope.denial_category;
|
|
340
|
+
this.cascade_step = envelope.cascade_step;
|
|
341
|
+
this.detail = envelope.detail;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Build the most-specific subclass for the envelope. Reason-code
|
|
345
|
+
* dispatch takes precedence over category dispatch so the most
|
|
346
|
+
* specific subclass wins (sequence denials are
|
|
347
|
+
* trajectory_denied but get their own subclass).
|
|
348
|
+
*/
|
|
349
|
+
static fromEnvelope(envelope, status, body) {
|
|
350
|
+
if (envelope.reason_code === "sequence_prohibited" || envelope.reason_code === "sequence_missing_predecessor") {
|
|
351
|
+
return new OapSequenceDenied(envelope, status, body);
|
|
352
|
+
}
|
|
353
|
+
switch (envelope.denial_category) {
|
|
354
|
+
case "authorization_denied":
|
|
355
|
+
return new OapAuthorizationDenied(envelope, status, body);
|
|
356
|
+
case "intent_denied":
|
|
357
|
+
return new OapIntentDenied(envelope, status, body);
|
|
358
|
+
case "trajectory_denied":
|
|
359
|
+
return new OapTrajectoryDenied(envelope, status, body);
|
|
360
|
+
default:
|
|
361
|
+
return new _OapDenied(envelope, status, body);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
var OapAuthorizationDenied = class extends OapDenied {
|
|
366
|
+
constructor(envelope, status, body) {
|
|
367
|
+
super(envelope, status, body);
|
|
368
|
+
this.name = "OapAuthorizationDenied";
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
var OapIntentDenied = class extends OapDenied {
|
|
372
|
+
constructor(envelope, status, body) {
|
|
373
|
+
super(envelope, status, body);
|
|
374
|
+
this.name = "OapIntentDenied";
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
var OapTrajectoryDenied = class extends OapDenied {
|
|
378
|
+
constructor(envelope, status, body) {
|
|
379
|
+
super(envelope, status, body);
|
|
380
|
+
this.name = "OapTrajectoryDenied";
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
var OapSequenceDenied = class extends OapTrajectoryDenied {
|
|
384
|
+
constructor(envelope, status, body) {
|
|
385
|
+
super(envelope, status, body);
|
|
386
|
+
this.name = "OapSequenceDenied";
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
// src/api.ts
|
|
391
|
+
function extractErrorMessage(body, status) {
|
|
392
|
+
if (body && typeof body === "object") {
|
|
393
|
+
const raw = body.error;
|
|
394
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
395
|
+
if (raw && typeof raw === "object") {
|
|
396
|
+
const inner = raw;
|
|
397
|
+
if (typeof inner.message === "string" && inner.message.length > 0) {
|
|
398
|
+
return typeof inner.code === "string" && inner.code.length > 0 ? `${inner.code}: ${inner.message}` : inner.message;
|
|
399
|
+
}
|
|
400
|
+
if (inner.errors && typeof inner.errors === "object") {
|
|
401
|
+
const firstField = Object.keys(inner.errors)[0];
|
|
402
|
+
if (firstField) {
|
|
403
|
+
const msgs = inner.errors[firstField];
|
|
404
|
+
const first = Array.isArray(msgs) ? msgs[0] : msgs;
|
|
405
|
+
if (typeof first === "string") {
|
|
406
|
+
const codePrefix = typeof inner.code === "string" && inner.code.length > 0 ? `${inner.code}: ` : "";
|
|
407
|
+
return `${codePrefix}${firstField} ${first}`;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (typeof inner.code === "string" && inner.code.length > 0) {
|
|
412
|
+
return inner.code;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
const topMessage = body.message;
|
|
416
|
+
if (typeof topMessage === "string" && topMessage.length > 0) return topMessage;
|
|
417
|
+
}
|
|
418
|
+
return `HTTP ${status}`;
|
|
419
|
+
}
|
|
420
|
+
function camelToSnake(str) {
|
|
421
|
+
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
422
|
+
}
|
|
423
|
+
function snakeToCamel(str) {
|
|
424
|
+
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
425
|
+
}
|
|
426
|
+
function toSnakeCase(obj) {
|
|
427
|
+
if (Array.isArray(obj)) {
|
|
428
|
+
return obj.map(toSnakeCase);
|
|
429
|
+
}
|
|
430
|
+
if (obj !== null && typeof obj === "object") {
|
|
431
|
+
const result = {};
|
|
432
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
433
|
+
result[camelToSnake(key)] = toSnakeCase(value);
|
|
434
|
+
}
|
|
435
|
+
return result;
|
|
436
|
+
}
|
|
437
|
+
return obj;
|
|
438
|
+
}
|
|
439
|
+
function toCamelCase(obj) {
|
|
440
|
+
if (Array.isArray(obj)) {
|
|
441
|
+
return obj.map(toCamelCase);
|
|
442
|
+
}
|
|
443
|
+
if (obj !== null && typeof obj === "object") {
|
|
444
|
+
const result = {};
|
|
445
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
446
|
+
result[snakeToCamel(key)] = toCamelCase(value);
|
|
447
|
+
}
|
|
448
|
+
return result;
|
|
449
|
+
}
|
|
450
|
+
return obj;
|
|
451
|
+
}
|
|
452
|
+
var ApiClient = class {
|
|
453
|
+
constructor(options) {
|
|
454
|
+
this.baseUrl = options.baseUrl;
|
|
455
|
+
this.publishableKey = options.publishableKey;
|
|
456
|
+
this.apiKey = options.apiKey;
|
|
457
|
+
this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
|
|
458
|
+
}
|
|
459
|
+
async get(path) {
|
|
460
|
+
return this.request("GET", path);
|
|
461
|
+
}
|
|
462
|
+
async post(path, body) {
|
|
463
|
+
return this.request("POST", path, body);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* GET that returns the raw Response object without JSON parsing, case
|
|
467
|
+
* conversion or error throwing. Used where part of the body must stay
|
|
468
|
+
* verbatim (keys that are data, such as purpose names).
|
|
469
|
+
*/
|
|
470
|
+
async rawGet(path) {
|
|
471
|
+
return this.rawRequest("GET", path);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* POST that returns the raw Response object without JSON parsing or error throwing.
|
|
475
|
+
* Used by exchange() to handle HTTP 202 (fulfillment pending) with retry logic.
|
|
476
|
+
*/
|
|
477
|
+
async rawPost(path, body) {
|
|
478
|
+
return this.rawRequest("POST", path, body);
|
|
479
|
+
}
|
|
480
|
+
async rawRequest(method, path, body) {
|
|
481
|
+
const url = `${this.baseUrl}${path}`;
|
|
482
|
+
const headers = {
|
|
483
|
+
"Content-Type": "application/json",
|
|
484
|
+
"X-Publishable-Key": this.publishableKey
|
|
485
|
+
};
|
|
486
|
+
if (this.apiKey) {
|
|
487
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
488
|
+
}
|
|
489
|
+
const controller = new AbortController();
|
|
490
|
+
let timeoutId;
|
|
491
|
+
if (this.timeout > 0) {
|
|
492
|
+
timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
493
|
+
}
|
|
494
|
+
try {
|
|
495
|
+
return await fetch(url, {
|
|
496
|
+
method,
|
|
497
|
+
headers,
|
|
498
|
+
body: body === void 0 ? void 0 : JSON.stringify(toSnakeCase(body)),
|
|
499
|
+
signal: controller.signal
|
|
500
|
+
});
|
|
501
|
+
} catch (error) {
|
|
502
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
503
|
+
throw new OverturoTimeoutError(`Request timed out after ${this.timeout}ms`);
|
|
504
|
+
}
|
|
505
|
+
throw new OverturoNetworkError("Network request failed", error);
|
|
506
|
+
} finally {
|
|
507
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
async request(method, path, body) {
|
|
511
|
+
const url = `${this.baseUrl}${path}`;
|
|
512
|
+
const headers = {
|
|
513
|
+
"Content-Type": "application/json",
|
|
514
|
+
"X-Publishable-Key": this.publishableKey
|
|
515
|
+
};
|
|
516
|
+
if (this.apiKey) {
|
|
517
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
518
|
+
}
|
|
519
|
+
const controller = new AbortController();
|
|
520
|
+
let timeoutId;
|
|
521
|
+
if (this.timeout > 0) {
|
|
522
|
+
timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
523
|
+
}
|
|
524
|
+
let response;
|
|
525
|
+
try {
|
|
526
|
+
response = await fetch(url, {
|
|
527
|
+
method,
|
|
528
|
+
headers,
|
|
529
|
+
body: body ? JSON.stringify(toSnakeCase(body)) : void 0,
|
|
530
|
+
signal: controller.signal
|
|
531
|
+
});
|
|
532
|
+
} catch (error) {
|
|
533
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
534
|
+
throw new OverturoTimeoutError(`Request timed out after ${this.timeout}ms`);
|
|
535
|
+
}
|
|
536
|
+
throw new OverturoNetworkError("Network request failed", error);
|
|
537
|
+
} finally {
|
|
538
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
539
|
+
}
|
|
540
|
+
if (!response.ok) {
|
|
541
|
+
let responseBody;
|
|
542
|
+
try {
|
|
543
|
+
responseBody = await response.json();
|
|
544
|
+
} catch {
|
|
545
|
+
responseBody = null;
|
|
546
|
+
}
|
|
547
|
+
const message = extractErrorMessage(responseBody, response.status);
|
|
548
|
+
throw new OverturoApiError(message, response.status, responseBody);
|
|
549
|
+
}
|
|
550
|
+
const text = await response.text();
|
|
551
|
+
if (!text) {
|
|
552
|
+
return {};
|
|
553
|
+
}
|
|
554
|
+
return toCamelCase(JSON.parse(text));
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
// src/approvals_facade.ts
|
|
559
|
+
var _decisions, _api;
|
|
560
|
+
var ApprovalsFacade = class {
|
|
561
|
+
constructor(decisions, api) {
|
|
562
|
+
__privateAdd(this, _decisions);
|
|
563
|
+
__privateAdd(this, _api);
|
|
564
|
+
__privateSet(this, _decisions, decisions);
|
|
565
|
+
__privateSet(this, _api, api);
|
|
566
|
+
}
|
|
567
|
+
async open(opts) {
|
|
568
|
+
if (!opts.escalationId) {
|
|
569
|
+
throw new OverturoValidationError("escalationId is required");
|
|
570
|
+
}
|
|
571
|
+
const mode = opts.mode ?? "embed";
|
|
572
|
+
const session = await __privateGet(this, _decisions).createSession({
|
|
573
|
+
kind: "approval",
|
|
574
|
+
subjectRef: opts.escalationId,
|
|
575
|
+
mode,
|
|
576
|
+
embedOrigin: opts.embedOrigin,
|
|
577
|
+
state: opts.state,
|
|
578
|
+
redirectUri: opts.redirectUri
|
|
579
|
+
});
|
|
580
|
+
if (mode === "popup") {
|
|
581
|
+
return __privateGet(this, _decisions).popup({
|
|
582
|
+
token: session.token,
|
|
583
|
+
onComplete: (outcome) => {
|
|
584
|
+
if (outcome.kind === "approval") opts.onComplete?.(outcome);
|
|
585
|
+
},
|
|
586
|
+
onCancel: opts.onCancel,
|
|
587
|
+
onError: opts.onError
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
if (mode === "redirect") {
|
|
591
|
+
const url = __privateGet(this, _decisions).url({ token: session.token, mode: "redirect" });
|
|
592
|
+
window.location.href = url;
|
|
593
|
+
return {
|
|
594
|
+
token: session.token,
|
|
595
|
+
mode: "redirect",
|
|
596
|
+
destroy: async () => {
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
return __privateGet(this, _decisions).embed({
|
|
601
|
+
token: session.token,
|
|
602
|
+
container: opts.container,
|
|
603
|
+
style: opts.style,
|
|
604
|
+
loading: opts.loading,
|
|
605
|
+
onReady: opts.onReady,
|
|
606
|
+
onState: (_kind, payload) => opts.onState?.(payload),
|
|
607
|
+
onComplete: (outcome) => {
|
|
608
|
+
if (outcome.kind === "approval") opts.onComplete?.(outcome);
|
|
609
|
+
},
|
|
610
|
+
onCancel: opts.onCancel,
|
|
611
|
+
onError: opts.onError,
|
|
612
|
+
onDeadline: opts.onDeadline,
|
|
613
|
+
onCounter: opts.onCounter
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
url(opts) {
|
|
617
|
+
return __privateGet(this, _decisions).url({
|
|
618
|
+
token: opts.escalationId,
|
|
619
|
+
mode: opts.mode
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Polls `${decisions_api}/:token` for deadline metadata. Returns the
|
|
624
|
+
* computed remainingMs alongside the absolute deadlineAt for clock-
|
|
625
|
+
* skew tolerance in consumers.
|
|
626
|
+
*/
|
|
627
|
+
async deadline(token) {
|
|
628
|
+
if (!token) {
|
|
629
|
+
throw new OverturoValidationError("token is required for deadline");
|
|
630
|
+
}
|
|
631
|
+
const status = await __privateGet(this, _api).get(`${DECISIONS_API_PATH}/${token}`);
|
|
632
|
+
return {
|
|
633
|
+
remainingMs: Math.max(0, new Date(status.deadlineAt).getTime() - Date.now()),
|
|
634
|
+
deadlineAt: status.deadlineAt
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
_decisions = new WeakMap();
|
|
639
|
+
_api = new WeakMap();
|
|
640
|
+
|
|
641
|
+
// src/consent_facade.ts
|
|
642
|
+
var _decisions2;
|
|
643
|
+
var ConsentFacade = class {
|
|
644
|
+
constructor(decisions) {
|
|
645
|
+
__privateAdd(this, _decisions2);
|
|
646
|
+
__privateSet(this, _decisions2, decisions);
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Creates a consent session and mounts the iframe in one call.
|
|
650
|
+
* Bridges v0's `onStep(payload)` to v1's `onState(kind, payload)`
|
|
651
|
+
* so existing call sites keep working with a single rename.
|
|
652
|
+
*/
|
|
653
|
+
async open(opts) {
|
|
654
|
+
if (!opts.flowId) {
|
|
655
|
+
throw new OverturoValidationError("flowId is required");
|
|
656
|
+
}
|
|
657
|
+
const mode = opts.mode ?? "embed";
|
|
658
|
+
const session = await __privateGet(this, _decisions2).createSession({
|
|
659
|
+
kind: "consent",
|
|
660
|
+
subjectRef: opts.flowId,
|
|
661
|
+
mode,
|
|
662
|
+
embedOrigin: opts.embedOrigin,
|
|
663
|
+
scope: opts.scope,
|
|
664
|
+
state: opts.state,
|
|
665
|
+
nonce: opts.nonce,
|
|
666
|
+
redirectUri: opts.redirectUri
|
|
667
|
+
});
|
|
668
|
+
if (mode === "popup") {
|
|
669
|
+
return __privateGet(this, _decisions2).popup({
|
|
670
|
+
token: session.token,
|
|
671
|
+
onComplete: (outcome) => {
|
|
672
|
+
if (outcome.kind === "consent") opts.onComplete?.(outcome);
|
|
673
|
+
},
|
|
674
|
+
onCancel: opts.onCancel,
|
|
675
|
+
onError: opts.onError
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
if (mode === "redirect") {
|
|
679
|
+
const url = __privateGet(this, _decisions2).url({ token: session.token, mode: "redirect" });
|
|
680
|
+
window.location.href = url;
|
|
681
|
+
return {
|
|
682
|
+
token: session.token,
|
|
683
|
+
mode: "redirect",
|
|
684
|
+
destroy: async () => {
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
return __privateGet(this, _decisions2).embed({
|
|
689
|
+
token: session.token,
|
|
690
|
+
container: opts.container,
|
|
691
|
+
style: opts.style,
|
|
692
|
+
loading: opts.loading,
|
|
693
|
+
onReady: opts.onReady,
|
|
694
|
+
onState: (_kind, payload) => opts.onStep?.(payload),
|
|
695
|
+
onComplete: (outcome) => {
|
|
696
|
+
if (outcome.kind === "consent") opts.onComplete?.(outcome);
|
|
697
|
+
},
|
|
698
|
+
onCancel: opts.onCancel,
|
|
699
|
+
onError: opts.onError
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
url(opts) {
|
|
703
|
+
return __privateGet(this, _decisions2).url({
|
|
704
|
+
token: opts.flowId,
|
|
705
|
+
mode: opts.mode
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* pre-flight disclosure discovery. Thin delegate to
|
|
710
|
+
* `decisions.discover` so the kind facades stay symmetric.
|
|
711
|
+
*/
|
|
712
|
+
discover(opts) {
|
|
713
|
+
return __privateGet(this, _decisions2).discover(opts);
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
_decisions2 = new WeakMap();
|
|
717
|
+
|
|
718
|
+
// src/forms/intercept.ts
|
|
719
|
+
var DEFAULT_TOKEN_FIELD = "overturo_capture_token";
|
|
720
|
+
var CAPTURED_MARK = "overturoCaptured";
|
|
721
|
+
var CAPTURE_TIMEOUT_MS = 5e3;
|
|
722
|
+
var attached = /* @__PURE__ */ new WeakMap();
|
|
723
|
+
function interceptSubmit(form, opts, run) {
|
|
724
|
+
if (attached.has(form)) {
|
|
725
|
+
throw new OverturoValidationError("duplicate_attach: this form already has a capture interception; detach it before attaching again");
|
|
726
|
+
}
|
|
727
|
+
attached.set(form, true);
|
|
728
|
+
let inFlight = false;
|
|
729
|
+
const tokenField = opts.tokenFieldName ?? DEFAULT_TOKEN_FIELD;
|
|
730
|
+
const handler = (ev) => {
|
|
731
|
+
if (form.dataset[CAPTURED_MARK] === "1") {
|
|
732
|
+
delete form.dataset[CAPTURED_MARK];
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
ev.preventDefault();
|
|
736
|
+
ev.stopImmediatePropagation();
|
|
737
|
+
if (inFlight) return;
|
|
738
|
+
inFlight = true;
|
|
739
|
+
form.querySelector(`input[name="${tokenField}"]`)?.remove();
|
|
740
|
+
const submitter = ev.submitter ?? null;
|
|
741
|
+
void (async () => {
|
|
742
|
+
try {
|
|
743
|
+
const { token } = await withTimeout(run({ submitter }), CAPTURE_TIMEOUT_MS);
|
|
744
|
+
setHiddenInput(form, tokenField, token);
|
|
745
|
+
} catch (e) {
|
|
746
|
+
opts.onError?.(e);
|
|
747
|
+
} finally {
|
|
748
|
+
inFlight = false;
|
|
749
|
+
if (opts.submitAfterCapture !== false) {
|
|
750
|
+
form.dataset[CAPTURED_MARK] = "1";
|
|
751
|
+
resubmit(form, submitter);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
})();
|
|
755
|
+
};
|
|
756
|
+
form.addEventListener("submit", handler, { capture: true });
|
|
757
|
+
return () => {
|
|
758
|
+
attached.delete(form);
|
|
759
|
+
form.removeEventListener("submit", handler, { capture: true });
|
|
760
|
+
delete form.dataset[CAPTURED_MARK];
|
|
761
|
+
form.querySelector(`input[name="${tokenField}"]`)?.remove();
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function withTimeout(promise, ms) {
|
|
765
|
+
return new Promise((resolve, reject) => {
|
|
766
|
+
const timer = setTimeout(
|
|
767
|
+
() => reject(new OverturoValidationError(`capture timed out after ${ms} ms; the form submits without a capture token`)),
|
|
768
|
+
ms
|
|
769
|
+
);
|
|
770
|
+
promise.then(
|
|
771
|
+
(v) => {
|
|
772
|
+
clearTimeout(timer);
|
|
773
|
+
resolve(v);
|
|
774
|
+
},
|
|
775
|
+
(e) => {
|
|
776
|
+
clearTimeout(timer);
|
|
777
|
+
reject(e);
|
|
778
|
+
}
|
|
779
|
+
);
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
function resubmit(form, submitter) {
|
|
783
|
+
if (submitter && submitter.isConnected && typeof form.requestSubmit === "function") {
|
|
784
|
+
try {
|
|
785
|
+
form.requestSubmit(submitter);
|
|
786
|
+
return;
|
|
787
|
+
} catch {
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (typeof form.requestSubmit === "function") form.requestSubmit();
|
|
791
|
+
else if (submitter && typeof submitter.click === "function") submitter.click();
|
|
792
|
+
else form.submit();
|
|
793
|
+
}
|
|
794
|
+
function resolveForm(form) {
|
|
795
|
+
const el = typeof form === "string" ? document.querySelector(form) : form;
|
|
796
|
+
if (!(el instanceof HTMLFormElement)) throw new OverturoValidationError("form must resolve to a <form> element");
|
|
797
|
+
return el;
|
|
798
|
+
}
|
|
799
|
+
function setHiddenInput(form, name, value) {
|
|
800
|
+
let input = form.querySelector(`input[name="${name}"]`);
|
|
801
|
+
if (!input) {
|
|
802
|
+
input = document.createElement("input");
|
|
803
|
+
input.type = "hidden";
|
|
804
|
+
input.name = name;
|
|
805
|
+
form.appendChild(input);
|
|
806
|
+
}
|
|
807
|
+
input.value = value;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// src/forms/presentation.ts
|
|
811
|
+
function resolveControl(root, selector) {
|
|
812
|
+
const el = root.querySelector(selector);
|
|
813
|
+
return el instanceof HTMLInputElement ? el : null;
|
|
814
|
+
}
|
|
815
|
+
function presentationFor(control, initiallyChecked) {
|
|
816
|
+
if (!control || control.type !== "checkbox" && control.type !== "radio") {
|
|
817
|
+
return { decision: "declined", default_checked: false, mandatory: false };
|
|
818
|
+
}
|
|
819
|
+
return {
|
|
820
|
+
decision: control.checked ? "granted" : "declined",
|
|
821
|
+
// Shown ticked by default: the HTML attribute, or a script that ticked it before the person saw it.
|
|
822
|
+
default_checked: control.defaultChecked || initiallyChecked === true,
|
|
823
|
+
mandatory: mandatoryFor(control)
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function mandatoryFor(control) {
|
|
827
|
+
if (!control.required) return false;
|
|
828
|
+
if (control.type !== "radio" || !control.name) return true;
|
|
829
|
+
const root = control.form ?? control.ownerDocument;
|
|
830
|
+
const group = Array.from(root.querySelectorAll('input[type="radio"]')).filter((r) => r.name === control.name);
|
|
831
|
+
return group.length <= 1;
|
|
832
|
+
}
|
|
833
|
+
function decisionsFor(form, map, initiallyChecked = {}) {
|
|
834
|
+
const out = {};
|
|
835
|
+
for (const [purpose, selector] of Object.entries(map)) {
|
|
836
|
+
out[purpose] = presentationFor(resolveControl(form, selector), initiallyChecked[purpose]);
|
|
837
|
+
}
|
|
838
|
+
return out;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// src/forms/snapshot.ts
|
|
842
|
+
var SNAPSHOT_MAX_BYTES = 16 * 1024;
|
|
843
|
+
var VALUE_BEARING = "input, textarea, select";
|
|
844
|
+
var EVENT_ATTR = /^on/i;
|
|
845
|
+
var FREE_TEXT_ATTRS = /* @__PURE__ */ new Set(["title", "aria-label", "aria-description"]);
|
|
846
|
+
function sanitisedSnapshot(form, consentSelectors) {
|
|
847
|
+
const clone = form.cloneNode(true);
|
|
848
|
+
const keep = /* @__PURE__ */ new Set();
|
|
849
|
+
for (const selector of consentSelectors) {
|
|
850
|
+
const el = clone.querySelector(selector);
|
|
851
|
+
if (el) keep.add(el);
|
|
852
|
+
}
|
|
853
|
+
clone.querySelectorAll("script, style, iframe, object, embed").forEach((el) => el.remove());
|
|
854
|
+
[clone, ...Array.from(clone.querySelectorAll("*"))].forEach((el) => {
|
|
855
|
+
for (const attr of Array.from(el.attributes)) {
|
|
856
|
+
const name = attr.name.toLowerCase();
|
|
857
|
+
if (EVENT_ATTR.test(name) || name === "srcdoc" || name.startsWith("data-") || FREE_TEXT_ATTRS.has(name)) {
|
|
858
|
+
el.removeAttribute(attr.name);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
clone.querySelectorAll(VALUE_BEARING).forEach((node) => {
|
|
863
|
+
const el = node;
|
|
864
|
+
if (keep.has(el)) {
|
|
865
|
+
const input = el;
|
|
866
|
+
if (input.checked) input.setAttribute("checked", "");
|
|
867
|
+
else input.removeAttribute("checked");
|
|
868
|
+
el.removeAttribute("value");
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
el.removeAttribute("value");
|
|
872
|
+
el.removeAttribute("placeholder");
|
|
873
|
+
if (el instanceof HTMLTextAreaElement) el.textContent = "";
|
|
874
|
+
if (el instanceof HTMLSelectElement) {
|
|
875
|
+
el.querySelectorAll("option").forEach((o) => {
|
|
876
|
+
o.removeAttribute("selected");
|
|
877
|
+
o.removeAttribute("value");
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
if (el instanceof HTMLInputElement) {
|
|
881
|
+
el.removeAttribute("checked");
|
|
882
|
+
if (el.type === "hidden") el.remove();
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
const html = clone.outerHTML;
|
|
886
|
+
return truncateUtf8(html, SNAPSHOT_MAX_BYTES);
|
|
887
|
+
}
|
|
888
|
+
function truncateUtf8(text, maxBytes) {
|
|
889
|
+
const encoder = new TextEncoder();
|
|
890
|
+
if (encoder.encode(text).byteLength <= maxBytes) return text;
|
|
891
|
+
let out = text;
|
|
892
|
+
while (encoder.encode(out).byteLength > maxBytes) {
|
|
893
|
+
out = out.slice(0, Math.floor(out.length * 0.9));
|
|
894
|
+
}
|
|
895
|
+
return out;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// src/forms.ts
|
|
899
|
+
var CAPTURE_PATH = "/api/v1/decisions/capture";
|
|
900
|
+
var FormsFacade = class {
|
|
901
|
+
constructor(api, decisions, flowBaseUrl, publishableKey) {
|
|
902
|
+
this.api = api;
|
|
903
|
+
this.decisions = decisions;
|
|
904
|
+
this.flowBaseUrl = flowBaseUrl;
|
|
905
|
+
this.publishableKey = publishableKey;
|
|
906
|
+
}
|
|
907
|
+
/** Wires the capture onto the form; returns a detach function. */
|
|
908
|
+
attach(opts) {
|
|
909
|
+
if (!opts.flowId) throw new OverturoValidationError("flowId is required");
|
|
910
|
+
const form = resolveForm(opts.form);
|
|
911
|
+
if (opts.field) return this.attachField(form, opts);
|
|
912
|
+
const map = opts.map;
|
|
913
|
+
if (!map || Object.keys(map).length === 0) throw new OverturoValidationError("map must name at least one purpose (or pass field)");
|
|
914
|
+
const initiallyChecked = initialCheckedState(form, map);
|
|
915
|
+
if (opts.wording) void this.writeWording(form, opts);
|
|
916
|
+
return interceptSubmit(form, opts, async () => {
|
|
917
|
+
const unresolved = Object.entries(map).filter(([, selector]) => !resolveControl(form, selector));
|
|
918
|
+
if (unresolved.length) {
|
|
919
|
+
throw new OverturoValidationError(`consent control not found for: ${unresolved.map(([p]) => p).join(", ")}`);
|
|
920
|
+
}
|
|
921
|
+
const body = this.buildCaptureBody(form, opts, initiallyChecked);
|
|
922
|
+
const digests = await this.labelDigests(form, opts);
|
|
923
|
+
if (digests) body.noticeHashes = digests;
|
|
924
|
+
const raw = await this.api.post(CAPTURE_PATH, body);
|
|
925
|
+
const result = {
|
|
926
|
+
token: raw.capture.sessionToken,
|
|
927
|
+
attestationId: raw.capture.attestationId,
|
|
928
|
+
committed: raw.capture.committed,
|
|
929
|
+
wordingVerdict: raw.capture.wordingVerdict ?? null,
|
|
930
|
+
recordId: raw.capture.recordId ?? null
|
|
931
|
+
};
|
|
932
|
+
opts.onCaptured?.(result);
|
|
933
|
+
return { token: result.token };
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* 202 D9 — the embedded consent field: the control is Overturo-rendered
|
|
938
|
+
* inside the form, so the element does the capture from its own frame. The
|
|
939
|
+
* field entry (`@overturo/js/field` / `overturo-field.js`) must be loaded;
|
|
940
|
+
* one field per flow per form.
|
|
941
|
+
*/
|
|
942
|
+
attachField(form, opts) {
|
|
943
|
+
const element = resolveField(form, opts.field);
|
|
944
|
+
const flow = element.getAttribute("flow");
|
|
945
|
+
if (flow && flow !== opts.flowId) throw new OverturoValidationError("the field's flow attribute must match flowId");
|
|
946
|
+
const duplicate = Array.from(form.querySelectorAll(CONSENT_FIELD_ELEMENT_NAME)).some(
|
|
947
|
+
(el) => el !== element && (el.getAttribute("flow") || opts.flowId) === opts.flowId
|
|
948
|
+
);
|
|
949
|
+
if (duplicate) throw new OverturoValidationError("duplicate_field: one consent field per flow per form");
|
|
950
|
+
return element.attachTo(form, opts, { flowBaseUrl: this.flowBaseUrl, publishableKey: this.publishableKey });
|
|
951
|
+
}
|
|
952
|
+
/** Builds the capture body the way `attach` does — exposed for integrators who post themselves. */
|
|
953
|
+
buildCaptureBody(form, opts, initiallyChecked = {}) {
|
|
954
|
+
const subject = resolveControl(form, opts.subjectField);
|
|
955
|
+
const external = opts.externalIdField ? resolveControl(form, opts.externalIdField) : null;
|
|
956
|
+
const map = opts.map ?? {};
|
|
957
|
+
const body = {
|
|
958
|
+
flowId: opts.flowId,
|
|
959
|
+
decisions: decisionsFor(form, map, initiallyChecked),
|
|
960
|
+
subject: {
|
|
961
|
+
email: subject?.value?.trim() || void 0,
|
|
962
|
+
externalId: external?.value?.trim() || void 0
|
|
963
|
+
},
|
|
964
|
+
snapshot: sanitisedSnapshot(form, Object.values(map)),
|
|
965
|
+
pageUrl: typeof window !== "undefined" ? window.location.href : void 0,
|
|
966
|
+
formId: form.getAttribute("id") || void 0
|
|
967
|
+
};
|
|
968
|
+
if (opts.commit) body.commit = true;
|
|
969
|
+
if (opts.locale) body.locale = opts.locale;
|
|
970
|
+
return body;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* 201 D11 — the digest of each mapped label's text as the person saw it
|
|
974
|
+
* (a 256-bit digest of the trimmed text — the algorithm the forms
|
|
975
|
+
* documentation publishes), so the record can
|
|
976
|
+
* say whether the form's wording matched the wording published for the flow.
|
|
977
|
+
* Needs `labels` (purpose → label selector) and WebCrypto; otherwise nothing is attested.
|
|
978
|
+
*/
|
|
979
|
+
async labelDigests(form, opts) {
|
|
980
|
+
const labels = opts.labels ?? opts.wording;
|
|
981
|
+
if (!labels || typeof crypto === "undefined" || !crypto.subtle) return void 0;
|
|
982
|
+
const out = {};
|
|
983
|
+
for (const [purpose, selector] of Object.entries(labels)) {
|
|
984
|
+
const text = form.querySelector(selector)?.textContent?.trim();
|
|
985
|
+
if (!text) continue;
|
|
986
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
987
|
+
out[purpose] = Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
988
|
+
}
|
|
989
|
+
return Object.keys(out).length ? out : void 0;
|
|
990
|
+
}
|
|
991
|
+
/** 201 D11 — writes the published wording into the labels the integrator names. */
|
|
992
|
+
async writeWording(form, opts) {
|
|
993
|
+
if (!opts.wording) return;
|
|
994
|
+
try {
|
|
995
|
+
const disclosures = await this.decisions.discover({ flowId: opts.flowId, locale: opts.locale });
|
|
996
|
+
for (const [purpose, selector] of Object.entries(opts.wording)) {
|
|
997
|
+
const target = form.querySelector(selector);
|
|
998
|
+
const row = disclosures.purposes.find((p) => p.name === purpose);
|
|
999
|
+
if (target && row) replaceText(target, row.description ?? row.label);
|
|
1000
|
+
}
|
|
1001
|
+
} catch (e) {
|
|
1002
|
+
opts.onError?.(e);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
function replaceText(target, text) {
|
|
1007
|
+
const textNodes = Array.from(target.childNodes).filter((n) => n.nodeType === Node.TEXT_NODE);
|
|
1008
|
+
if (textNodes.length === 0 || target.children.length === 0) {
|
|
1009
|
+
if (target.children.length === 0) target.textContent = text;
|
|
1010
|
+
else target.appendChild(document.createTextNode(" " + text));
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
textNodes.forEach((n, i) => {
|
|
1014
|
+
n.textContent = i === 0 ? text : "";
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
function initialCheckedState(form, map) {
|
|
1018
|
+
const out = {};
|
|
1019
|
+
for (const [purpose, selector] of Object.entries(map)) {
|
|
1020
|
+
const control = resolveControl(form, selector);
|
|
1021
|
+
if (control) out[purpose] = control.checked;
|
|
1022
|
+
}
|
|
1023
|
+
return out;
|
|
1024
|
+
}
|
|
1025
|
+
function resolveField(form, field) {
|
|
1026
|
+
const el = typeof field === "string" ? form.querySelector(field) || document.querySelector(field) : field;
|
|
1027
|
+
if (!(el instanceof HTMLElement) || el.tagName.toLowerCase() !== CONSENT_FIELD_ELEMENT_NAME) {
|
|
1028
|
+
throw new OverturoValidationError(`field must resolve to an <${CONSENT_FIELD_ELEMENT_NAME}> element`);
|
|
1029
|
+
}
|
|
1030
|
+
if (typeof el.attachTo !== "function") {
|
|
1031
|
+
throw new OverturoValidationError("field_entry_not_loaded: load @overturo/js/field (overturo-field.js) before attaching a field");
|
|
1032
|
+
}
|
|
1033
|
+
return el;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
// src/signing_facade.ts
|
|
1037
|
+
var _decisions3, _api2;
|
|
1038
|
+
var SigningFacade = class {
|
|
1039
|
+
constructor(decisions, api) {
|
|
1040
|
+
__privateAdd(this, _decisions3);
|
|
1041
|
+
__privateAdd(this, _api2);
|
|
1042
|
+
__privateSet(this, _decisions3, decisions);
|
|
1043
|
+
__privateSet(this, _api2, api);
|
|
1044
|
+
}
|
|
1045
|
+
async open(opts) {
|
|
1046
|
+
if (!opts.signatureRef) {
|
|
1047
|
+
throw new OverturoValidationError("signatureRef is required");
|
|
1048
|
+
}
|
|
1049
|
+
const mode = opts.mode ?? "embed";
|
|
1050
|
+
const session = await __privateGet(this, _decisions3).createSession({
|
|
1051
|
+
kind: "signature_request",
|
|
1052
|
+
subjectRef: opts.signatureRef,
|
|
1053
|
+
mode,
|
|
1054
|
+
embedOrigin: opts.embedOrigin,
|
|
1055
|
+
state: opts.state,
|
|
1056
|
+
redirectUri: opts.redirectUri
|
|
1057
|
+
});
|
|
1058
|
+
if (mode === "popup") {
|
|
1059
|
+
return __privateGet(this, _decisions3).popup({
|
|
1060
|
+
token: session.token,
|
|
1061
|
+
onComplete: (outcome) => {
|
|
1062
|
+
if (outcome.kind === "signature_request") opts.onComplete?.(outcome);
|
|
1063
|
+
},
|
|
1064
|
+
onCancel: opts.onCancel,
|
|
1065
|
+
onError: opts.onError
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
if (mode === "redirect") {
|
|
1069
|
+
const url = __privateGet(this, _decisions3).url({ token: session.token, mode: "redirect" });
|
|
1070
|
+
window.location.href = url;
|
|
1071
|
+
return {
|
|
1072
|
+
token: session.token,
|
|
1073
|
+
mode: "redirect",
|
|
1074
|
+
destroy: async () => {
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
return __privateGet(this, _decisions3).embed({
|
|
1079
|
+
token: session.token,
|
|
1080
|
+
container: opts.container,
|
|
1081
|
+
style: opts.style,
|
|
1082
|
+
loading: opts.loading,
|
|
1083
|
+
onReady: opts.onReady,
|
|
1084
|
+
onState: (_kind, payload) => opts.onState?.(payload),
|
|
1085
|
+
onComplete: (outcome) => {
|
|
1086
|
+
if (outcome.kind === "signature_request") opts.onComplete?.(outcome);
|
|
1087
|
+
},
|
|
1088
|
+
onCancel: opts.onCancel,
|
|
1089
|
+
onError: opts.onError,
|
|
1090
|
+
onDeadline: opts.onDeadline,
|
|
1091
|
+
onCounter: opts.onCounter
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
url(opts) {
|
|
1095
|
+
return __privateGet(this, _decisions3).url({
|
|
1096
|
+
token: opts.signatureRef,
|
|
1097
|
+
mode: opts.mode
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Polls `${decisions_api}/:token` for deadline metadata. Returns the
|
|
1102
|
+
* computed remainingMs alongside the absolute deadlineAt for clock-
|
|
1103
|
+
* skew tolerance in consumers.
|
|
1104
|
+
*/
|
|
1105
|
+
async deadline(token) {
|
|
1106
|
+
if (!token) {
|
|
1107
|
+
throw new OverturoValidationError("token is required for deadline");
|
|
1108
|
+
}
|
|
1109
|
+
const status = await __privateGet(this, _api2).get(`${DECISIONS_API_PATH}/${token}`);
|
|
1110
|
+
return {
|
|
1111
|
+
remainingMs: Math.max(0, new Date(status.deadlineAt).getTime() - Date.now()),
|
|
1112
|
+
deadlineAt: status.deadlineAt
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
_decisions3 = new WeakMap();
|
|
1117
|
+
_api2 = new WeakMap();
|
|
1118
|
+
|
|
1119
|
+
// src/dom.ts
|
|
1120
|
+
function resolveContainer(container) {
|
|
1121
|
+
if (typeof container === "string") {
|
|
1122
|
+
const el = document.querySelector(container);
|
|
1123
|
+
if (!el) {
|
|
1124
|
+
throw new OverturoValidationError(`Container element not found: "${container}"`);
|
|
1125
|
+
}
|
|
1126
|
+
return el;
|
|
1127
|
+
}
|
|
1128
|
+
return container;
|
|
1129
|
+
}
|
|
1130
|
+
function applyStyle(el, defaults, overrides) {
|
|
1131
|
+
const style = { ...defaults };
|
|
1132
|
+
if (overrides) {
|
|
1133
|
+
for (const key of EMBED_STYLE_KEYS) {
|
|
1134
|
+
if (key in overrides) {
|
|
1135
|
+
style[key] = overrides[key];
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
for (const [key, value] of Object.entries(style)) {
|
|
1140
|
+
;
|
|
1141
|
+
el.style[key] = value;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
// src/generated/postmessage-v2/envelope.js
|
|
1146
|
+
var envelope_default = validate29;
|
|
1147
|
+
var schema40 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/envelope.json", "title": "TrustSurface postMessage envelope v2", "type": "object", "additionalProperties": false, "required": ["type", "kind", "version", "payload", "ts", "message_id"], "properties": { "type": { "type": "string", "enum": ["overturo:ready", "overturo:state", "overturo:complete", "overturo:cancel", "overturo:error", "overturo:resize", "overturo:deadline"] }, "kind": { "type": "string", "enum": ["consent", "approval", "signature_request"] }, "version": { "type": "integer", "const": 2 }, "payload": { "type": "object", "additionalProperties": true }, "ts": { "type": "string", "format": "date-time" }, "message_id": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" } } };
|
|
1148
|
+
var formats0 = require_formats().fullFormats["date-time"];
|
|
1149
|
+
var pattern4 = new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", "u");
|
|
1150
|
+
function validate29(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
1151
|
+
;
|
|
1152
|
+
let vErrors = null;
|
|
1153
|
+
let errors = 0;
|
|
1154
|
+
const evaluated0 = validate29.evaluated;
|
|
1155
|
+
if (evaluated0.dynamicProps) {
|
|
1156
|
+
evaluated0.props = void 0;
|
|
1157
|
+
}
|
|
1158
|
+
if (evaluated0.dynamicItems) {
|
|
1159
|
+
evaluated0.items = void 0;
|
|
1160
|
+
}
|
|
1161
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1162
|
+
if (data.type === void 0) {
|
|
1163
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
1164
|
+
if (vErrors === null) {
|
|
1165
|
+
vErrors = [err0];
|
|
1166
|
+
} else {
|
|
1167
|
+
vErrors.push(err0);
|
|
1168
|
+
}
|
|
1169
|
+
errors++;
|
|
1170
|
+
}
|
|
1171
|
+
if (data.kind === void 0) {
|
|
1172
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
|
|
1173
|
+
if (vErrors === null) {
|
|
1174
|
+
vErrors = [err1];
|
|
1175
|
+
} else {
|
|
1176
|
+
vErrors.push(err1);
|
|
1177
|
+
}
|
|
1178
|
+
errors++;
|
|
1179
|
+
}
|
|
1180
|
+
if (data.version === void 0) {
|
|
1181
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
|
|
1182
|
+
if (vErrors === null) {
|
|
1183
|
+
vErrors = [err2];
|
|
1184
|
+
} else {
|
|
1185
|
+
vErrors.push(err2);
|
|
1186
|
+
}
|
|
1187
|
+
errors++;
|
|
1188
|
+
}
|
|
1189
|
+
if (data.payload === void 0) {
|
|
1190
|
+
const err3 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "payload" }, message: "must have required property 'payload'" };
|
|
1191
|
+
if (vErrors === null) {
|
|
1192
|
+
vErrors = [err3];
|
|
1193
|
+
} else {
|
|
1194
|
+
vErrors.push(err3);
|
|
1195
|
+
}
|
|
1196
|
+
errors++;
|
|
1197
|
+
}
|
|
1198
|
+
if (data.ts === void 0) {
|
|
1199
|
+
const err4 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "ts" }, message: "must have required property 'ts'" };
|
|
1200
|
+
if (vErrors === null) {
|
|
1201
|
+
vErrors = [err4];
|
|
1202
|
+
} else {
|
|
1203
|
+
vErrors.push(err4);
|
|
1204
|
+
}
|
|
1205
|
+
errors++;
|
|
1206
|
+
}
|
|
1207
|
+
if (data.message_id === void 0) {
|
|
1208
|
+
const err5 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "message_id" }, message: "must have required property 'message_id'" };
|
|
1209
|
+
if (vErrors === null) {
|
|
1210
|
+
vErrors = [err5];
|
|
1211
|
+
} else {
|
|
1212
|
+
vErrors.push(err5);
|
|
1213
|
+
}
|
|
1214
|
+
errors++;
|
|
1215
|
+
}
|
|
1216
|
+
for (const key0 in data) {
|
|
1217
|
+
if (!(key0 === "type" || key0 === "kind" || key0 === "version" || key0 === "payload" || key0 === "ts" || key0 === "message_id")) {
|
|
1218
|
+
const err6 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1219
|
+
if (vErrors === null) {
|
|
1220
|
+
vErrors = [err6];
|
|
1221
|
+
} else {
|
|
1222
|
+
vErrors.push(err6);
|
|
1223
|
+
}
|
|
1224
|
+
errors++;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
if (data.type !== void 0) {
|
|
1228
|
+
let data0 = data.type;
|
|
1229
|
+
if (typeof data0 !== "string") {
|
|
1230
|
+
const err7 = { instancePath: instancePath + "/type", schemaPath: "#/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1231
|
+
if (vErrors === null) {
|
|
1232
|
+
vErrors = [err7];
|
|
1233
|
+
} else {
|
|
1234
|
+
vErrors.push(err7);
|
|
1235
|
+
}
|
|
1236
|
+
errors++;
|
|
1237
|
+
}
|
|
1238
|
+
if (!(data0 === "overturo:ready" || data0 === "overturo:state" || data0 === "overturo:complete" || data0 === "overturo:cancel" || data0 === "overturo:error" || data0 === "overturo:resize" || data0 === "overturo:deadline")) {
|
|
1239
|
+
const err8 = { instancePath: instancePath + "/type", schemaPath: "#/properties/type/enum", keyword: "enum", params: { allowedValues: schema40.properties.type.enum }, message: "must be equal to one of the allowed values" };
|
|
1240
|
+
if (vErrors === null) {
|
|
1241
|
+
vErrors = [err8];
|
|
1242
|
+
} else {
|
|
1243
|
+
vErrors.push(err8);
|
|
1244
|
+
}
|
|
1245
|
+
errors++;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
if (data.kind !== void 0) {
|
|
1249
|
+
let data1 = data.kind;
|
|
1250
|
+
if (typeof data1 !== "string") {
|
|
1251
|
+
const err9 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1252
|
+
if (vErrors === null) {
|
|
1253
|
+
vErrors = [err9];
|
|
1254
|
+
} else {
|
|
1255
|
+
vErrors.push(err9);
|
|
1256
|
+
}
|
|
1257
|
+
errors++;
|
|
1258
|
+
}
|
|
1259
|
+
if (!(data1 === "consent" || data1 === "approval" || data1 === "signature_request")) {
|
|
1260
|
+
const err10 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema40.properties.kind.enum }, message: "must be equal to one of the allowed values" };
|
|
1261
|
+
if (vErrors === null) {
|
|
1262
|
+
vErrors = [err10];
|
|
1263
|
+
} else {
|
|
1264
|
+
vErrors.push(err10);
|
|
1265
|
+
}
|
|
1266
|
+
errors++;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
if (data.version !== void 0) {
|
|
1270
|
+
let data2 = data.version;
|
|
1271
|
+
if (!(typeof data2 == "number" && (!(data2 % 1) && !isNaN(data2)))) {
|
|
1272
|
+
const err11 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
1273
|
+
if (vErrors === null) {
|
|
1274
|
+
vErrors = [err11];
|
|
1275
|
+
} else {
|
|
1276
|
+
vErrors.push(err11);
|
|
1277
|
+
}
|
|
1278
|
+
errors++;
|
|
1279
|
+
}
|
|
1280
|
+
if (2 !== data2) {
|
|
1281
|
+
const err12 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/const", keyword: "const", params: { allowedValue: 2 }, message: "must be equal to constant" };
|
|
1282
|
+
if (vErrors === null) {
|
|
1283
|
+
vErrors = [err12];
|
|
1284
|
+
} else {
|
|
1285
|
+
vErrors.push(err12);
|
|
1286
|
+
}
|
|
1287
|
+
errors++;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
if (data.payload !== void 0) {
|
|
1291
|
+
let data3 = data.payload;
|
|
1292
|
+
if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
|
|
1293
|
+
} else {
|
|
1294
|
+
const err13 = { instancePath: instancePath + "/payload", schemaPath: "#/properties/payload/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1295
|
+
if (vErrors === null) {
|
|
1296
|
+
vErrors = [err13];
|
|
1297
|
+
} else {
|
|
1298
|
+
vErrors.push(err13);
|
|
1299
|
+
}
|
|
1300
|
+
errors++;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
if (data.ts !== void 0) {
|
|
1304
|
+
let data4 = data.ts;
|
|
1305
|
+
if (typeof data4 === "string") {
|
|
1306
|
+
if (!formats0.validate(data4)) {
|
|
1307
|
+
const err14 = { instancePath: instancePath + "/ts", schemaPath: "#/properties/ts/format", keyword: "format", params: { format: "date-time" }, message: 'must match format "date-time"' };
|
|
1308
|
+
if (vErrors === null) {
|
|
1309
|
+
vErrors = [err14];
|
|
1310
|
+
} else {
|
|
1311
|
+
vErrors.push(err14);
|
|
1312
|
+
}
|
|
1313
|
+
errors++;
|
|
1314
|
+
}
|
|
1315
|
+
} else {
|
|
1316
|
+
const err15 = { instancePath: instancePath + "/ts", schemaPath: "#/properties/ts/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1317
|
+
if (vErrors === null) {
|
|
1318
|
+
vErrors = [err15];
|
|
1319
|
+
} else {
|
|
1320
|
+
vErrors.push(err15);
|
|
1321
|
+
}
|
|
1322
|
+
errors++;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
if (data.message_id !== void 0) {
|
|
1326
|
+
let data5 = data.message_id;
|
|
1327
|
+
if (typeof data5 === "string") {
|
|
1328
|
+
if (!pattern4.test(data5)) {
|
|
1329
|
+
const err16 = { instancePath: instancePath + "/message_id", schemaPath: "#/properties/message_id/pattern", keyword: "pattern", params: { pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" }, message: 'must match pattern "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"' };
|
|
1330
|
+
if (vErrors === null) {
|
|
1331
|
+
vErrors = [err16];
|
|
1332
|
+
} else {
|
|
1333
|
+
vErrors.push(err16);
|
|
1334
|
+
}
|
|
1335
|
+
errors++;
|
|
1336
|
+
}
|
|
1337
|
+
} else {
|
|
1338
|
+
const err17 = { instancePath: instancePath + "/message_id", schemaPath: "#/properties/message_id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1339
|
+
if (vErrors === null) {
|
|
1340
|
+
vErrors = [err17];
|
|
1341
|
+
} else {
|
|
1342
|
+
vErrors.push(err17);
|
|
1343
|
+
}
|
|
1344
|
+
errors++;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
} else {
|
|
1348
|
+
const err18 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1349
|
+
if (vErrors === null) {
|
|
1350
|
+
vErrors = [err18];
|
|
1351
|
+
} else {
|
|
1352
|
+
vErrors.push(err18);
|
|
1353
|
+
}
|
|
1354
|
+
errors++;
|
|
1355
|
+
}
|
|
1356
|
+
validate29.errors = vErrors;
|
|
1357
|
+
return errors === 0;
|
|
1358
|
+
}
|
|
1359
|
+
validate29.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
1360
|
+
|
|
1361
|
+
// src/generated/postmessage-v2/ready.js
|
|
1362
|
+
var ready_default = validate30;
|
|
1363
|
+
var schema41 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/ready.json", "title": "READY payload (kind-agnostic; branding fields vary per application)", "type": "object", "additionalProperties": true, "required": ["kind", "session_token", "deadline_at", "branding", "mode", "locale"], "properties": { "kind": { "type": "string", "enum": ["consent", "approval", "signature_request"] }, "session_token": { "type": "string", "minLength": 43, "maxLength": 43 }, "deadline_at": { "type": ["string", "null"], "format": "date-time" }, "branding": { "type": "object", "additionalProperties": true, "required": ["application_name"], "properties": { "application_name": { "type": "string" }, "logo_url": { "type": ["string", "null"] }, "primary_color": { "type": ["string", "null"] } } }, "mode": { "type": "string", "enum": ["embed", "popup", "redirect"] }, "locale": { "type": "string" } } };
|
|
1364
|
+
var func1 = require_ucs2length().default;
|
|
1365
|
+
var formats02 = require_formats().fullFormats["date-time"];
|
|
1366
|
+
function validate30(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
1367
|
+
;
|
|
1368
|
+
let vErrors = null;
|
|
1369
|
+
let errors = 0;
|
|
1370
|
+
const evaluated0 = validate30.evaluated;
|
|
1371
|
+
if (evaluated0.dynamicProps) {
|
|
1372
|
+
evaluated0.props = void 0;
|
|
1373
|
+
}
|
|
1374
|
+
if (evaluated0.dynamicItems) {
|
|
1375
|
+
evaluated0.items = void 0;
|
|
1376
|
+
}
|
|
1377
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1378
|
+
if (data.kind === void 0) {
|
|
1379
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
|
|
1380
|
+
if (vErrors === null) {
|
|
1381
|
+
vErrors = [err0];
|
|
1382
|
+
} else {
|
|
1383
|
+
vErrors.push(err0);
|
|
1384
|
+
}
|
|
1385
|
+
errors++;
|
|
1386
|
+
}
|
|
1387
|
+
if (data.session_token === void 0) {
|
|
1388
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "session_token" }, message: "must have required property 'session_token'" };
|
|
1389
|
+
if (vErrors === null) {
|
|
1390
|
+
vErrors = [err1];
|
|
1391
|
+
} else {
|
|
1392
|
+
vErrors.push(err1);
|
|
1393
|
+
}
|
|
1394
|
+
errors++;
|
|
1395
|
+
}
|
|
1396
|
+
if (data.deadline_at === void 0) {
|
|
1397
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "deadline_at" }, message: "must have required property 'deadline_at'" };
|
|
1398
|
+
if (vErrors === null) {
|
|
1399
|
+
vErrors = [err2];
|
|
1400
|
+
} else {
|
|
1401
|
+
vErrors.push(err2);
|
|
1402
|
+
}
|
|
1403
|
+
errors++;
|
|
1404
|
+
}
|
|
1405
|
+
if (data.branding === void 0) {
|
|
1406
|
+
const err3 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "branding" }, message: "must have required property 'branding'" };
|
|
1407
|
+
if (vErrors === null) {
|
|
1408
|
+
vErrors = [err3];
|
|
1409
|
+
} else {
|
|
1410
|
+
vErrors.push(err3);
|
|
1411
|
+
}
|
|
1412
|
+
errors++;
|
|
1413
|
+
}
|
|
1414
|
+
if (data.mode === void 0) {
|
|
1415
|
+
const err4 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "mode" }, message: "must have required property 'mode'" };
|
|
1416
|
+
if (vErrors === null) {
|
|
1417
|
+
vErrors = [err4];
|
|
1418
|
+
} else {
|
|
1419
|
+
vErrors.push(err4);
|
|
1420
|
+
}
|
|
1421
|
+
errors++;
|
|
1422
|
+
}
|
|
1423
|
+
if (data.locale === void 0) {
|
|
1424
|
+
const err5 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "locale" }, message: "must have required property 'locale'" };
|
|
1425
|
+
if (vErrors === null) {
|
|
1426
|
+
vErrors = [err5];
|
|
1427
|
+
} else {
|
|
1428
|
+
vErrors.push(err5);
|
|
1429
|
+
}
|
|
1430
|
+
errors++;
|
|
1431
|
+
}
|
|
1432
|
+
if (data.kind !== void 0) {
|
|
1433
|
+
let data0 = data.kind;
|
|
1434
|
+
if (typeof data0 !== "string") {
|
|
1435
|
+
const err6 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1436
|
+
if (vErrors === null) {
|
|
1437
|
+
vErrors = [err6];
|
|
1438
|
+
} else {
|
|
1439
|
+
vErrors.push(err6);
|
|
1440
|
+
}
|
|
1441
|
+
errors++;
|
|
1442
|
+
}
|
|
1443
|
+
if (!(data0 === "consent" || data0 === "approval" || data0 === "signature_request")) {
|
|
1444
|
+
const err7 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema41.properties.kind.enum }, message: "must be equal to one of the allowed values" };
|
|
1445
|
+
if (vErrors === null) {
|
|
1446
|
+
vErrors = [err7];
|
|
1447
|
+
} else {
|
|
1448
|
+
vErrors.push(err7);
|
|
1449
|
+
}
|
|
1450
|
+
errors++;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
if (data.session_token !== void 0) {
|
|
1454
|
+
let data1 = data.session_token;
|
|
1455
|
+
if (typeof data1 === "string") {
|
|
1456
|
+
if (func1(data1) > 43) {
|
|
1457
|
+
const err8 = { instancePath: instancePath + "/session_token", schemaPath: "#/properties/session_token/maxLength", keyword: "maxLength", params: { limit: 43 }, message: "must NOT have more than 43 characters" };
|
|
1458
|
+
if (vErrors === null) {
|
|
1459
|
+
vErrors = [err8];
|
|
1460
|
+
} else {
|
|
1461
|
+
vErrors.push(err8);
|
|
1462
|
+
}
|
|
1463
|
+
errors++;
|
|
1464
|
+
}
|
|
1465
|
+
if (func1(data1) < 43) {
|
|
1466
|
+
const err9 = { instancePath: instancePath + "/session_token", schemaPath: "#/properties/session_token/minLength", keyword: "minLength", params: { limit: 43 }, message: "must NOT have fewer than 43 characters" };
|
|
1467
|
+
if (vErrors === null) {
|
|
1468
|
+
vErrors = [err9];
|
|
1469
|
+
} else {
|
|
1470
|
+
vErrors.push(err9);
|
|
1471
|
+
}
|
|
1472
|
+
errors++;
|
|
1473
|
+
}
|
|
1474
|
+
} else {
|
|
1475
|
+
const err10 = { instancePath: instancePath + "/session_token", schemaPath: "#/properties/session_token/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1476
|
+
if (vErrors === null) {
|
|
1477
|
+
vErrors = [err10];
|
|
1478
|
+
} else {
|
|
1479
|
+
vErrors.push(err10);
|
|
1480
|
+
}
|
|
1481
|
+
errors++;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
if (data.deadline_at !== void 0) {
|
|
1485
|
+
let data2 = data.deadline_at;
|
|
1486
|
+
if (typeof data2 !== "string" && data2 !== null) {
|
|
1487
|
+
const err11 = { instancePath: instancePath + "/deadline_at", schemaPath: "#/properties/deadline_at/type", keyword: "type", params: { type: schema41.properties.deadline_at.type }, message: "must be string,null" };
|
|
1488
|
+
if (vErrors === null) {
|
|
1489
|
+
vErrors = [err11];
|
|
1490
|
+
} else {
|
|
1491
|
+
vErrors.push(err11);
|
|
1492
|
+
}
|
|
1493
|
+
errors++;
|
|
1494
|
+
}
|
|
1495
|
+
if (typeof data2 === "string") {
|
|
1496
|
+
if (!formats02.validate(data2)) {
|
|
1497
|
+
const err12 = { instancePath: instancePath + "/deadline_at", schemaPath: "#/properties/deadline_at/format", keyword: "format", params: { format: "date-time" }, message: 'must match format "date-time"' };
|
|
1498
|
+
if (vErrors === null) {
|
|
1499
|
+
vErrors = [err12];
|
|
1500
|
+
} else {
|
|
1501
|
+
vErrors.push(err12);
|
|
1502
|
+
}
|
|
1503
|
+
errors++;
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
if (data.branding !== void 0) {
|
|
1508
|
+
let data3 = data.branding;
|
|
1509
|
+
if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
|
|
1510
|
+
if (data3.application_name === void 0) {
|
|
1511
|
+
const err13 = { instancePath: instancePath + "/branding", schemaPath: "#/properties/branding/required", keyword: "required", params: { missingProperty: "application_name" }, message: "must have required property 'application_name'" };
|
|
1512
|
+
if (vErrors === null) {
|
|
1513
|
+
vErrors = [err13];
|
|
1514
|
+
} else {
|
|
1515
|
+
vErrors.push(err13);
|
|
1516
|
+
}
|
|
1517
|
+
errors++;
|
|
1518
|
+
}
|
|
1519
|
+
if (data3.application_name !== void 0) {
|
|
1520
|
+
if (typeof data3.application_name !== "string") {
|
|
1521
|
+
const err14 = { instancePath: instancePath + "/branding/application_name", schemaPath: "#/properties/branding/properties/application_name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1522
|
+
if (vErrors === null) {
|
|
1523
|
+
vErrors = [err14];
|
|
1524
|
+
} else {
|
|
1525
|
+
vErrors.push(err14);
|
|
1526
|
+
}
|
|
1527
|
+
errors++;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
if (data3.logo_url !== void 0) {
|
|
1531
|
+
let data5 = data3.logo_url;
|
|
1532
|
+
if (typeof data5 !== "string" && data5 !== null) {
|
|
1533
|
+
const err15 = { instancePath: instancePath + "/branding/logo_url", schemaPath: "#/properties/branding/properties/logo_url/type", keyword: "type", params: { type: schema41.properties.branding.properties.logo_url.type }, message: "must be string,null" };
|
|
1534
|
+
if (vErrors === null) {
|
|
1535
|
+
vErrors = [err15];
|
|
1536
|
+
} else {
|
|
1537
|
+
vErrors.push(err15);
|
|
1538
|
+
}
|
|
1539
|
+
errors++;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
if (data3.primary_color !== void 0) {
|
|
1543
|
+
let data6 = data3.primary_color;
|
|
1544
|
+
if (typeof data6 !== "string" && data6 !== null) {
|
|
1545
|
+
const err16 = { instancePath: instancePath + "/branding/primary_color", schemaPath: "#/properties/branding/properties/primary_color/type", keyword: "type", params: { type: schema41.properties.branding.properties.primary_color.type }, message: "must be string,null" };
|
|
1546
|
+
if (vErrors === null) {
|
|
1547
|
+
vErrors = [err16];
|
|
1548
|
+
} else {
|
|
1549
|
+
vErrors.push(err16);
|
|
1550
|
+
}
|
|
1551
|
+
errors++;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
} else {
|
|
1555
|
+
const err17 = { instancePath: instancePath + "/branding", schemaPath: "#/properties/branding/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1556
|
+
if (vErrors === null) {
|
|
1557
|
+
vErrors = [err17];
|
|
1558
|
+
} else {
|
|
1559
|
+
vErrors.push(err17);
|
|
1560
|
+
}
|
|
1561
|
+
errors++;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
if (data.mode !== void 0) {
|
|
1565
|
+
let data7 = data.mode;
|
|
1566
|
+
if (typeof data7 !== "string") {
|
|
1567
|
+
const err18 = { instancePath: instancePath + "/mode", schemaPath: "#/properties/mode/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1568
|
+
if (vErrors === null) {
|
|
1569
|
+
vErrors = [err18];
|
|
1570
|
+
} else {
|
|
1571
|
+
vErrors.push(err18);
|
|
1572
|
+
}
|
|
1573
|
+
errors++;
|
|
1574
|
+
}
|
|
1575
|
+
if (!(data7 === "embed" || data7 === "popup" || data7 === "redirect")) {
|
|
1576
|
+
const err19 = { instancePath: instancePath + "/mode", schemaPath: "#/properties/mode/enum", keyword: "enum", params: { allowedValues: schema41.properties.mode.enum }, message: "must be equal to one of the allowed values" };
|
|
1577
|
+
if (vErrors === null) {
|
|
1578
|
+
vErrors = [err19];
|
|
1579
|
+
} else {
|
|
1580
|
+
vErrors.push(err19);
|
|
1581
|
+
}
|
|
1582
|
+
errors++;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
if (data.locale !== void 0) {
|
|
1586
|
+
if (typeof data.locale !== "string") {
|
|
1587
|
+
const err20 = { instancePath: instancePath + "/locale", schemaPath: "#/properties/locale/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1588
|
+
if (vErrors === null) {
|
|
1589
|
+
vErrors = [err20];
|
|
1590
|
+
} else {
|
|
1591
|
+
vErrors.push(err20);
|
|
1592
|
+
}
|
|
1593
|
+
errors++;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
} else {
|
|
1597
|
+
const err21 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1598
|
+
if (vErrors === null) {
|
|
1599
|
+
vErrors = [err21];
|
|
1600
|
+
} else {
|
|
1601
|
+
vErrors.push(err21);
|
|
1602
|
+
}
|
|
1603
|
+
errors++;
|
|
1604
|
+
}
|
|
1605
|
+
validate30.errors = vErrors;
|
|
1606
|
+
return errors === 0;
|
|
1607
|
+
}
|
|
1608
|
+
validate30.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
1609
|
+
|
|
1610
|
+
// src/generated/postmessage-v2/resize.js
|
|
1611
|
+
var resize_default = validate31;
|
|
1612
|
+
function validate31(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
1613
|
+
;
|
|
1614
|
+
let vErrors = null;
|
|
1615
|
+
let errors = 0;
|
|
1616
|
+
const evaluated0 = validate31.evaluated;
|
|
1617
|
+
if (evaluated0.dynamicProps) {
|
|
1618
|
+
evaluated0.props = void 0;
|
|
1619
|
+
}
|
|
1620
|
+
if (evaluated0.dynamicItems) {
|
|
1621
|
+
evaluated0.items = void 0;
|
|
1622
|
+
}
|
|
1623
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1624
|
+
if (data.height === void 0) {
|
|
1625
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "height" }, message: "must have required property 'height'" };
|
|
1626
|
+
if (vErrors === null) {
|
|
1627
|
+
vErrors = [err0];
|
|
1628
|
+
} else {
|
|
1629
|
+
vErrors.push(err0);
|
|
1630
|
+
}
|
|
1631
|
+
errors++;
|
|
1632
|
+
}
|
|
1633
|
+
if (data.height !== void 0) {
|
|
1634
|
+
let data0 = data.height;
|
|
1635
|
+
if (!(typeof data0 == "number" && (!(data0 % 1) && !isNaN(data0)))) {
|
|
1636
|
+
const err1 = { instancePath: instancePath + "/height", schemaPath: "#/properties/height/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
1637
|
+
if (vErrors === null) {
|
|
1638
|
+
vErrors = [err1];
|
|
1639
|
+
} else {
|
|
1640
|
+
vErrors.push(err1);
|
|
1641
|
+
}
|
|
1642
|
+
errors++;
|
|
1643
|
+
}
|
|
1644
|
+
if (typeof data0 == "number") {
|
|
1645
|
+
if (data0 < 0 || isNaN(data0)) {
|
|
1646
|
+
const err2 = { instancePath: instancePath + "/height", schemaPath: "#/properties/height/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
|
|
1647
|
+
if (vErrors === null) {
|
|
1648
|
+
vErrors = [err2];
|
|
1649
|
+
} else {
|
|
1650
|
+
vErrors.push(err2);
|
|
1651
|
+
}
|
|
1652
|
+
errors++;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
} else {
|
|
1657
|
+
const err3 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1658
|
+
if (vErrors === null) {
|
|
1659
|
+
vErrors = [err3];
|
|
1660
|
+
} else {
|
|
1661
|
+
vErrors.push(err3);
|
|
1662
|
+
}
|
|
1663
|
+
errors++;
|
|
1664
|
+
}
|
|
1665
|
+
validate31.errors = vErrors;
|
|
1666
|
+
return errors === 0;
|
|
1667
|
+
}
|
|
1668
|
+
validate31.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
1669
|
+
|
|
1670
|
+
// src/generated/postmessage-v2/cancel.js
|
|
1671
|
+
var cancel_default = validate24;
|
|
1672
|
+
var schema35 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/cancel.json", "title": "CANCEL payload (kind-agnostic \u2014 bidirectional)", "type": "object", "additionalProperties": true, "required": ["reason", "cancelled_by"], "properties": { "reason": { "type": "string", "enum": ["user_declined", "principal_navigated_away", "host_requested", "system_revoked"] }, "cancelled_by": { "type": "string", "enum": ["principal", "host", "system"] } } };
|
|
1673
|
+
function validate24(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
1674
|
+
;
|
|
1675
|
+
let vErrors = null;
|
|
1676
|
+
let errors = 0;
|
|
1677
|
+
const evaluated0 = validate24.evaluated;
|
|
1678
|
+
if (evaluated0.dynamicProps) {
|
|
1679
|
+
evaluated0.props = void 0;
|
|
1680
|
+
}
|
|
1681
|
+
if (evaluated0.dynamicItems) {
|
|
1682
|
+
evaluated0.items = void 0;
|
|
1683
|
+
}
|
|
1684
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1685
|
+
if (data.reason === void 0) {
|
|
1686
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "reason" }, message: "must have required property 'reason'" };
|
|
1687
|
+
if (vErrors === null) {
|
|
1688
|
+
vErrors = [err0];
|
|
1689
|
+
} else {
|
|
1690
|
+
vErrors.push(err0);
|
|
1691
|
+
}
|
|
1692
|
+
errors++;
|
|
1693
|
+
}
|
|
1694
|
+
if (data.cancelled_by === void 0) {
|
|
1695
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "cancelled_by" }, message: "must have required property 'cancelled_by'" };
|
|
1696
|
+
if (vErrors === null) {
|
|
1697
|
+
vErrors = [err1];
|
|
1698
|
+
} else {
|
|
1699
|
+
vErrors.push(err1);
|
|
1700
|
+
}
|
|
1701
|
+
errors++;
|
|
1702
|
+
}
|
|
1703
|
+
if (data.reason !== void 0) {
|
|
1704
|
+
let data0 = data.reason;
|
|
1705
|
+
if (typeof data0 !== "string") {
|
|
1706
|
+
const err2 = { instancePath: instancePath + "/reason", schemaPath: "#/properties/reason/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1707
|
+
if (vErrors === null) {
|
|
1708
|
+
vErrors = [err2];
|
|
1709
|
+
} else {
|
|
1710
|
+
vErrors.push(err2);
|
|
1711
|
+
}
|
|
1712
|
+
errors++;
|
|
1713
|
+
}
|
|
1714
|
+
if (!(data0 === "user_declined" || data0 === "principal_navigated_away" || data0 === "host_requested" || data0 === "system_revoked")) {
|
|
1715
|
+
const err3 = { instancePath: instancePath + "/reason", schemaPath: "#/properties/reason/enum", keyword: "enum", params: { allowedValues: schema35.properties.reason.enum }, message: "must be equal to one of the allowed values" };
|
|
1716
|
+
if (vErrors === null) {
|
|
1717
|
+
vErrors = [err3];
|
|
1718
|
+
} else {
|
|
1719
|
+
vErrors.push(err3);
|
|
1720
|
+
}
|
|
1721
|
+
errors++;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
if (data.cancelled_by !== void 0) {
|
|
1725
|
+
let data1 = data.cancelled_by;
|
|
1726
|
+
if (typeof data1 !== "string") {
|
|
1727
|
+
const err4 = { instancePath: instancePath + "/cancelled_by", schemaPath: "#/properties/cancelled_by/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1728
|
+
if (vErrors === null) {
|
|
1729
|
+
vErrors = [err4];
|
|
1730
|
+
} else {
|
|
1731
|
+
vErrors.push(err4);
|
|
1732
|
+
}
|
|
1733
|
+
errors++;
|
|
1734
|
+
}
|
|
1735
|
+
if (!(data1 === "principal" || data1 === "host" || data1 === "system")) {
|
|
1736
|
+
const err5 = { instancePath: instancePath + "/cancelled_by", schemaPath: "#/properties/cancelled_by/enum", keyword: "enum", params: { allowedValues: schema35.properties.cancelled_by.enum }, message: "must be equal to one of the allowed values" };
|
|
1737
|
+
if (vErrors === null) {
|
|
1738
|
+
vErrors = [err5];
|
|
1739
|
+
} else {
|
|
1740
|
+
vErrors.push(err5);
|
|
1741
|
+
}
|
|
1742
|
+
errors++;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
} else {
|
|
1746
|
+
const err6 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1747
|
+
if (vErrors === null) {
|
|
1748
|
+
vErrors = [err6];
|
|
1749
|
+
} else {
|
|
1750
|
+
vErrors.push(err6);
|
|
1751
|
+
}
|
|
1752
|
+
errors++;
|
|
1753
|
+
}
|
|
1754
|
+
validate24.errors = vErrors;
|
|
1755
|
+
return errors === 0;
|
|
1756
|
+
}
|
|
1757
|
+
validate24.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
1758
|
+
|
|
1759
|
+
// src/generated/postmessage-v2/consent/state.js
|
|
1760
|
+
var state_default = validate28;
|
|
1761
|
+
var schema39 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/consent/state.json", "title": "consent STATE payload", "type": "object", "additionalProperties": true, "required": ["from", "to", "step_index", "total_steps"], "properties": { "from": { "type": ["string", "null"] }, "to": { "type": "string" }, "step_index": { "type": "integer", "minimum": 0 }, "total_steps": { "type": "integer", "minimum": 1 }, "kind_payload": { "type": "object", "additionalProperties": true } } };
|
|
1762
|
+
function validate28(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
1763
|
+
;
|
|
1764
|
+
let vErrors = null;
|
|
1765
|
+
let errors = 0;
|
|
1766
|
+
const evaluated0 = validate28.evaluated;
|
|
1767
|
+
if (evaluated0.dynamicProps) {
|
|
1768
|
+
evaluated0.props = void 0;
|
|
1769
|
+
}
|
|
1770
|
+
if (evaluated0.dynamicItems) {
|
|
1771
|
+
evaluated0.items = void 0;
|
|
1772
|
+
}
|
|
1773
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1774
|
+
if (data.from === void 0) {
|
|
1775
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
|
|
1776
|
+
if (vErrors === null) {
|
|
1777
|
+
vErrors = [err0];
|
|
1778
|
+
} else {
|
|
1779
|
+
vErrors.push(err0);
|
|
1780
|
+
}
|
|
1781
|
+
errors++;
|
|
1782
|
+
}
|
|
1783
|
+
if (data.to === void 0) {
|
|
1784
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "to" }, message: "must have required property 'to'" };
|
|
1785
|
+
if (vErrors === null) {
|
|
1786
|
+
vErrors = [err1];
|
|
1787
|
+
} else {
|
|
1788
|
+
vErrors.push(err1);
|
|
1789
|
+
}
|
|
1790
|
+
errors++;
|
|
1791
|
+
}
|
|
1792
|
+
if (data.step_index === void 0) {
|
|
1793
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "step_index" }, message: "must have required property 'step_index'" };
|
|
1794
|
+
if (vErrors === null) {
|
|
1795
|
+
vErrors = [err2];
|
|
1796
|
+
} else {
|
|
1797
|
+
vErrors.push(err2);
|
|
1798
|
+
}
|
|
1799
|
+
errors++;
|
|
1800
|
+
}
|
|
1801
|
+
if (data.total_steps === void 0) {
|
|
1802
|
+
const err3 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "total_steps" }, message: "must have required property 'total_steps'" };
|
|
1803
|
+
if (vErrors === null) {
|
|
1804
|
+
vErrors = [err3];
|
|
1805
|
+
} else {
|
|
1806
|
+
vErrors.push(err3);
|
|
1807
|
+
}
|
|
1808
|
+
errors++;
|
|
1809
|
+
}
|
|
1810
|
+
if (data.from !== void 0) {
|
|
1811
|
+
let data0 = data.from;
|
|
1812
|
+
if (typeof data0 !== "string" && data0 !== null) {
|
|
1813
|
+
const err4 = { instancePath: instancePath + "/from", schemaPath: "#/properties/from/type", keyword: "type", params: { type: schema39.properties.from.type }, message: "must be string,null" };
|
|
1814
|
+
if (vErrors === null) {
|
|
1815
|
+
vErrors = [err4];
|
|
1816
|
+
} else {
|
|
1817
|
+
vErrors.push(err4);
|
|
1818
|
+
}
|
|
1819
|
+
errors++;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
if (data.to !== void 0) {
|
|
1823
|
+
if (typeof data.to !== "string") {
|
|
1824
|
+
const err5 = { instancePath: instancePath + "/to", schemaPath: "#/properties/to/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1825
|
+
if (vErrors === null) {
|
|
1826
|
+
vErrors = [err5];
|
|
1827
|
+
} else {
|
|
1828
|
+
vErrors.push(err5);
|
|
1829
|
+
}
|
|
1830
|
+
errors++;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
if (data.step_index !== void 0) {
|
|
1834
|
+
let data2 = data.step_index;
|
|
1835
|
+
if (!(typeof data2 == "number" && (!(data2 % 1) && !isNaN(data2)))) {
|
|
1836
|
+
const err6 = { instancePath: instancePath + "/step_index", schemaPath: "#/properties/step_index/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
1837
|
+
if (vErrors === null) {
|
|
1838
|
+
vErrors = [err6];
|
|
1839
|
+
} else {
|
|
1840
|
+
vErrors.push(err6);
|
|
1841
|
+
}
|
|
1842
|
+
errors++;
|
|
1843
|
+
}
|
|
1844
|
+
if (typeof data2 == "number") {
|
|
1845
|
+
if (data2 < 0 || isNaN(data2)) {
|
|
1846
|
+
const err7 = { instancePath: instancePath + "/step_index", schemaPath: "#/properties/step_index/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
|
|
1847
|
+
if (vErrors === null) {
|
|
1848
|
+
vErrors = [err7];
|
|
1849
|
+
} else {
|
|
1850
|
+
vErrors.push(err7);
|
|
1851
|
+
}
|
|
1852
|
+
errors++;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
if (data.total_steps !== void 0) {
|
|
1857
|
+
let data3 = data.total_steps;
|
|
1858
|
+
if (!(typeof data3 == "number" && (!(data3 % 1) && !isNaN(data3)))) {
|
|
1859
|
+
const err8 = { instancePath: instancePath + "/total_steps", schemaPath: "#/properties/total_steps/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
1860
|
+
if (vErrors === null) {
|
|
1861
|
+
vErrors = [err8];
|
|
1862
|
+
} else {
|
|
1863
|
+
vErrors.push(err8);
|
|
1864
|
+
}
|
|
1865
|
+
errors++;
|
|
1866
|
+
}
|
|
1867
|
+
if (typeof data3 == "number") {
|
|
1868
|
+
if (data3 < 1 || isNaN(data3)) {
|
|
1869
|
+
const err9 = { instancePath: instancePath + "/total_steps", schemaPath: "#/properties/total_steps/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
|
|
1870
|
+
if (vErrors === null) {
|
|
1871
|
+
vErrors = [err9];
|
|
1872
|
+
} else {
|
|
1873
|
+
vErrors.push(err9);
|
|
1874
|
+
}
|
|
1875
|
+
errors++;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
if (data.kind_payload !== void 0) {
|
|
1880
|
+
let data4 = data.kind_payload;
|
|
1881
|
+
if (data4 && typeof data4 == "object" && !Array.isArray(data4)) {
|
|
1882
|
+
} else {
|
|
1883
|
+
const err10 = { instancePath: instancePath + "/kind_payload", schemaPath: "#/properties/kind_payload/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1884
|
+
if (vErrors === null) {
|
|
1885
|
+
vErrors = [err10];
|
|
1886
|
+
} else {
|
|
1887
|
+
vErrors.push(err10);
|
|
1888
|
+
}
|
|
1889
|
+
errors++;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
} else {
|
|
1893
|
+
const err11 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1894
|
+
if (vErrors === null) {
|
|
1895
|
+
vErrors = [err11];
|
|
1896
|
+
} else {
|
|
1897
|
+
vErrors.push(err11);
|
|
1898
|
+
}
|
|
1899
|
+
errors++;
|
|
1900
|
+
}
|
|
1901
|
+
validate28.errors = vErrors;
|
|
1902
|
+
return errors === 0;
|
|
1903
|
+
}
|
|
1904
|
+
validate28.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
1905
|
+
|
|
1906
|
+
// src/generated/postmessage-v2/consent/complete.js
|
|
1907
|
+
var complete_default = validate25;
|
|
1908
|
+
var schema36 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/consent/complete.json", "title": "consent COMPLETE payload", "type": "object", "additionalProperties": true, "required": ["outcome", "completed_at"], "properties": { "outcome": { "type": "string", "enum": ["granted", "declined"] }, "exchange_token": { "type": ["string", "null"], "description": "Consent token the host exchanges via POST /api/v1/decisions/:token/exchange" }, "completed_at": { "type": "string", "format": "date-time" } } };
|
|
1909
|
+
var formats03 = require_formats().fullFormats["date-time"];
|
|
1910
|
+
function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
1911
|
+
;
|
|
1912
|
+
let vErrors = null;
|
|
1913
|
+
let errors = 0;
|
|
1914
|
+
const evaluated0 = validate25.evaluated;
|
|
1915
|
+
if (evaluated0.dynamicProps) {
|
|
1916
|
+
evaluated0.props = void 0;
|
|
1917
|
+
}
|
|
1918
|
+
if (evaluated0.dynamicItems) {
|
|
1919
|
+
evaluated0.items = void 0;
|
|
1920
|
+
}
|
|
1921
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1922
|
+
if (data.outcome === void 0) {
|
|
1923
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "outcome" }, message: "must have required property 'outcome'" };
|
|
1924
|
+
if (vErrors === null) {
|
|
1925
|
+
vErrors = [err0];
|
|
1926
|
+
} else {
|
|
1927
|
+
vErrors.push(err0);
|
|
1928
|
+
}
|
|
1929
|
+
errors++;
|
|
1930
|
+
}
|
|
1931
|
+
if (data.completed_at === void 0) {
|
|
1932
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "completed_at" }, message: "must have required property 'completed_at'" };
|
|
1933
|
+
if (vErrors === null) {
|
|
1934
|
+
vErrors = [err1];
|
|
1935
|
+
} else {
|
|
1936
|
+
vErrors.push(err1);
|
|
1937
|
+
}
|
|
1938
|
+
errors++;
|
|
1939
|
+
}
|
|
1940
|
+
if (data.outcome !== void 0) {
|
|
1941
|
+
let data0 = data.outcome;
|
|
1942
|
+
if (typeof data0 !== "string") {
|
|
1943
|
+
const err2 = { instancePath: instancePath + "/outcome", schemaPath: "#/properties/outcome/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1944
|
+
if (vErrors === null) {
|
|
1945
|
+
vErrors = [err2];
|
|
1946
|
+
} else {
|
|
1947
|
+
vErrors.push(err2);
|
|
1948
|
+
}
|
|
1949
|
+
errors++;
|
|
1950
|
+
}
|
|
1951
|
+
if (!(data0 === "granted" || data0 === "declined")) {
|
|
1952
|
+
const err3 = { instancePath: instancePath + "/outcome", schemaPath: "#/properties/outcome/enum", keyword: "enum", params: { allowedValues: schema36.properties.outcome.enum }, message: "must be equal to one of the allowed values" };
|
|
1953
|
+
if (vErrors === null) {
|
|
1954
|
+
vErrors = [err3];
|
|
1955
|
+
} else {
|
|
1956
|
+
vErrors.push(err3);
|
|
1957
|
+
}
|
|
1958
|
+
errors++;
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
if (data.exchange_token !== void 0) {
|
|
1962
|
+
let data1 = data.exchange_token;
|
|
1963
|
+
if (typeof data1 !== "string" && data1 !== null) {
|
|
1964
|
+
const err4 = { instancePath: instancePath + "/exchange_token", schemaPath: "#/properties/exchange_token/type", keyword: "type", params: { type: schema36.properties.exchange_token.type }, message: "must be string,null" };
|
|
1965
|
+
if (vErrors === null) {
|
|
1966
|
+
vErrors = [err4];
|
|
1967
|
+
} else {
|
|
1968
|
+
vErrors.push(err4);
|
|
1969
|
+
}
|
|
1970
|
+
errors++;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
if (data.completed_at !== void 0) {
|
|
1974
|
+
let data2 = data.completed_at;
|
|
1975
|
+
if (typeof data2 === "string") {
|
|
1976
|
+
if (!formats03.validate(data2)) {
|
|
1977
|
+
const err5 = { instancePath: instancePath + "/completed_at", schemaPath: "#/properties/completed_at/format", keyword: "format", params: { format: "date-time" }, message: 'must match format "date-time"' };
|
|
1978
|
+
if (vErrors === null) {
|
|
1979
|
+
vErrors = [err5];
|
|
1980
|
+
} else {
|
|
1981
|
+
vErrors.push(err5);
|
|
1982
|
+
}
|
|
1983
|
+
errors++;
|
|
1984
|
+
}
|
|
1985
|
+
} else {
|
|
1986
|
+
const err6 = { instancePath: instancePath + "/completed_at", schemaPath: "#/properties/completed_at/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1987
|
+
if (vErrors === null) {
|
|
1988
|
+
vErrors = [err6];
|
|
1989
|
+
} else {
|
|
1990
|
+
vErrors.push(err6);
|
|
1991
|
+
}
|
|
1992
|
+
errors++;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
} else {
|
|
1996
|
+
const err7 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1997
|
+
if (vErrors === null) {
|
|
1998
|
+
vErrors = [err7];
|
|
1999
|
+
} else {
|
|
2000
|
+
vErrors.push(err7);
|
|
2001
|
+
}
|
|
2002
|
+
errors++;
|
|
2003
|
+
}
|
|
2004
|
+
validate25.errors = vErrors;
|
|
2005
|
+
return errors === 0;
|
|
2006
|
+
}
|
|
2007
|
+
validate25.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
2008
|
+
|
|
2009
|
+
// src/generated/postmessage-v2/consent/error.js
|
|
2010
|
+
var error_default = validate27;
|
|
2011
|
+
var schema38 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/consent/error.json", "title": "consent ERROR payload", "type": "object", "additionalProperties": true, "required": ["code", "message", "fatal"], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "fatal": { "type": "boolean" }, "recoverable_via": { "type": ["string", "null"], "enum": ["reload", "new_session", null] } } };
|
|
2012
|
+
function validate27(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
2013
|
+
;
|
|
2014
|
+
let vErrors = null;
|
|
2015
|
+
let errors = 0;
|
|
2016
|
+
const evaluated0 = validate27.evaluated;
|
|
2017
|
+
if (evaluated0.dynamicProps) {
|
|
2018
|
+
evaluated0.props = void 0;
|
|
2019
|
+
}
|
|
2020
|
+
if (evaluated0.dynamicItems) {
|
|
2021
|
+
evaluated0.items = void 0;
|
|
2022
|
+
}
|
|
2023
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2024
|
+
if (data.code === void 0) {
|
|
2025
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "code" }, message: "must have required property 'code'" };
|
|
2026
|
+
if (vErrors === null) {
|
|
2027
|
+
vErrors = [err0];
|
|
2028
|
+
} else {
|
|
2029
|
+
vErrors.push(err0);
|
|
2030
|
+
}
|
|
2031
|
+
errors++;
|
|
2032
|
+
}
|
|
2033
|
+
if (data.message === void 0) {
|
|
2034
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "message" }, message: "must have required property 'message'" };
|
|
2035
|
+
if (vErrors === null) {
|
|
2036
|
+
vErrors = [err1];
|
|
2037
|
+
} else {
|
|
2038
|
+
vErrors.push(err1);
|
|
2039
|
+
}
|
|
2040
|
+
errors++;
|
|
2041
|
+
}
|
|
2042
|
+
if (data.fatal === void 0) {
|
|
2043
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "fatal" }, message: "must have required property 'fatal'" };
|
|
2044
|
+
if (vErrors === null) {
|
|
2045
|
+
vErrors = [err2];
|
|
2046
|
+
} else {
|
|
2047
|
+
vErrors.push(err2);
|
|
2048
|
+
}
|
|
2049
|
+
errors++;
|
|
2050
|
+
}
|
|
2051
|
+
if (data.code !== void 0) {
|
|
2052
|
+
if (typeof data.code !== "string") {
|
|
2053
|
+
const err3 = { instancePath: instancePath + "/code", schemaPath: "#/properties/code/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2054
|
+
if (vErrors === null) {
|
|
2055
|
+
vErrors = [err3];
|
|
2056
|
+
} else {
|
|
2057
|
+
vErrors.push(err3);
|
|
2058
|
+
}
|
|
2059
|
+
errors++;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
if (data.message !== void 0) {
|
|
2063
|
+
if (typeof data.message !== "string") {
|
|
2064
|
+
const err4 = { instancePath: instancePath + "/message", schemaPath: "#/properties/message/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2065
|
+
if (vErrors === null) {
|
|
2066
|
+
vErrors = [err4];
|
|
2067
|
+
} else {
|
|
2068
|
+
vErrors.push(err4);
|
|
2069
|
+
}
|
|
2070
|
+
errors++;
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
if (data.fatal !== void 0) {
|
|
2074
|
+
if (typeof data.fatal !== "boolean") {
|
|
2075
|
+
const err5 = { instancePath: instancePath + "/fatal", schemaPath: "#/properties/fatal/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" };
|
|
2076
|
+
if (vErrors === null) {
|
|
2077
|
+
vErrors = [err5];
|
|
2078
|
+
} else {
|
|
2079
|
+
vErrors.push(err5);
|
|
2080
|
+
}
|
|
2081
|
+
errors++;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
if (data.recoverable_via !== void 0) {
|
|
2085
|
+
let data3 = data.recoverable_via;
|
|
2086
|
+
if (typeof data3 !== "string" && data3 !== null) {
|
|
2087
|
+
const err6 = { instancePath: instancePath + "/recoverable_via", schemaPath: "#/properties/recoverable_via/type", keyword: "type", params: { type: schema38.properties.recoverable_via.type }, message: "must be string,null" };
|
|
2088
|
+
if (vErrors === null) {
|
|
2089
|
+
vErrors = [err6];
|
|
2090
|
+
} else {
|
|
2091
|
+
vErrors.push(err6);
|
|
2092
|
+
}
|
|
2093
|
+
errors++;
|
|
2094
|
+
}
|
|
2095
|
+
if (!(data3 === "reload" || data3 === "new_session" || data3 === null)) {
|
|
2096
|
+
const err7 = { instancePath: instancePath + "/recoverable_via", schemaPath: "#/properties/recoverable_via/enum", keyword: "enum", params: { allowedValues: schema38.properties.recoverable_via.enum }, message: "must be equal to one of the allowed values" };
|
|
2097
|
+
if (vErrors === null) {
|
|
2098
|
+
vErrors = [err7];
|
|
2099
|
+
} else {
|
|
2100
|
+
vErrors.push(err7);
|
|
2101
|
+
}
|
|
2102
|
+
errors++;
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
} else {
|
|
2106
|
+
const err8 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2107
|
+
if (vErrors === null) {
|
|
2108
|
+
vErrors = [err8];
|
|
2109
|
+
} else {
|
|
2110
|
+
vErrors.push(err8);
|
|
2111
|
+
}
|
|
2112
|
+
errors++;
|
|
2113
|
+
}
|
|
2114
|
+
validate27.errors = vErrors;
|
|
2115
|
+
return errors === 0;
|
|
2116
|
+
}
|
|
2117
|
+
validate27.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
2118
|
+
|
|
2119
|
+
// src/generated/postmessage-v2/consent/deadline.js
|
|
2120
|
+
var deadline_default = validate26;
|
|
2121
|
+
var schema37 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/consent/deadline.json", "title": "consent DEADLINE payload", "type": "object", "additionalProperties": true, "required": ["remaining_seconds", "level", "deadline_at"], "properties": { "remaining_seconds": { "type": "integer", "minimum": 0 }, "level": { "type": "string", "enum": ["warning", "expired"] }, "deadline_at": { "type": "string", "format": "date-time" } } };
|
|
2122
|
+
var formats04 = require_formats().fullFormats["date-time"];
|
|
2123
|
+
function validate26(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
2124
|
+
;
|
|
2125
|
+
let vErrors = null;
|
|
2126
|
+
let errors = 0;
|
|
2127
|
+
const evaluated0 = validate26.evaluated;
|
|
2128
|
+
if (evaluated0.dynamicProps) {
|
|
2129
|
+
evaluated0.props = void 0;
|
|
2130
|
+
}
|
|
2131
|
+
if (evaluated0.dynamicItems) {
|
|
2132
|
+
evaluated0.items = void 0;
|
|
2133
|
+
}
|
|
2134
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2135
|
+
if (data.remaining_seconds === void 0) {
|
|
2136
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "remaining_seconds" }, message: "must have required property 'remaining_seconds'" };
|
|
2137
|
+
if (vErrors === null) {
|
|
2138
|
+
vErrors = [err0];
|
|
2139
|
+
} else {
|
|
2140
|
+
vErrors.push(err0);
|
|
2141
|
+
}
|
|
2142
|
+
errors++;
|
|
2143
|
+
}
|
|
2144
|
+
if (data.level === void 0) {
|
|
2145
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "level" }, message: "must have required property 'level'" };
|
|
2146
|
+
if (vErrors === null) {
|
|
2147
|
+
vErrors = [err1];
|
|
2148
|
+
} else {
|
|
2149
|
+
vErrors.push(err1);
|
|
2150
|
+
}
|
|
2151
|
+
errors++;
|
|
2152
|
+
}
|
|
2153
|
+
if (data.deadline_at === void 0) {
|
|
2154
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "deadline_at" }, message: "must have required property 'deadline_at'" };
|
|
2155
|
+
if (vErrors === null) {
|
|
2156
|
+
vErrors = [err2];
|
|
2157
|
+
} else {
|
|
2158
|
+
vErrors.push(err2);
|
|
2159
|
+
}
|
|
2160
|
+
errors++;
|
|
2161
|
+
}
|
|
2162
|
+
if (data.remaining_seconds !== void 0) {
|
|
2163
|
+
let data0 = data.remaining_seconds;
|
|
2164
|
+
if (!(typeof data0 == "number" && (!(data0 % 1) && !isNaN(data0)))) {
|
|
2165
|
+
const err3 = { instancePath: instancePath + "/remaining_seconds", schemaPath: "#/properties/remaining_seconds/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
2166
|
+
if (vErrors === null) {
|
|
2167
|
+
vErrors = [err3];
|
|
2168
|
+
} else {
|
|
2169
|
+
vErrors.push(err3);
|
|
2170
|
+
}
|
|
2171
|
+
errors++;
|
|
2172
|
+
}
|
|
2173
|
+
if (typeof data0 == "number") {
|
|
2174
|
+
if (data0 < 0 || isNaN(data0)) {
|
|
2175
|
+
const err4 = { instancePath: instancePath + "/remaining_seconds", schemaPath: "#/properties/remaining_seconds/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
|
|
2176
|
+
if (vErrors === null) {
|
|
2177
|
+
vErrors = [err4];
|
|
2178
|
+
} else {
|
|
2179
|
+
vErrors.push(err4);
|
|
2180
|
+
}
|
|
2181
|
+
errors++;
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
if (data.level !== void 0) {
|
|
2186
|
+
let data1 = data.level;
|
|
2187
|
+
if (typeof data1 !== "string") {
|
|
2188
|
+
const err5 = { instancePath: instancePath + "/level", schemaPath: "#/properties/level/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2189
|
+
if (vErrors === null) {
|
|
2190
|
+
vErrors = [err5];
|
|
2191
|
+
} else {
|
|
2192
|
+
vErrors.push(err5);
|
|
2193
|
+
}
|
|
2194
|
+
errors++;
|
|
2195
|
+
}
|
|
2196
|
+
if (!(data1 === "warning" || data1 === "expired")) {
|
|
2197
|
+
const err6 = { instancePath: instancePath + "/level", schemaPath: "#/properties/level/enum", keyword: "enum", params: { allowedValues: schema37.properties.level.enum }, message: "must be equal to one of the allowed values" };
|
|
2198
|
+
if (vErrors === null) {
|
|
2199
|
+
vErrors = [err6];
|
|
2200
|
+
} else {
|
|
2201
|
+
vErrors.push(err6);
|
|
2202
|
+
}
|
|
2203
|
+
errors++;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
if (data.deadline_at !== void 0) {
|
|
2207
|
+
let data2 = data.deadline_at;
|
|
2208
|
+
if (typeof data2 === "string") {
|
|
2209
|
+
if (!formats04.validate(data2)) {
|
|
2210
|
+
const err7 = { instancePath: instancePath + "/deadline_at", schemaPath: "#/properties/deadline_at/format", keyword: "format", params: { format: "date-time" }, message: 'must match format "date-time"' };
|
|
2211
|
+
if (vErrors === null) {
|
|
2212
|
+
vErrors = [err7];
|
|
2213
|
+
} else {
|
|
2214
|
+
vErrors.push(err7);
|
|
2215
|
+
}
|
|
2216
|
+
errors++;
|
|
2217
|
+
}
|
|
2218
|
+
} else {
|
|
2219
|
+
const err8 = { instancePath: instancePath + "/deadline_at", schemaPath: "#/properties/deadline_at/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2220
|
+
if (vErrors === null) {
|
|
2221
|
+
vErrors = [err8];
|
|
2222
|
+
} else {
|
|
2223
|
+
vErrors.push(err8);
|
|
2224
|
+
}
|
|
2225
|
+
errors++;
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
} else {
|
|
2229
|
+
const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2230
|
+
if (vErrors === null) {
|
|
2231
|
+
vErrors = [err9];
|
|
2232
|
+
} else {
|
|
2233
|
+
vErrors.push(err9);
|
|
2234
|
+
}
|
|
2235
|
+
errors++;
|
|
2236
|
+
}
|
|
2237
|
+
validate26.errors = vErrors;
|
|
2238
|
+
return errors === 0;
|
|
2239
|
+
}
|
|
2240
|
+
validate26.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
2241
|
+
|
|
2242
|
+
// src/generated/postmessage-v2/approval/state.js
|
|
2243
|
+
var state_default2 = validate23;
|
|
2244
|
+
var schema34 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/approval/state.json", "title": "approval STATE payload", "type": "object", "additionalProperties": true, "required": ["from", "to", "kind_payload"], "properties": { "from": { "type": ["string", "null"] }, "to": { "type": "string", "enum": ["pending", "opened", "in_progress", "approved", "denied", "expired"] }, "kind_payload": { "type": "object", "additionalProperties": true, "required": ["agent_id", "action_class", "scope_invoked"], "properties": { "agent_id": { "type": "string" }, "action_class": { "type": "string" }, "bounded_authority": { "type": "object", "additionalProperties": true }, "scope_invoked": { "type": "string" }, "value_invoked": { "type": ["object", "null"], "additionalProperties": true } } } } };
|
|
2245
|
+
function validate23(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
2246
|
+
;
|
|
2247
|
+
let vErrors = null;
|
|
2248
|
+
let errors = 0;
|
|
2249
|
+
const evaluated0 = validate23.evaluated;
|
|
2250
|
+
if (evaluated0.dynamicProps) {
|
|
2251
|
+
evaluated0.props = void 0;
|
|
2252
|
+
}
|
|
2253
|
+
if (evaluated0.dynamicItems) {
|
|
2254
|
+
evaluated0.items = void 0;
|
|
2255
|
+
}
|
|
2256
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2257
|
+
if (data.from === void 0) {
|
|
2258
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
|
|
2259
|
+
if (vErrors === null) {
|
|
2260
|
+
vErrors = [err0];
|
|
2261
|
+
} else {
|
|
2262
|
+
vErrors.push(err0);
|
|
2263
|
+
}
|
|
2264
|
+
errors++;
|
|
2265
|
+
}
|
|
2266
|
+
if (data.to === void 0) {
|
|
2267
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "to" }, message: "must have required property 'to'" };
|
|
2268
|
+
if (vErrors === null) {
|
|
2269
|
+
vErrors = [err1];
|
|
2270
|
+
} else {
|
|
2271
|
+
vErrors.push(err1);
|
|
2272
|
+
}
|
|
2273
|
+
errors++;
|
|
2274
|
+
}
|
|
2275
|
+
if (data.kind_payload === void 0) {
|
|
2276
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind_payload" }, message: "must have required property 'kind_payload'" };
|
|
2277
|
+
if (vErrors === null) {
|
|
2278
|
+
vErrors = [err2];
|
|
2279
|
+
} else {
|
|
2280
|
+
vErrors.push(err2);
|
|
2281
|
+
}
|
|
2282
|
+
errors++;
|
|
2283
|
+
}
|
|
2284
|
+
if (data.from !== void 0) {
|
|
2285
|
+
let data0 = data.from;
|
|
2286
|
+
if (typeof data0 !== "string" && data0 !== null) {
|
|
2287
|
+
const err3 = { instancePath: instancePath + "/from", schemaPath: "#/properties/from/type", keyword: "type", params: { type: schema34.properties.from.type }, message: "must be string,null" };
|
|
2288
|
+
if (vErrors === null) {
|
|
2289
|
+
vErrors = [err3];
|
|
2290
|
+
} else {
|
|
2291
|
+
vErrors.push(err3);
|
|
2292
|
+
}
|
|
2293
|
+
errors++;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
if (data.to !== void 0) {
|
|
2297
|
+
let data1 = data.to;
|
|
2298
|
+
if (typeof data1 !== "string") {
|
|
2299
|
+
const err4 = { instancePath: instancePath + "/to", schemaPath: "#/properties/to/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2300
|
+
if (vErrors === null) {
|
|
2301
|
+
vErrors = [err4];
|
|
2302
|
+
} else {
|
|
2303
|
+
vErrors.push(err4);
|
|
2304
|
+
}
|
|
2305
|
+
errors++;
|
|
2306
|
+
}
|
|
2307
|
+
if (!(data1 === "pending" || data1 === "opened" || data1 === "in_progress" || data1 === "approved" || data1 === "denied" || data1 === "expired")) {
|
|
2308
|
+
const err5 = { instancePath: instancePath + "/to", schemaPath: "#/properties/to/enum", keyword: "enum", params: { allowedValues: schema34.properties.to.enum }, message: "must be equal to one of the allowed values" };
|
|
2309
|
+
if (vErrors === null) {
|
|
2310
|
+
vErrors = [err5];
|
|
2311
|
+
} else {
|
|
2312
|
+
vErrors.push(err5);
|
|
2313
|
+
}
|
|
2314
|
+
errors++;
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
if (data.kind_payload !== void 0) {
|
|
2318
|
+
let data2 = data.kind_payload;
|
|
2319
|
+
if (data2 && typeof data2 == "object" && !Array.isArray(data2)) {
|
|
2320
|
+
if (data2.agent_id === void 0) {
|
|
2321
|
+
const err6 = { instancePath: instancePath + "/kind_payload", schemaPath: "#/properties/kind_payload/required", keyword: "required", params: { missingProperty: "agent_id" }, message: "must have required property 'agent_id'" };
|
|
2322
|
+
if (vErrors === null) {
|
|
2323
|
+
vErrors = [err6];
|
|
2324
|
+
} else {
|
|
2325
|
+
vErrors.push(err6);
|
|
2326
|
+
}
|
|
2327
|
+
errors++;
|
|
2328
|
+
}
|
|
2329
|
+
if (data2.action_class === void 0) {
|
|
2330
|
+
const err7 = { instancePath: instancePath + "/kind_payload", schemaPath: "#/properties/kind_payload/required", keyword: "required", params: { missingProperty: "action_class" }, message: "must have required property 'action_class'" };
|
|
2331
|
+
if (vErrors === null) {
|
|
2332
|
+
vErrors = [err7];
|
|
2333
|
+
} else {
|
|
2334
|
+
vErrors.push(err7);
|
|
2335
|
+
}
|
|
2336
|
+
errors++;
|
|
2337
|
+
}
|
|
2338
|
+
if (data2.scope_invoked === void 0) {
|
|
2339
|
+
const err8 = { instancePath: instancePath + "/kind_payload", schemaPath: "#/properties/kind_payload/required", keyword: "required", params: { missingProperty: "scope_invoked" }, message: "must have required property 'scope_invoked'" };
|
|
2340
|
+
if (vErrors === null) {
|
|
2341
|
+
vErrors = [err8];
|
|
2342
|
+
} else {
|
|
2343
|
+
vErrors.push(err8);
|
|
2344
|
+
}
|
|
2345
|
+
errors++;
|
|
2346
|
+
}
|
|
2347
|
+
if (data2.agent_id !== void 0) {
|
|
2348
|
+
if (typeof data2.agent_id !== "string") {
|
|
2349
|
+
const err9 = { instancePath: instancePath + "/kind_payload/agent_id", schemaPath: "#/properties/kind_payload/properties/agent_id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2350
|
+
if (vErrors === null) {
|
|
2351
|
+
vErrors = [err9];
|
|
2352
|
+
} else {
|
|
2353
|
+
vErrors.push(err9);
|
|
2354
|
+
}
|
|
2355
|
+
errors++;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
if (data2.action_class !== void 0) {
|
|
2359
|
+
if (typeof data2.action_class !== "string") {
|
|
2360
|
+
const err10 = { instancePath: instancePath + "/kind_payload/action_class", schemaPath: "#/properties/kind_payload/properties/action_class/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2361
|
+
if (vErrors === null) {
|
|
2362
|
+
vErrors = [err10];
|
|
2363
|
+
} else {
|
|
2364
|
+
vErrors.push(err10);
|
|
2365
|
+
}
|
|
2366
|
+
errors++;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
if (data2.bounded_authority !== void 0) {
|
|
2370
|
+
let data5 = data2.bounded_authority;
|
|
2371
|
+
if (data5 && typeof data5 == "object" && !Array.isArray(data5)) {
|
|
2372
|
+
} else {
|
|
2373
|
+
const err11 = { instancePath: instancePath + "/kind_payload/bounded_authority", schemaPath: "#/properties/kind_payload/properties/bounded_authority/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2374
|
+
if (vErrors === null) {
|
|
2375
|
+
vErrors = [err11];
|
|
2376
|
+
} else {
|
|
2377
|
+
vErrors.push(err11);
|
|
2378
|
+
}
|
|
2379
|
+
errors++;
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
if (data2.scope_invoked !== void 0) {
|
|
2383
|
+
if (typeof data2.scope_invoked !== "string") {
|
|
2384
|
+
const err12 = { instancePath: instancePath + "/kind_payload/scope_invoked", schemaPath: "#/properties/kind_payload/properties/scope_invoked/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2385
|
+
if (vErrors === null) {
|
|
2386
|
+
vErrors = [err12];
|
|
2387
|
+
} else {
|
|
2388
|
+
vErrors.push(err12);
|
|
2389
|
+
}
|
|
2390
|
+
errors++;
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
if (data2.value_invoked !== void 0) {
|
|
2394
|
+
let data7 = data2.value_invoked;
|
|
2395
|
+
if (!(data7 && typeof data7 == "object" && !Array.isArray(data7)) && data7 !== null) {
|
|
2396
|
+
const err13 = { instancePath: instancePath + "/kind_payload/value_invoked", schemaPath: "#/properties/kind_payload/properties/value_invoked/type", keyword: "type", params: { type: schema34.properties.kind_payload.properties.value_invoked.type }, message: "must be object,null" };
|
|
2397
|
+
if (vErrors === null) {
|
|
2398
|
+
vErrors = [err13];
|
|
2399
|
+
} else {
|
|
2400
|
+
vErrors.push(err13);
|
|
2401
|
+
}
|
|
2402
|
+
errors++;
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
} else {
|
|
2406
|
+
const err14 = { instancePath: instancePath + "/kind_payload", schemaPath: "#/properties/kind_payload/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2407
|
+
if (vErrors === null) {
|
|
2408
|
+
vErrors = [err14];
|
|
2409
|
+
} else {
|
|
2410
|
+
vErrors.push(err14);
|
|
2411
|
+
}
|
|
2412
|
+
errors++;
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
} else {
|
|
2416
|
+
const err15 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2417
|
+
if (vErrors === null) {
|
|
2418
|
+
vErrors = [err15];
|
|
2419
|
+
} else {
|
|
2420
|
+
vErrors.push(err15);
|
|
2421
|
+
}
|
|
2422
|
+
errors++;
|
|
2423
|
+
}
|
|
2424
|
+
validate23.errors = vErrors;
|
|
2425
|
+
return errors === 0;
|
|
2426
|
+
}
|
|
2427
|
+
validate23.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
2428
|
+
|
|
2429
|
+
// src/generated/postmessage-v2/approval/complete.js
|
|
2430
|
+
var complete_default2 = validate20;
|
|
2431
|
+
var schema31 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/approval/complete.json", "title": "approval COMPLETE payload", "type": "object", "additionalProperties": true, "required": ["outcome", "completed_at"], "properties": { "outcome": { "type": "string", "enum": ["approved", "denied"] }, "exchange_token": { "type": ["string", "null"], "description": "Approval-decision exchange token; host calls POST /api/v1/decisions/:token/exchange" }, "completed_at": { "type": "string", "format": "date-time" } } };
|
|
2432
|
+
var formats05 = require_formats().fullFormats["date-time"];
|
|
2433
|
+
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
2434
|
+
;
|
|
2435
|
+
let vErrors = null;
|
|
2436
|
+
let errors = 0;
|
|
2437
|
+
const evaluated0 = validate20.evaluated;
|
|
2438
|
+
if (evaluated0.dynamicProps) {
|
|
2439
|
+
evaluated0.props = void 0;
|
|
2440
|
+
}
|
|
2441
|
+
if (evaluated0.dynamicItems) {
|
|
2442
|
+
evaluated0.items = void 0;
|
|
2443
|
+
}
|
|
2444
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2445
|
+
if (data.outcome === void 0) {
|
|
2446
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "outcome" }, message: "must have required property 'outcome'" };
|
|
2447
|
+
if (vErrors === null) {
|
|
2448
|
+
vErrors = [err0];
|
|
2449
|
+
} else {
|
|
2450
|
+
vErrors.push(err0);
|
|
2451
|
+
}
|
|
2452
|
+
errors++;
|
|
2453
|
+
}
|
|
2454
|
+
if (data.completed_at === void 0) {
|
|
2455
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "completed_at" }, message: "must have required property 'completed_at'" };
|
|
2456
|
+
if (vErrors === null) {
|
|
2457
|
+
vErrors = [err1];
|
|
2458
|
+
} else {
|
|
2459
|
+
vErrors.push(err1);
|
|
2460
|
+
}
|
|
2461
|
+
errors++;
|
|
2462
|
+
}
|
|
2463
|
+
if (data.outcome !== void 0) {
|
|
2464
|
+
let data0 = data.outcome;
|
|
2465
|
+
if (typeof data0 !== "string") {
|
|
2466
|
+
const err2 = { instancePath: instancePath + "/outcome", schemaPath: "#/properties/outcome/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2467
|
+
if (vErrors === null) {
|
|
2468
|
+
vErrors = [err2];
|
|
2469
|
+
} else {
|
|
2470
|
+
vErrors.push(err2);
|
|
2471
|
+
}
|
|
2472
|
+
errors++;
|
|
2473
|
+
}
|
|
2474
|
+
if (!(data0 === "approved" || data0 === "denied")) {
|
|
2475
|
+
const err3 = { instancePath: instancePath + "/outcome", schemaPath: "#/properties/outcome/enum", keyword: "enum", params: { allowedValues: schema31.properties.outcome.enum }, message: "must be equal to one of the allowed values" };
|
|
2476
|
+
if (vErrors === null) {
|
|
2477
|
+
vErrors = [err3];
|
|
2478
|
+
} else {
|
|
2479
|
+
vErrors.push(err3);
|
|
2480
|
+
}
|
|
2481
|
+
errors++;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
if (data.exchange_token !== void 0) {
|
|
2485
|
+
let data1 = data.exchange_token;
|
|
2486
|
+
if (typeof data1 !== "string" && data1 !== null) {
|
|
2487
|
+
const err4 = { instancePath: instancePath + "/exchange_token", schemaPath: "#/properties/exchange_token/type", keyword: "type", params: { type: schema31.properties.exchange_token.type }, message: "must be string,null" };
|
|
2488
|
+
if (vErrors === null) {
|
|
2489
|
+
vErrors = [err4];
|
|
2490
|
+
} else {
|
|
2491
|
+
vErrors.push(err4);
|
|
2492
|
+
}
|
|
2493
|
+
errors++;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
if (data.completed_at !== void 0) {
|
|
2497
|
+
let data2 = data.completed_at;
|
|
2498
|
+
if (typeof data2 === "string") {
|
|
2499
|
+
if (!formats05.validate(data2)) {
|
|
2500
|
+
const err5 = { instancePath: instancePath + "/completed_at", schemaPath: "#/properties/completed_at/format", keyword: "format", params: { format: "date-time" }, message: 'must match format "date-time"' };
|
|
2501
|
+
if (vErrors === null) {
|
|
2502
|
+
vErrors = [err5];
|
|
2503
|
+
} else {
|
|
2504
|
+
vErrors.push(err5);
|
|
2505
|
+
}
|
|
2506
|
+
errors++;
|
|
2507
|
+
}
|
|
2508
|
+
} else {
|
|
2509
|
+
const err6 = { instancePath: instancePath + "/completed_at", schemaPath: "#/properties/completed_at/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2510
|
+
if (vErrors === null) {
|
|
2511
|
+
vErrors = [err6];
|
|
2512
|
+
} else {
|
|
2513
|
+
vErrors.push(err6);
|
|
2514
|
+
}
|
|
2515
|
+
errors++;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
} else {
|
|
2519
|
+
const err7 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2520
|
+
if (vErrors === null) {
|
|
2521
|
+
vErrors = [err7];
|
|
2522
|
+
} else {
|
|
2523
|
+
vErrors.push(err7);
|
|
2524
|
+
}
|
|
2525
|
+
errors++;
|
|
2526
|
+
}
|
|
2527
|
+
validate20.errors = vErrors;
|
|
2528
|
+
return errors === 0;
|
|
2529
|
+
}
|
|
2530
|
+
validate20.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
2531
|
+
|
|
2532
|
+
// src/generated/postmessage-v2/approval/error.js
|
|
2533
|
+
var error_default2 = validate22;
|
|
2534
|
+
var schema33 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/approval/error.json", "title": "approval ERROR payload", "type": "object", "additionalProperties": true, "required": ["code", "message", "fatal"], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "fatal": { "type": "boolean" }, "recoverable_via": { "type": ["string", "null"], "enum": ["reload", "new_session", null] } } };
|
|
2535
|
+
function validate22(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
2536
|
+
;
|
|
2537
|
+
let vErrors = null;
|
|
2538
|
+
let errors = 0;
|
|
2539
|
+
const evaluated0 = validate22.evaluated;
|
|
2540
|
+
if (evaluated0.dynamicProps) {
|
|
2541
|
+
evaluated0.props = void 0;
|
|
2542
|
+
}
|
|
2543
|
+
if (evaluated0.dynamicItems) {
|
|
2544
|
+
evaluated0.items = void 0;
|
|
2545
|
+
}
|
|
2546
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2547
|
+
if (data.code === void 0) {
|
|
2548
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "code" }, message: "must have required property 'code'" };
|
|
2549
|
+
if (vErrors === null) {
|
|
2550
|
+
vErrors = [err0];
|
|
2551
|
+
} else {
|
|
2552
|
+
vErrors.push(err0);
|
|
2553
|
+
}
|
|
2554
|
+
errors++;
|
|
2555
|
+
}
|
|
2556
|
+
if (data.message === void 0) {
|
|
2557
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "message" }, message: "must have required property 'message'" };
|
|
2558
|
+
if (vErrors === null) {
|
|
2559
|
+
vErrors = [err1];
|
|
2560
|
+
} else {
|
|
2561
|
+
vErrors.push(err1);
|
|
2562
|
+
}
|
|
2563
|
+
errors++;
|
|
2564
|
+
}
|
|
2565
|
+
if (data.fatal === void 0) {
|
|
2566
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "fatal" }, message: "must have required property 'fatal'" };
|
|
2567
|
+
if (vErrors === null) {
|
|
2568
|
+
vErrors = [err2];
|
|
2569
|
+
} else {
|
|
2570
|
+
vErrors.push(err2);
|
|
2571
|
+
}
|
|
2572
|
+
errors++;
|
|
2573
|
+
}
|
|
2574
|
+
if (data.code !== void 0) {
|
|
2575
|
+
if (typeof data.code !== "string") {
|
|
2576
|
+
const err3 = { instancePath: instancePath + "/code", schemaPath: "#/properties/code/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2577
|
+
if (vErrors === null) {
|
|
2578
|
+
vErrors = [err3];
|
|
2579
|
+
} else {
|
|
2580
|
+
vErrors.push(err3);
|
|
2581
|
+
}
|
|
2582
|
+
errors++;
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
if (data.message !== void 0) {
|
|
2586
|
+
if (typeof data.message !== "string") {
|
|
2587
|
+
const err4 = { instancePath: instancePath + "/message", schemaPath: "#/properties/message/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2588
|
+
if (vErrors === null) {
|
|
2589
|
+
vErrors = [err4];
|
|
2590
|
+
} else {
|
|
2591
|
+
vErrors.push(err4);
|
|
2592
|
+
}
|
|
2593
|
+
errors++;
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
if (data.fatal !== void 0) {
|
|
2597
|
+
if (typeof data.fatal !== "boolean") {
|
|
2598
|
+
const err5 = { instancePath: instancePath + "/fatal", schemaPath: "#/properties/fatal/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" };
|
|
2599
|
+
if (vErrors === null) {
|
|
2600
|
+
vErrors = [err5];
|
|
2601
|
+
} else {
|
|
2602
|
+
vErrors.push(err5);
|
|
2603
|
+
}
|
|
2604
|
+
errors++;
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
if (data.recoverable_via !== void 0) {
|
|
2608
|
+
let data3 = data.recoverable_via;
|
|
2609
|
+
if (typeof data3 !== "string" && data3 !== null) {
|
|
2610
|
+
const err6 = { instancePath: instancePath + "/recoverable_via", schemaPath: "#/properties/recoverable_via/type", keyword: "type", params: { type: schema33.properties.recoverable_via.type }, message: "must be string,null" };
|
|
2611
|
+
if (vErrors === null) {
|
|
2612
|
+
vErrors = [err6];
|
|
2613
|
+
} else {
|
|
2614
|
+
vErrors.push(err6);
|
|
2615
|
+
}
|
|
2616
|
+
errors++;
|
|
2617
|
+
}
|
|
2618
|
+
if (!(data3 === "reload" || data3 === "new_session" || data3 === null)) {
|
|
2619
|
+
const err7 = { instancePath: instancePath + "/recoverable_via", schemaPath: "#/properties/recoverable_via/enum", keyword: "enum", params: { allowedValues: schema33.properties.recoverable_via.enum }, message: "must be equal to one of the allowed values" };
|
|
2620
|
+
if (vErrors === null) {
|
|
2621
|
+
vErrors = [err7];
|
|
2622
|
+
} else {
|
|
2623
|
+
vErrors.push(err7);
|
|
2624
|
+
}
|
|
2625
|
+
errors++;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
} else {
|
|
2629
|
+
const err8 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2630
|
+
if (vErrors === null) {
|
|
2631
|
+
vErrors = [err8];
|
|
2632
|
+
} else {
|
|
2633
|
+
vErrors.push(err8);
|
|
2634
|
+
}
|
|
2635
|
+
errors++;
|
|
2636
|
+
}
|
|
2637
|
+
validate22.errors = vErrors;
|
|
2638
|
+
return errors === 0;
|
|
2639
|
+
}
|
|
2640
|
+
validate22.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
2641
|
+
|
|
2642
|
+
// src/generated/postmessage-v2/approval/deadline.js
|
|
2643
|
+
var deadline_default2 = validate21;
|
|
2644
|
+
var schema32 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/approval/deadline.json", "title": "approval DEADLINE payload", "type": "object", "additionalProperties": true, "required": ["remaining_seconds", "level", "deadline_at"], "properties": { "remaining_seconds": { "type": "integer", "minimum": 0 }, "level": { "type": "string", "enum": ["warning", "expired"] }, "deadline_at": { "type": "string", "format": "date-time" } } };
|
|
2645
|
+
var formats06 = require_formats().fullFormats["date-time"];
|
|
2646
|
+
function validate21(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
2647
|
+
;
|
|
2648
|
+
let vErrors = null;
|
|
2649
|
+
let errors = 0;
|
|
2650
|
+
const evaluated0 = validate21.evaluated;
|
|
2651
|
+
if (evaluated0.dynamicProps) {
|
|
2652
|
+
evaluated0.props = void 0;
|
|
2653
|
+
}
|
|
2654
|
+
if (evaluated0.dynamicItems) {
|
|
2655
|
+
evaluated0.items = void 0;
|
|
2656
|
+
}
|
|
2657
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2658
|
+
if (data.remaining_seconds === void 0) {
|
|
2659
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "remaining_seconds" }, message: "must have required property 'remaining_seconds'" };
|
|
2660
|
+
if (vErrors === null) {
|
|
2661
|
+
vErrors = [err0];
|
|
2662
|
+
} else {
|
|
2663
|
+
vErrors.push(err0);
|
|
2664
|
+
}
|
|
2665
|
+
errors++;
|
|
2666
|
+
}
|
|
2667
|
+
if (data.level === void 0) {
|
|
2668
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "level" }, message: "must have required property 'level'" };
|
|
2669
|
+
if (vErrors === null) {
|
|
2670
|
+
vErrors = [err1];
|
|
2671
|
+
} else {
|
|
2672
|
+
vErrors.push(err1);
|
|
2673
|
+
}
|
|
2674
|
+
errors++;
|
|
2675
|
+
}
|
|
2676
|
+
if (data.deadline_at === void 0) {
|
|
2677
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "deadline_at" }, message: "must have required property 'deadline_at'" };
|
|
2678
|
+
if (vErrors === null) {
|
|
2679
|
+
vErrors = [err2];
|
|
2680
|
+
} else {
|
|
2681
|
+
vErrors.push(err2);
|
|
2682
|
+
}
|
|
2683
|
+
errors++;
|
|
2684
|
+
}
|
|
2685
|
+
if (data.remaining_seconds !== void 0) {
|
|
2686
|
+
let data0 = data.remaining_seconds;
|
|
2687
|
+
if (!(typeof data0 == "number" && (!(data0 % 1) && !isNaN(data0)))) {
|
|
2688
|
+
const err3 = { instancePath: instancePath + "/remaining_seconds", schemaPath: "#/properties/remaining_seconds/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
2689
|
+
if (vErrors === null) {
|
|
2690
|
+
vErrors = [err3];
|
|
2691
|
+
} else {
|
|
2692
|
+
vErrors.push(err3);
|
|
2693
|
+
}
|
|
2694
|
+
errors++;
|
|
2695
|
+
}
|
|
2696
|
+
if (typeof data0 == "number") {
|
|
2697
|
+
if (data0 < 0 || isNaN(data0)) {
|
|
2698
|
+
const err4 = { instancePath: instancePath + "/remaining_seconds", schemaPath: "#/properties/remaining_seconds/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
|
|
2699
|
+
if (vErrors === null) {
|
|
2700
|
+
vErrors = [err4];
|
|
2701
|
+
} else {
|
|
2702
|
+
vErrors.push(err4);
|
|
2703
|
+
}
|
|
2704
|
+
errors++;
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
if (data.level !== void 0) {
|
|
2709
|
+
let data1 = data.level;
|
|
2710
|
+
if (typeof data1 !== "string") {
|
|
2711
|
+
const err5 = { instancePath: instancePath + "/level", schemaPath: "#/properties/level/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2712
|
+
if (vErrors === null) {
|
|
2713
|
+
vErrors = [err5];
|
|
2714
|
+
} else {
|
|
2715
|
+
vErrors.push(err5);
|
|
2716
|
+
}
|
|
2717
|
+
errors++;
|
|
2718
|
+
}
|
|
2719
|
+
if (!(data1 === "warning" || data1 === "expired")) {
|
|
2720
|
+
const err6 = { instancePath: instancePath + "/level", schemaPath: "#/properties/level/enum", keyword: "enum", params: { allowedValues: schema32.properties.level.enum }, message: "must be equal to one of the allowed values" };
|
|
2721
|
+
if (vErrors === null) {
|
|
2722
|
+
vErrors = [err6];
|
|
2723
|
+
} else {
|
|
2724
|
+
vErrors.push(err6);
|
|
2725
|
+
}
|
|
2726
|
+
errors++;
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
if (data.deadline_at !== void 0) {
|
|
2730
|
+
let data2 = data.deadline_at;
|
|
2731
|
+
if (typeof data2 === "string") {
|
|
2732
|
+
if (!formats06.validate(data2)) {
|
|
2733
|
+
const err7 = { instancePath: instancePath + "/deadline_at", schemaPath: "#/properties/deadline_at/format", keyword: "format", params: { format: "date-time" }, message: 'must match format "date-time"' };
|
|
2734
|
+
if (vErrors === null) {
|
|
2735
|
+
vErrors = [err7];
|
|
2736
|
+
} else {
|
|
2737
|
+
vErrors.push(err7);
|
|
2738
|
+
}
|
|
2739
|
+
errors++;
|
|
2740
|
+
}
|
|
2741
|
+
} else {
|
|
2742
|
+
const err8 = { instancePath: instancePath + "/deadline_at", schemaPath: "#/properties/deadline_at/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2743
|
+
if (vErrors === null) {
|
|
2744
|
+
vErrors = [err8];
|
|
2745
|
+
} else {
|
|
2746
|
+
vErrors.push(err8);
|
|
2747
|
+
}
|
|
2748
|
+
errors++;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
} else {
|
|
2752
|
+
const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2753
|
+
if (vErrors === null) {
|
|
2754
|
+
vErrors = [err9];
|
|
2755
|
+
} else {
|
|
2756
|
+
vErrors.push(err9);
|
|
2757
|
+
}
|
|
2758
|
+
errors++;
|
|
2759
|
+
}
|
|
2760
|
+
validate21.errors = vErrors;
|
|
2761
|
+
return errors === 0;
|
|
2762
|
+
}
|
|
2763
|
+
validate21.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
2764
|
+
|
|
2765
|
+
// src/generated/postmessage-v2/signature/state.js
|
|
2766
|
+
var state_default3 = validate35;
|
|
2767
|
+
var schema46 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/signature/state.json", "title": "signature STATE payload", "type": "object", "additionalProperties": true, "required": ["from", "to", "kind_payload"], "properties": { "from": { "type": ["string", "null"] }, "to": { "type": "string", "enum": ["pending", "opened", "in_progress", "signed", "declined", "expired"] }, "kind_payload": { "type": "object", "additionalProperties": true, "required": ["required_assurance_level"], "properties": { "required_assurance_level": { "type": "string", "enum": ["integrity_proof", "advanced", "qualified"] }, "participant_role": { "type": ["string", "null"] } } } } };
|
|
2768
|
+
function validate35(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
2769
|
+
;
|
|
2770
|
+
let vErrors = null;
|
|
2771
|
+
let errors = 0;
|
|
2772
|
+
const evaluated0 = validate35.evaluated;
|
|
2773
|
+
if (evaluated0.dynamicProps) {
|
|
2774
|
+
evaluated0.props = void 0;
|
|
2775
|
+
}
|
|
2776
|
+
if (evaluated0.dynamicItems) {
|
|
2777
|
+
evaluated0.items = void 0;
|
|
2778
|
+
}
|
|
2779
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2780
|
+
if (data.from === void 0) {
|
|
2781
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
|
|
2782
|
+
if (vErrors === null) {
|
|
2783
|
+
vErrors = [err0];
|
|
2784
|
+
} else {
|
|
2785
|
+
vErrors.push(err0);
|
|
2786
|
+
}
|
|
2787
|
+
errors++;
|
|
2788
|
+
}
|
|
2789
|
+
if (data.to === void 0) {
|
|
2790
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "to" }, message: "must have required property 'to'" };
|
|
2791
|
+
if (vErrors === null) {
|
|
2792
|
+
vErrors = [err1];
|
|
2793
|
+
} else {
|
|
2794
|
+
vErrors.push(err1);
|
|
2795
|
+
}
|
|
2796
|
+
errors++;
|
|
2797
|
+
}
|
|
2798
|
+
if (data.kind_payload === void 0) {
|
|
2799
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind_payload" }, message: "must have required property 'kind_payload'" };
|
|
2800
|
+
if (vErrors === null) {
|
|
2801
|
+
vErrors = [err2];
|
|
2802
|
+
} else {
|
|
2803
|
+
vErrors.push(err2);
|
|
2804
|
+
}
|
|
2805
|
+
errors++;
|
|
2806
|
+
}
|
|
2807
|
+
if (data.from !== void 0) {
|
|
2808
|
+
let data0 = data.from;
|
|
2809
|
+
if (typeof data0 !== "string" && data0 !== null) {
|
|
2810
|
+
const err3 = { instancePath: instancePath + "/from", schemaPath: "#/properties/from/type", keyword: "type", params: { type: schema46.properties.from.type }, message: "must be string,null" };
|
|
2811
|
+
if (vErrors === null) {
|
|
2812
|
+
vErrors = [err3];
|
|
2813
|
+
} else {
|
|
2814
|
+
vErrors.push(err3);
|
|
2815
|
+
}
|
|
2816
|
+
errors++;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
if (data.to !== void 0) {
|
|
2820
|
+
let data1 = data.to;
|
|
2821
|
+
if (typeof data1 !== "string") {
|
|
2822
|
+
const err4 = { instancePath: instancePath + "/to", schemaPath: "#/properties/to/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2823
|
+
if (vErrors === null) {
|
|
2824
|
+
vErrors = [err4];
|
|
2825
|
+
} else {
|
|
2826
|
+
vErrors.push(err4);
|
|
2827
|
+
}
|
|
2828
|
+
errors++;
|
|
2829
|
+
}
|
|
2830
|
+
if (!(data1 === "pending" || data1 === "opened" || data1 === "in_progress" || data1 === "signed" || data1 === "declined" || data1 === "expired")) {
|
|
2831
|
+
const err5 = { instancePath: instancePath + "/to", schemaPath: "#/properties/to/enum", keyword: "enum", params: { allowedValues: schema46.properties.to.enum }, message: "must be equal to one of the allowed values" };
|
|
2832
|
+
if (vErrors === null) {
|
|
2833
|
+
vErrors = [err5];
|
|
2834
|
+
} else {
|
|
2835
|
+
vErrors.push(err5);
|
|
2836
|
+
}
|
|
2837
|
+
errors++;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
if (data.kind_payload !== void 0) {
|
|
2841
|
+
let data2 = data.kind_payload;
|
|
2842
|
+
if (data2 && typeof data2 == "object" && !Array.isArray(data2)) {
|
|
2843
|
+
if (data2.required_assurance_level === void 0) {
|
|
2844
|
+
const err6 = { instancePath: instancePath + "/kind_payload", schemaPath: "#/properties/kind_payload/required", keyword: "required", params: { missingProperty: "required_assurance_level" }, message: "must have required property 'required_assurance_level'" };
|
|
2845
|
+
if (vErrors === null) {
|
|
2846
|
+
vErrors = [err6];
|
|
2847
|
+
} else {
|
|
2848
|
+
vErrors.push(err6);
|
|
2849
|
+
}
|
|
2850
|
+
errors++;
|
|
2851
|
+
}
|
|
2852
|
+
if (data2.required_assurance_level !== void 0) {
|
|
2853
|
+
let data3 = data2.required_assurance_level;
|
|
2854
|
+
if (typeof data3 !== "string") {
|
|
2855
|
+
const err7 = { instancePath: instancePath + "/kind_payload/required_assurance_level", schemaPath: "#/properties/kind_payload/properties/required_assurance_level/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2856
|
+
if (vErrors === null) {
|
|
2857
|
+
vErrors = [err7];
|
|
2858
|
+
} else {
|
|
2859
|
+
vErrors.push(err7);
|
|
2860
|
+
}
|
|
2861
|
+
errors++;
|
|
2862
|
+
}
|
|
2863
|
+
if (!(data3 === "integrity_proof" || data3 === "advanced" || data3 === "qualified")) {
|
|
2864
|
+
const err8 = { instancePath: instancePath + "/kind_payload/required_assurance_level", schemaPath: "#/properties/kind_payload/properties/required_assurance_level/enum", keyword: "enum", params: { allowedValues: schema46.properties.kind_payload.properties.required_assurance_level.enum }, message: "must be equal to one of the allowed values" };
|
|
2865
|
+
if (vErrors === null) {
|
|
2866
|
+
vErrors = [err8];
|
|
2867
|
+
} else {
|
|
2868
|
+
vErrors.push(err8);
|
|
2869
|
+
}
|
|
2870
|
+
errors++;
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
if (data2.participant_role !== void 0) {
|
|
2874
|
+
let data4 = data2.participant_role;
|
|
2875
|
+
if (typeof data4 !== "string" && data4 !== null) {
|
|
2876
|
+
const err9 = { instancePath: instancePath + "/kind_payload/participant_role", schemaPath: "#/properties/kind_payload/properties/participant_role/type", keyword: "type", params: { type: schema46.properties.kind_payload.properties.participant_role.type }, message: "must be string,null" };
|
|
2877
|
+
if (vErrors === null) {
|
|
2878
|
+
vErrors = [err9];
|
|
2879
|
+
} else {
|
|
2880
|
+
vErrors.push(err9);
|
|
2881
|
+
}
|
|
2882
|
+
errors++;
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
} else {
|
|
2886
|
+
const err10 = { instancePath: instancePath + "/kind_payload", schemaPath: "#/properties/kind_payload/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2887
|
+
if (vErrors === null) {
|
|
2888
|
+
vErrors = [err10];
|
|
2889
|
+
} else {
|
|
2890
|
+
vErrors.push(err10);
|
|
2891
|
+
}
|
|
2892
|
+
errors++;
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
} else {
|
|
2896
|
+
const err11 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2897
|
+
if (vErrors === null) {
|
|
2898
|
+
vErrors = [err11];
|
|
2899
|
+
} else {
|
|
2900
|
+
vErrors.push(err11);
|
|
2901
|
+
}
|
|
2902
|
+
errors++;
|
|
2903
|
+
}
|
|
2904
|
+
validate35.errors = vErrors;
|
|
2905
|
+
return errors === 0;
|
|
2906
|
+
}
|
|
2907
|
+
validate35.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
2908
|
+
|
|
2909
|
+
// src/generated/postmessage-v2/signature/complete.js
|
|
2910
|
+
var complete_default3 = validate32;
|
|
2911
|
+
var schema43 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/signature/complete.json", "title": "signature COMPLETE payload", "type": "object", "additionalProperties": true, "required": ["outcome", "completed_at"], "properties": { "outcome": { "type": "string", "enum": ["signed", "declined", "countered"] }, "assurance_level": { "type": ["string", "null"], "enum": ["integrity_proof", "advanced", "qualified", null], "description": "The signature assurance level recorded on the agreement." }, "completed_at": { "type": "string", "format": "date-time" } } };
|
|
2912
|
+
var formats07 = require_formats().fullFormats["date-time"];
|
|
2913
|
+
function validate32(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
2914
|
+
;
|
|
2915
|
+
let vErrors = null;
|
|
2916
|
+
let errors = 0;
|
|
2917
|
+
const evaluated0 = validate32.evaluated;
|
|
2918
|
+
if (evaluated0.dynamicProps) {
|
|
2919
|
+
evaluated0.props = void 0;
|
|
2920
|
+
}
|
|
2921
|
+
if (evaluated0.dynamicItems) {
|
|
2922
|
+
evaluated0.items = void 0;
|
|
2923
|
+
}
|
|
2924
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2925
|
+
if (data.outcome === void 0) {
|
|
2926
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "outcome" }, message: "must have required property 'outcome'" };
|
|
2927
|
+
if (vErrors === null) {
|
|
2928
|
+
vErrors = [err0];
|
|
2929
|
+
} else {
|
|
2930
|
+
vErrors.push(err0);
|
|
2931
|
+
}
|
|
2932
|
+
errors++;
|
|
2933
|
+
}
|
|
2934
|
+
if (data.completed_at === void 0) {
|
|
2935
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "completed_at" }, message: "must have required property 'completed_at'" };
|
|
2936
|
+
if (vErrors === null) {
|
|
2937
|
+
vErrors = [err1];
|
|
2938
|
+
} else {
|
|
2939
|
+
vErrors.push(err1);
|
|
2940
|
+
}
|
|
2941
|
+
errors++;
|
|
2942
|
+
}
|
|
2943
|
+
if (data.outcome !== void 0) {
|
|
2944
|
+
let data0 = data.outcome;
|
|
2945
|
+
if (typeof data0 !== "string") {
|
|
2946
|
+
const err2 = { instancePath: instancePath + "/outcome", schemaPath: "#/properties/outcome/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2947
|
+
if (vErrors === null) {
|
|
2948
|
+
vErrors = [err2];
|
|
2949
|
+
} else {
|
|
2950
|
+
vErrors.push(err2);
|
|
2951
|
+
}
|
|
2952
|
+
errors++;
|
|
2953
|
+
}
|
|
2954
|
+
if (!(data0 === "signed" || data0 === "declined" || data0 === "countered")) {
|
|
2955
|
+
const err3 = { instancePath: instancePath + "/outcome", schemaPath: "#/properties/outcome/enum", keyword: "enum", params: { allowedValues: schema43.properties.outcome.enum }, message: "must be equal to one of the allowed values" };
|
|
2956
|
+
if (vErrors === null) {
|
|
2957
|
+
vErrors = [err3];
|
|
2958
|
+
} else {
|
|
2959
|
+
vErrors.push(err3);
|
|
2960
|
+
}
|
|
2961
|
+
errors++;
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
if (data.assurance_level !== void 0) {
|
|
2965
|
+
let data1 = data.assurance_level;
|
|
2966
|
+
if (typeof data1 !== "string" && data1 !== null) {
|
|
2967
|
+
const err4 = { instancePath: instancePath + "/assurance_level", schemaPath: "#/properties/assurance_level/type", keyword: "type", params: { type: schema43.properties.assurance_level.type }, message: "must be string,null" };
|
|
2968
|
+
if (vErrors === null) {
|
|
2969
|
+
vErrors = [err4];
|
|
2970
|
+
} else {
|
|
2971
|
+
vErrors.push(err4);
|
|
2972
|
+
}
|
|
2973
|
+
errors++;
|
|
2974
|
+
}
|
|
2975
|
+
if (!(data1 === "integrity_proof" || data1 === "advanced" || data1 === "qualified" || data1 === null)) {
|
|
2976
|
+
const err5 = { instancePath: instancePath + "/assurance_level", schemaPath: "#/properties/assurance_level/enum", keyword: "enum", params: { allowedValues: schema43.properties.assurance_level.enum }, message: "must be equal to one of the allowed values" };
|
|
2977
|
+
if (vErrors === null) {
|
|
2978
|
+
vErrors = [err5];
|
|
2979
|
+
} else {
|
|
2980
|
+
vErrors.push(err5);
|
|
2981
|
+
}
|
|
2982
|
+
errors++;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
if (data.completed_at !== void 0) {
|
|
2986
|
+
let data2 = data.completed_at;
|
|
2987
|
+
if (typeof data2 === "string") {
|
|
2988
|
+
if (!formats07.validate(data2)) {
|
|
2989
|
+
const err6 = { instancePath: instancePath + "/completed_at", schemaPath: "#/properties/completed_at/format", keyword: "format", params: { format: "date-time" }, message: 'must match format "date-time"' };
|
|
2990
|
+
if (vErrors === null) {
|
|
2991
|
+
vErrors = [err6];
|
|
2992
|
+
} else {
|
|
2993
|
+
vErrors.push(err6);
|
|
2994
|
+
}
|
|
2995
|
+
errors++;
|
|
2996
|
+
}
|
|
2997
|
+
} else {
|
|
2998
|
+
const err7 = { instancePath: instancePath + "/completed_at", schemaPath: "#/properties/completed_at/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2999
|
+
if (vErrors === null) {
|
|
3000
|
+
vErrors = [err7];
|
|
3001
|
+
} else {
|
|
3002
|
+
vErrors.push(err7);
|
|
3003
|
+
}
|
|
3004
|
+
errors++;
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
} else {
|
|
3008
|
+
const err8 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
3009
|
+
if (vErrors === null) {
|
|
3010
|
+
vErrors = [err8];
|
|
3011
|
+
} else {
|
|
3012
|
+
vErrors.push(err8);
|
|
3013
|
+
}
|
|
3014
|
+
errors++;
|
|
3015
|
+
}
|
|
3016
|
+
validate32.errors = vErrors;
|
|
3017
|
+
return errors === 0;
|
|
3018
|
+
}
|
|
3019
|
+
validate32.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
3020
|
+
|
|
3021
|
+
// src/generated/postmessage-v2/signature/error.js
|
|
3022
|
+
var error_default3 = validate34;
|
|
3023
|
+
var schema45 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/signature/error.json", "title": "signature ERROR payload", "type": "object", "additionalProperties": true, "required": ["code", "message", "fatal"], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "fatal": { "type": "boolean" }, "recoverable_via": { "type": ["string", "null"], "enum": ["reload", "new_session", null] } } };
|
|
3024
|
+
function validate34(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
3025
|
+
;
|
|
3026
|
+
let vErrors = null;
|
|
3027
|
+
let errors = 0;
|
|
3028
|
+
const evaluated0 = validate34.evaluated;
|
|
3029
|
+
if (evaluated0.dynamicProps) {
|
|
3030
|
+
evaluated0.props = void 0;
|
|
3031
|
+
}
|
|
3032
|
+
if (evaluated0.dynamicItems) {
|
|
3033
|
+
evaluated0.items = void 0;
|
|
3034
|
+
}
|
|
3035
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
3036
|
+
if (data.code === void 0) {
|
|
3037
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "code" }, message: "must have required property 'code'" };
|
|
3038
|
+
if (vErrors === null) {
|
|
3039
|
+
vErrors = [err0];
|
|
3040
|
+
} else {
|
|
3041
|
+
vErrors.push(err0);
|
|
3042
|
+
}
|
|
3043
|
+
errors++;
|
|
3044
|
+
}
|
|
3045
|
+
if (data.message === void 0) {
|
|
3046
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "message" }, message: "must have required property 'message'" };
|
|
3047
|
+
if (vErrors === null) {
|
|
3048
|
+
vErrors = [err1];
|
|
3049
|
+
} else {
|
|
3050
|
+
vErrors.push(err1);
|
|
3051
|
+
}
|
|
3052
|
+
errors++;
|
|
3053
|
+
}
|
|
3054
|
+
if (data.fatal === void 0) {
|
|
3055
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "fatal" }, message: "must have required property 'fatal'" };
|
|
3056
|
+
if (vErrors === null) {
|
|
3057
|
+
vErrors = [err2];
|
|
3058
|
+
} else {
|
|
3059
|
+
vErrors.push(err2);
|
|
3060
|
+
}
|
|
3061
|
+
errors++;
|
|
3062
|
+
}
|
|
3063
|
+
if (data.code !== void 0) {
|
|
3064
|
+
if (typeof data.code !== "string") {
|
|
3065
|
+
const err3 = { instancePath: instancePath + "/code", schemaPath: "#/properties/code/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
3066
|
+
if (vErrors === null) {
|
|
3067
|
+
vErrors = [err3];
|
|
3068
|
+
} else {
|
|
3069
|
+
vErrors.push(err3);
|
|
3070
|
+
}
|
|
3071
|
+
errors++;
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
if (data.message !== void 0) {
|
|
3075
|
+
if (typeof data.message !== "string") {
|
|
3076
|
+
const err4 = { instancePath: instancePath + "/message", schemaPath: "#/properties/message/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
3077
|
+
if (vErrors === null) {
|
|
3078
|
+
vErrors = [err4];
|
|
3079
|
+
} else {
|
|
3080
|
+
vErrors.push(err4);
|
|
3081
|
+
}
|
|
3082
|
+
errors++;
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
if (data.fatal !== void 0) {
|
|
3086
|
+
if (typeof data.fatal !== "boolean") {
|
|
3087
|
+
const err5 = { instancePath: instancePath + "/fatal", schemaPath: "#/properties/fatal/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" };
|
|
3088
|
+
if (vErrors === null) {
|
|
3089
|
+
vErrors = [err5];
|
|
3090
|
+
} else {
|
|
3091
|
+
vErrors.push(err5);
|
|
3092
|
+
}
|
|
3093
|
+
errors++;
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
if (data.recoverable_via !== void 0) {
|
|
3097
|
+
let data3 = data.recoverable_via;
|
|
3098
|
+
if (typeof data3 !== "string" && data3 !== null) {
|
|
3099
|
+
const err6 = { instancePath: instancePath + "/recoverable_via", schemaPath: "#/properties/recoverable_via/type", keyword: "type", params: { type: schema45.properties.recoverable_via.type }, message: "must be string,null" };
|
|
3100
|
+
if (vErrors === null) {
|
|
3101
|
+
vErrors = [err6];
|
|
3102
|
+
} else {
|
|
3103
|
+
vErrors.push(err6);
|
|
3104
|
+
}
|
|
3105
|
+
errors++;
|
|
3106
|
+
}
|
|
3107
|
+
if (!(data3 === "reload" || data3 === "new_session" || data3 === null)) {
|
|
3108
|
+
const err7 = { instancePath: instancePath + "/recoverable_via", schemaPath: "#/properties/recoverable_via/enum", keyword: "enum", params: { allowedValues: schema45.properties.recoverable_via.enum }, message: "must be equal to one of the allowed values" };
|
|
3109
|
+
if (vErrors === null) {
|
|
3110
|
+
vErrors = [err7];
|
|
3111
|
+
} else {
|
|
3112
|
+
vErrors.push(err7);
|
|
3113
|
+
}
|
|
3114
|
+
errors++;
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
} else {
|
|
3118
|
+
const err8 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
3119
|
+
if (vErrors === null) {
|
|
3120
|
+
vErrors = [err8];
|
|
3121
|
+
} else {
|
|
3122
|
+
vErrors.push(err8);
|
|
3123
|
+
}
|
|
3124
|
+
errors++;
|
|
3125
|
+
}
|
|
3126
|
+
validate34.errors = vErrors;
|
|
3127
|
+
return errors === 0;
|
|
3128
|
+
}
|
|
3129
|
+
validate34.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
3130
|
+
|
|
3131
|
+
// src/generated/postmessage-v2/signature/deadline.js
|
|
3132
|
+
var deadline_default3 = validate33;
|
|
3133
|
+
var schema44 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/postmessage-v2/signature/deadline.json", "title": "signature DEADLINE payload", "type": "object", "additionalProperties": true, "required": ["remaining_seconds", "level", "deadline_at"], "properties": { "remaining_seconds": { "type": "integer", "minimum": 0 }, "level": { "type": "string", "enum": ["warning", "expired"] }, "deadline_at": { "type": "string", "format": "date-time" } } };
|
|
3134
|
+
var formats08 = require_formats().fullFormats["date-time"];
|
|
3135
|
+
function validate33(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
3136
|
+
;
|
|
3137
|
+
let vErrors = null;
|
|
3138
|
+
let errors = 0;
|
|
3139
|
+
const evaluated0 = validate33.evaluated;
|
|
3140
|
+
if (evaluated0.dynamicProps) {
|
|
3141
|
+
evaluated0.props = void 0;
|
|
3142
|
+
}
|
|
3143
|
+
if (evaluated0.dynamicItems) {
|
|
3144
|
+
evaluated0.items = void 0;
|
|
3145
|
+
}
|
|
3146
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
3147
|
+
if (data.remaining_seconds === void 0) {
|
|
3148
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "remaining_seconds" }, message: "must have required property 'remaining_seconds'" };
|
|
3149
|
+
if (vErrors === null) {
|
|
3150
|
+
vErrors = [err0];
|
|
3151
|
+
} else {
|
|
3152
|
+
vErrors.push(err0);
|
|
3153
|
+
}
|
|
3154
|
+
errors++;
|
|
3155
|
+
}
|
|
3156
|
+
if (data.level === void 0) {
|
|
3157
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "level" }, message: "must have required property 'level'" };
|
|
3158
|
+
if (vErrors === null) {
|
|
3159
|
+
vErrors = [err1];
|
|
3160
|
+
} else {
|
|
3161
|
+
vErrors.push(err1);
|
|
3162
|
+
}
|
|
3163
|
+
errors++;
|
|
3164
|
+
}
|
|
3165
|
+
if (data.deadline_at === void 0) {
|
|
3166
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "deadline_at" }, message: "must have required property 'deadline_at'" };
|
|
3167
|
+
if (vErrors === null) {
|
|
3168
|
+
vErrors = [err2];
|
|
3169
|
+
} else {
|
|
3170
|
+
vErrors.push(err2);
|
|
3171
|
+
}
|
|
3172
|
+
errors++;
|
|
3173
|
+
}
|
|
3174
|
+
if (data.remaining_seconds !== void 0) {
|
|
3175
|
+
let data0 = data.remaining_seconds;
|
|
3176
|
+
if (!(typeof data0 == "number" && (!(data0 % 1) && !isNaN(data0)))) {
|
|
3177
|
+
const err3 = { instancePath: instancePath + "/remaining_seconds", schemaPath: "#/properties/remaining_seconds/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
3178
|
+
if (vErrors === null) {
|
|
3179
|
+
vErrors = [err3];
|
|
3180
|
+
} else {
|
|
3181
|
+
vErrors.push(err3);
|
|
3182
|
+
}
|
|
3183
|
+
errors++;
|
|
3184
|
+
}
|
|
3185
|
+
if (typeof data0 == "number") {
|
|
3186
|
+
if (data0 < 0 || isNaN(data0)) {
|
|
3187
|
+
const err4 = { instancePath: instancePath + "/remaining_seconds", schemaPath: "#/properties/remaining_seconds/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
|
|
3188
|
+
if (vErrors === null) {
|
|
3189
|
+
vErrors = [err4];
|
|
3190
|
+
} else {
|
|
3191
|
+
vErrors.push(err4);
|
|
3192
|
+
}
|
|
3193
|
+
errors++;
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
if (data.level !== void 0) {
|
|
3198
|
+
let data1 = data.level;
|
|
3199
|
+
if (typeof data1 !== "string") {
|
|
3200
|
+
const err5 = { instancePath: instancePath + "/level", schemaPath: "#/properties/level/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
3201
|
+
if (vErrors === null) {
|
|
3202
|
+
vErrors = [err5];
|
|
3203
|
+
} else {
|
|
3204
|
+
vErrors.push(err5);
|
|
3205
|
+
}
|
|
3206
|
+
errors++;
|
|
3207
|
+
}
|
|
3208
|
+
if (!(data1 === "warning" || data1 === "expired")) {
|
|
3209
|
+
const err6 = { instancePath: instancePath + "/level", schemaPath: "#/properties/level/enum", keyword: "enum", params: { allowedValues: schema44.properties.level.enum }, message: "must be equal to one of the allowed values" };
|
|
3210
|
+
if (vErrors === null) {
|
|
3211
|
+
vErrors = [err6];
|
|
3212
|
+
} else {
|
|
3213
|
+
vErrors.push(err6);
|
|
3214
|
+
}
|
|
3215
|
+
errors++;
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
if (data.deadline_at !== void 0) {
|
|
3219
|
+
let data2 = data.deadline_at;
|
|
3220
|
+
if (typeof data2 === "string") {
|
|
3221
|
+
if (!formats08.validate(data2)) {
|
|
3222
|
+
const err7 = { instancePath: instancePath + "/deadline_at", schemaPath: "#/properties/deadline_at/format", keyword: "format", params: { format: "date-time" }, message: 'must match format "date-time"' };
|
|
3223
|
+
if (vErrors === null) {
|
|
3224
|
+
vErrors = [err7];
|
|
3225
|
+
} else {
|
|
3226
|
+
vErrors.push(err7);
|
|
3227
|
+
}
|
|
3228
|
+
errors++;
|
|
3229
|
+
}
|
|
3230
|
+
} else {
|
|
3231
|
+
const err8 = { instancePath: instancePath + "/deadline_at", schemaPath: "#/properties/deadline_at/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
3232
|
+
if (vErrors === null) {
|
|
3233
|
+
vErrors = [err8];
|
|
3234
|
+
} else {
|
|
3235
|
+
vErrors.push(err8);
|
|
3236
|
+
}
|
|
3237
|
+
errors++;
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
} else {
|
|
3241
|
+
const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
3242
|
+
if (vErrors === null) {
|
|
3243
|
+
vErrors = [err9];
|
|
3244
|
+
} else {
|
|
3245
|
+
vErrors.push(err9);
|
|
3246
|
+
}
|
|
3247
|
+
errors++;
|
|
3248
|
+
}
|
|
3249
|
+
validate33.errors = vErrors;
|
|
3250
|
+
return errors === 0;
|
|
3251
|
+
}
|
|
3252
|
+
validate33.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
3253
|
+
|
|
3254
|
+
// src/postmessage_v2.ts
|
|
3255
|
+
var VALIDATORS = {
|
|
3256
|
+
[MESSAGE_TYPES_V2.READY]: { _agnostic: ready_default },
|
|
3257
|
+
[MESSAGE_TYPES_V2.RESIZE]: { _agnostic: resize_default },
|
|
3258
|
+
[MESSAGE_TYPES_V2.CANCEL]: { _agnostic: cancel_default },
|
|
3259
|
+
[MESSAGE_TYPES_V2.STATE]: {
|
|
3260
|
+
consent: state_default,
|
|
3261
|
+
approval: state_default2,
|
|
3262
|
+
signature_request: state_default3
|
|
3263
|
+
},
|
|
3264
|
+
[MESSAGE_TYPES_V2.COMPLETE]: {
|
|
3265
|
+
consent: complete_default,
|
|
3266
|
+
approval: complete_default2,
|
|
3267
|
+
signature_request: complete_default3
|
|
3268
|
+
},
|
|
3269
|
+
[MESSAGE_TYPES_V2.ERROR]: {
|
|
3270
|
+
consent: error_default,
|
|
3271
|
+
approval: error_default2,
|
|
3272
|
+
signature_request: error_default3
|
|
3273
|
+
},
|
|
3274
|
+
[MESSAGE_TYPES_V2.DEADLINE]: {
|
|
3275
|
+
consent: deadline_default,
|
|
3276
|
+
approval: deadline_default2,
|
|
3277
|
+
signature_request: deadline_default3
|
|
3278
|
+
}
|
|
3279
|
+
};
|
|
3280
|
+
var envelopeFn = envelope_default;
|
|
3281
|
+
function validateEnvelope(message) {
|
|
3282
|
+
const valid = envelopeFn(message);
|
|
3283
|
+
return { valid, errors: valid ? null : envelopeFn.errors ?? null };
|
|
3284
|
+
}
|
|
3285
|
+
function validatePayload(message) {
|
|
3286
|
+
const typeMap = VALIDATORS[message.type];
|
|
3287
|
+
if (!typeMap) {
|
|
3288
|
+
return { valid: false, errors: [{ message: `Unknown type ${message.type}` }] };
|
|
3289
|
+
}
|
|
3290
|
+
const validator = typeMap._agnostic ?? typeMap[message.kind];
|
|
3291
|
+
if (!validator) {
|
|
3292
|
+
return {
|
|
3293
|
+
valid: false,
|
|
3294
|
+
errors: [{ message: `No validator for ${message.type}/${message.kind}` }]
|
|
3295
|
+
};
|
|
3296
|
+
}
|
|
3297
|
+
const valid = validator(message.payload);
|
|
3298
|
+
return { valid, errors: valid ? null : validator.errors ?? null };
|
|
3299
|
+
}
|
|
3300
|
+
function validate(message) {
|
|
3301
|
+
const envelopeResult = validateEnvelope(message);
|
|
3302
|
+
if (!envelopeResult.valid) return envelopeResult;
|
|
3303
|
+
return validatePayload(message);
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
// src/decisions.ts
|
|
3307
|
+
var _api3, _flowBaseUrl, _debug, _liveHandles, _Decisions_instances, dispatch_fn;
|
|
3308
|
+
var Decisions = class {
|
|
3309
|
+
constructor(config) {
|
|
3310
|
+
__privateAdd(this, _Decisions_instances);
|
|
3311
|
+
__privateAdd(this, _api3);
|
|
3312
|
+
__privateAdd(this, _flowBaseUrl);
|
|
3313
|
+
__privateAdd(this, _debug);
|
|
3314
|
+
__privateAdd(this, _liveHandles, /* @__PURE__ */ new Set());
|
|
3315
|
+
__privateSet(this, _api3, config.api);
|
|
3316
|
+
__privateSet(this, _flowBaseUrl, config.flowBaseUrl);
|
|
3317
|
+
__privateSet(this, _debug, config.debug);
|
|
3318
|
+
}
|
|
3319
|
+
/**
|
|
3320
|
+
* Returns the canonical decisions URL for a token. `mode="embed"`
|
|
3321
|
+
* gets the `/embed` suffix; `popup` and `redirect` use the bare
|
|
3322
|
+
* path (the server-rendered page handles both).
|
|
3323
|
+
*/
|
|
3324
|
+
url(opts) {
|
|
3325
|
+
const tail = opts.mode === "embed" ? "/embed" : "";
|
|
3326
|
+
return `${__privateGet(this, _flowBaseUrl)}${DECISIONS_FLOW_PATH}/${opts.token}${tail}`;
|
|
3327
|
+
}
|
|
3328
|
+
/**
|
|
3329
|
+
* Creates a new decisions session via `POST /api/v1/decisions`.
|
|
3330
|
+
* Wraps the legacy v0 API client's snake-case helpers so existing
|
|
3331
|
+
* tests around case conversion keep working.
|
|
3332
|
+
*/
|
|
3333
|
+
async createSession(input) {
|
|
3334
|
+
if (!input.subjectRef) {
|
|
3335
|
+
throw new OverturoValidationError("subjectRef is required");
|
|
3336
|
+
}
|
|
3337
|
+
const embedOrigin = input.embedOrigin ?? (typeof window !== "undefined" ? window.location.origin : void 0);
|
|
3338
|
+
const body = {
|
|
3339
|
+
kind: input.kind,
|
|
3340
|
+
subjectRef: input.subjectRef,
|
|
3341
|
+
deliveryMode: input.mode ?? "embed",
|
|
3342
|
+
embedOrigin,
|
|
3343
|
+
state: input.state,
|
|
3344
|
+
redirectUri: input.redirectUri
|
|
3345
|
+
};
|
|
3346
|
+
if (input.kind === "consent") {
|
|
3347
|
+
body.scope = input.scope;
|
|
3348
|
+
body.nonce = input.nonce;
|
|
3349
|
+
}
|
|
3350
|
+
const envelope = await __privateGet(this, _api3).post(DECISIONS_API_PATH, body);
|
|
3351
|
+
const raw = envelope.decision;
|
|
3352
|
+
if (__privateGet(this, _debug)) {
|
|
3353
|
+
console.debug("[overturo:sdk]", "session_created", {
|
|
3354
|
+
kind: raw.kind,
|
|
3355
|
+
mode: raw.mode
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
return {
|
|
3359
|
+
token: raw.sessionToken,
|
|
3360
|
+
kind: raw.kind,
|
|
3361
|
+
mode: raw.mode,
|
|
3362
|
+
expiresAt: raw.deadlineAt ?? "",
|
|
3363
|
+
embedUrl: raw.embedUrl
|
|
3364
|
+
};
|
|
3365
|
+
}
|
|
3366
|
+
/**
|
|
3367
|
+
* pre-flight disclosure discovery. Fetches what the decision screen
|
|
3368
|
+
* will present for a flow, BEFORE any session exists: purposes, fields,
|
|
3369
|
+
* steps, the action label, expiry, and application branding, in public
|
|
3370
|
+
* vocabulary and the requested locale. The recommended first call in the
|
|
3371
|
+
* embed flow: discover -> createSession -> (SDK reads config).
|
|
3372
|
+
*
|
|
3373
|
+
* Publishable-key authenticated — the ApiClient already sends
|
|
3374
|
+
* `X-Publishable-Key` (api.ts); the server ignores any bearer header on this
|
|
3375
|
+
* endpoint. An unknown / foreign / non-consent flow answers a uniform 404
|
|
3376
|
+
* (OverturoApiError, status 404).
|
|
3377
|
+
*/
|
|
3378
|
+
async discover(opts) {
|
|
3379
|
+
if (!opts.flowId) {
|
|
3380
|
+
throw new OverturoValidationError("flowId is required");
|
|
3381
|
+
}
|
|
3382
|
+
const qs = opts.locale ? `?locale=${encodeURIComponent(opts.locale)}` : "";
|
|
3383
|
+
const envelope = await __privateGet(this, _api3).get(
|
|
3384
|
+
`${DECISIONS_API_PATH}/flows/${encodeURIComponent(opts.flowId)}/disclosures${qs}`
|
|
3385
|
+
);
|
|
3386
|
+
if (!envelope || typeof envelope !== "object" || !("flow" in envelope)) {
|
|
3387
|
+
throw new OverturoApiError("Malformed discovery response: missing 'flow'", 200, envelope);
|
|
3388
|
+
}
|
|
3389
|
+
return envelope.flow;
|
|
3390
|
+
}
|
|
3391
|
+
/**
|
|
3392
|
+
* Mounts the decisions flow inside an iframe under `opts.container`.
|
|
3393
|
+
* Validates inbound v2 envelopes; drops on origin mismatch /
|
|
3394
|
+
* schema-invalid. Returns a handle whose `.destroy()` tears down
|
|
3395
|
+
* the iframe + listener.
|
|
3396
|
+
*/
|
|
3397
|
+
embed(opts) {
|
|
3398
|
+
if (!opts.token) {
|
|
3399
|
+
throw new OverturoValidationError("token is required");
|
|
3400
|
+
}
|
|
3401
|
+
const url = this.url({ token: opts.token, mode: "embed" });
|
|
3402
|
+
const expectedOrigin = new URL(url).origin;
|
|
3403
|
+
const container = resolveContainer(opts.container);
|
|
3404
|
+
container.innerHTML = "";
|
|
3405
|
+
if (opts.loading) {
|
|
3406
|
+
const loadingEl = document.createElement("div");
|
|
3407
|
+
loadingEl.setAttribute("data-overturo-loading", "");
|
|
3408
|
+
if (typeof opts.loading === "string") {
|
|
3409
|
+
loadingEl.innerHTML = opts.loading;
|
|
3410
|
+
} else {
|
|
3411
|
+
loadingEl.appendChild(opts.loading);
|
|
3412
|
+
}
|
|
3413
|
+
container.appendChild(loadingEl);
|
|
3414
|
+
}
|
|
3415
|
+
const iframe = document.createElement("iframe");
|
|
3416
|
+
iframe.src = url;
|
|
3417
|
+
iframe.setAttribute("sandbox", "allow-scripts allow-forms allow-same-origin allow-popups");
|
|
3418
|
+
applyStyle(iframe, { ...EMBED_DEFAULTS }, opts.style);
|
|
3419
|
+
const clearLoading = () => {
|
|
3420
|
+
const loadingChild = container.querySelector("[data-overturo-loading]");
|
|
3421
|
+
if (loadingChild) container.removeChild(loadingChild);
|
|
3422
|
+
};
|
|
3423
|
+
iframe.addEventListener("load", clearLoading);
|
|
3424
|
+
iframe.addEventListener("error", () => {
|
|
3425
|
+
clearLoading();
|
|
3426
|
+
opts.onError?.({
|
|
3427
|
+
code: "iframe_load_failed",
|
|
3428
|
+
message: "The trust-host iframe failed to load."
|
|
3429
|
+
});
|
|
3430
|
+
});
|
|
3431
|
+
const ac = new AbortController();
|
|
3432
|
+
const onMessage = (event) => {
|
|
3433
|
+
if (event.origin !== expectedOrigin || isForeignEnvelope(event.data)) return;
|
|
3434
|
+
const result = validate(event.data);
|
|
3435
|
+
if (!result.valid) {
|
|
3436
|
+
opts.onError?.({
|
|
3437
|
+
code: "protocol_violation",
|
|
3438
|
+
errors: result.errors
|
|
3439
|
+
});
|
|
3440
|
+
if (__privateGet(this, _debug)) {
|
|
3441
|
+
console.debug("[overturo:sdk]", "envelope_dropped", {
|
|
3442
|
+
reason: "schema_invalid"
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
return;
|
|
3446
|
+
}
|
|
3447
|
+
__privateMethod(this, _Decisions_instances, dispatch_fn).call(this, event.data, opts, iframe);
|
|
3448
|
+
};
|
|
3449
|
+
window.addEventListener("message", onMessage, { signal: ac.signal });
|
|
3450
|
+
container.appendChild(iframe);
|
|
3451
|
+
const handle = {
|
|
3452
|
+
token: opts.token,
|
|
3453
|
+
mode: "embed",
|
|
3454
|
+
destroy: async () => {
|
|
3455
|
+
ac.abort();
|
|
3456
|
+
if (iframe.parentNode) iframe.parentNode.removeChild(iframe);
|
|
3457
|
+
__privateGet(this, _liveHandles).delete(handle);
|
|
3458
|
+
if (__privateGet(this, _debug)) {
|
|
3459
|
+
console.debug("[overturo:sdk]", "iframe_destroyed", {});
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
};
|
|
3463
|
+
__privateGet(this, _liveHandles).add(handle);
|
|
3464
|
+
if (__privateGet(this, _debug)) {
|
|
3465
|
+
console.debug("[overturo:sdk]", "iframe_mounted", {
|
|
3466
|
+
sandboxAttr: iframe.getAttribute("sandbox")
|
|
3467
|
+
});
|
|
3468
|
+
}
|
|
3469
|
+
return handle;
|
|
3470
|
+
}
|
|
3471
|
+
/**
|
|
3472
|
+
* Opens the decisions flow in a popup window. Caller MUST invoke this
|
|
3473
|
+
* synchronously from a user-action handler or browsers will block.
|
|
3474
|
+
*/
|
|
3475
|
+
popup(opts) {
|
|
3476
|
+
if (!opts.token) {
|
|
3477
|
+
throw new OverturoValidationError("token is required");
|
|
3478
|
+
}
|
|
3479
|
+
const url = this.url({ token: opts.token, mode: "popup" });
|
|
3480
|
+
const expectedOrigin = new URL(url).origin;
|
|
3481
|
+
const width = opts.width ?? POPUP_DEFAULTS.width;
|
|
3482
|
+
const height = opts.height ?? POPUP_DEFAULTS.height;
|
|
3483
|
+
const left = Math.round((screen.width - width) / 2);
|
|
3484
|
+
const top = Math.round((screen.height - height) / 2);
|
|
3485
|
+
const features = `width=${width},height=${height},left=${left},top=${top},scrollbars=yes,status=yes`;
|
|
3486
|
+
const win = window.open(url, "_blank", features);
|
|
3487
|
+
if (!win) {
|
|
3488
|
+
if (__privateGet(this, _debug)) {
|
|
3489
|
+
console.debug("[overturo:sdk]", "popup_blocked", {});
|
|
3490
|
+
}
|
|
3491
|
+
throw new OverturoError("Popup was blocked by the browser. Allow popups for this site and try again.");
|
|
3492
|
+
}
|
|
3493
|
+
if (__privateGet(this, _debug)) {
|
|
3494
|
+
console.debug("[overturo:sdk]", "popup_opened", { features });
|
|
3495
|
+
}
|
|
3496
|
+
const ac = new AbortController();
|
|
3497
|
+
const onMessage = (event) => {
|
|
3498
|
+
if (event.origin !== expectedOrigin || isForeignEnvelope(event.data)) return;
|
|
3499
|
+
const result = validate(event.data);
|
|
3500
|
+
if (!result.valid) {
|
|
3501
|
+
opts.onError?.({ code: "protocol_violation" });
|
|
3502
|
+
return;
|
|
3503
|
+
}
|
|
3504
|
+
const envelope = event.data;
|
|
3505
|
+
switch (envelope.type) {
|
|
3506
|
+
case MESSAGE_TYPES_V2.COMPLETE:
|
|
3507
|
+
opts.onComplete?.(buildOutcome(envelope.kind, envelope.payload));
|
|
3508
|
+
handle.destroy();
|
|
3509
|
+
break;
|
|
3510
|
+
case MESSAGE_TYPES_V2.CANCEL:
|
|
3511
|
+
opts.onCancel?.(envelope.payload);
|
|
3512
|
+
handle.destroy();
|
|
3513
|
+
break;
|
|
3514
|
+
case MESSAGE_TYPES_V2.ERROR:
|
|
3515
|
+
opts.onError?.(envelope.payload);
|
|
3516
|
+
break;
|
|
3517
|
+
}
|
|
3518
|
+
};
|
|
3519
|
+
window.addEventListener("message", onMessage, { signal: ac.signal });
|
|
3520
|
+
let closeTimer = setInterval(() => {
|
|
3521
|
+
if (win.closed) {
|
|
3522
|
+
if (closeTimer) {
|
|
3523
|
+
clearInterval(closeTimer);
|
|
3524
|
+
closeTimer = null;
|
|
3525
|
+
}
|
|
3526
|
+
opts.onCancel?.({ reason: "user_closed_popup" });
|
|
3527
|
+
handle.destroy();
|
|
3528
|
+
}
|
|
3529
|
+
}, 500);
|
|
3530
|
+
const handle = {
|
|
3531
|
+
token: opts.token,
|
|
3532
|
+
mode: "popup",
|
|
3533
|
+
destroy: async () => {
|
|
3534
|
+
if (closeTimer) {
|
|
3535
|
+
clearInterval(closeTimer);
|
|
3536
|
+
closeTimer = null;
|
|
3537
|
+
}
|
|
3538
|
+
ac.abort();
|
|
3539
|
+
if (win && !win.closed) win.close();
|
|
3540
|
+
__privateGet(this, _liveHandles).delete(handle);
|
|
3541
|
+
}
|
|
3542
|
+
};
|
|
3543
|
+
__privateGet(this, _liveHandles).add(handle);
|
|
3544
|
+
return handle;
|
|
3545
|
+
}
|
|
3546
|
+
/**
|
|
3547
|
+
* Exchanges a completed decision's token for the per-kind receipt.
|
|
3548
|
+
* Server returns a discriminated union; the SDK preserves the
|
|
3549
|
+
* discriminator so consumers using strict TypeScript get narrowing.
|
|
3550
|
+
*/
|
|
3551
|
+
async exchange(input) {
|
|
3552
|
+
if (!input.token || !input.exchangeToken) {
|
|
3553
|
+
throw new OverturoValidationError("token and exchangeToken are required for exchange");
|
|
3554
|
+
}
|
|
3555
|
+
const path = `${DECISIONS_API_PATH}/${input.token}/exchange`;
|
|
3556
|
+
const raw = await __privateGet(this, _api3).post(path, {
|
|
3557
|
+
exchangeToken: input.exchangeToken
|
|
3558
|
+
});
|
|
3559
|
+
return raw;
|
|
3560
|
+
}
|
|
3561
|
+
/**
|
|
3562
|
+
* Asks the server to mark a session as cancelled. Idempotent on
|
|
3563
|
+
* already-terminal sessions.
|
|
3564
|
+
*/
|
|
3565
|
+
async cancel(token) {
|
|
3566
|
+
if (!token) {
|
|
3567
|
+
throw new OverturoValidationError("token is required for cancel");
|
|
3568
|
+
}
|
|
3569
|
+
await __privateGet(this, _api3).post(`${DECISIONS_API_PATH}/${token}/cancel`, {});
|
|
3570
|
+
}
|
|
3571
|
+
/**
|
|
3572
|
+
* Tears down every live handle (embed or popup) this client created.
|
|
3573
|
+
* Called by `Overturo#destroy()`. Errors during destroy are swallowed
|
|
3574
|
+
* — we want best-effort cleanup, not a half-destroyed state.
|
|
3575
|
+
*/
|
|
3576
|
+
async destroyAll() {
|
|
3577
|
+
const handles = [...__privateGet(this, _liveHandles)];
|
|
3578
|
+
await Promise.allSettled(handles.map((h) => h.destroy()));
|
|
3579
|
+
__privateGet(this, _liveHandles).clear();
|
|
3580
|
+
}
|
|
3581
|
+
};
|
|
3582
|
+
_api3 = new WeakMap();
|
|
3583
|
+
_flowBaseUrl = new WeakMap();
|
|
3584
|
+
_debug = new WeakMap();
|
|
3585
|
+
_liveHandles = new WeakMap();
|
|
3586
|
+
_Decisions_instances = new WeakSet();
|
|
3587
|
+
dispatch_fn = function(envelope, opts, iframe) {
|
|
3588
|
+
const isCounterState = envelope.type === MESSAGE_TYPES_V2.STATE && envelope.kind === "approval" && envelope.payload?.phase === "countered";
|
|
3589
|
+
switch (envelope.type) {
|
|
3590
|
+
case MESSAGE_TYPES_V2.READY:
|
|
3591
|
+
opts.onReady?.(envelope.payload);
|
|
3592
|
+
break;
|
|
3593
|
+
case MESSAGE_TYPES_V2.STATE:
|
|
3594
|
+
if (isCounterState) {
|
|
3595
|
+
opts.onCounter?.(envelope.payload);
|
|
3596
|
+
} else {
|
|
3597
|
+
opts.onState?.(envelope.kind, envelope.payload);
|
|
3598
|
+
}
|
|
3599
|
+
break;
|
|
3600
|
+
case MESSAGE_TYPES_V2.RESIZE: {
|
|
3601
|
+
const height = envelope.payload.height;
|
|
3602
|
+
if (typeof height === "number") {
|
|
3603
|
+
iframe.style.height = `${height}px`;
|
|
3604
|
+
opts.onResize?.(height);
|
|
3605
|
+
}
|
|
3606
|
+
break;
|
|
3607
|
+
}
|
|
3608
|
+
case MESSAGE_TYPES_V2.COMPLETE:
|
|
3609
|
+
opts.onComplete?.(buildOutcome(envelope.kind, envelope.payload));
|
|
3610
|
+
break;
|
|
3611
|
+
case MESSAGE_TYPES_V2.CANCEL:
|
|
3612
|
+
opts.onCancel?.(envelope.payload);
|
|
3613
|
+
break;
|
|
3614
|
+
case MESSAGE_TYPES_V2.ERROR:
|
|
3615
|
+
opts.onError?.(envelope.payload);
|
|
3616
|
+
break;
|
|
3617
|
+
case MESSAGE_TYPES_V2.DEADLINE:
|
|
3618
|
+
opts.onDeadline?.(envelope.payload);
|
|
3619
|
+
break;
|
|
3620
|
+
}
|
|
3621
|
+
if (__privateGet(this, _debug)) {
|
|
3622
|
+
console.debug("[overturo:sdk]", "envelope_received", {
|
|
3623
|
+
type: envelope.type,
|
|
3624
|
+
kind: envelope.kind
|
|
3625
|
+
});
|
|
3626
|
+
}
|
|
3627
|
+
};
|
|
3628
|
+
function buildOutcome(kind, payload) {
|
|
3629
|
+
const p = payload ?? {};
|
|
3630
|
+
if (kind === "consent") {
|
|
3631
|
+
return {
|
|
3632
|
+
kind: "consent",
|
|
3633
|
+
result: p.outcome ?? p.result ?? "granted",
|
|
3634
|
+
consentToken: p.exchange_token ?? p.consentToken,
|
|
3635
|
+
purposesGranted: p.purposesGranted,
|
|
3636
|
+
purposesDeclined: p.purposesDeclined
|
|
3637
|
+
};
|
|
3638
|
+
}
|
|
3639
|
+
if (kind === "signature_request") {
|
|
3640
|
+
return {
|
|
3641
|
+
kind: "signature_request",
|
|
3642
|
+
result: p.outcome ?? p.result ?? "signed",
|
|
3643
|
+
assuranceLevel: p.assurance_level ?? p.assuranceLevel,
|
|
3644
|
+
completedAt: p.completed_at ?? p.completedAt
|
|
3645
|
+
};
|
|
3646
|
+
}
|
|
3647
|
+
return {
|
|
3648
|
+
kind: "approval",
|
|
3649
|
+
result: p.outcome ?? p.result ?? "approved",
|
|
3650
|
+
escalationToken: p.exchange_token ?? p.escalationToken,
|
|
3651
|
+
counterProposal: p.counterProposal
|
|
3652
|
+
};
|
|
3653
|
+
}
|
|
3654
|
+
|
|
3655
|
+
// src/embed.ts
|
|
3656
|
+
function createEmbed(baseUrl, options) {
|
|
3657
|
+
const container = resolveContainer(options.container);
|
|
3658
|
+
const expectedOrigin = new URL(baseUrl).origin;
|
|
3659
|
+
const embedUrl = `${baseUrl}/accord/embed/${options.sessionToken}`;
|
|
3660
|
+
container.innerHTML = "";
|
|
3661
|
+
if (options.loading) {
|
|
3662
|
+
const loadingEl = document.createElement("div");
|
|
3663
|
+
loadingEl.setAttribute("data-overturo-loading", "");
|
|
3664
|
+
if (typeof options.loading === "string") {
|
|
3665
|
+
loadingEl.innerHTML = options.loading;
|
|
3666
|
+
} else {
|
|
3667
|
+
loadingEl.appendChild(options.loading);
|
|
3668
|
+
}
|
|
3669
|
+
container.appendChild(loadingEl);
|
|
3670
|
+
}
|
|
3671
|
+
const iframe = document.createElement("iframe");
|
|
3672
|
+
iframe.src = embedUrl;
|
|
3673
|
+
iframe.setAttribute("sandbox", "allow-scripts allow-forms allow-same-origin allow-popups");
|
|
3674
|
+
applyStyle(iframe, { ...EMBED_DEFAULTS }, options.style);
|
|
3675
|
+
iframe.addEventListener("load", () => {
|
|
3676
|
+
const loadingChild = container.querySelector("[data-overturo-loading]");
|
|
3677
|
+
if (loadingChild) container.removeChild(loadingChild);
|
|
3678
|
+
});
|
|
3679
|
+
const ac = new AbortController();
|
|
3680
|
+
function handleMessage(event) {
|
|
3681
|
+
if (event.origin !== expectedOrigin) return;
|
|
3682
|
+
const result = validate(event.data);
|
|
3683
|
+
if (!result.valid) return;
|
|
3684
|
+
const envelope = event.data;
|
|
3685
|
+
switch (envelope.type) {
|
|
3686
|
+
case MESSAGE_TYPES_V2.READY:
|
|
3687
|
+
options.onReady?.(envelope.payload);
|
|
3688
|
+
break;
|
|
3689
|
+
case MESSAGE_TYPES_V2.RESIZE: {
|
|
3690
|
+
const height = envelope.payload.height;
|
|
3691
|
+
if (typeof height === "number") {
|
|
3692
|
+
iframe.style.height = `${height}px`;
|
|
3693
|
+
options.onResize?.(height);
|
|
3694
|
+
}
|
|
3695
|
+
break;
|
|
3696
|
+
}
|
|
3697
|
+
case MESSAGE_TYPES_V2.STATE:
|
|
3698
|
+
options.onState?.(envelope.kind, envelope.payload);
|
|
3699
|
+
break;
|
|
3700
|
+
case MESSAGE_TYPES_V2.DEADLINE:
|
|
3701
|
+
options.onDeadline?.(envelope.payload);
|
|
3702
|
+
break;
|
|
3703
|
+
case MESSAGE_TYPES_V2.COMPLETE:
|
|
3704
|
+
options.onComplete?.(envelope.kind, envelope.payload);
|
|
3705
|
+
break;
|
|
3706
|
+
case MESSAGE_TYPES_V2.CANCEL:
|
|
3707
|
+
options.onCancel?.(envelope.payload);
|
|
3708
|
+
break;
|
|
3709
|
+
case MESSAGE_TYPES_V2.ERROR:
|
|
3710
|
+
options.onError?.(envelope.payload);
|
|
3711
|
+
break;
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3714
|
+
window.addEventListener("message", handleMessage, { signal: ac.signal });
|
|
3715
|
+
container.appendChild(iframe);
|
|
3716
|
+
return {
|
|
3717
|
+
iframe,
|
|
3718
|
+
destroy() {
|
|
3719
|
+
ac.abort();
|
|
3720
|
+
if (iframe.parentNode) {
|
|
3721
|
+
iframe.parentNode.removeChild(iframe);
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3727
|
+
// src/popup.ts
|
|
3728
|
+
var popupCounter = 0;
|
|
3729
|
+
function createPopup(baseUrl, options) {
|
|
3730
|
+
if (!options.sessionToken) {
|
|
3731
|
+
throw new OverturoValidationError("sessionToken is required for popup mode");
|
|
3732
|
+
}
|
|
3733
|
+
const embedUrl = `${baseUrl}/accord/embed/${options.sessionToken}`;
|
|
3734
|
+
const width = options.width ?? POPUP_DEFAULTS.width;
|
|
3735
|
+
const height = options.height ?? POPUP_DEFAULTS.height;
|
|
3736
|
+
const left = Math.round((screen.width - width) / 2);
|
|
3737
|
+
const top = Math.round((screen.height - height) / 2);
|
|
3738
|
+
const windowName = `overturo_decision_${++popupCounter}`;
|
|
3739
|
+
const popup = window.open(
|
|
3740
|
+
embedUrl,
|
|
3741
|
+
windowName,
|
|
3742
|
+
`width=${width},height=${height},left=${left},top=${top},scrollbars=yes,status=yes`
|
|
3743
|
+
);
|
|
3744
|
+
if (!popup) {
|
|
3745
|
+
throw new OverturoError("Popup was blocked by the browser. Allow popups for this site and try again.");
|
|
3746
|
+
}
|
|
3747
|
+
const expectedOrigin = new URL(baseUrl).origin;
|
|
3748
|
+
const ac = new AbortController();
|
|
3749
|
+
function handleMessage(event) {
|
|
3750
|
+
if (event.origin !== expectedOrigin) return;
|
|
3751
|
+
const result = validate(event.data);
|
|
3752
|
+
if (!result.valid) return;
|
|
3753
|
+
const envelope = event.data;
|
|
3754
|
+
switch (envelope.type) {
|
|
3755
|
+
case MESSAGE_TYPES_V2.COMPLETE:
|
|
3756
|
+
options.onComplete?.(envelope.kind, envelope.payload);
|
|
3757
|
+
cleanup();
|
|
3758
|
+
break;
|
|
3759
|
+
case MESSAGE_TYPES_V2.CANCEL:
|
|
3760
|
+
options.onCancel?.(envelope.payload);
|
|
3761
|
+
cleanup();
|
|
3762
|
+
break;
|
|
3763
|
+
case MESSAGE_TYPES_V2.ERROR:
|
|
3764
|
+
options.onError?.(envelope.payload);
|
|
3765
|
+
break;
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
function cleanup() {
|
|
3769
|
+
ac.abort();
|
|
3770
|
+
if (popup && !popup.closed) popup.close();
|
|
3771
|
+
}
|
|
3772
|
+
window.addEventListener("message", handleMessage, { signal: ac.signal });
|
|
3773
|
+
return { close: cleanup };
|
|
3774
|
+
}
|
|
3775
|
+
|
|
3776
|
+
// src/preview.ts
|
|
3777
|
+
var VIEWPORTS = {
|
|
3778
|
+
mobile: { width: 375, height: 667 },
|
|
3779
|
+
tablet: { width: 768, height: 1024 },
|
|
3780
|
+
desktop: { width: null, height: 800 }
|
|
3781
|
+
};
|
|
3782
|
+
function renderPreview(previewUrl, options) {
|
|
3783
|
+
const container = resolveContainer2(options.container);
|
|
3784
|
+
let currentDevice = options.device || "desktop";
|
|
3785
|
+
let currentTheme = options.theme || "default";
|
|
3786
|
+
let currentLocale = options.locale;
|
|
3787
|
+
const url = buildUrl(previewUrl, currentTheme, currentDevice, currentLocale);
|
|
3788
|
+
if (options.loading) {
|
|
3789
|
+
showLoading(container, options.loading);
|
|
3790
|
+
}
|
|
3791
|
+
const iframe = document.createElement("iframe");
|
|
3792
|
+
iframe.src = url;
|
|
3793
|
+
iframe.sandbox.add("allow-scripts", "allow-same-origin");
|
|
3794
|
+
iframe.style.border = "none";
|
|
3795
|
+
iframe.title = "Preview";
|
|
3796
|
+
applyViewport(iframe, currentDevice);
|
|
3797
|
+
applyStyle2(iframe, options.style);
|
|
3798
|
+
iframe.addEventListener(
|
|
3799
|
+
"load",
|
|
3800
|
+
() => {
|
|
3801
|
+
const loader = container.querySelector("[data-preview-loading]");
|
|
3802
|
+
if (loader) loader.remove();
|
|
3803
|
+
},
|
|
3804
|
+
{ once: true }
|
|
3805
|
+
);
|
|
3806
|
+
container.appendChild(iframe);
|
|
3807
|
+
const handle = {
|
|
3808
|
+
iframe,
|
|
3809
|
+
setDevice(device) {
|
|
3810
|
+
currentDevice = device;
|
|
3811
|
+
applyViewport(iframe, device);
|
|
3812
|
+
iframe.src = buildUrl(previewUrl, currentTheme, currentDevice, currentLocale);
|
|
3813
|
+
},
|
|
3814
|
+
setTheme(theme) {
|
|
3815
|
+
currentTheme = theme;
|
|
3816
|
+
iframe.src = buildUrl(previewUrl, currentTheme, currentDevice, currentLocale);
|
|
3817
|
+
},
|
|
3818
|
+
destroy() {
|
|
3819
|
+
iframe.remove();
|
|
3820
|
+
}
|
|
3821
|
+
};
|
|
3822
|
+
return handle;
|
|
3823
|
+
}
|
|
3824
|
+
function resolveContainer2(target) {
|
|
3825
|
+
if (typeof target === "string") {
|
|
3826
|
+
const el = document.querySelector(target);
|
|
3827
|
+
if (!el) throw new Error(`Preview container not found: ${target}`);
|
|
3828
|
+
return el;
|
|
3829
|
+
}
|
|
3830
|
+
return target;
|
|
3831
|
+
}
|
|
3832
|
+
function buildUrl(base, theme, device, locale) {
|
|
3833
|
+
const url = new URL(base, window.location.origin);
|
|
3834
|
+
url.searchParams.set("theme", theme);
|
|
3835
|
+
url.searchParams.set("device", device);
|
|
3836
|
+
if (locale) url.searchParams.set("locale", locale);
|
|
3837
|
+
return url.toString();
|
|
3838
|
+
}
|
|
3839
|
+
function applyViewport(iframe, device) {
|
|
3840
|
+
const vp = VIEWPORTS[device] || VIEWPORTS.desktop;
|
|
3841
|
+
if (vp.width) {
|
|
3842
|
+
iframe.style.width = `${vp.width}px`;
|
|
3843
|
+
iframe.style.maxWidth = "100%";
|
|
3844
|
+
} else {
|
|
3845
|
+
iframe.style.width = "100%";
|
|
3846
|
+
iframe.style.maxWidth = "none";
|
|
3847
|
+
}
|
|
3848
|
+
iframe.style.height = `${vp.height}px`;
|
|
3849
|
+
}
|
|
3850
|
+
function applyStyle2(iframe, style) {
|
|
3851
|
+
if (!style) return;
|
|
3852
|
+
if (style.width) iframe.style.width = style.width;
|
|
3853
|
+
if (style.minHeight) iframe.style.minHeight = style.minHeight;
|
|
3854
|
+
if (style.maxHeight) iframe.style.maxHeight = style.maxHeight;
|
|
3855
|
+
if (style.borderRadius) iframe.style.borderRadius = style.borderRadius;
|
|
3856
|
+
if (style.border) iframe.style.border = style.border;
|
|
3857
|
+
if (style.background) iframe.style.background = style.background;
|
|
3858
|
+
}
|
|
3859
|
+
function showLoading(container, loading) {
|
|
3860
|
+
const wrapper = document.createElement("div");
|
|
3861
|
+
wrapper.setAttribute("data-preview-loading", "");
|
|
3862
|
+
if (typeof loading === "string") {
|
|
3863
|
+
wrapper.textContent = loading;
|
|
3864
|
+
} else {
|
|
3865
|
+
wrapper.appendChild(loading);
|
|
3866
|
+
}
|
|
3867
|
+
container.appendChild(wrapper);
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3870
|
+
// src/redirect.ts
|
|
3871
|
+
function performRedirect(baseUrl, options) {
|
|
3872
|
+
if (!options.flowId) {
|
|
3873
|
+
throw new OverturoValidationError("flowId is required for redirect mode");
|
|
3874
|
+
}
|
|
3875
|
+
if (!options.redirectUri) {
|
|
3876
|
+
throw new OverturoValidationError("redirectUri is required for redirect mode");
|
|
3877
|
+
}
|
|
3878
|
+
const url = new URL(`${baseUrl}/accord/${options.flowId}`);
|
|
3879
|
+
const params = new URLSearchParams();
|
|
3880
|
+
params.set("redirect_uri", options.redirectUri);
|
|
3881
|
+
if (options.state) params.set("state", options.state);
|
|
3882
|
+
if (options.nonce) params.set("nonce", options.nonce);
|
|
3883
|
+
if (options.scope) params.set("scope", options.scope);
|
|
3884
|
+
url.search = params.toString();
|
|
3885
|
+
window.location.href = url.toString();
|
|
3886
|
+
}
|
|
3887
|
+
|
|
3888
|
+
// src/setup.ts
|
|
3889
|
+
function createSetupEmbed(baseUrl, options) {
|
|
3890
|
+
const container = resolveContainer(options.container);
|
|
3891
|
+
const expectedOrigin = new URL(baseUrl).origin;
|
|
3892
|
+
const embedUrl = `${baseUrl}/accord_setup/embed/${options.sessionToken}`;
|
|
3893
|
+
container.innerHTML = "";
|
|
3894
|
+
if (options.loading) {
|
|
3895
|
+
const loadingEl = document.createElement("div");
|
|
3896
|
+
loadingEl.setAttribute("data-overturo-loading", "");
|
|
3897
|
+
if (typeof options.loading === "string") {
|
|
3898
|
+
loadingEl.innerHTML = options.loading;
|
|
3899
|
+
} else {
|
|
3900
|
+
loadingEl.appendChild(options.loading);
|
|
3901
|
+
}
|
|
3902
|
+
container.appendChild(loadingEl);
|
|
3903
|
+
}
|
|
3904
|
+
const iframe = document.createElement("iframe");
|
|
3905
|
+
iframe.src = embedUrl;
|
|
3906
|
+
iframe.setAttribute("allow", "popups");
|
|
3907
|
+
iframe.setAttribute("sandbox", "allow-scripts allow-forms allow-same-origin allow-popups");
|
|
3908
|
+
applyStyle(iframe, { ...EMBED_DEFAULTS }, options.style);
|
|
3909
|
+
iframe.addEventListener("load", () => {
|
|
3910
|
+
const loadingChild = container.querySelector("[data-overturo-loading]");
|
|
3911
|
+
if (loadingChild) container.removeChild(loadingChild);
|
|
3912
|
+
});
|
|
3913
|
+
const ac = new AbortController();
|
|
3914
|
+
function handleMessage(event) {
|
|
3915
|
+
if (event.origin !== expectedOrigin) return;
|
|
3916
|
+
const data = event.data;
|
|
3917
|
+
if (!data || !data.type) return;
|
|
3918
|
+
switch (data.type) {
|
|
3919
|
+
case SETUP_MESSAGE_TYPES.READY:
|
|
3920
|
+
options.onReady?.();
|
|
3921
|
+
break;
|
|
3922
|
+
case SETUP_MESSAGE_TYPES.RESIZE:
|
|
3923
|
+
if (data.height) {
|
|
3924
|
+
iframe.style.height = `${data.height}px`;
|
|
3925
|
+
options.onResize?.(data.height);
|
|
3926
|
+
}
|
|
3927
|
+
break;
|
|
3928
|
+
case SETUP_MESSAGE_TYPES.STEP:
|
|
3929
|
+
options.onStep?.({
|
|
3930
|
+
key: data.step,
|
|
3931
|
+
index: data.stepIndex,
|
|
3932
|
+
total: data.totalSteps
|
|
3933
|
+
});
|
|
3934
|
+
break;
|
|
3935
|
+
case SETUP_MESSAGE_TYPES.CREATED:
|
|
3936
|
+
options.onCreated?.({
|
|
3937
|
+
accordId: data.accordId,
|
|
3938
|
+
flowId: data.flowId
|
|
3939
|
+
});
|
|
3940
|
+
break;
|
|
3941
|
+
case SETUP_MESSAGE_TYPES.CANCEL:
|
|
3942
|
+
options.onCancel?.();
|
|
3943
|
+
break;
|
|
3944
|
+
case SETUP_MESSAGE_TYPES.ERROR:
|
|
3945
|
+
options.onError?.(data.error);
|
|
3946
|
+
break;
|
|
3947
|
+
}
|
|
3948
|
+
}
|
|
3949
|
+
window.addEventListener("message", handleMessage, { signal: ac.signal });
|
|
3950
|
+
container.appendChild(iframe);
|
|
3951
|
+
return {
|
|
3952
|
+
iframe,
|
|
3953
|
+
destroy() {
|
|
3954
|
+
ac.abort();
|
|
3955
|
+
if (iframe.parentNode) {
|
|
3956
|
+
iframe.parentNode.removeChild(iframe);
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
};
|
|
3960
|
+
}
|
|
3961
|
+
function createSetupPopup(baseUrl, options) {
|
|
3962
|
+
const embedUrl = `${baseUrl}/accord_setup/embed/${options.sessionToken}`;
|
|
3963
|
+
const expectedOrigin = new URL(baseUrl).origin;
|
|
3964
|
+
const w = options.width ?? SETUP_POPUP_DEFAULTS.width;
|
|
3965
|
+
const h = options.height ?? SETUP_POPUP_DEFAULTS.height;
|
|
3966
|
+
const left = Math.round((screen.width - w) / 2);
|
|
3967
|
+
const top = Math.round((screen.height - h) / 2);
|
|
3968
|
+
const popup = window.open(
|
|
3969
|
+
embedUrl,
|
|
3970
|
+
"accord_setup_popup",
|
|
3971
|
+
`width=${w},height=${h},left=${left},top=${top},scrollbars=yes`
|
|
3972
|
+
);
|
|
3973
|
+
const ac = new AbortController();
|
|
3974
|
+
let pollTimer = null;
|
|
3975
|
+
function handleMessage(event) {
|
|
3976
|
+
if (event.origin !== expectedOrigin) return;
|
|
3977
|
+
const data = event.data;
|
|
3978
|
+
if (!data || !data.type) return;
|
|
3979
|
+
switch (data.type) {
|
|
3980
|
+
case SETUP_MESSAGE_TYPES.CREATED:
|
|
3981
|
+
options.onCreated?.({
|
|
3982
|
+
accordId: data.accordId,
|
|
3983
|
+
flowId: data.flowId
|
|
3984
|
+
});
|
|
3985
|
+
cleanup();
|
|
3986
|
+
break;
|
|
3987
|
+
case SETUP_MESSAGE_TYPES.CANCEL:
|
|
3988
|
+
options.onCancel?.();
|
|
3989
|
+
cleanup();
|
|
3990
|
+
break;
|
|
3991
|
+
case SETUP_MESSAGE_TYPES.ERROR:
|
|
3992
|
+
options.onError?.(data.error);
|
|
3993
|
+
break;
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
function cleanup() {
|
|
3997
|
+
ac.abort();
|
|
3998
|
+
if (pollTimer) clearInterval(pollTimer);
|
|
3999
|
+
}
|
|
4000
|
+
window.addEventListener("message", handleMessage, { signal: ac.signal });
|
|
4001
|
+
pollTimer = setInterval(() => {
|
|
4002
|
+
if (popup && popup.closed) {
|
|
4003
|
+
options.onCancel?.();
|
|
4004
|
+
cleanup();
|
|
4005
|
+
}
|
|
4006
|
+
}, 500);
|
|
4007
|
+
return {
|
|
4008
|
+
close() {
|
|
4009
|
+
popup?.close();
|
|
4010
|
+
cleanup();
|
|
4011
|
+
}
|
|
4012
|
+
};
|
|
4013
|
+
}
|
|
4014
|
+
function setupRedirect(baseUrl, options) {
|
|
4015
|
+
const embedUrl = `${baseUrl}/accord_setup/embed/${options.sessionToken}`;
|
|
4016
|
+
window.location.href = embedUrl;
|
|
4017
|
+
}
|
|
4018
|
+
|
|
4019
|
+
// src/overturo.ts
|
|
4020
|
+
var Overturo = class {
|
|
4021
|
+
constructor(options) {
|
|
4022
|
+
if (!options.publishableKey) {
|
|
4023
|
+
throw new OverturoValidationError("publishableKey is required");
|
|
4024
|
+
}
|
|
4025
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
4026
|
+
this.flowBaseUrl = (options.flowBaseUrl ?? this.baseUrl).replace(/\/+$/, "");
|
|
4027
|
+
this.debugFlag = options.debug === true;
|
|
4028
|
+
this.api = new ApiClient({
|
|
4029
|
+
baseUrl: this.baseUrl,
|
|
4030
|
+
publishableKey: options.publishableKey,
|
|
4031
|
+
apiKey: options.apiKey,
|
|
4032
|
+
timeout: options.timeout
|
|
4033
|
+
});
|
|
4034
|
+
this.decisions = new Decisions({
|
|
4035
|
+
api: this.api,
|
|
4036
|
+
flowBaseUrl: this.flowBaseUrl,
|
|
4037
|
+
debug: this.debugFlag
|
|
4038
|
+
});
|
|
4039
|
+
this.consent = new ConsentFacade(this.decisions);
|
|
4040
|
+
this.approvals = new ApprovalsFacade(this.decisions, this.api);
|
|
4041
|
+
this.signing = new SigningFacade(this.decisions, this.api);
|
|
4042
|
+
this.forms = new FormsFacade(this.api, this.decisions, this.flowBaseUrl, options.publishableKey);
|
|
4043
|
+
if (this.debugFlag && typeof window !== "undefined") {
|
|
4044
|
+
const url = new URL(this.baseUrl);
|
|
4045
|
+
const devHosts = url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "lvh.me" || url.hostname.endsWith(".lvh.me") || url.hostname.endsWith(".localhost");
|
|
4046
|
+
if (url.protocol === "http:" && !devHosts) {
|
|
4047
|
+
console.warn(
|
|
4048
|
+
"[overturo:sdk]",
|
|
4049
|
+
"OVERTURO_INSECURE_HOST",
|
|
4050
|
+
`API host ${url.host} is not HTTPS; treat this as dev-only.`
|
|
4051
|
+
);
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
/**
|
|
4056
|
+
* Tears down every live decisions handle (embed iframes + popups).
|
|
4057
|
+
* Best-effort: errors during teardown are swallowed.
|
|
4058
|
+
*
|
|
4059
|
+
* @since 1.0.0
|
|
4060
|
+
*/
|
|
4061
|
+
async destroy() {
|
|
4062
|
+
await this.decisions.destroyAll();
|
|
4063
|
+
}
|
|
4064
|
+
// v0's `Overturo#consent({...})` method is REPLACED
|
|
4065
|
+
// by the `consent` facade property declared above. Consumers must
|
|
4066
|
+
// migrate `client.consent({...})` → `client.consent.open({...})`.
|
|
4067
|
+
// The migration is documented in CHANGELOG.md and the developer
|
|
4068
|
+
// portal. Calling `client.consent(...)`
|
|
4069
|
+
// as a function now raises `TypeError` (consent is an object, not
|
|
4070
|
+
// a function); we accept this surprise per the spec's "v0 callers
|
|
4071
|
+
// break" pre-production stance.
|
|
4072
|
+
/**
|
|
4073
|
+
* Creates a new consent session.
|
|
4074
|
+
* The flowId is sent as accord_id to the server (automatic parameter aliasing).
|
|
4075
|
+
*/
|
|
4076
|
+
async createSession(params) {
|
|
4077
|
+
return this.api.post(API_PATH, {
|
|
4078
|
+
accordId: params.flowId,
|
|
4079
|
+
deliveryMode: params.deliveryMode,
|
|
4080
|
+
embedOrigin: params.embedOrigin,
|
|
4081
|
+
redirectUri: params.redirectUri,
|
|
4082
|
+
state: params.state,
|
|
4083
|
+
nonce: params.nonce,
|
|
4084
|
+
scope: params.scope,
|
|
4085
|
+
skipSteps: params.skipSteps
|
|
4086
|
+
});
|
|
4087
|
+
}
|
|
4088
|
+
/**
|
|
4089
|
+
* Retrieves the status of an existing consent session.
|
|
4090
|
+
*/
|
|
4091
|
+
async getSession(sessionToken) {
|
|
4092
|
+
return this.api.get(`${API_PATH}/${sessionToken}`);
|
|
4093
|
+
}
|
|
4094
|
+
/**
|
|
4095
|
+
* This participant's consent status for ONE meeting (the meeting's own
|
|
4096
|
+
* window and platform ride along). Identified by the participant's own
|
|
4097
|
+
* session token — never lists other participants.
|
|
4098
|
+
*/
|
|
4099
|
+
async getMeetingParticipantStatus(meetingId, sessionToken) {
|
|
4100
|
+
if (!meetingId) throw new OverturoValidationError("meetingId is required");
|
|
4101
|
+
if (!sessionToken) throw new OverturoValidationError("sessionToken is required");
|
|
4102
|
+
const response = await this.api.rawGet(
|
|
4103
|
+
`${MEETING_CONSENTS_API_PATH}/${encodeURIComponent(meetingId)}/status?session_token=${encodeURIComponent(sessionToken)}`
|
|
4104
|
+
);
|
|
4105
|
+
return this.decodeParticipantStatus(response);
|
|
4106
|
+
}
|
|
4107
|
+
/**
|
|
4108
|
+
* Withdraws this participant's consent for ONE meeting. The host is told;
|
|
4109
|
+
* the record keeps the withdrawal.
|
|
4110
|
+
*/
|
|
4111
|
+
async withdrawMeetingConsent(meetingId, sessionToken) {
|
|
4112
|
+
if (!meetingId) throw new OverturoValidationError("meetingId is required");
|
|
4113
|
+
if (!sessionToken) throw new OverturoValidationError("sessionToken is required");
|
|
4114
|
+
const response = await this.api.rawPost(`${MEETING_CONSENTS_API_PATH}/${encodeURIComponent(meetingId)}/revoke`, {
|
|
4115
|
+
sessionToken
|
|
4116
|
+
});
|
|
4117
|
+
return this.decodeParticipantStatus(response);
|
|
4118
|
+
}
|
|
4119
|
+
// Purpose names are data, not keys: everything camelCases except `purposes`.
|
|
4120
|
+
async decodeParticipantStatus(response) {
|
|
4121
|
+
if (!response.ok) {
|
|
4122
|
+
let responseBody;
|
|
4123
|
+
try {
|
|
4124
|
+
responseBody = await response.json();
|
|
4125
|
+
} catch {
|
|
4126
|
+
responseBody = null;
|
|
4127
|
+
}
|
|
4128
|
+
throw new OverturoApiError(extractErrorMessage(responseBody, response.status), response.status, responseBody);
|
|
4129
|
+
}
|
|
4130
|
+
const raw = JSON.parse(await response.text());
|
|
4131
|
+
const purposes = raw.purposes ?? {};
|
|
4132
|
+
const decoded = toCamelCase({ ...raw, purposes: {} });
|
|
4133
|
+
return { ...decoded, purposes: { ...purposes } };
|
|
4134
|
+
}
|
|
4135
|
+
/**
|
|
4136
|
+
* Embeds a consent flow in an iframe.
|
|
4137
|
+
* Requires a sessionToken from createSession().
|
|
4138
|
+
*/
|
|
4139
|
+
embed(options) {
|
|
4140
|
+
return createEmbed(this.flowBaseUrl, options);
|
|
4141
|
+
}
|
|
4142
|
+
/**
|
|
4143
|
+
* Opens a consent flow in a popup window.
|
|
4144
|
+
* Requires a sessionToken from createSession().
|
|
4145
|
+
*
|
|
4146
|
+
* @throws {OverturoError} If the browser blocks the popup.
|
|
4147
|
+
*/
|
|
4148
|
+
popup(options) {
|
|
4149
|
+
return createPopup(this.flowBaseUrl, options);
|
|
4150
|
+
}
|
|
4151
|
+
/**
|
|
4152
|
+
* Redirects to a consent flow (full-page navigation).
|
|
4153
|
+
* No session token needed — the server creates one on arrival.
|
|
4154
|
+
*/
|
|
4155
|
+
redirect(options) {
|
|
4156
|
+
performRedirect(this.flowBaseUrl, options);
|
|
4157
|
+
}
|
|
4158
|
+
/**
|
|
4159
|
+
* Exchanges a consent token for claims, attestations, credentials, and tokens.
|
|
4160
|
+
* Best used server-side with apiKey set.
|
|
4161
|
+
*
|
|
4162
|
+
* Handles HTTP 202 (fulfillment pending) transparently by retrying with
|
|
4163
|
+
* the Retry-After interval until the server returns the full result.
|
|
4164
|
+
*/
|
|
4165
|
+
async exchange(params) {
|
|
4166
|
+
const maxRetries = 5;
|
|
4167
|
+
const path = `${API_PATH}/${params.sessionToken}/exchange`;
|
|
4168
|
+
const body = { consentToken: params.consentToken };
|
|
4169
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
4170
|
+
const response = await this.api.rawPost(path, body);
|
|
4171
|
+
if (response.status === 202) {
|
|
4172
|
+
if (attempt === maxRetries) {
|
|
4173
|
+
throw new OverturoApiError("Exchange timeout: fulfillment still pending", 202, null);
|
|
4174
|
+
}
|
|
4175
|
+
const retryAfter = parseInt(response.headers.get("Retry-After") || "1", 10);
|
|
4176
|
+
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1e3));
|
|
4177
|
+
continue;
|
|
4178
|
+
}
|
|
4179
|
+
if (!response.ok) {
|
|
4180
|
+
let responseBody;
|
|
4181
|
+
try {
|
|
4182
|
+
responseBody = await response.json();
|
|
4183
|
+
} catch {
|
|
4184
|
+
responseBody = null;
|
|
4185
|
+
}
|
|
4186
|
+
const message = extractErrorMessage(responseBody, response.status);
|
|
4187
|
+
throw new OverturoApiError(
|
|
4188
|
+
message === `HTTP ${response.status}` ? `Exchange failed: HTTP ${response.status}` : message,
|
|
4189
|
+
response.status,
|
|
4190
|
+
responseBody
|
|
4191
|
+
);
|
|
4192
|
+
}
|
|
4193
|
+
const text = await response.text();
|
|
4194
|
+
return toCamelCase(JSON.parse(text));
|
|
4195
|
+
}
|
|
4196
|
+
throw new OverturoApiError("Exchange failed: max retries exceeded", 202, null);
|
|
4197
|
+
}
|
|
4198
|
+
// ── AccordSetup Methods ──────────────────────────────
|
|
4199
|
+
/**
|
|
4200
|
+
* Creates a new AccordSetup session via the API.
|
|
4201
|
+
* Lower-level than accordSetup() — use when you need manual control.
|
|
4202
|
+
*/
|
|
4203
|
+
async createSetupSession(params) {
|
|
4204
|
+
return this.api.post(SETUP_API_PATH, {
|
|
4205
|
+
solution: params.solution,
|
|
4206
|
+
vertical: params.vertical,
|
|
4207
|
+
archetype: params.archetype,
|
|
4208
|
+
templateKey: params.templateKey,
|
|
4209
|
+
deliveryMode: params.deliveryMode || "embed",
|
|
4210
|
+
embedOrigin: params.embedOrigin || (typeof window !== "undefined" ? window.location.origin : void 0),
|
|
4211
|
+
redirectUri: params.redirectUri,
|
|
4212
|
+
state: params.state,
|
|
4213
|
+
locale: params.locale || (typeof navigator !== "undefined" ? navigator.language : void 0),
|
|
4214
|
+
constraints: params.constraints,
|
|
4215
|
+
presetId: params.presetId
|
|
4216
|
+
});
|
|
4217
|
+
}
|
|
4218
|
+
/**
|
|
4219
|
+
* High-level: creates a setup session and embeds the wizard in an iframe.
|
|
4220
|
+
*
|
|
4221
|
+
* @example
|
|
4222
|
+
* ```ts
|
|
4223
|
+
* const handle = await overturo.accordSetup({
|
|
4224
|
+
* solution: "meetings",
|
|
4225
|
+
* container: "#setup",
|
|
4226
|
+
* onCreated: ({ flowId }) => console.log("Created:", flowId),
|
|
4227
|
+
* });
|
|
4228
|
+
* ```
|
|
4229
|
+
*/
|
|
4230
|
+
async accordSetup(options) {
|
|
4231
|
+
const session = await this.createSetupSession(this.buildSetupParams(options, "embed"));
|
|
4232
|
+
return createSetupEmbed(this.flowBaseUrl, {
|
|
4233
|
+
...options,
|
|
4234
|
+
sessionToken: session.sessionToken
|
|
4235
|
+
});
|
|
4236
|
+
}
|
|
4237
|
+
/**
|
|
4238
|
+
* Creates a setup session and opens the wizard in a popup window.
|
|
4239
|
+
*/
|
|
4240
|
+
async accordSetupPopup(options) {
|
|
4241
|
+
const session = await this.createSetupSession(this.buildSetupParams(options, "popup"));
|
|
4242
|
+
return createSetupPopup(this.flowBaseUrl, {
|
|
4243
|
+
...options,
|
|
4244
|
+
sessionToken: session.sessionToken
|
|
4245
|
+
});
|
|
4246
|
+
}
|
|
4247
|
+
/**
|
|
4248
|
+
* Creates a setup session and redirects to the wizard (full-page navigation).
|
|
4249
|
+
* On completion, the user is redirected back to `redirectUri` with query params.
|
|
4250
|
+
*/
|
|
4251
|
+
async accordSetupRedirect(options) {
|
|
4252
|
+
const session = await this.createSetupSession({
|
|
4253
|
+
...this.buildSetupParams(options, "redirect"),
|
|
4254
|
+
redirectUri: options.redirectUri,
|
|
4255
|
+
state: options.state
|
|
4256
|
+
});
|
|
4257
|
+
setupRedirect(this.flowBaseUrl, {
|
|
4258
|
+
...options,
|
|
4259
|
+
sessionToken: session.sessionToken
|
|
4260
|
+
});
|
|
4261
|
+
}
|
|
4262
|
+
// ── Preview ────────────────────────────────────────────────────────
|
|
4263
|
+
/**
|
|
4264
|
+
* Preview a template in an iframe.
|
|
4265
|
+
*
|
|
4266
|
+
* Creates a preview token via the API, then renders the preview in the
|
|
4267
|
+
* specified container. Returns a handle for controlling the preview.
|
|
4268
|
+
*
|
|
4269
|
+
* @example
|
|
4270
|
+
* ```ts
|
|
4271
|
+
* const preview = await overturo.previewTemplate({
|
|
4272
|
+
* templateId: "tpl_abc123",
|
|
4273
|
+
* container: "#preview",
|
|
4274
|
+
* device: "mobile",
|
|
4275
|
+
* theme: "corporate",
|
|
4276
|
+
* });
|
|
4277
|
+
* preview.setDevice("desktop");
|
|
4278
|
+
* preview.destroy();
|
|
4279
|
+
* ```
|
|
4280
|
+
*/
|
|
4281
|
+
async previewTemplate(options) {
|
|
4282
|
+
if (!options.templateId) throw new OverturoValidationError("templateId is required");
|
|
4283
|
+
if (!options.container) throw new OverturoValidationError("container is required");
|
|
4284
|
+
const response = await this.api.post(
|
|
4285
|
+
PREVIEW_TOKENS_PATH,
|
|
4286
|
+
{
|
|
4287
|
+
previewable_type: "template",
|
|
4288
|
+
previewable_id: options.templateId,
|
|
4289
|
+
theme: options.theme,
|
|
4290
|
+
device: options.device,
|
|
4291
|
+
locale: options.locale
|
|
4292
|
+
}
|
|
4293
|
+
);
|
|
4294
|
+
return renderPreview(response.preview_url, options);
|
|
4295
|
+
}
|
|
4296
|
+
/**
|
|
4297
|
+
* Preview a setup session in an iframe.
|
|
4298
|
+
*
|
|
4299
|
+
* Creates a preview token via the API for the specified setup session,
|
|
4300
|
+
* then renders the preview in the specified container.
|
|
4301
|
+
*
|
|
4302
|
+
* @example
|
|
4303
|
+
* ```ts
|
|
4304
|
+
* const preview = await overturo.previewSetup({
|
|
4305
|
+
* sessionToken: "acs_abc123",
|
|
4306
|
+
* container: "#preview",
|
|
4307
|
+
* });
|
|
4308
|
+
* preview.setTheme("dark");
|
|
4309
|
+
* preview.destroy();
|
|
4310
|
+
* ```
|
|
4311
|
+
*/
|
|
4312
|
+
async previewSetup(options) {
|
|
4313
|
+
if (!options.sessionToken) throw new OverturoValidationError("sessionToken is required");
|
|
4314
|
+
if (!options.container) throw new OverturoValidationError("container is required");
|
|
4315
|
+
const response = await this.api.post(
|
|
4316
|
+
PREVIEW_TOKENS_PATH,
|
|
4317
|
+
{
|
|
4318
|
+
previewable_type: "setup_session",
|
|
4319
|
+
previewable_id: options.sessionToken,
|
|
4320
|
+
theme: options.theme,
|
|
4321
|
+
device: options.device,
|
|
4322
|
+
locale: options.locale
|
|
4323
|
+
}
|
|
4324
|
+
);
|
|
4325
|
+
return renderPreview(response.preview_url, options);
|
|
4326
|
+
}
|
|
4327
|
+
/**
|
|
4328
|
+
* Builds common CreateSetupSessionParams from any setup options variant.
|
|
4329
|
+
*/
|
|
4330
|
+
buildSetupParams(options, deliveryMode) {
|
|
4331
|
+
return {
|
|
4332
|
+
solution: options.solution,
|
|
4333
|
+
vertical: options.vertical,
|
|
4334
|
+
archetype: options.archetype,
|
|
4335
|
+
templateKey: options.templateKey,
|
|
4336
|
+
deliveryMode,
|
|
4337
|
+
locale: options.locale,
|
|
4338
|
+
constraints: options.constraints,
|
|
4339
|
+
presetId: options.presetId
|
|
4340
|
+
};
|
|
4341
|
+
}
|
|
4342
|
+
};
|
|
4343
|
+
|
|
4344
|
+
// src/elements/decision_element.ts
|
|
4345
|
+
var ELEMENT_NAME = "overturo-decision";
|
|
4346
|
+
var ALREADY_DEFINED_CODE = "OVERTURO_ELEMENT_ALREADY_DEFINED";
|
|
4347
|
+
var _shadow, _iframe, _ac, _errorRegion, _DecisionElement_instances, mount_fn, renderClickToOpen_fn, handleEnvelope_fn, emitError_fn, teardown_fn, _onKey;
|
|
4348
|
+
var DecisionElement = class extends HTMLElement {
|
|
4349
|
+
constructor() {
|
|
4350
|
+
super();
|
|
4351
|
+
__privateAdd(this, _DecisionElement_instances);
|
|
4352
|
+
__privateAdd(this, _shadow);
|
|
4353
|
+
__privateAdd(this, _iframe, null);
|
|
4354
|
+
__privateAdd(this, _ac, null);
|
|
4355
|
+
__privateAdd(this, _errorRegion, null);
|
|
4356
|
+
__privateAdd(this, _onKey, (event) => {
|
|
4357
|
+
if (event.key === "Escape") {
|
|
4358
|
+
this.dispatchEvent(
|
|
4359
|
+
new CustomEvent("decision:cancel", {
|
|
4360
|
+
detail: { reason: "user_pressed_esc" },
|
|
4361
|
+
bubbles: true,
|
|
4362
|
+
composed: true
|
|
4363
|
+
})
|
|
4364
|
+
);
|
|
4365
|
+
__privateMethod(this, _DecisionElement_instances, teardown_fn).call(this);
|
|
4366
|
+
}
|
|
4367
|
+
});
|
|
4368
|
+
__privateSet(this, _shadow, this.attachShadow({ mode: "open" }));
|
|
4369
|
+
}
|
|
4370
|
+
connectedCallback() {
|
|
4371
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "region");
|
|
4372
|
+
if (!this.hasAttribute("aria-label")) {
|
|
4373
|
+
this.setAttribute("aria-label", "Loading decision");
|
|
4374
|
+
}
|
|
4375
|
+
this.setAttribute("aria-busy", "true");
|
|
4376
|
+
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
4377
|
+
this.addEventListener("keydown", __privateGet(this, _onKey));
|
|
4378
|
+
__privateMethod(this, _DecisionElement_instances, mount_fn).call(this);
|
|
4379
|
+
}
|
|
4380
|
+
disconnectedCallback() {
|
|
4381
|
+
this.removeEventListener("keydown", __privateGet(this, _onKey));
|
|
4382
|
+
__privateMethod(this, _DecisionElement_instances, teardown_fn).call(this);
|
|
4383
|
+
}
|
|
4384
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
4385
|
+
if (oldValue === newValue) return;
|
|
4386
|
+
if (!this.isConnected) return;
|
|
4387
|
+
if (name === "token" || name === "mode" || name === "flow-base-url" || name === "theme") {
|
|
4388
|
+
__privateMethod(this, _DecisionElement_instances, teardown_fn).call(this);
|
|
4389
|
+
__privateMethod(this, _DecisionElement_instances, mount_fn).call(this);
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4392
|
+
};
|
|
4393
|
+
_shadow = new WeakMap();
|
|
4394
|
+
_iframe = new WeakMap();
|
|
4395
|
+
_ac = new WeakMap();
|
|
4396
|
+
_errorRegion = new WeakMap();
|
|
4397
|
+
_DecisionElement_instances = new WeakSet();
|
|
4398
|
+
mount_fn = function() {
|
|
4399
|
+
const token = this.getAttribute("token");
|
|
4400
|
+
if (!token) return;
|
|
4401
|
+
const mode = this.getAttribute("mode") ?? "embed";
|
|
4402
|
+
const flowBaseUrl = this.getAttribute("flow-base-url") ?? defaultFlowBaseUrl();
|
|
4403
|
+
if (mode !== "embed") {
|
|
4404
|
+
__privateMethod(this, _DecisionElement_instances, renderClickToOpen_fn).call(this, flowBaseUrl, token, mode);
|
|
4405
|
+
return;
|
|
4406
|
+
}
|
|
4407
|
+
const themeAttr = this.getAttribute("theme");
|
|
4408
|
+
const baseUrl = `${flowBaseUrl.replace(/\/+$/, "")}/decisions/${token}/embed`;
|
|
4409
|
+
const url = themeAttr ? `${baseUrl}?theme=${encodeURIComponent(themeAttr)}` : baseUrl;
|
|
4410
|
+
const expectedOrigin = new URL(url).origin;
|
|
4411
|
+
const iframe = document.createElement("iframe");
|
|
4412
|
+
iframe.src = url;
|
|
4413
|
+
iframe.title = "Overturo decision form";
|
|
4414
|
+
iframe.setAttribute("allow", "popups");
|
|
4415
|
+
iframe.setAttribute("sandbox", "allow-scripts allow-forms allow-same-origin allow-popups");
|
|
4416
|
+
iframe.style.cssText = "width:100%;min-height:400px;border:0;background:transparent;";
|
|
4417
|
+
if (themeAttr) iframe.dataset.theme = themeAttr;
|
|
4418
|
+
const nonce = readCspNonce();
|
|
4419
|
+
if (nonce) iframe.setAttribute("nonce", nonce);
|
|
4420
|
+
iframe.addEventListener("error", () => {
|
|
4421
|
+
this.dispatchEvent(
|
|
4422
|
+
new CustomEvent("decision:error", {
|
|
4423
|
+
detail: {
|
|
4424
|
+
code: "iframe_load_failed",
|
|
4425
|
+
message: "The trust-host iframe failed to load."
|
|
4426
|
+
},
|
|
4427
|
+
bubbles: true,
|
|
4428
|
+
composed: true
|
|
4429
|
+
})
|
|
4430
|
+
);
|
|
4431
|
+
this.setAttribute("aria-busy", "false");
|
|
4432
|
+
});
|
|
4433
|
+
__privateSet(this, _ac, new AbortController());
|
|
4434
|
+
const onMessage = (event) => {
|
|
4435
|
+
if (event.origin !== expectedOrigin || isForeignEnvelope(event.data)) return;
|
|
4436
|
+
const result = validate(event.data);
|
|
4437
|
+
if (!result.valid) {
|
|
4438
|
+
__privateMethod(this, _DecisionElement_instances, emitError_fn).call(this, { code: "protocol_violation" });
|
|
4439
|
+
return;
|
|
4440
|
+
}
|
|
4441
|
+
__privateMethod(this, _DecisionElement_instances, handleEnvelope_fn).call(this, event.data, iframe);
|
|
4442
|
+
};
|
|
4443
|
+
window.addEventListener("message", onMessage, { signal: __privateGet(this, _ac).signal });
|
|
4444
|
+
__privateSet(this, _iframe, iframe);
|
|
4445
|
+
__privateGet(this, _shadow).appendChild(iframe);
|
|
4446
|
+
};
|
|
4447
|
+
renderClickToOpen_fn = function(flowBaseUrl, token, mode) {
|
|
4448
|
+
const a = document.createElement("a");
|
|
4449
|
+
a.href = `${flowBaseUrl.replace(/\/+$/, "")}/decisions/${token}`;
|
|
4450
|
+
a.target = mode === "popup" ? "_blank" : "_self";
|
|
4451
|
+
a.rel = "noopener noreferrer";
|
|
4452
|
+
a.textContent = "Open decision";
|
|
4453
|
+
a.style.cssText = "display:inline-block;padding:0.5em 1em;text-decoration:none;";
|
|
4454
|
+
__privateGet(this, _shadow).appendChild(a);
|
|
4455
|
+
this.setAttribute("aria-busy", "false");
|
|
4456
|
+
};
|
|
4457
|
+
handleEnvelope_fn = function(envelope, iframe) {
|
|
4458
|
+
switch (envelope.type) {
|
|
4459
|
+
case MESSAGE_TYPES_V2.READY: {
|
|
4460
|
+
this.setAttribute("aria-busy", "false");
|
|
4461
|
+
const payload = envelope.payload ?? {};
|
|
4462
|
+
const labelSource = (typeof payload.title === "string" ? payload.title : null) ?? payload.branding?.application_name ?? null;
|
|
4463
|
+
if (labelSource) {
|
|
4464
|
+
this.setAttribute("aria-label", labelSource);
|
|
4465
|
+
}
|
|
4466
|
+
this.dispatchEvent(new CustomEvent("decision:ready", { detail: envelope.payload }));
|
|
4467
|
+
break;
|
|
4468
|
+
}
|
|
4469
|
+
case MESSAGE_TYPES_V2.STATE:
|
|
4470
|
+
this.dispatchEvent(
|
|
4471
|
+
new CustomEvent("decision:state", {
|
|
4472
|
+
detail: { kind: envelope.kind, payload: envelope.payload }
|
|
4473
|
+
})
|
|
4474
|
+
);
|
|
4475
|
+
break;
|
|
4476
|
+
case MESSAGE_TYPES_V2.RESIZE: {
|
|
4477
|
+
const height = envelope.payload.height;
|
|
4478
|
+
if (typeof height === "number") iframe.style.height = `${height}px`;
|
|
4479
|
+
break;
|
|
4480
|
+
}
|
|
4481
|
+
case MESSAGE_TYPES_V2.COMPLETE:
|
|
4482
|
+
this.dispatchEvent(
|
|
4483
|
+
new CustomEvent("decision:complete", {
|
|
4484
|
+
detail: { kind: envelope.kind, payload: envelope.payload },
|
|
4485
|
+
bubbles: true,
|
|
4486
|
+
composed: true
|
|
4487
|
+
})
|
|
4488
|
+
);
|
|
4489
|
+
break;
|
|
4490
|
+
case MESSAGE_TYPES_V2.CANCEL:
|
|
4491
|
+
this.dispatchEvent(
|
|
4492
|
+
new CustomEvent("decision:cancel", {
|
|
4493
|
+
detail: envelope.payload,
|
|
4494
|
+
bubbles: true,
|
|
4495
|
+
composed: true
|
|
4496
|
+
})
|
|
4497
|
+
);
|
|
4498
|
+
break;
|
|
4499
|
+
case MESSAGE_TYPES_V2.ERROR:
|
|
4500
|
+
__privateMethod(this, _DecisionElement_instances, emitError_fn).call(this, envelope.payload);
|
|
4501
|
+
break;
|
|
4502
|
+
case MESSAGE_TYPES_V2.DEADLINE:
|
|
4503
|
+
this.dispatchEvent(new CustomEvent("decision:deadline", { detail: envelope.payload }));
|
|
4504
|
+
break;
|
|
4505
|
+
}
|
|
4506
|
+
};
|
|
4507
|
+
emitError_fn = function(payload) {
|
|
4508
|
+
this.dispatchEvent(new CustomEvent("decision:error", { detail: payload, bubbles: true }));
|
|
4509
|
+
if (!__privateGet(this, _errorRegion)) {
|
|
4510
|
+
__privateSet(this, _errorRegion, document.createElement("div"));
|
|
4511
|
+
__privateGet(this, _errorRegion).setAttribute("role", "alert");
|
|
4512
|
+
__privateGet(this, _errorRegion).setAttribute("aria-live", "assertive");
|
|
4513
|
+
__privateGet(this, _errorRegion).style.cssText = "position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);";
|
|
4514
|
+
__privateGet(this, _shadow).appendChild(__privateGet(this, _errorRegion));
|
|
4515
|
+
}
|
|
4516
|
+
const msg = typeof payload.message === "string" ? payload.message : "An error occurred. Please try again.";
|
|
4517
|
+
__privateGet(this, _errorRegion).textContent = msg;
|
|
4518
|
+
window.setTimeout(() => {
|
|
4519
|
+
if (__privateGet(this, _errorRegion)) __privateGet(this, _errorRegion).textContent = "";
|
|
4520
|
+
}, 3e4);
|
|
4521
|
+
};
|
|
4522
|
+
teardown_fn = function() {
|
|
4523
|
+
if (__privateGet(this, _ac)) {
|
|
4524
|
+
__privateGet(this, _ac).abort();
|
|
4525
|
+
__privateSet(this, _ac, null);
|
|
4526
|
+
}
|
|
4527
|
+
if (__privateGet(this, _iframe) && __privateGet(this, _iframe).parentNode) {
|
|
4528
|
+
__privateGet(this, _iframe).parentNode.removeChild(__privateGet(this, _iframe));
|
|
4529
|
+
}
|
|
4530
|
+
__privateSet(this, _iframe, null);
|
|
4531
|
+
if (__privateGet(this, _errorRegion)) {
|
|
4532
|
+
__privateGet(this, _errorRegion).textContent = "";
|
|
4533
|
+
}
|
|
4534
|
+
this.setAttribute("aria-busy", "true");
|
|
4535
|
+
};
|
|
4536
|
+
_onKey = new WeakMap();
|
|
4537
|
+
DecisionElement.observedAttributes = ["token", "mode", "theme", "flow-base-url"];
|
|
4538
|
+
function readCspNonce() {
|
|
4539
|
+
if (typeof document === "undefined") return null;
|
|
4540
|
+
const meta = document.querySelector('meta[name="csp-nonce"]');
|
|
4541
|
+
return meta?.getAttribute("content") ?? null;
|
|
4542
|
+
}
|
|
4543
|
+
function defaultFlowBaseUrl() {
|
|
4544
|
+
if (typeof window !== "undefined") return window.location.origin;
|
|
4545
|
+
return "https://overturo.com";
|
|
4546
|
+
}
|
|
4547
|
+
function registerDecisionElement() {
|
|
4548
|
+
if (typeof customElements === "undefined") return;
|
|
4549
|
+
if (customElements.get(ELEMENT_NAME)) {
|
|
4550
|
+
console.warn("[overturo:sdk]", ALREADY_DEFINED_CODE, `<${ELEMENT_NAME}> already registered; skipping.`);
|
|
4551
|
+
return;
|
|
4552
|
+
}
|
|
4553
|
+
customElements.define(ELEMENT_NAME, DecisionElement);
|
|
4554
|
+
}
|
|
4555
|
+
|
|
4556
|
+
// src/elements/index.ts
|
|
4557
|
+
registerDecisionElement();
|
|
4558
|
+
export {
|
|
4559
|
+
ALREADY_DEFINED_CODE,
|
|
4560
|
+
DecisionElement,
|
|
4561
|
+
ELEMENT_NAME,
|
|
4562
|
+
OapAuthorizationDenied,
|
|
4563
|
+
OapDenied,
|
|
4564
|
+
OapIntentDenied,
|
|
4565
|
+
OapSequenceDenied,
|
|
4566
|
+
OapTrajectoryDenied,
|
|
4567
|
+
Overturo,
|
|
4568
|
+
OverturoApiError,
|
|
4569
|
+
OverturoError,
|
|
4570
|
+
OverturoNetworkError,
|
|
4571
|
+
OverturoTimeoutError,
|
|
4572
|
+
OverturoValidationError,
|
|
4573
|
+
createSetupEmbed,
|
|
4574
|
+
createSetupPopup,
|
|
4575
|
+
Overturo as default,
|
|
4576
|
+
registerDecisionElement,
|
|
4577
|
+
setupRedirect
|
|
4578
|
+
};
|
|
4579
|
+
//# sourceMappingURL=index.js.map
|