@overturo/js 0.0.0-stage → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +391 -2
- package/dist/field/index.cjs +1290 -0
- package/dist/field/index.cjs.map +1 -0
- package/dist/field/index.d.cts +176 -0
- package/dist/field/index.d.ts +176 -0
- package/dist/field/index.js +1251 -0
- package/dist/field/index.js.map +1 -0
- package/dist/index.cjs +4625 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1366 -0
- package/dist/index.d.ts +1366 -0
- package/dist/index.js +4583 -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
|
@@ -0,0 +1,1251 @@
|
|
|
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/dist/runtime/ucs2length.js
|
|
19
|
+
var require_ucs2length = __commonJS({
|
|
20
|
+
"node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
|
|
21
|
+
"use strict";
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
function ucs2length(str) {
|
|
24
|
+
const len = str.length;
|
|
25
|
+
let length = 0;
|
|
26
|
+
let pos = 0;
|
|
27
|
+
let value;
|
|
28
|
+
while (pos < len) {
|
|
29
|
+
length++;
|
|
30
|
+
value = str.charCodeAt(pos++);
|
|
31
|
+
if (value >= 55296 && value <= 56319 && pos < len) {
|
|
32
|
+
value = str.charCodeAt(pos);
|
|
33
|
+
if ((value & 64512) === 56320)
|
|
34
|
+
pos++;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return length;
|
|
38
|
+
}
|
|
39
|
+
exports.default = ucs2length;
|
|
40
|
+
ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default';
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// src/constants.ts
|
|
45
|
+
var EMBED_DEFAULTS = {
|
|
46
|
+
width: "100%",
|
|
47
|
+
minHeight: "400px",
|
|
48
|
+
maxHeight: "none",
|
|
49
|
+
border: "none",
|
|
50
|
+
borderRadius: "0",
|
|
51
|
+
background: "transparent"
|
|
52
|
+
};
|
|
53
|
+
var EMBED_STYLE_KEYS = Object.keys(EMBED_DEFAULTS);
|
|
54
|
+
var DEFAULT_BASE_URL = "https://overturo.com";
|
|
55
|
+
var CONSENT_FIELD_ELEMENT_NAME = "overturo-consent-field";
|
|
56
|
+
|
|
57
|
+
// src/field/constants.ts
|
|
58
|
+
var FIELD_PROTOCOL_VERSION = 1;
|
|
59
|
+
var FIELD_ELEMENT_NAME = CONSENT_FIELD_ELEMENT_NAME;
|
|
60
|
+
var FIELD_MESSAGE_TYPES = {
|
|
61
|
+
READY: "overturo-field:ready",
|
|
62
|
+
STATE: "overturo-field:state",
|
|
63
|
+
RESIZE: "overturo-field:resize",
|
|
64
|
+
COMPLETE: "overturo-field:complete",
|
|
65
|
+
ERROR: "overturo-field:error",
|
|
66
|
+
SUBMIT_REQUESTED: "overturo-field:submit_requested",
|
|
67
|
+
INIT: "overturo-field:init",
|
|
68
|
+
CAPTURE: "overturo-field:capture",
|
|
69
|
+
RESET: "overturo-field:reset"
|
|
70
|
+
};
|
|
71
|
+
var FIELD_DOCUMENT_PATH = "/decisions/fields";
|
|
72
|
+
|
|
73
|
+
// src/field/appearance.ts
|
|
74
|
+
var APPEARANCE_KEYS = ["fontFamily", "fontSize", "text", "muted", "accent", "border", "radius", "density"];
|
|
75
|
+
function sanitiseAppearance(input) {
|
|
76
|
+
const out = {};
|
|
77
|
+
if (!input || typeof input !== "object") return out;
|
|
78
|
+
for (const key of APPEARANCE_KEYS) {
|
|
79
|
+
const value = input[key];
|
|
80
|
+
if (typeof value === "string" && value.length <= 64) out[key] = value;
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
function encodeAppearance(input) {
|
|
85
|
+
const clean = sanitiseAppearance(input);
|
|
86
|
+
if (Object.keys(clean).length === 0) return "";
|
|
87
|
+
const json = JSON.stringify(clean);
|
|
88
|
+
const b64 = btoa(unescape(encodeURIComponent(json)));
|
|
89
|
+
return `#a=${b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/generated/field-v1/envelope.js
|
|
93
|
+
var envelope_default = validate22;
|
|
94
|
+
var schema33 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/field-v1/envelope.json", "title": "Embedded consent field envelope v1", "type": "object", "additionalProperties": false, "required": ["type", "version", "payload", "ts", "message_id"], "properties": { "type": { "type": "string", "enum": ["overturo-field:ready", "overturo-field:state", "overturo-field:resize", "overturo-field:complete", "overturo-field:error", "overturo-field:submit_requested", "overturo-field:init", "overturo-field:capture", "overturo-field:reset"] }, "version": { "type": "integer", "const": 1 }, "payload": { "type": "object", "additionalProperties": true }, "ts": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$" }, "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}$" } } };
|
|
95
|
+
var pattern4 = new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$", "u");
|
|
96
|
+
var pattern5 = 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");
|
|
97
|
+
function validate22(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
98
|
+
;
|
|
99
|
+
let vErrors = null;
|
|
100
|
+
let errors = 0;
|
|
101
|
+
const evaluated0 = validate22.evaluated;
|
|
102
|
+
if (evaluated0.dynamicProps) {
|
|
103
|
+
evaluated0.props = void 0;
|
|
104
|
+
}
|
|
105
|
+
if (evaluated0.dynamicItems) {
|
|
106
|
+
evaluated0.items = void 0;
|
|
107
|
+
}
|
|
108
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
109
|
+
if (data.type === void 0) {
|
|
110
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
111
|
+
if (vErrors === null) {
|
|
112
|
+
vErrors = [err0];
|
|
113
|
+
} else {
|
|
114
|
+
vErrors.push(err0);
|
|
115
|
+
}
|
|
116
|
+
errors++;
|
|
117
|
+
}
|
|
118
|
+
if (data.version === void 0) {
|
|
119
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
|
|
120
|
+
if (vErrors === null) {
|
|
121
|
+
vErrors = [err1];
|
|
122
|
+
} else {
|
|
123
|
+
vErrors.push(err1);
|
|
124
|
+
}
|
|
125
|
+
errors++;
|
|
126
|
+
}
|
|
127
|
+
if (data.payload === void 0) {
|
|
128
|
+
const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "payload" }, message: "must have required property 'payload'" };
|
|
129
|
+
if (vErrors === null) {
|
|
130
|
+
vErrors = [err2];
|
|
131
|
+
} else {
|
|
132
|
+
vErrors.push(err2);
|
|
133
|
+
}
|
|
134
|
+
errors++;
|
|
135
|
+
}
|
|
136
|
+
if (data.ts === void 0) {
|
|
137
|
+
const err3 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "ts" }, message: "must have required property 'ts'" };
|
|
138
|
+
if (vErrors === null) {
|
|
139
|
+
vErrors = [err3];
|
|
140
|
+
} else {
|
|
141
|
+
vErrors.push(err3);
|
|
142
|
+
}
|
|
143
|
+
errors++;
|
|
144
|
+
}
|
|
145
|
+
if (data.message_id === void 0) {
|
|
146
|
+
const err4 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "message_id" }, message: "must have required property 'message_id'" };
|
|
147
|
+
if (vErrors === null) {
|
|
148
|
+
vErrors = [err4];
|
|
149
|
+
} else {
|
|
150
|
+
vErrors.push(err4);
|
|
151
|
+
}
|
|
152
|
+
errors++;
|
|
153
|
+
}
|
|
154
|
+
for (const key0 in data) {
|
|
155
|
+
if (!(key0 === "type" || key0 === "version" || key0 === "payload" || key0 === "ts" || key0 === "message_id")) {
|
|
156
|
+
const err5 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
157
|
+
if (vErrors === null) {
|
|
158
|
+
vErrors = [err5];
|
|
159
|
+
} else {
|
|
160
|
+
vErrors.push(err5);
|
|
161
|
+
}
|
|
162
|
+
errors++;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (data.type !== void 0) {
|
|
166
|
+
let data0 = data.type;
|
|
167
|
+
if (typeof data0 !== "string") {
|
|
168
|
+
const err6 = { instancePath: instancePath + "/type", schemaPath: "#/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
169
|
+
if (vErrors === null) {
|
|
170
|
+
vErrors = [err6];
|
|
171
|
+
} else {
|
|
172
|
+
vErrors.push(err6);
|
|
173
|
+
}
|
|
174
|
+
errors++;
|
|
175
|
+
}
|
|
176
|
+
if (!(data0 === "overturo-field:ready" || data0 === "overturo-field:state" || data0 === "overturo-field:resize" || data0 === "overturo-field:complete" || data0 === "overturo-field:error" || data0 === "overturo-field:submit_requested" || data0 === "overturo-field:init" || data0 === "overturo-field:capture" || data0 === "overturo-field:reset")) {
|
|
177
|
+
const err7 = { instancePath: instancePath + "/type", schemaPath: "#/properties/type/enum", keyword: "enum", params: { allowedValues: schema33.properties.type.enum }, message: "must be equal to one of the allowed values" };
|
|
178
|
+
if (vErrors === null) {
|
|
179
|
+
vErrors = [err7];
|
|
180
|
+
} else {
|
|
181
|
+
vErrors.push(err7);
|
|
182
|
+
}
|
|
183
|
+
errors++;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (data.version !== void 0) {
|
|
187
|
+
let data1 = data.version;
|
|
188
|
+
if (!(typeof data1 == "number" && (!(data1 % 1) && !isNaN(data1)))) {
|
|
189
|
+
const err8 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
190
|
+
if (vErrors === null) {
|
|
191
|
+
vErrors = [err8];
|
|
192
|
+
} else {
|
|
193
|
+
vErrors.push(err8);
|
|
194
|
+
}
|
|
195
|
+
errors++;
|
|
196
|
+
}
|
|
197
|
+
if (1 !== data1) {
|
|
198
|
+
const err9 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/const", keyword: "const", params: { allowedValue: 1 }, message: "must be equal to constant" };
|
|
199
|
+
if (vErrors === null) {
|
|
200
|
+
vErrors = [err9];
|
|
201
|
+
} else {
|
|
202
|
+
vErrors.push(err9);
|
|
203
|
+
}
|
|
204
|
+
errors++;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (data.payload !== void 0) {
|
|
208
|
+
let data2 = data.payload;
|
|
209
|
+
if (data2 && typeof data2 == "object" && !Array.isArray(data2)) {
|
|
210
|
+
} else {
|
|
211
|
+
const err10 = { instancePath: instancePath + "/payload", schemaPath: "#/properties/payload/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
212
|
+
if (vErrors === null) {
|
|
213
|
+
vErrors = [err10];
|
|
214
|
+
} else {
|
|
215
|
+
vErrors.push(err10);
|
|
216
|
+
}
|
|
217
|
+
errors++;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (data.ts !== void 0) {
|
|
221
|
+
let data3 = data.ts;
|
|
222
|
+
if (typeof data3 === "string") {
|
|
223
|
+
if (!pattern4.test(data3)) {
|
|
224
|
+
const err11 = { instancePath: instancePath + "/ts", schemaPath: "#/properties/ts/pattern", keyword: "pattern", params: { pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$" }, message: 'must match pattern "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$"' };
|
|
225
|
+
if (vErrors === null) {
|
|
226
|
+
vErrors = [err11];
|
|
227
|
+
} else {
|
|
228
|
+
vErrors.push(err11);
|
|
229
|
+
}
|
|
230
|
+
errors++;
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
const err12 = { instancePath: instancePath + "/ts", schemaPath: "#/properties/ts/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
234
|
+
if (vErrors === null) {
|
|
235
|
+
vErrors = [err12];
|
|
236
|
+
} else {
|
|
237
|
+
vErrors.push(err12);
|
|
238
|
+
}
|
|
239
|
+
errors++;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (data.message_id !== void 0) {
|
|
243
|
+
let data4 = data.message_id;
|
|
244
|
+
if (typeof data4 === "string") {
|
|
245
|
+
if (!pattern5.test(data4)) {
|
|
246
|
+
const err13 = { 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}$"' };
|
|
247
|
+
if (vErrors === null) {
|
|
248
|
+
vErrors = [err13];
|
|
249
|
+
} else {
|
|
250
|
+
vErrors.push(err13);
|
|
251
|
+
}
|
|
252
|
+
errors++;
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
const err14 = { instancePath: instancePath + "/message_id", schemaPath: "#/properties/message_id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
256
|
+
if (vErrors === null) {
|
|
257
|
+
vErrors = [err14];
|
|
258
|
+
} else {
|
|
259
|
+
vErrors.push(err14);
|
|
260
|
+
}
|
|
261
|
+
errors++;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
const err15 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
266
|
+
if (vErrors === null) {
|
|
267
|
+
vErrors = [err15];
|
|
268
|
+
} else {
|
|
269
|
+
vErrors.push(err15);
|
|
270
|
+
}
|
|
271
|
+
errors++;
|
|
272
|
+
}
|
|
273
|
+
validate22.errors = vErrors;
|
|
274
|
+
return errors === 0;
|
|
275
|
+
}
|
|
276
|
+
validate22.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
277
|
+
|
|
278
|
+
// src/generated/field-v1/ready.js
|
|
279
|
+
var ready_default = validate25;
|
|
280
|
+
function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
281
|
+
;
|
|
282
|
+
let vErrors = null;
|
|
283
|
+
let errors = 0;
|
|
284
|
+
const evaluated0 = validate25.evaluated;
|
|
285
|
+
if (evaluated0.dynamicProps) {
|
|
286
|
+
evaluated0.props = void 0;
|
|
287
|
+
}
|
|
288
|
+
if (evaluated0.dynamicItems) {
|
|
289
|
+
evaluated0.items = void 0;
|
|
290
|
+
}
|
|
291
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
292
|
+
} else {
|
|
293
|
+
const err0 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
294
|
+
if (vErrors === null) {
|
|
295
|
+
vErrors = [err0];
|
|
296
|
+
} else {
|
|
297
|
+
vErrors.push(err0);
|
|
298
|
+
}
|
|
299
|
+
errors++;
|
|
300
|
+
}
|
|
301
|
+
validate25.errors = vErrors;
|
|
302
|
+
return errors === 0;
|
|
303
|
+
}
|
|
304
|
+
validate25.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
305
|
+
|
|
306
|
+
// src/generated/field-v1/state.js
|
|
307
|
+
var state_default = validate28;
|
|
308
|
+
var schema39 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/field-v1/state.json", "title": "STATE payload", "type": "object", "additionalProperties": true, "required": ["decisions"], "properties": { "decisions": { "type": "object", "additionalProperties": { "type": "string", "enum": ["granted", "declined"] } } } };
|
|
309
|
+
function validate28(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
310
|
+
;
|
|
311
|
+
let vErrors = null;
|
|
312
|
+
let errors = 0;
|
|
313
|
+
const evaluated0 = validate28.evaluated;
|
|
314
|
+
if (evaluated0.dynamicProps) {
|
|
315
|
+
evaluated0.props = void 0;
|
|
316
|
+
}
|
|
317
|
+
if (evaluated0.dynamicItems) {
|
|
318
|
+
evaluated0.items = void 0;
|
|
319
|
+
}
|
|
320
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
321
|
+
if (data.decisions === void 0) {
|
|
322
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "decisions" }, message: "must have required property 'decisions'" };
|
|
323
|
+
if (vErrors === null) {
|
|
324
|
+
vErrors = [err0];
|
|
325
|
+
} else {
|
|
326
|
+
vErrors.push(err0);
|
|
327
|
+
}
|
|
328
|
+
errors++;
|
|
329
|
+
}
|
|
330
|
+
if (data.decisions !== void 0) {
|
|
331
|
+
let data0 = data.decisions;
|
|
332
|
+
if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
|
|
333
|
+
for (const key0 in data0) {
|
|
334
|
+
let data1 = data0[key0];
|
|
335
|
+
if (typeof data1 !== "string") {
|
|
336
|
+
const err1 = { instancePath: instancePath + "/decisions/" + key0.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/decisions/additionalProperties/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
337
|
+
if (vErrors === null) {
|
|
338
|
+
vErrors = [err1];
|
|
339
|
+
} else {
|
|
340
|
+
vErrors.push(err1);
|
|
341
|
+
}
|
|
342
|
+
errors++;
|
|
343
|
+
}
|
|
344
|
+
if (!(data1 === "granted" || data1 === "declined")) {
|
|
345
|
+
const err2 = { instancePath: instancePath + "/decisions/" + key0.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/decisions/additionalProperties/enum", keyword: "enum", params: { allowedValues: schema39.properties.decisions.additionalProperties.enum }, message: "must be equal to one of the allowed values" };
|
|
346
|
+
if (vErrors === null) {
|
|
347
|
+
vErrors = [err2];
|
|
348
|
+
} else {
|
|
349
|
+
vErrors.push(err2);
|
|
350
|
+
}
|
|
351
|
+
errors++;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
const err3 = { instancePath: instancePath + "/decisions", schemaPath: "#/properties/decisions/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
356
|
+
if (vErrors === null) {
|
|
357
|
+
vErrors = [err3];
|
|
358
|
+
} else {
|
|
359
|
+
vErrors.push(err3);
|
|
360
|
+
}
|
|
361
|
+
errors++;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
} else {
|
|
365
|
+
const err4 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
366
|
+
if (vErrors === null) {
|
|
367
|
+
vErrors = [err4];
|
|
368
|
+
} else {
|
|
369
|
+
vErrors.push(err4);
|
|
370
|
+
}
|
|
371
|
+
errors++;
|
|
372
|
+
}
|
|
373
|
+
validate28.errors = vErrors;
|
|
374
|
+
return errors === 0;
|
|
375
|
+
}
|
|
376
|
+
validate28.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
377
|
+
|
|
378
|
+
// src/generated/field-v1/resize.js
|
|
379
|
+
var resize_default = validate27;
|
|
380
|
+
function validate27(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
381
|
+
;
|
|
382
|
+
let vErrors = null;
|
|
383
|
+
let errors = 0;
|
|
384
|
+
const evaluated0 = validate27.evaluated;
|
|
385
|
+
if (evaluated0.dynamicProps) {
|
|
386
|
+
evaluated0.props = void 0;
|
|
387
|
+
}
|
|
388
|
+
if (evaluated0.dynamicItems) {
|
|
389
|
+
evaluated0.items = void 0;
|
|
390
|
+
}
|
|
391
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
392
|
+
if (data.height === void 0) {
|
|
393
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "height" }, message: "must have required property 'height'" };
|
|
394
|
+
if (vErrors === null) {
|
|
395
|
+
vErrors = [err0];
|
|
396
|
+
} else {
|
|
397
|
+
vErrors.push(err0);
|
|
398
|
+
}
|
|
399
|
+
errors++;
|
|
400
|
+
}
|
|
401
|
+
if (data.height !== void 0) {
|
|
402
|
+
let data0 = data.height;
|
|
403
|
+
if (!(typeof data0 == "number" && (!(data0 % 1) && !isNaN(data0)))) {
|
|
404
|
+
const err1 = { instancePath: instancePath + "/height", schemaPath: "#/properties/height/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
405
|
+
if (vErrors === null) {
|
|
406
|
+
vErrors = [err1];
|
|
407
|
+
} else {
|
|
408
|
+
vErrors.push(err1);
|
|
409
|
+
}
|
|
410
|
+
errors++;
|
|
411
|
+
}
|
|
412
|
+
if (typeof data0 == "number") {
|
|
413
|
+
if (data0 < 0 || isNaN(data0)) {
|
|
414
|
+
const err2 = { instancePath: instancePath + "/height", schemaPath: "#/properties/height/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
|
|
415
|
+
if (vErrors === null) {
|
|
416
|
+
vErrors = [err2];
|
|
417
|
+
} else {
|
|
418
|
+
vErrors.push(err2);
|
|
419
|
+
}
|
|
420
|
+
errors++;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} else {
|
|
425
|
+
const err3 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
426
|
+
if (vErrors === null) {
|
|
427
|
+
vErrors = [err3];
|
|
428
|
+
} else {
|
|
429
|
+
vErrors.push(err3);
|
|
430
|
+
}
|
|
431
|
+
errors++;
|
|
432
|
+
}
|
|
433
|
+
validate27.errors = vErrors;
|
|
434
|
+
return errors === 0;
|
|
435
|
+
}
|
|
436
|
+
validate27.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
437
|
+
|
|
438
|
+
// src/generated/field-v1/complete.js
|
|
439
|
+
var complete_default = validate21;
|
|
440
|
+
var schema32 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/field-v1/complete.json", "title": "COMPLETE payload (the capture token)", "type": "object", "additionalProperties": true, "required": ["token", "committed"], "properties": { "token": { "type": "string", "minLength": 1 }, "committed": { "type": "boolean" }, "record_id": { "type": ["string", "null"] } } };
|
|
441
|
+
var func1 = require_ucs2length().default;
|
|
442
|
+
function validate21(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
443
|
+
;
|
|
444
|
+
let vErrors = null;
|
|
445
|
+
let errors = 0;
|
|
446
|
+
const evaluated0 = validate21.evaluated;
|
|
447
|
+
if (evaluated0.dynamicProps) {
|
|
448
|
+
evaluated0.props = void 0;
|
|
449
|
+
}
|
|
450
|
+
if (evaluated0.dynamicItems) {
|
|
451
|
+
evaluated0.items = void 0;
|
|
452
|
+
}
|
|
453
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
454
|
+
if (data.token === void 0) {
|
|
455
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "token" }, message: "must have required property 'token'" };
|
|
456
|
+
if (vErrors === null) {
|
|
457
|
+
vErrors = [err0];
|
|
458
|
+
} else {
|
|
459
|
+
vErrors.push(err0);
|
|
460
|
+
}
|
|
461
|
+
errors++;
|
|
462
|
+
}
|
|
463
|
+
if (data.committed === void 0) {
|
|
464
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "committed" }, message: "must have required property 'committed'" };
|
|
465
|
+
if (vErrors === null) {
|
|
466
|
+
vErrors = [err1];
|
|
467
|
+
} else {
|
|
468
|
+
vErrors.push(err1);
|
|
469
|
+
}
|
|
470
|
+
errors++;
|
|
471
|
+
}
|
|
472
|
+
if (data.token !== void 0) {
|
|
473
|
+
let data0 = data.token;
|
|
474
|
+
if (typeof data0 === "string") {
|
|
475
|
+
if (func1(data0) < 1) {
|
|
476
|
+
const err2 = { instancePath: instancePath + "/token", schemaPath: "#/properties/token/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
477
|
+
if (vErrors === null) {
|
|
478
|
+
vErrors = [err2];
|
|
479
|
+
} else {
|
|
480
|
+
vErrors.push(err2);
|
|
481
|
+
}
|
|
482
|
+
errors++;
|
|
483
|
+
}
|
|
484
|
+
} else {
|
|
485
|
+
const err3 = { instancePath: instancePath + "/token", schemaPath: "#/properties/token/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
486
|
+
if (vErrors === null) {
|
|
487
|
+
vErrors = [err3];
|
|
488
|
+
} else {
|
|
489
|
+
vErrors.push(err3);
|
|
490
|
+
}
|
|
491
|
+
errors++;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (data.committed !== void 0) {
|
|
495
|
+
if (typeof data.committed !== "boolean") {
|
|
496
|
+
const err4 = { instancePath: instancePath + "/committed", schemaPath: "#/properties/committed/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" };
|
|
497
|
+
if (vErrors === null) {
|
|
498
|
+
vErrors = [err4];
|
|
499
|
+
} else {
|
|
500
|
+
vErrors.push(err4);
|
|
501
|
+
}
|
|
502
|
+
errors++;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
if (data.record_id !== void 0) {
|
|
506
|
+
let data2 = data.record_id;
|
|
507
|
+
if (typeof data2 !== "string" && data2 !== null) {
|
|
508
|
+
const err5 = { instancePath: instancePath + "/record_id", schemaPath: "#/properties/record_id/type", keyword: "type", params: { type: schema32.properties.record_id.type }, message: "must be string,null" };
|
|
509
|
+
if (vErrors === null) {
|
|
510
|
+
vErrors = [err5];
|
|
511
|
+
} else {
|
|
512
|
+
vErrors.push(err5);
|
|
513
|
+
}
|
|
514
|
+
errors++;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
} else {
|
|
518
|
+
const err6 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
519
|
+
if (vErrors === null) {
|
|
520
|
+
vErrors = [err6];
|
|
521
|
+
} else {
|
|
522
|
+
vErrors.push(err6);
|
|
523
|
+
}
|
|
524
|
+
errors++;
|
|
525
|
+
}
|
|
526
|
+
validate21.errors = vErrors;
|
|
527
|
+
return errors === 0;
|
|
528
|
+
}
|
|
529
|
+
validate21.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
530
|
+
|
|
531
|
+
// src/generated/field-v1/error.js
|
|
532
|
+
var error_default = validate23;
|
|
533
|
+
var func12 = require_ucs2length().default;
|
|
534
|
+
function validate23(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
535
|
+
;
|
|
536
|
+
let vErrors = null;
|
|
537
|
+
let errors = 0;
|
|
538
|
+
const evaluated0 = validate23.evaluated;
|
|
539
|
+
if (evaluated0.dynamicProps) {
|
|
540
|
+
evaluated0.props = void 0;
|
|
541
|
+
}
|
|
542
|
+
if (evaluated0.dynamicItems) {
|
|
543
|
+
evaluated0.items = void 0;
|
|
544
|
+
}
|
|
545
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
546
|
+
if (data.code === void 0) {
|
|
547
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "code" }, message: "must have required property 'code'" };
|
|
548
|
+
if (vErrors === null) {
|
|
549
|
+
vErrors = [err0];
|
|
550
|
+
} else {
|
|
551
|
+
vErrors.push(err0);
|
|
552
|
+
}
|
|
553
|
+
errors++;
|
|
554
|
+
}
|
|
555
|
+
if (data.code !== void 0) {
|
|
556
|
+
let data0 = data.code;
|
|
557
|
+
if (typeof data0 === "string") {
|
|
558
|
+
if (func12(data0) < 1) {
|
|
559
|
+
const err1 = { instancePath: instancePath + "/code", schemaPath: "#/properties/code/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
560
|
+
if (vErrors === null) {
|
|
561
|
+
vErrors = [err1];
|
|
562
|
+
} else {
|
|
563
|
+
vErrors.push(err1);
|
|
564
|
+
}
|
|
565
|
+
errors++;
|
|
566
|
+
}
|
|
567
|
+
} else {
|
|
568
|
+
const err2 = { instancePath: instancePath + "/code", schemaPath: "#/properties/code/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
569
|
+
if (vErrors === null) {
|
|
570
|
+
vErrors = [err2];
|
|
571
|
+
} else {
|
|
572
|
+
vErrors.push(err2);
|
|
573
|
+
}
|
|
574
|
+
errors++;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
if (data.message !== void 0) {
|
|
578
|
+
if (typeof data.message !== "string") {
|
|
579
|
+
const err3 = { instancePath: instancePath + "/message", schemaPath: "#/properties/message/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
580
|
+
if (vErrors === null) {
|
|
581
|
+
vErrors = [err3];
|
|
582
|
+
} else {
|
|
583
|
+
vErrors.push(err3);
|
|
584
|
+
}
|
|
585
|
+
errors++;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
} else {
|
|
589
|
+
const err4 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
590
|
+
if (vErrors === null) {
|
|
591
|
+
vErrors = [err4];
|
|
592
|
+
} else {
|
|
593
|
+
vErrors.push(err4);
|
|
594
|
+
}
|
|
595
|
+
errors++;
|
|
596
|
+
}
|
|
597
|
+
validate23.errors = vErrors;
|
|
598
|
+
return errors === 0;
|
|
599
|
+
}
|
|
600
|
+
validate23.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
601
|
+
|
|
602
|
+
// src/generated/field-v1/submit_requested.js
|
|
603
|
+
var submit_requested_default = validate29;
|
|
604
|
+
function validate29(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
605
|
+
;
|
|
606
|
+
let vErrors = null;
|
|
607
|
+
let errors = 0;
|
|
608
|
+
const evaluated0 = validate29.evaluated;
|
|
609
|
+
if (evaluated0.dynamicProps) {
|
|
610
|
+
evaluated0.props = void 0;
|
|
611
|
+
}
|
|
612
|
+
if (evaluated0.dynamicItems) {
|
|
613
|
+
evaluated0.items = void 0;
|
|
614
|
+
}
|
|
615
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
616
|
+
} else {
|
|
617
|
+
const err0 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
618
|
+
if (vErrors === null) {
|
|
619
|
+
vErrors = [err0];
|
|
620
|
+
} else {
|
|
621
|
+
vErrors.push(err0);
|
|
622
|
+
}
|
|
623
|
+
errors++;
|
|
624
|
+
}
|
|
625
|
+
validate29.errors = vErrors;
|
|
626
|
+
return errors === 0;
|
|
627
|
+
}
|
|
628
|
+
validate29.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
629
|
+
|
|
630
|
+
// src/generated/field-v1/init.js
|
|
631
|
+
var init_default = validate24;
|
|
632
|
+
function validate24(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
633
|
+
;
|
|
634
|
+
let vErrors = null;
|
|
635
|
+
let errors = 0;
|
|
636
|
+
const evaluated0 = validate24.evaluated;
|
|
637
|
+
if (evaluated0.dynamicProps) {
|
|
638
|
+
evaluated0.props = void 0;
|
|
639
|
+
}
|
|
640
|
+
if (evaluated0.dynamicItems) {
|
|
641
|
+
evaluated0.items = void 0;
|
|
642
|
+
}
|
|
643
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
644
|
+
if (data.locale !== void 0) {
|
|
645
|
+
if (typeof data.locale !== "string") {
|
|
646
|
+
const err0 = { instancePath: instancePath + "/locale", schemaPath: "#/properties/locale/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
647
|
+
if (vErrors === null) {
|
|
648
|
+
vErrors = [err0];
|
|
649
|
+
} else {
|
|
650
|
+
vErrors.push(err0);
|
|
651
|
+
}
|
|
652
|
+
errors++;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
} else {
|
|
656
|
+
const err1 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
657
|
+
if (vErrors === null) {
|
|
658
|
+
vErrors = [err1];
|
|
659
|
+
} else {
|
|
660
|
+
vErrors.push(err1);
|
|
661
|
+
}
|
|
662
|
+
errors++;
|
|
663
|
+
}
|
|
664
|
+
validate24.errors = vErrors;
|
|
665
|
+
return errors === 0;
|
|
666
|
+
}
|
|
667
|
+
validate24.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
668
|
+
|
|
669
|
+
// src/generated/field-v1/capture.js
|
|
670
|
+
var capture_default = validate20;
|
|
671
|
+
var schema31 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.overturo.com/field-v1/capture.json", "title": "CAPTURE payload (host \u2192 frame; what only the host knows)", "type": "object", "additionalProperties": true, "properties": { "subject": { "type": "object", "additionalProperties": true, "properties": { "email": { "type": "string" }, "external_id": { "type": "string" } } }, "page_url": { "type": ["string", "null"] }, "form_id": { "type": ["string", "null"] }, "submitter": { "type": ["string", "null"] }, "commit": { "type": "boolean" } } };
|
|
672
|
+
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
673
|
+
;
|
|
674
|
+
let vErrors = null;
|
|
675
|
+
let errors = 0;
|
|
676
|
+
const evaluated0 = validate20.evaluated;
|
|
677
|
+
if (evaluated0.dynamicProps) {
|
|
678
|
+
evaluated0.props = void 0;
|
|
679
|
+
}
|
|
680
|
+
if (evaluated0.dynamicItems) {
|
|
681
|
+
evaluated0.items = void 0;
|
|
682
|
+
}
|
|
683
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
684
|
+
if (data.subject !== void 0) {
|
|
685
|
+
let data0 = data.subject;
|
|
686
|
+
if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
|
|
687
|
+
if (data0.email !== void 0) {
|
|
688
|
+
if (typeof data0.email !== "string") {
|
|
689
|
+
const err0 = { instancePath: instancePath + "/subject/email", schemaPath: "#/properties/subject/properties/email/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
690
|
+
if (vErrors === null) {
|
|
691
|
+
vErrors = [err0];
|
|
692
|
+
} else {
|
|
693
|
+
vErrors.push(err0);
|
|
694
|
+
}
|
|
695
|
+
errors++;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (data0.external_id !== void 0) {
|
|
699
|
+
if (typeof data0.external_id !== "string") {
|
|
700
|
+
const err1 = { instancePath: instancePath + "/subject/external_id", schemaPath: "#/properties/subject/properties/external_id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
701
|
+
if (vErrors === null) {
|
|
702
|
+
vErrors = [err1];
|
|
703
|
+
} else {
|
|
704
|
+
vErrors.push(err1);
|
|
705
|
+
}
|
|
706
|
+
errors++;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
} else {
|
|
710
|
+
const err2 = { instancePath: instancePath + "/subject", schemaPath: "#/properties/subject/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
711
|
+
if (vErrors === null) {
|
|
712
|
+
vErrors = [err2];
|
|
713
|
+
} else {
|
|
714
|
+
vErrors.push(err2);
|
|
715
|
+
}
|
|
716
|
+
errors++;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
if (data.page_url !== void 0) {
|
|
720
|
+
let data3 = data.page_url;
|
|
721
|
+
if (typeof data3 !== "string" && data3 !== null) {
|
|
722
|
+
const err3 = { instancePath: instancePath + "/page_url", schemaPath: "#/properties/page_url/type", keyword: "type", params: { type: schema31.properties.page_url.type }, message: "must be string,null" };
|
|
723
|
+
if (vErrors === null) {
|
|
724
|
+
vErrors = [err3];
|
|
725
|
+
} else {
|
|
726
|
+
vErrors.push(err3);
|
|
727
|
+
}
|
|
728
|
+
errors++;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
if (data.form_id !== void 0) {
|
|
732
|
+
let data4 = data.form_id;
|
|
733
|
+
if (typeof data4 !== "string" && data4 !== null) {
|
|
734
|
+
const err4 = { instancePath: instancePath + "/form_id", schemaPath: "#/properties/form_id/type", keyword: "type", params: { type: schema31.properties.form_id.type }, message: "must be string,null" };
|
|
735
|
+
if (vErrors === null) {
|
|
736
|
+
vErrors = [err4];
|
|
737
|
+
} else {
|
|
738
|
+
vErrors.push(err4);
|
|
739
|
+
}
|
|
740
|
+
errors++;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
if (data.submitter !== void 0) {
|
|
744
|
+
let data5 = data.submitter;
|
|
745
|
+
if (typeof data5 !== "string" && data5 !== null) {
|
|
746
|
+
const err5 = { instancePath: instancePath + "/submitter", schemaPath: "#/properties/submitter/type", keyword: "type", params: { type: schema31.properties.submitter.type }, message: "must be string,null" };
|
|
747
|
+
if (vErrors === null) {
|
|
748
|
+
vErrors = [err5];
|
|
749
|
+
} else {
|
|
750
|
+
vErrors.push(err5);
|
|
751
|
+
}
|
|
752
|
+
errors++;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (data.commit !== void 0) {
|
|
756
|
+
if (typeof data.commit !== "boolean") {
|
|
757
|
+
const err6 = { instancePath: instancePath + "/commit", schemaPath: "#/properties/commit/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" };
|
|
758
|
+
if (vErrors === null) {
|
|
759
|
+
vErrors = [err6];
|
|
760
|
+
} else {
|
|
761
|
+
vErrors.push(err6);
|
|
762
|
+
}
|
|
763
|
+
errors++;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
} else {
|
|
767
|
+
const err7 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
768
|
+
if (vErrors === null) {
|
|
769
|
+
vErrors = [err7];
|
|
770
|
+
} else {
|
|
771
|
+
vErrors.push(err7);
|
|
772
|
+
}
|
|
773
|
+
errors++;
|
|
774
|
+
}
|
|
775
|
+
validate20.errors = vErrors;
|
|
776
|
+
return errors === 0;
|
|
777
|
+
}
|
|
778
|
+
validate20.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
779
|
+
|
|
780
|
+
// src/generated/field-v1/reset.js
|
|
781
|
+
var reset_default = validate26;
|
|
782
|
+
function validate26(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
783
|
+
;
|
|
784
|
+
let vErrors = null;
|
|
785
|
+
let errors = 0;
|
|
786
|
+
const evaluated0 = validate26.evaluated;
|
|
787
|
+
if (evaluated0.dynamicProps) {
|
|
788
|
+
evaluated0.props = void 0;
|
|
789
|
+
}
|
|
790
|
+
if (evaluated0.dynamicItems) {
|
|
791
|
+
evaluated0.items = void 0;
|
|
792
|
+
}
|
|
793
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
794
|
+
} else {
|
|
795
|
+
const err0 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
796
|
+
if (vErrors === null) {
|
|
797
|
+
vErrors = [err0];
|
|
798
|
+
} else {
|
|
799
|
+
vErrors.push(err0);
|
|
800
|
+
}
|
|
801
|
+
errors++;
|
|
802
|
+
}
|
|
803
|
+
validate26.errors = vErrors;
|
|
804
|
+
return errors === 0;
|
|
805
|
+
}
|
|
806
|
+
validate26.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
807
|
+
|
|
808
|
+
// src/field/protocol.ts
|
|
809
|
+
var VALIDATORS = {
|
|
810
|
+
[FIELD_MESSAGE_TYPES.READY]: ready_default,
|
|
811
|
+
[FIELD_MESSAGE_TYPES.STATE]: state_default,
|
|
812
|
+
[FIELD_MESSAGE_TYPES.RESIZE]: resize_default,
|
|
813
|
+
[FIELD_MESSAGE_TYPES.COMPLETE]: complete_default,
|
|
814
|
+
[FIELD_MESSAGE_TYPES.ERROR]: error_default,
|
|
815
|
+
[FIELD_MESSAGE_TYPES.SUBMIT_REQUESTED]: submit_requested_default,
|
|
816
|
+
[FIELD_MESSAGE_TYPES.INIT]: init_default,
|
|
817
|
+
[FIELD_MESSAGE_TYPES.CAPTURE]: capture_default,
|
|
818
|
+
[FIELD_MESSAGE_TYPES.RESET]: reset_default
|
|
819
|
+
};
|
|
820
|
+
var envelopeFn = envelope_default;
|
|
821
|
+
function validateFieldEnvelope(message) {
|
|
822
|
+
const valid = envelopeFn(message);
|
|
823
|
+
return { valid, errors: valid ? null : envelopeFn.errors ?? null };
|
|
824
|
+
}
|
|
825
|
+
function validateFieldPayload(message) {
|
|
826
|
+
const validator = VALIDATORS[message.type];
|
|
827
|
+
if (!validator) return { valid: false, errors: [{ message: `Unknown type ${message.type}` }] };
|
|
828
|
+
const valid = validator(message.payload);
|
|
829
|
+
return { valid, errors: valid ? null : validator.errors ?? null };
|
|
830
|
+
}
|
|
831
|
+
function validateField(message) {
|
|
832
|
+
const envelopeResult = validateFieldEnvelope(message);
|
|
833
|
+
if (!envelopeResult.valid) return envelopeResult;
|
|
834
|
+
return validateFieldPayload(message);
|
|
835
|
+
}
|
|
836
|
+
function fieldEnvelope(type, payload) {
|
|
837
|
+
return { type, version: FIELD_PROTOCOL_VERSION, payload, ts: (/* @__PURE__ */ new Date()).toISOString(), message_id: uuidV4() };
|
|
838
|
+
}
|
|
839
|
+
function uuidV4() {
|
|
840
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
|
|
841
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
842
|
+
const r = Math.random() * 16 | 0;
|
|
843
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// src/errors.ts
|
|
848
|
+
var OverturoError = class extends Error {
|
|
849
|
+
constructor(message) {
|
|
850
|
+
super(message);
|
|
851
|
+
this.name = "OverturoError";
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
var OverturoValidationError = class extends OverturoError {
|
|
855
|
+
constructor(message) {
|
|
856
|
+
super(message);
|
|
857
|
+
this.name = "OverturoValidationError";
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
// src/forms/intercept.ts
|
|
862
|
+
var DEFAULT_TOKEN_FIELD = "overturo_capture_token";
|
|
863
|
+
var CAPTURED_MARK = "overturoCaptured";
|
|
864
|
+
var CAPTURE_TIMEOUT_MS = 5e3;
|
|
865
|
+
var attached = /* @__PURE__ */ new WeakMap();
|
|
866
|
+
function interceptSubmit(form, opts, run) {
|
|
867
|
+
if (attached.has(form)) {
|
|
868
|
+
throw new OverturoValidationError("duplicate_attach: this form already has a capture interception; detach it before attaching again");
|
|
869
|
+
}
|
|
870
|
+
attached.set(form, true);
|
|
871
|
+
let inFlight = false;
|
|
872
|
+
const tokenField = opts.tokenFieldName ?? DEFAULT_TOKEN_FIELD;
|
|
873
|
+
const handler = (ev) => {
|
|
874
|
+
if (form.dataset[CAPTURED_MARK] === "1") {
|
|
875
|
+
delete form.dataset[CAPTURED_MARK];
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
ev.preventDefault();
|
|
879
|
+
ev.stopImmediatePropagation();
|
|
880
|
+
if (inFlight) return;
|
|
881
|
+
inFlight = true;
|
|
882
|
+
form.querySelector(`input[name="${tokenField}"]`)?.remove();
|
|
883
|
+
const submitter = ev.submitter ?? null;
|
|
884
|
+
void (async () => {
|
|
885
|
+
try {
|
|
886
|
+
const { token } = await withTimeout(run({ submitter }), CAPTURE_TIMEOUT_MS);
|
|
887
|
+
setHiddenInput(form, tokenField, token);
|
|
888
|
+
} catch (e) {
|
|
889
|
+
opts.onError?.(e);
|
|
890
|
+
} finally {
|
|
891
|
+
inFlight = false;
|
|
892
|
+
if (opts.submitAfterCapture !== false) {
|
|
893
|
+
form.dataset[CAPTURED_MARK] = "1";
|
|
894
|
+
resubmit(form, submitter);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
})();
|
|
898
|
+
};
|
|
899
|
+
form.addEventListener("submit", handler, { capture: true });
|
|
900
|
+
return () => {
|
|
901
|
+
attached.delete(form);
|
|
902
|
+
form.removeEventListener("submit", handler, { capture: true });
|
|
903
|
+
delete form.dataset[CAPTURED_MARK];
|
|
904
|
+
form.querySelector(`input[name="${tokenField}"]`)?.remove();
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
function withTimeout(promise, ms) {
|
|
908
|
+
return new Promise((resolve, reject) => {
|
|
909
|
+
const timer = setTimeout(
|
|
910
|
+
() => reject(new OverturoValidationError(`capture timed out after ${ms} ms; the form submits without a capture token`)),
|
|
911
|
+
ms
|
|
912
|
+
);
|
|
913
|
+
promise.then(
|
|
914
|
+
(v) => {
|
|
915
|
+
clearTimeout(timer);
|
|
916
|
+
resolve(v);
|
|
917
|
+
},
|
|
918
|
+
(e) => {
|
|
919
|
+
clearTimeout(timer);
|
|
920
|
+
reject(e);
|
|
921
|
+
}
|
|
922
|
+
);
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
function resubmit(form, submitter) {
|
|
926
|
+
if (submitter && submitter.isConnected && typeof form.requestSubmit === "function") {
|
|
927
|
+
try {
|
|
928
|
+
form.requestSubmit(submitter);
|
|
929
|
+
return;
|
|
930
|
+
} catch {
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
if (typeof form.requestSubmit === "function") form.requestSubmit();
|
|
934
|
+
else if (submitter && typeof submitter.click === "function") submitter.click();
|
|
935
|
+
else form.submit();
|
|
936
|
+
}
|
|
937
|
+
function setHiddenInput(form, name, value) {
|
|
938
|
+
let input = form.querySelector(`input[name="${name}"]`);
|
|
939
|
+
if (!input) {
|
|
940
|
+
input = document.createElement("input");
|
|
941
|
+
input.type = "hidden";
|
|
942
|
+
input.name = name;
|
|
943
|
+
form.appendChild(input);
|
|
944
|
+
}
|
|
945
|
+
input.value = value;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// src/forms/presentation.ts
|
|
949
|
+
function resolveControl(root, selector) {
|
|
950
|
+
const el = root.querySelector(selector);
|
|
951
|
+
return el instanceof HTMLInputElement ? el : null;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// src/element_base.ts
|
|
955
|
+
var ElementBase = typeof HTMLElement === "undefined" ? class {
|
|
956
|
+
} : HTMLElement;
|
|
957
|
+
|
|
958
|
+
// src/field/element.ts
|
|
959
|
+
var FIELD_ALREADY_DEFINED_CODE = "OVERTURO_FIELD_ELEMENT_ALREADY_DEFINED";
|
|
960
|
+
var FieldCaptureError = class extends Error {
|
|
961
|
+
constructor(code, message) {
|
|
962
|
+
super(message || code);
|
|
963
|
+
this.name = "FieldCaptureError";
|
|
964
|
+
this.code = code;
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
var _internals, _shadow, _iframe, _ac, _frameOrigin, _ready, _value, _decisions, _pending, _ConsentFieldElement_instances, mount_fn, _onMessage, post_fn, setValue_fn, emit_fn, teardown_fn;
|
|
968
|
+
var ConsentFieldElement = class extends ElementBase {
|
|
969
|
+
constructor() {
|
|
970
|
+
super();
|
|
971
|
+
__privateAdd(this, _ConsentFieldElement_instances);
|
|
972
|
+
__privateAdd(this, _internals, null);
|
|
973
|
+
__privateAdd(this, _shadow);
|
|
974
|
+
__privateAdd(this, _iframe, null);
|
|
975
|
+
__privateAdd(this, _ac, null);
|
|
976
|
+
__privateAdd(this, _frameOrigin, "");
|
|
977
|
+
__privateAdd(this, _ready, false);
|
|
978
|
+
__privateAdd(this, _value, "");
|
|
979
|
+
__privateAdd(this, _decisions, {});
|
|
980
|
+
__privateAdd(this, _pending, null);
|
|
981
|
+
__privateAdd(this, _onMessage, (event) => {
|
|
982
|
+
if (!__privateGet(this, _iframe) || event.origin !== __privateGet(this, _frameOrigin)) return;
|
|
983
|
+
const source = __privateGet(this, _iframe).contentWindow;
|
|
984
|
+
if (!source || event.source !== source) return;
|
|
985
|
+
const result = validateField(event.data);
|
|
986
|
+
if (!result.valid) {
|
|
987
|
+
__privateMethod(this, _ConsentFieldElement_instances, emit_fn).call(this, "field:error", { code: "protocol_violation" });
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
const envelope = event.data;
|
|
991
|
+
switch (envelope.type) {
|
|
992
|
+
case FIELD_MESSAGE_TYPES.READY:
|
|
993
|
+
__privateSet(this, _ready, true);
|
|
994
|
+
this.setAttribute("aria-busy", "false");
|
|
995
|
+
__privateMethod(this, _ConsentFieldElement_instances, post_fn).call(this, FIELD_MESSAGE_TYPES.INIT, this.getAttribute("locale") ? { locale: this.getAttribute("locale") } : {});
|
|
996
|
+
__privateMethod(this, _ConsentFieldElement_instances, emit_fn).call(this, "field:ready", {});
|
|
997
|
+
break;
|
|
998
|
+
case FIELD_MESSAGE_TYPES.STATE:
|
|
999
|
+
__privateSet(this, _decisions, { ...envelope.payload.decisions });
|
|
1000
|
+
__privateMethod(this, _ConsentFieldElement_instances, emit_fn).call(this, "field:state", { decisions: this.decisions });
|
|
1001
|
+
break;
|
|
1002
|
+
case FIELD_MESSAGE_TYPES.RESIZE: {
|
|
1003
|
+
const height = envelope.payload.height;
|
|
1004
|
+
if (typeof height === "number" && __privateGet(this, _iframe)) __privateGet(this, _iframe).style.height = `${height}px`;
|
|
1005
|
+
break;
|
|
1006
|
+
}
|
|
1007
|
+
case FIELD_MESSAGE_TYPES.COMPLETE: {
|
|
1008
|
+
const payload = envelope.payload;
|
|
1009
|
+
__privateMethod(this, _ConsentFieldElement_instances, setValue_fn).call(this, payload.token);
|
|
1010
|
+
const outcome = { token: payload.token, committed: payload.committed === true, recordId: payload.record_id ?? null };
|
|
1011
|
+
__privateGet(this, _pending)?.resolve(outcome);
|
|
1012
|
+
__privateSet(this, _pending, null);
|
|
1013
|
+
__privateMethod(this, _ConsentFieldElement_instances, emit_fn).call(this, "field:complete", outcome);
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
case FIELD_MESSAGE_TYPES.ERROR: {
|
|
1017
|
+
const payload = envelope.payload;
|
|
1018
|
+
__privateGet(this, _pending)?.reject(new FieldCaptureError(payload.code, payload.message));
|
|
1019
|
+
__privateSet(this, _pending, null);
|
|
1020
|
+
__privateMethod(this, _ConsentFieldElement_instances, emit_fn).call(this, "field:error", payload);
|
|
1021
|
+
break;
|
|
1022
|
+
}
|
|
1023
|
+
case FIELD_MESSAGE_TYPES.SUBMIT_REQUESTED:
|
|
1024
|
+
this.form?.requestSubmit?.();
|
|
1025
|
+
break;
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
__privateSet(this, _shadow, this.attachShadow({ mode: "open" }));
|
|
1029
|
+
if (typeof this.attachInternals === "function") {
|
|
1030
|
+
try {
|
|
1031
|
+
__privateSet(this, _internals, this.attachInternals());
|
|
1032
|
+
} catch {
|
|
1033
|
+
__privateSet(this, _internals, null);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
/** The capture token once captured; empty before. */
|
|
1038
|
+
get value() {
|
|
1039
|
+
return __privateGet(this, _value);
|
|
1040
|
+
}
|
|
1041
|
+
/** The host form this control belongs to (form association), if any. */
|
|
1042
|
+
get form() {
|
|
1043
|
+
return __privateGet(this, _internals)?.form ?? this.closest("form");
|
|
1044
|
+
}
|
|
1045
|
+
/** The last STATE the frame reported. */
|
|
1046
|
+
get decisions() {
|
|
1047
|
+
return { ...__privateGet(this, _decisions) };
|
|
1048
|
+
}
|
|
1049
|
+
get ready() {
|
|
1050
|
+
return __privateGet(this, _ready);
|
|
1051
|
+
}
|
|
1052
|
+
connectedCallback() {
|
|
1053
|
+
if (!this.style.display) this.style.display = "block";
|
|
1054
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "group");
|
|
1055
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("name") || "Consent choices");
|
|
1056
|
+
this.setAttribute("aria-busy", "true");
|
|
1057
|
+
__privateMethod(this, _ConsentFieldElement_instances, mount_fn).call(this);
|
|
1058
|
+
}
|
|
1059
|
+
disconnectedCallback() {
|
|
1060
|
+
__privateMethod(this, _ConsentFieldElement_instances, teardown_fn).call(this);
|
|
1061
|
+
}
|
|
1062
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1063
|
+
if (oldValue === newValue || !this.isConnected) return;
|
|
1064
|
+
if (name === "name") {
|
|
1065
|
+
this.setAttribute("aria-label", newValue || "Consent choices");
|
|
1066
|
+
if (__privateGet(this, _iframe)) __privateGet(this, _iframe).title = newValue || "Consent choices";
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
__privateMethod(this, _ConsentFieldElement_instances, teardown_fn).call(this);
|
|
1070
|
+
__privateMethod(this, _ConsentFieldElement_instances, mount_fn).call(this);
|
|
1071
|
+
}
|
|
1072
|
+
/** The facade's handoff: the trust-host base and the publishable key the client was built with. */
|
|
1073
|
+
configure(opts) {
|
|
1074
|
+
this.setAttribute("base-url", opts.flowBaseUrl.replace(/\/+$/, ""));
|
|
1075
|
+
this.setAttribute("publishable-key", opts.publishableKey);
|
|
1076
|
+
if (this.isConnected && !__privateGet(this, _iframe)) __privateMethod(this, _ConsentFieldElement_instances, mount_fn).call(this);
|
|
1077
|
+
}
|
|
1078
|
+
/** Asks the frame to capture; resolves on COMPLETE, rejects on ERROR. */
|
|
1079
|
+
capture(request) {
|
|
1080
|
+
return new Promise((resolve, reject) => {
|
|
1081
|
+
if (!__privateGet(this, _ready) || !__privateGet(this, _frameOrigin)) {
|
|
1082
|
+
reject(new FieldCaptureError("field_not_ready", "The consent field has not finished loading."));
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
if (__privateGet(this, _pending)) {
|
|
1086
|
+
reject(new FieldCaptureError("capture_in_flight", "A capture is already in progress; the first one answers."));
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
__privateSet(this, _pending, { resolve, reject });
|
|
1090
|
+
__privateMethod(this, _ConsentFieldElement_instances, post_fn).call(this, FIELD_MESSAGE_TYPES.CAPTURE, {
|
|
1091
|
+
subject: request.subject ?? {},
|
|
1092
|
+
page_url: request.pageUrl ?? null,
|
|
1093
|
+
form_id: request.formId ?? null,
|
|
1094
|
+
submitter: request.submitter ?? null,
|
|
1095
|
+
commit: request.commit === true
|
|
1096
|
+
});
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* 202 D9 — the facade's handoff (`overturo.forms.attach({ field })` lands
|
|
1101
|
+
* here): the 201 submit interception is reused unchanged in shape, and the
|
|
1102
|
+
* capture is asked of this element instead of being read from the DOM.
|
|
1103
|
+
*/
|
|
1104
|
+
attachTo(form, opts, client) {
|
|
1105
|
+
if (!this.getAttribute("flow")) this.setAttribute("flow", opts.flowId);
|
|
1106
|
+
if (opts.locale && !this.getAttribute("locale")) this.setAttribute("locale", opts.locale);
|
|
1107
|
+
this.configure(client);
|
|
1108
|
+
return interceptSubmit(form, opts, async ({ submitter }) => {
|
|
1109
|
+
const subject = resolveControl(form, opts.subjectField);
|
|
1110
|
+
const external = opts.externalIdField ? resolveControl(form, opts.externalIdField) : null;
|
|
1111
|
+
const outcome = await this.capture({
|
|
1112
|
+
subject: { email: subject?.value?.trim() || void 0, external_id: external?.value?.trim() || void 0 },
|
|
1113
|
+
pageUrl: typeof window !== "undefined" ? window.location.href : void 0,
|
|
1114
|
+
formId: form.getAttribute("id") || void 0,
|
|
1115
|
+
submitter: submitter?.getAttribute("name") ?? null,
|
|
1116
|
+
commit: opts.commit === true
|
|
1117
|
+
});
|
|
1118
|
+
const result = {
|
|
1119
|
+
token: outcome.token,
|
|
1120
|
+
attestationId: "",
|
|
1121
|
+
committed: outcome.committed,
|
|
1122
|
+
wordingVerdict: "match",
|
|
1123
|
+
recordId: outcome.recordId
|
|
1124
|
+
};
|
|
1125
|
+
opts.onCaptured?.(result);
|
|
1126
|
+
return { token: outcome.token };
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
/** Returns every control to its rendered state and clears the token. */
|
|
1130
|
+
reset() {
|
|
1131
|
+
__privateMethod(this, _ConsentFieldElement_instances, post_fn).call(this, FIELD_MESSAGE_TYPES.RESET, {});
|
|
1132
|
+
__privateMethod(this, _ConsentFieldElement_instances, setValue_fn).call(this, "");
|
|
1133
|
+
}
|
|
1134
|
+
/** Form-associated hook: the host form was reset. */
|
|
1135
|
+
formResetCallback() {
|
|
1136
|
+
this.reset();
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
_internals = new WeakMap();
|
|
1140
|
+
_shadow = new WeakMap();
|
|
1141
|
+
_iframe = new WeakMap();
|
|
1142
|
+
_ac = new WeakMap();
|
|
1143
|
+
_frameOrigin = new WeakMap();
|
|
1144
|
+
_ready = new WeakMap();
|
|
1145
|
+
_value = new WeakMap();
|
|
1146
|
+
_decisions = new WeakMap();
|
|
1147
|
+
_pending = new WeakMap();
|
|
1148
|
+
_ConsentFieldElement_instances = new WeakSet();
|
|
1149
|
+
mount_fn = function() {
|
|
1150
|
+
const flow = this.getAttribute("flow");
|
|
1151
|
+
const key = this.getAttribute("publishable-key");
|
|
1152
|
+
if (!flow || !key) return;
|
|
1153
|
+
const base = (this.getAttribute("base-url") || defaultBaseUrl()).replace(/\/+$/, "");
|
|
1154
|
+
const url = new URL(`${base}${FIELD_DOCUMENT_PATH}/${encodeURIComponent(flow)}`);
|
|
1155
|
+
url.searchParams.set("pk", key);
|
|
1156
|
+
for (const attr of ["locale", "purposes", "theme"]) {
|
|
1157
|
+
const value = this.getAttribute(attr);
|
|
1158
|
+
if (value) url.searchParams.set(attr, value);
|
|
1159
|
+
}
|
|
1160
|
+
const appearance = this.getAttribute("appearance");
|
|
1161
|
+
if (appearance) {
|
|
1162
|
+
try {
|
|
1163
|
+
url.hash = encodeAppearance(JSON.parse(appearance));
|
|
1164
|
+
} catch {
|
|
1165
|
+
url.hash = "";
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
__privateSet(this, _frameOrigin, url.origin);
|
|
1169
|
+
const iframe = document.createElement("iframe");
|
|
1170
|
+
iframe.src = url.toString();
|
|
1171
|
+
iframe.title = this.getAttribute("name") || "Consent choices";
|
|
1172
|
+
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups");
|
|
1173
|
+
iframe.setAttribute("referrerpolicy", "strict-origin");
|
|
1174
|
+
iframe.style.cssText = "width:100%;height:0;border:0;display:block;background:transparent;";
|
|
1175
|
+
const nonce = readCspNonce();
|
|
1176
|
+
if (nonce) iframe.setAttribute("nonce", nonce);
|
|
1177
|
+
iframe.addEventListener("error", () => {
|
|
1178
|
+
__privateMethod(this, _ConsentFieldElement_instances, emit_fn).call(this, "field:error", { code: "iframe_load_failed", message: "The consent field failed to load." });
|
|
1179
|
+
this.setAttribute("aria-busy", "false");
|
|
1180
|
+
});
|
|
1181
|
+
__privateSet(this, _ac, new AbortController());
|
|
1182
|
+
window.addEventListener("message", __privateGet(this, _onMessage), { signal: __privateGet(this, _ac).signal });
|
|
1183
|
+
__privateSet(this, _iframe, iframe);
|
|
1184
|
+
__privateGet(this, _shadow).appendChild(iframe);
|
|
1185
|
+
};
|
|
1186
|
+
_onMessage = new WeakMap();
|
|
1187
|
+
post_fn = function(type, payload) {
|
|
1188
|
+
const target = __privateGet(this, _iframe)?.contentWindow;
|
|
1189
|
+
if (!target || !__privateGet(this, _frameOrigin)) return;
|
|
1190
|
+
try {
|
|
1191
|
+
target.postMessage(fieldEnvelope(type, payload), __privateGet(this, _frameOrigin));
|
|
1192
|
+
} catch {
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
setValue_fn = function(token) {
|
|
1196
|
+
__privateSet(this, _value, token);
|
|
1197
|
+
if (__privateGet(this, _internals) && typeof __privateGet(this, _internals).setFormValue === "function") __privateGet(this, _internals).setFormValue(token || null);
|
|
1198
|
+
};
|
|
1199
|
+
emit_fn = function(name, detail) {
|
|
1200
|
+
this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
|
|
1201
|
+
};
|
|
1202
|
+
teardown_fn = function() {
|
|
1203
|
+
__privateGet(this, _ac)?.abort();
|
|
1204
|
+
__privateSet(this, _ac, null);
|
|
1205
|
+
if (__privateGet(this, _iframe)?.parentNode) __privateGet(this, _iframe).parentNode.removeChild(__privateGet(this, _iframe));
|
|
1206
|
+
__privateSet(this, _iframe, null);
|
|
1207
|
+
__privateSet(this, _ready, false);
|
|
1208
|
+
__privateSet(this, _frameOrigin, "");
|
|
1209
|
+
__privateGet(this, _pending)?.reject(new FieldCaptureError("field_unmounted"));
|
|
1210
|
+
__privateSet(this, _pending, null);
|
|
1211
|
+
this.setAttribute("aria-busy", "true");
|
|
1212
|
+
};
|
|
1213
|
+
ConsentFieldElement.formAssociated = true;
|
|
1214
|
+
ConsentFieldElement.observedAttributes = ["flow", "purposes", "locale", "theme", "name", "appearance", "publishable-key", "base-url"];
|
|
1215
|
+
function readCspNonce() {
|
|
1216
|
+
if (typeof document === "undefined") return null;
|
|
1217
|
+
return document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content") ?? null;
|
|
1218
|
+
}
|
|
1219
|
+
function defaultBaseUrl() {
|
|
1220
|
+
return DEFAULT_BASE_URL;
|
|
1221
|
+
}
|
|
1222
|
+
function registerConsentFieldElement() {
|
|
1223
|
+
if (typeof customElements === "undefined") return;
|
|
1224
|
+
if (customElements.get(FIELD_ELEMENT_NAME)) {
|
|
1225
|
+
console.warn("[overturo:sdk]", FIELD_ALREADY_DEFINED_CODE, `<${FIELD_ELEMENT_NAME}> already registered; skipping.`);
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
customElements.define(FIELD_ELEMENT_NAME, ConsentFieldElement);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
// src/field/index.ts
|
|
1232
|
+
registerConsentFieldElement();
|
|
1233
|
+
export {
|
|
1234
|
+
APPEARANCE_KEYS,
|
|
1235
|
+
ConsentFieldElement,
|
|
1236
|
+
FIELD_ALREADY_DEFINED_CODE,
|
|
1237
|
+
FIELD_DOCUMENT_PATH,
|
|
1238
|
+
FIELD_ELEMENT_NAME,
|
|
1239
|
+
FIELD_MESSAGE_TYPES,
|
|
1240
|
+
FIELD_PROTOCOL_VERSION,
|
|
1241
|
+
FieldCaptureError,
|
|
1242
|
+
ConsentFieldElement as default,
|
|
1243
|
+
encodeAppearance,
|
|
1244
|
+
fieldEnvelope,
|
|
1245
|
+
registerConsentFieldElement,
|
|
1246
|
+
sanitiseAppearance,
|
|
1247
|
+
validateField,
|
|
1248
|
+
validateFieldEnvelope,
|
|
1249
|
+
validateFieldPayload
|
|
1250
|
+
};
|
|
1251
|
+
//# sourceMappingURL=index.js.map
|