jsfe 1.74.0 → 1.75.0
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/dist/forms/identity-flows.d.ts.map +1 -1
- package/dist/forms/identity-flows.js +8 -3
- package/dist/helpers/contact.d.ts +6 -0
- package/dist/helpers/contact.d.ts.map +1 -1
- package/dist/helpers/contact.js +48 -5
- package/dist/helpers/match-inputs.d.ts.map +1 -1
- package/dist/helpers/match-inputs.js +10 -2
- package/dist/runtime-identity.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-flows.d.ts","sourceRoot":"","sources":["../../src/forms/identity-flows.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identity-flows.d.ts","sourceRoot":"","sources":["../../src/forms/identity-flows.js"],"names":[],"mappings":"AAgDA,+GAA+G;AAC/G,oFAOC;AAQD,wFAAwF;AACxF,iDAGC;AACD,6CAMC;AACD,qHAQC;AASD,4EAMC;AAkGD,2DAOC;AACD,4DAOC;AACD,gHAAgH;AAChH,8DAGC;AAyJD,8EAGC;AA4BD,4FAA4F;AAC5F;;;;EAOC;AAWD,oGAOC;AApQD,iCAAgC,wIAAwI,CAAC;AACzK,wCAAuC,CAAC,CAAC;AAuRzC,0BAAsK"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import { defineWorker, defineForm } from './contracts.js';
|
|
3
3
|
import { OTP_EXPIRY_MS } from '../helpers/otp-check.js';
|
|
4
4
|
// maskEmail is a standard function: these functions run as flow expressions too, where it is in scope by name.
|
|
5
|
-
import { maskEmail } from '../helpers/contact.js';
|
|
5
|
+
import { maskEmail, emailAttempt } from '../helpers/contact.js';
|
|
6
|
+
// an answer that tries to give an email is never a phone number (prod 2026-11-17); inlined, so it needs no host function
|
|
7
|
+
const emailTry = `(${emailAttempt.toString()})(contact_text)`;
|
|
6
8
|
const vars = o => Object.fromEntries(Object.entries(o).map(([k, v]) => [k, { type: Array.isArray(v) ? 'array' : v === null || typeof v === 'object' ? 'object' : typeof v, value: v }]));
|
|
7
9
|
const param = (name, description, type = 'string') => ({ name, type, description });
|
|
8
10
|
const set = (id, variable, value) => ({ id, type: 'SET', variable, value });
|
|
@@ -104,6 +106,8 @@ export function contactError(kind, options, es = false) {
|
|
|
104
106
|
const account = options.account_pattern ? (es ? options.account_name_es || options.account_name : options.account_name) : '';
|
|
105
107
|
if (kind === 'international')
|
|
106
108
|
return es ? "Un número fuera de EE. UU. y Canadá no se puede usar aquí. Por favor indique el correo de su cuenta" + (account ? ', o ' + account : '') + ", o un celular de EE. UU. o Canadá." : "A number outside the US and Canada can't be used here. Please give the email on your account" + (account ? ', or ' + account : '') + ", or a US or Canadian mobile number.";
|
|
109
|
+
if (kind === 'invalid_email')
|
|
110
|
+
return es ? 'Lo siento, no entendí el correo electrónico completo, por ejemplo: nombre arroba gmail punto com.' : "Sorry, I didn't get the whole email address, for example: name at gmail dot com.";
|
|
107
111
|
if (kind === 'invalid_phone')
|
|
108
112
|
return es ? 'El número de teléfono que proporcionó no es válido.' : "Sorry, the phone number you provided isn't valid.";
|
|
109
113
|
return es ? 'Lo siento, necesito el teléfono o correo electrónico asociado con su cuenta' + (account ? ', o ' + account : '') + ' para continuar.' : 'Sorry, I do need the phone or email associated with your account' + (account ? ', or ' + account : '') + ' to proceed.';
|
|
@@ -132,7 +136,7 @@ const contact = worker('get-cell-or-email', 'GetCellOrEmail', 'Identify a suppli
|
|
|
132
136
|
call('identity_contact_collect', 'collect-service-answer', { profiles: '{{contact_profiles}}', question: '{{contact_question}}', question_es: '{{contact_question_es}}', keypad: '{{contact_keypad}}', prefill: '{{contact_prefill}}', parent_form: '{{contact_options.parent_form}}', context: 'account verification', context_es: 'verificación de cuenta' }),
|
|
133
137
|
set('identity_contact_answer', 'contact_text', expression(contactAnswer, 'cargo.serviceAnswer')),
|
|
134
138
|
set('identity_contact_spoken', 'contact_digits', `(${serviceDigits.toString()})(contact_text)`),
|
|
135
|
-
set('identity_contact_piece', 'contact_digits', "!/@/.test(contact_text) && !readEmail(contact_text) && /^[^0-9]*[0-9][0-9\\s.,-]*[^0-9]*$/.test(contact_digits) ? contact_digits.replace(/\\D/g,'') : ''"),
|
|
139
|
+
set('identity_contact_piece', 'contact_digits', "!/@/.test(contact_text) && !readEmail(contact_text) && !" + emailTry + " && /^[^0-9]*[0-9][0-9\\s.,-]*[^0-9]*$/.test(contact_digits) ? contact_digits.replace(/\\D/g,'') : ''"),
|
|
136
140
|
set('identity_contact_join', 'contact_text', "contact_partial && contact_digits ? String(cargo.gcePartial)+contact_digits : contact_text"),
|
|
137
141
|
set('identity_contact_join_digits', 'contact_digits', "contact_partial && contact_digits ? String(cargo.gcePartial)+contact_digits : contact_digits"), effect('identity_contact_piece_consumed', "(cargo.gcePartial='',cargo.contactIntroSkip=false,true)"),
|
|
138
142
|
when('identity_contact_split', "contact_options.merge_partials && contact_digits && (contact_options.account_shape || []).some(function(s){return String(s.first || '').includes(contact_digits.charAt(0)) && contact_digits.length < Math.min.apply(null,s.lengths || [0]);})", effect('identity_contact_hold', '(cargo.gcePartial=contact_digits,true)')),
|
|
@@ -140,7 +144,7 @@ const contact = worker('get-cell-or-email', 'GetCellOrEmail', 'Identify a suppli
|
|
|
140
144
|
when('identity_contact_split_overshoot', "contact_partial && contact_digits.length > (contact_options.account_shape || []).reduce(function(max,s){return Math.max(max,Math.max.apply(null,s.lengths || [0]));},0)", call('identity_contact_restart_split', 'contact-split-failed', { contact_options: '{{contact_options}}' }, 'replace')),
|
|
141
145
|
set('identity_contact_identifier', 'contact_id', "contact_options.account_pattern ? readIdentifier(contact_text,contact_options.account_pattern) : null"),
|
|
142
146
|
set('identity_contact_phone', 'contact_phone', "readPhone(contact_text) || (validatePhone(contact_digits) ? contact_digits : '')"), set('identity_contact_email', 'contact_mail', 'readEmail(contact_text)'),
|
|
143
|
-
set('identity_contact_classify', 'contact_kind', "contact_id && contact_id.kind === 'account' ? 'account' : contact_phone ? 'phone' : contact_mail ? 'email' : contact_options.account_pattern && !contact_digits && matchesChoice(contact_text,contact_names_account) ? 'names_account' : readInternationalPhone(contact_text) ? 'international' : isAgentRequest(contact_text) ? 'agent' : isExitRequest(contact_text) ? 'exit' : contact_allowed && /^(?:no|nope|nah)\\b/i.test(contact_text.trim()) && !/[0-9@]/.test(contact_text) ? 'decline' : contact_allowed && cargo.serviceAnswer && cargo.serviceAnswer.values.caller_decision === 'yes' ? 'caller' : contact_digits ? 'invalid_phone' : contact_text.trim().split(/\\s+/).length>=3 && !/[0-9@]/.test(contact_text) ? 'unmapped' : 'invalid'"),
|
|
147
|
+
set('identity_contact_classify', 'contact_kind', "contact_id && contact_id.kind === 'account' ? 'account' : contact_phone ? 'phone' : contact_mail ? 'email' : contact_options.account_pattern && !contact_digits && matchesChoice(contact_text,contact_names_account) ? 'names_account' : readInternationalPhone(contact_text) ? 'international' : isAgentRequest(contact_text) ? 'agent' : isExitRequest(contact_text) ? 'exit' : " + emailTry + " ? 'invalid_email' : contact_allowed && /^(?:no|nope|nah)\\b/i.test(contact_text.trim()) && !/[0-9@]/.test(contact_text) ? 'decline' : contact_allowed && cargo.serviceAnswer && cargo.serviceAnswer.values.caller_decision === 'yes' ? 'caller' : contact_digits ? 'invalid_phone' : contact_text.trim().split(/\\s+/).length>=3 && !/[0-9@]/.test(contact_text) ? 'unmapped' : 'invalid'"),
|
|
144
148
|
set('identity_contact_named', 'contact_named_options', "Object.assign({},contact_options,{fromMenu:false,intro:'Sure, your account number.',intro_es:'Claro, su número de cuenta.'})"),
|
|
145
149
|
set('identity_contact_error', 'contact_error', expression(contactError, 'contact_kind', 'contact_options')), set('identity_contact_error_es', 'contact_error_es', expression(contactError, 'contact_kind', 'contact_options', 'true')),
|
|
146
150
|
cases('identity_contact_route', {
|
|
@@ -152,6 +156,7 @@ const contact = worker('get-cell-or-email', 'GetCellOrEmail', 'Identify a suppli
|
|
|
152
156
|
"condition: contact_kind === 'names_account'": contactReplay('identity_contact_names_account', { contact_options: '{{contact_named_options}}' }),
|
|
153
157
|
"condition: contact_kind === 'international'": contactMiss('identity_contact_international'),
|
|
154
158
|
"condition: contact_kind === 'invalid_phone'": contactMiss('identity_contact_invalid_phone'),
|
|
159
|
+
"condition: contact_kind === 'invalid_email'": contactMiss('identity_contact_invalid_email'),
|
|
155
160
|
"condition: contact_kind === 'unmapped'": { id: 'identity_contact_off_topic', type: 'DISPATCH', onResponse: 'continue', responseContext: 'account identifier: phone number, email address or account number (teléfono, correo o número de cuenta)', outcome: 'unresolved', reason: 'auth_prompt_off_topic' },
|
|
156
161
|
"condition: contact_kind === 'invalid'": contactMiss('identity_contact_missing'), default: effect('identity_contact_typed', 'true')
|
|
157
162
|
}),
|
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
export function readEmail(text: any, { literal }?: {
|
|
11
11
|
literal?: boolean | undefined;
|
|
12
12
|
}): string;
|
|
13
|
+
/**
|
|
14
|
+
* True when an answer tries to give an email address that could not be read: an @, "arroba", or a known provider's name
|
|
15
|
+
* ("at gmail", "Yahoo"), so the caller hears the email was incomplete rather than that a phone number was invalid (prod
|
|
16
|
+
* 2026-11-17: "Juana Perez 12 34 at gmail." heard "the phone number you provided isn't valid").
|
|
17
|
+
*/
|
|
18
|
+
export function emailAttempt(text: any): boolean;
|
|
13
19
|
/**
|
|
14
20
|
* The 10-digit North American number in the answer (a leading 1 dropped), or ''. A caller who restates the number
|
|
15
21
|
* ("Area code 21. 213 555 0147.", "Area code, 213 555. Area code 213-555-0147.") is read by the last complete number
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contact.d.ts","sourceRoot":"","sources":["../../src/helpers/contact.js"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH;;
|
|
1
|
+
{"version":3,"file":"contact.d.ts","sourceRoot":"","sources":["../../src/helpers/contact.js"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH;;WAiDC;AAoBD;;;;GAIG;AACH,iDAEC;AAID;;;;;GAKG;AACH,0CAWC;AAED;;;;;GAKG;AACH,0DAgBC;AAED,qHAAqH;AACrH,2DAIC;AAED;;;;GAIG;AACH;;;SAmBC;AAED;;;GAGG;AACH,sDAOC;AAED;;;;;GAKG;AACH,yEAUC;AAQD;;;;;GAKG;AACH,qDAIC;AAED,mHAAmH;AACnH,oDAIC"}
|
package/dist/helpers/contact.js
CHANGED
|
@@ -30,11 +30,24 @@ export function readEmail(text, { literal = false } = {}) {
|
|
|
30
30
|
if (addresses.length)
|
|
31
31
|
return new Set(addresses).size === 1 ? addresses[0] : '';
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
let spoken = String(text ?? '')
|
|
34
|
+
// how speech engines write the commonest providers and endings (prod 2026-11-10..17): "g mail", "Gmaildot",
|
|
35
|
+
// "punt com", "ponto com", "Gmail com"
|
|
36
|
+
.replace(/\b(?:g[\s-]mail|gee\s?mail|gmai|gmial|gamil|gmaill)\b/gi, 'gmail')
|
|
37
|
+
.replace(/\b(gmail|hotmail|yahoo|outlook|icloud|aol)dot\b/gi, '$1') // its "com" was lost: read as the bare provider
|
|
38
|
+
.replace(/(?:^|\s+)(?:at|arroba)\s+/gi, ' @ ')
|
|
39
|
+
.replace(/\s+(?:dot|punto|punt|ponto)\s+/gi, '.')
|
|
40
|
+
.replace(/\b(gmail|hotmail|yahoo|outlook|icloud|aol)\s+(?:com|con)\b/gi, '$1.com')
|
|
36
41
|
.replace(/\s+(?:underscore|gui[oó]n bajo)[.,]?(?:\s+|$)/gi, '_')
|
|
37
42
|
.replace(/\s+(?:dash|hyphen|gui[oó]n)[.,]?(?:\s+|$)/gi, '-');
|
|
43
|
+
// a provider with its ending and no "at" (the speech engine dropped it): "Castillo Mónica 22 Gmail punto com"
|
|
44
|
+
const inferred = !spoken.includes('@') && PROVIDER_WITH_ENDING.test(spoken);
|
|
45
|
+
if (inferred) {
|
|
46
|
+
spoken = spoken.replace(PROVIDER_WITH_ENDING, ' @ $1');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// the @ was said or typed, or there is none
|
|
50
|
+
}
|
|
38
51
|
const at = spoken.lastIndexOf('@'); // a speech engine may write an @ inside the name too: the last one is the address's
|
|
39
52
|
if (at < 0) {
|
|
40
53
|
return '';
|
|
@@ -55,9 +68,39 @@ export function readEmail(text, { literal = false } = {}) {
|
|
|
55
68
|
local.unshift(pieces[k]);
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
// "gmail dot" cut short (a window of "gmail dot com") is no bare gmail
|
|
72
|
+
const fixed = /^\s*(?:dot|punto|punt|ponto)\b/i.test(after.slice(after.toLowerCase().indexOf(domain.toLowerCase()) + domain.length)) ? domain : providerDomain(domain);
|
|
73
|
+
const email = (local.join('') + '@' + fixed).toLowerCase();
|
|
74
|
+
// a guessed @ or ending needs a name with a letter: "8 4 Gmail punto com" is the end of an address given across turns
|
|
75
|
+
const guessed = inferred || fixed !== domain.toLowerCase();
|
|
76
|
+
return /^[a-z0-9][a-z0-9._%+-]*@[a-z0-9.-]+\.[a-z]{2,}$/.test(email) && (!guessed || /[a-z]/i.test(local.join(''))) ? email : '';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const PROVIDER_WITH_ENDING = /\s+((?:gmail|hotmail|yahoo|outlook|icloud|aol)\.(?:com|net|es|com\.mx|co\.uk)\b)/i;
|
|
80
|
+
/**
|
|
81
|
+
* A provider's domain as callers say it: "gmail" alone is gmail.com (the one consumer Gmail address), and a misheard
|
|
82
|
+
* ending of a known provider (".con", ".cmo") is ".com". Another provider without its ending is left alone: hotmail and
|
|
83
|
+
* yahoo have country domains, so the caller is asked again (owner 2026-11-17).
|
|
84
|
+
*/
|
|
85
|
+
function providerDomain(domain) {
|
|
86
|
+
const d = domain.toLowerCase();
|
|
87
|
+
if (d === 'gmail') {
|
|
88
|
+
return 'gmail.com';
|
|
60
89
|
}
|
|
90
|
+
else if (/^(?:gmail|hotmail|yahoo|outlook|icloud|aol)\.(?:con|cmo|calm|come|comm|om)$/.test(d)) {
|
|
91
|
+
return d.replace(/\.[a-z]+$/, '.com');
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return d;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* True when an answer tries to give an email address that could not be read: an @, "arroba", or a known provider's name
|
|
99
|
+
* ("at gmail", "Yahoo"), so the caller hears the email was incomplete rather than that a phone number was invalid (prod
|
|
100
|
+
* 2026-11-17: "Juana Perez 12 34 at gmail." heard "the phone number you provided isn't valid").
|
|
101
|
+
*/
|
|
102
|
+
export function emailAttempt(text) {
|
|
103
|
+
return /@|\barroba\b|\b(?:g\s?mail|gmai|hotmail|hot mail|yahoo|outlook|icloud|aol)\b/i.test(String(text ?? ''));
|
|
61
104
|
}
|
|
62
105
|
const northAmerican = (digits) => digits.length === 11 && digits.startsWith('1') ? digits.slice(1) : digits.length === 10 ? digits : '';
|
|
63
106
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH,sEAQC;
|
|
1
|
+
{"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH,sEAQC;AAkGD;;;GAGG;AACH,sFA8HC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;mHACmH;AAEnH,iEAEC;AAGD,gGAOC;AAYD,kDAGC;AAED;;;;;;;;;;;;;;;;;;;;;;EAeC;AACD;;;;;;;;;;;;;;;;;;;;;;;EAgXC"}
|
|
@@ -106,8 +106,16 @@ function emailSpans(raw, value) {
|
|
|
106
106
|
const spans = [];
|
|
107
107
|
for (let i = 0; i + size <= tokens.length; i++) {
|
|
108
108
|
const a = tokens[i].index, b = tokens[i + size - 1].index + tokens[i + size - 1][0].length;
|
|
109
|
-
if (readEmail(raw.slice(a, b)) === value)
|
|
110
|
-
|
|
109
|
+
if (readEmail(raw.slice(a, b)) === value) {
|
|
110
|
+
// "juan at gmail" already reads as gmail.com: the spoken ending after it belongs to the same address
|
|
111
|
+
let j = i + size;
|
|
112
|
+
while (j < tokens.length && /^(?:dot|punto|punt|ponto|com|con|\.com)[.,;:!?]*$/i.test(tokens[j][0]))
|
|
113
|
+
j++;
|
|
114
|
+
spans.push([a, j > i + size ? tokens[j - 1].index + tokens[j - 1][0].length : b]);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// this window is not the address
|
|
118
|
+
}
|
|
111
119
|
}
|
|
112
120
|
if (spans.length)
|
|
113
121
|
return spans;
|
package/dist/runtime-identity.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const JSFE_RUNTIME_FINGERPRINT = "sha256:
|
|
1
|
+
export const JSFE_RUNTIME_FINGERPRINT = "sha256:48e6e2c4fceae55d0e1cf8184768c712140e1b03251a75d54ca307412312d33a";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.75.0",
|
|
4
4
|
"description": "TypeScript workflow engine for conversational/automation apps: multi-flow orchestration, interrupt/resume, stack-based control, robust errors, and flexible tool/REST integration.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ron Pinkas",
|