@userflow-tech/react-native 0.1.0 → 0.1.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/README.md +24 -14
- package/app.plugin.js +3 -0
- package/babel-plugin/index.d.ts +43 -0
- package/babel-plugin/index.d.ts.map +1 -0
- package/babel-plugin/index.js +854 -0
- package/babel-plugin/index.js.map +1 -0
- package/docs/deep-linking.md +2 -2
- package/docs/troubleshooting.md +2 -2
- package/expo-plugin/withUserflow.d.ts +17 -0
- package/expo-plugin/withUserflow.d.ts.map +1 -0
- package/expo-plugin/withUserflow.js +99 -0
- package/expo-plugin/withUserflow.js.map +1 -0
- package/lib/commonjs/anchors/AutoAnchorRegistry.js +1 -1
- package/lib/commonjs/anchors/autoAnchor.js +1 -1
- package/lib/commonjs/anchors/hintsCodec.js +1 -1
- package/lib/commonjs/pairing/diagnostics.js +2 -2
- package/lib/commonjs/pairing/diagnostics.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/anchors/AutoAnchorRegistry.js +1 -1
- package/lib/module/anchors/autoAnchor.js +1 -1
- package/lib/module/anchors/hintsCodec.js +1 -1
- package/lib/module/pairing/diagnostics.js +2 -2
- package/lib/module/pairing/diagnostics.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/commonjs/src/anchors/AutoAnchorRegistry.d.ts +1 -1
- package/lib/typescript/commonjs/src/anchors/AutoAnchorRegistry.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/autoAnchor.d.ts +1 -1
- package/lib/typescript/commonjs/src/anchors/hintsCodec.d.ts +1 -1
- package/lib/typescript/commonjs/src/version.d.ts +1 -1
- package/lib/typescript/module/src/anchors/AutoAnchorRegistry.d.ts +1 -1
- package/lib/typescript/module/src/anchors/AutoAnchorRegistry.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/autoAnchor.d.ts +1 -1
- package/lib/typescript/module/src/anchors/hintsCodec.d.ts +1 -1
- package/lib/typescript/module/src/version.d.ts +1 -1
- package/package.json +15 -7
- package/src/anchors/AutoAnchorRegistry.ts +1 -1
- package/src/anchors/autoAnchor.ts +1 -1
- package/src/anchors/hintsCodec.ts +1 -1
- package/src/pairing/diagnostics.ts +2 -2
- package/src/version.ts +1 -1
- package/vendor/core/LICENSE +76 -0
- package/vendor/core/README.md +9 -0
- package/vendor/core/dist/attributes.d.ts +16 -0
- package/vendor/core/dist/attributes.d.ts.map +1 -0
- package/vendor/core/dist/attributes.js +55 -0
- package/vendor/core/dist/attributes.js.map +1 -0
- package/vendor/core/dist/constants.d.ts +21 -0
- package/vendor/core/dist/constants.d.ts.map +1 -0
- package/vendor/core/dist/constants.js +21 -0
- package/vendor/core/dist/constants.js.map +1 -0
- package/vendor/core/dist/engine/ClientConditionEngine.d.ts +68 -0
- package/vendor/core/dist/engine/ClientConditionEngine.d.ts.map +1 -0
- package/vendor/core/dist/engine/ClientConditionEngine.js +197 -0
- package/vendor/core/dist/engine/ClientConditionEngine.js.map +1 -0
- package/vendor/core/dist/engine/FlowSessionEngine.d.ts +92 -0
- package/vendor/core/dist/engine/FlowSessionEngine.d.ts.map +1 -0
- package/vendor/core/dist/engine/FlowSessionEngine.js +310 -0
- package/vendor/core/dist/engine/FlowSessionEngine.js.map +1 -0
- package/vendor/core/dist/engine/PairingEngine.d.ts +92 -0
- package/vendor/core/dist/engine/PairingEngine.d.ts.map +1 -0
- package/vendor/core/dist/engine/PairingEngine.js +302 -0
- package/vendor/core/dist/engine/PairingEngine.js.map +1 -0
- package/vendor/core/dist/engine/UserflowCore.d.ts +126 -0
- package/vendor/core/dist/engine/UserflowCore.d.ts.map +1 -0
- package/vendor/core/dist/engine/UserflowCore.js +266 -0
- package/vendor/core/dist/engine/UserflowCore.js.map +1 -0
- package/vendor/core/dist/engine/handleActions.d.ts +19 -0
- package/vendor/core/dist/engine/handleActions.d.ts.map +1 -0
- package/vendor/core/dist/engine/handleActions.js +71 -0
- package/vendor/core/dist/engine/handleActions.js.map +1 -0
- package/vendor/core/dist/engine/interpolateSessionData.d.ts +7 -0
- package/vendor/core/dist/engine/interpolateSessionData.d.ts.map +1 -0
- package/vendor/core/dist/engine/interpolateSessionData.js +29 -0
- package/vendor/core/dist/engine/interpolateSessionData.js.map +1 -0
- package/vendor/core/dist/errors.d.ts +9 -0
- package/vendor/core/dist/errors.d.ts.map +1 -0
- package/vendor/core/dist/errors.js +15 -0
- package/vendor/core/dist/errors.js.map +1 -0
- package/vendor/core/dist/eventAttributes.d.ts +7 -0
- package/vendor/core/dist/eventAttributes.d.ts.map +1 -0
- package/vendor/core/dist/eventAttributes.js +31 -0
- package/vendor/core/dist/eventAttributes.js.map +1 -0
- package/vendor/core/dist/index.d.ts +30 -0
- package/vendor/core/dist/index.d.ts.map +1 -0
- package/vendor/core/dist/index.js +21 -0
- package/vendor/core/dist/index.js.map +1 -0
- package/vendor/core/dist/transport/backoff.d.ts +11 -0
- package/vendor/core/dist/transport/backoff.d.ts.map +1 -0
- package/vendor/core/dist/transport/backoff.js +17 -0
- package/vendor/core/dist/transport/backoff.js.map +1 -0
- package/vendor/core/dist/transport/pairing.d.ts +121 -0
- package/vendor/core/dist/transport/pairing.d.ts.map +1 -0
- package/vendor/core/dist/transport/pairing.js +551 -0
- package/vendor/core/dist/transport/pairing.js.map +1 -0
- package/vendor/core/dist/transport/phoenix.d.ts +223 -0
- package/vendor/core/dist/transport/phoenix.d.ts.map +1 -0
- package/vendor/core/dist/transport/phoenix.js +757 -0
- package/vendor/core/dist/transport/phoenix.js.map +1 -0
- package/vendor/core/dist/transport/rateLimiter.d.ts +17 -0
- package/vendor/core/dist/transport/rateLimiter.d.ts.map +1 -0
- package/vendor/core/dist/transport/rateLimiter.js +30 -0
- package/vendor/core/dist/transport/rateLimiter.js.map +1 -0
- package/vendor/core/dist/transport/scheduler.d.ts +12 -0
- package/vendor/core/dist/transport/scheduler.d.ts.map +1 -0
- package/vendor/core/dist/transport/scheduler.js +11 -0
- package/vendor/core/dist/transport/scheduler.js.map +1 -0
- package/vendor/core/dist/types.d.ts +35 -0
- package/vendor/core/dist/types.d.ts.map +1 -0
- package/vendor/core/dist/types.js +2 -0
- package/vendor/core/dist/types.js.map +1 -0
- package/vendor/core/dist/version.d.ts +3 -0
- package/vendor/core/dist/version.d.ts.map +1 -0
- package/vendor/core/dist/version.js +3 -0
- package/vendor/core/dist/version.js.map +1 -0
- package/vendor/core/package.json +20 -0
- package/vendor/protocol/LICENSE +76 -0
- package/vendor/protocol/README.md +8 -0
- package/vendor/protocol/dist/autoData.d.ts +232 -0
- package/vendor/protocol/dist/autoData.d.ts.map +1 -0
- package/vendor/protocol/dist/autoData.js +78 -0
- package/vendor/protocol/dist/autoData.js.map +1 -0
- package/vendor/protocol/dist/events.d.ts +16 -0
- package/vendor/protocol/dist/events.d.ts.map +1 -0
- package/vendor/protocol/dist/events.js +8 -0
- package/vendor/protocol/dist/events.js.map +1 -0
- package/vendor/protocol/dist/flows.d.ts +298 -0
- package/vendor/protocol/dist/flows.d.ts.map +1 -0
- package/vendor/protocol/dist/flows.js +154 -0
- package/vendor/protocol/dist/flows.js.map +1 -0
- package/vendor/protocol/dist/index.d.ts +24 -0
- package/vendor/protocol/dist/index.d.ts.map +1 -0
- package/vendor/protocol/dist/index.js +16 -0
- package/vendor/protocol/dist/index.js.map +1 -0
- package/vendor/protocol/dist/messages.d.ts +166 -0
- package/vendor/protocol/dist/messages.d.ts.map +1 -0
- package/vendor/protocol/dist/messages.js +57 -0
- package/vendor/protocol/dist/messages.js.map +1 -0
- package/vendor/protocol/dist/pairing.d.ts +56 -0
- package/vendor/protocol/dist/pairing.d.ts.map +1 -0
- package/vendor/protocol/dist/pairing.js +146 -0
- package/vendor/protocol/dist/pairing.js.map +1 -0
- package/vendor/protocol/package.json +17 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { PairingConnection, } from '../transport/pairing.js';
|
|
2
|
+
const IDLE_STATE = {
|
|
3
|
+
status: 'idle',
|
|
4
|
+
pairingId: null,
|
|
5
|
+
deviceId: null,
|
|
6
|
+
previewActive: false,
|
|
7
|
+
lastError: null,
|
|
8
|
+
needsRescan: false,
|
|
9
|
+
awaitingStartCondition: false,
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Orchestrates a pairing session: connect/join the pairing socket, bridge
|
|
13
|
+
* `startFlowWithToken` onto the end-user channel, and expose preview-mode state.
|
|
14
|
+
*/
|
|
15
|
+
export class PairingEngine {
|
|
16
|
+
constructor(deps) {
|
|
17
|
+
this.connection = null;
|
|
18
|
+
this.unsubscribe = null;
|
|
19
|
+
this.state = { ...IDLE_STATE };
|
|
20
|
+
this.listeners = new Set();
|
|
21
|
+
this.pendingStartTokens = [];
|
|
22
|
+
/** True while the server is waiting on a start condition (see TestStartCondition). */
|
|
23
|
+
this.testingStartCondition = false;
|
|
24
|
+
this.startConditionUnsub = null;
|
|
25
|
+
this.deps = deps;
|
|
26
|
+
}
|
|
27
|
+
getState() {
|
|
28
|
+
return { ...this.state };
|
|
29
|
+
}
|
|
30
|
+
isPreviewActive() {
|
|
31
|
+
return this.state.previewActive;
|
|
32
|
+
}
|
|
33
|
+
onStateChange(listener) {
|
|
34
|
+
this.listeners.add(listener);
|
|
35
|
+
return () => {
|
|
36
|
+
this.listeners.delete(listener);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Begin (or replace) a pairing session with a JWT from a deep link.
|
|
41
|
+
* Closes any existing pairing websocket first (warm re-scan).
|
|
42
|
+
*/
|
|
43
|
+
async start(pairingToken) {
|
|
44
|
+
this.teardownConnection();
|
|
45
|
+
this.pendingStartTokens = [];
|
|
46
|
+
// A re-scan is a new session: stop tracking the previous one's condition.
|
|
47
|
+
this.testingStartCondition = false;
|
|
48
|
+
this.unwatchStartCondition();
|
|
49
|
+
this.setState({
|
|
50
|
+
status: 'connecting',
|
|
51
|
+
pairingId: null,
|
|
52
|
+
deviceId: null,
|
|
53
|
+
previewActive: true,
|
|
54
|
+
lastError: null,
|
|
55
|
+
needsRescan: false,
|
|
56
|
+
awaitingStartCondition: false,
|
|
57
|
+
});
|
|
58
|
+
const options = this.deps.pairingOptions ?? {};
|
|
59
|
+
const connection = (this.deps.createConnection ?? ((opts) => new PairingConnection(opts)))(options);
|
|
60
|
+
this.connection = connection;
|
|
61
|
+
this.unsubscribe = connection.onEvent((event) => this.handleConnectionEvent(event));
|
|
62
|
+
const meta = this.deps.deviceMeta?.() ?? {};
|
|
63
|
+
try {
|
|
64
|
+
await connection.connect(pairingToken, meta);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
const message = error instanceof Error ? error.message : 'Pairing connect failed';
|
|
68
|
+
if (this.state.status === 'token_expired' || this.state.status === 'device_already_paired') {
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
this.setState({
|
|
72
|
+
...this.state,
|
|
73
|
+
status: 'error',
|
|
74
|
+
lastError: message,
|
|
75
|
+
needsRescan: true,
|
|
76
|
+
previewActive: false,
|
|
77
|
+
});
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Exit preview: disconnect pairing and clear queued preview tokens. */
|
|
82
|
+
stop() {
|
|
83
|
+
this.pendingStartTokens = [];
|
|
84
|
+
// Web sends TestStartConditionCancel when leaving start-condition testing so
|
|
85
|
+
// the server stops waiting on the draft flow. Best-effort: the channel may
|
|
86
|
+
// already be gone, and teardown must not reject.
|
|
87
|
+
if (this.testingStartCondition) {
|
|
88
|
+
this.testingStartCondition = false;
|
|
89
|
+
void this.deps.sendClientMessage({ kind: 'TestStartConditionCancel' }).catch(() => {
|
|
90
|
+
// Intentionally empty — teardown is best-effort.
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
this.unwatchStartCondition();
|
|
94
|
+
this.teardownConnection();
|
|
95
|
+
this.setState({ ...IDLE_STATE });
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Listen for the server confirming the tested start condition matched. Called
|
|
99
|
+
* only after a `TestStartCondition` send succeeded, which means the end-user
|
|
100
|
+
* channel exists and subscribing is safe.
|
|
101
|
+
*/
|
|
102
|
+
watchStartCondition() {
|
|
103
|
+
if (this.startConditionUnsub || !this.deps.onServerMessage)
|
|
104
|
+
return;
|
|
105
|
+
try {
|
|
106
|
+
this.startConditionUnsub = this.deps.onServerMessage((message) => {
|
|
107
|
+
if (message.kind === 'TestStartConditionSuccess')
|
|
108
|
+
this.notifyStartConditionMatched();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// No channel to listen on. The preview still works; it just keeps
|
|
113
|
+
// reporting "awaiting" until preview is exited.
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
unwatchStartCondition() {
|
|
117
|
+
this.startConditionUnsub?.();
|
|
118
|
+
this.startConditionUnsub = null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The tested start condition matched, so the flow is now on screen. Stops the
|
|
122
|
+
* waiting state and makes `stop()` skip a cancel the server no longer needs.
|
|
123
|
+
*/
|
|
124
|
+
notifyStartConditionMatched() {
|
|
125
|
+
if (!this.testingStartCondition)
|
|
126
|
+
return;
|
|
127
|
+
this.testingStartCondition = false;
|
|
128
|
+
this.unwatchStartCondition();
|
|
129
|
+
this.setState({ ...this.state, awaitingStartCondition: false });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Call after end-user identify so queued `startFlowWithToken` relays can flush.
|
|
133
|
+
*/
|
|
134
|
+
notifyIdentified() {
|
|
135
|
+
void this.flushPendingStartTokens();
|
|
136
|
+
}
|
|
137
|
+
ensureAlive() {
|
|
138
|
+
this.connection?.ensureAlive();
|
|
139
|
+
}
|
|
140
|
+
handleConnectionEvent(event) {
|
|
141
|
+
switch (event.type) {
|
|
142
|
+
case 'state': {
|
|
143
|
+
if (event.state === 'reconnecting') {
|
|
144
|
+
this.setState({ ...this.state, status: 'reconnecting' });
|
|
145
|
+
}
|
|
146
|
+
else if (event.state === 'connected' && this.state.previewActive) {
|
|
147
|
+
this.setState({
|
|
148
|
+
...this.state,
|
|
149
|
+
status: 'connected',
|
|
150
|
+
lastError: null,
|
|
151
|
+
needsRescan: false,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else if (event.state === 'connecting') {
|
|
155
|
+
this.setState({ ...this.state, status: 'connecting' });
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case 'joined':
|
|
160
|
+
this.setState({
|
|
161
|
+
...this.state,
|
|
162
|
+
status: 'connected',
|
|
163
|
+
pairingId: event.pairingId,
|
|
164
|
+
deviceId: event.deviceId,
|
|
165
|
+
previewActive: true,
|
|
166
|
+
lastError: null,
|
|
167
|
+
needsRescan: false,
|
|
168
|
+
});
|
|
169
|
+
break;
|
|
170
|
+
case 'token_expired':
|
|
171
|
+
this.pendingStartTokens = [];
|
|
172
|
+
this.setState({
|
|
173
|
+
...this.state,
|
|
174
|
+
status: 'token_expired',
|
|
175
|
+
previewActive: false,
|
|
176
|
+
needsRescan: true,
|
|
177
|
+
lastError: 'Pairing token expired — re-scan the QR code',
|
|
178
|
+
});
|
|
179
|
+
this.teardownConnection();
|
|
180
|
+
break;
|
|
181
|
+
case 'device_already_paired':
|
|
182
|
+
this.setState({
|
|
183
|
+
...this.state,
|
|
184
|
+
status: 'device_already_paired',
|
|
185
|
+
previewActive: false,
|
|
186
|
+
needsRescan: true,
|
|
187
|
+
lastError: 'Another device is already paired for this session',
|
|
188
|
+
});
|
|
189
|
+
this.teardownConnection();
|
|
190
|
+
break;
|
|
191
|
+
case 'join_error':
|
|
192
|
+
this.setState({
|
|
193
|
+
...this.state,
|
|
194
|
+
status: 'error',
|
|
195
|
+
lastError: event.reason,
|
|
196
|
+
needsRescan: true,
|
|
197
|
+
previewActive: false,
|
|
198
|
+
});
|
|
199
|
+
break;
|
|
200
|
+
case 'startFlowWithToken':
|
|
201
|
+
void this.handleStartFlowWithToken(event.payload);
|
|
202
|
+
break;
|
|
203
|
+
case 'relay':
|
|
204
|
+
// Phase 2: selectElement / screenshot / etc.
|
|
205
|
+
break;
|
|
206
|
+
default:
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async handleStartFlowWithToken(payload) {
|
|
211
|
+
const idempotencyKey = typeof payload.idempotency_key === 'string'
|
|
212
|
+
? payload.idempotency_key
|
|
213
|
+
: typeof payload.idempotencyKey === 'string'
|
|
214
|
+
? payload.idempotencyKey
|
|
215
|
+
: undefined;
|
|
216
|
+
const normalized = {
|
|
217
|
+
...payload,
|
|
218
|
+
...(idempotencyKey !== undefined ? { idempotency_key: idempotencyKey } : {}),
|
|
219
|
+
};
|
|
220
|
+
if (typeof payload.token !== 'string' || payload.token.length === 0) {
|
|
221
|
+
await this.pushStartResult(false, 'missing token', idempotencyKey);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (!this.deps.isIdentified()) {
|
|
225
|
+
this.pendingStartTokens.push(normalized);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
await this.deliverStartFlowWithToken(normalized);
|
|
229
|
+
}
|
|
230
|
+
async flushPendingStartTokens() {
|
|
231
|
+
if (!this.deps.isIdentified() || this.pendingStartTokens.length === 0)
|
|
232
|
+
return;
|
|
233
|
+
const queued = this.pendingStartTokens;
|
|
234
|
+
this.pendingStartTokens = [];
|
|
235
|
+
for (const payload of queued) {
|
|
236
|
+
await this.deliverStartFlowWithToken(payload);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
async deliverStartFlowWithToken(payload) {
|
|
240
|
+
// Mirrors web `userflow-client.ts`: testing a start condition is handled
|
|
241
|
+
// differently from starting the draft flow immediately. `StartFlowWithToken`
|
|
242
|
+
// force-starts server-side (no condition check), so honoring this flag is
|
|
243
|
+
// what makes "when auto start conditions are triggered" actually wait.
|
|
244
|
+
const testStartCondition = payload.testStartCondition === true;
|
|
245
|
+
try {
|
|
246
|
+
await this.deps.sendClientMessage(testStartCondition
|
|
247
|
+
? { kind: 'TestStartCondition', token: payload.token }
|
|
248
|
+
: { kind: 'StartFlowWithToken', token: payload.token });
|
|
249
|
+
this.testingStartCondition = testStartCondition;
|
|
250
|
+
if (testStartCondition)
|
|
251
|
+
this.watchStartCondition();
|
|
252
|
+
else
|
|
253
|
+
this.unwatchStartCondition();
|
|
254
|
+
// Preview is live either way, but a tested condition has not fired yet.
|
|
255
|
+
this.setState({
|
|
256
|
+
...this.state,
|
|
257
|
+
previewActive: true,
|
|
258
|
+
awaitingStartCondition: testStartCondition,
|
|
259
|
+
});
|
|
260
|
+
await this.pushStartResult(true, undefined, payload.idempotency_key);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
const fallback = testStartCondition
|
|
264
|
+
? 'TestStartCondition failed'
|
|
265
|
+
: 'StartFlowWithToken failed';
|
|
266
|
+
const message = error instanceof Error ? error.message : fallback;
|
|
267
|
+
await this.pushStartResult(false, message, payload.idempotency_key);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async pushStartResult(ok, error, idempotencyKey) {
|
|
271
|
+
if (!this.connection)
|
|
272
|
+
return;
|
|
273
|
+
try {
|
|
274
|
+
await this.connection.push('startFlowWithTokenResult', {
|
|
275
|
+
ok,
|
|
276
|
+
...(error !== undefined ? { error } : {}),
|
|
277
|
+
...(idempotencyKey !== undefined ? { idempotency_key: idempotencyKey } : {}),
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// Best-effort ack to builder.
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
teardownConnection() {
|
|
285
|
+
this.unsubscribe?.();
|
|
286
|
+
this.unsubscribe = null;
|
|
287
|
+
this.connection?.disconnect({ emitState: false });
|
|
288
|
+
this.connection = null;
|
|
289
|
+
}
|
|
290
|
+
setState(next) {
|
|
291
|
+
this.state = next;
|
|
292
|
+
for (const listener of this.listeners) {
|
|
293
|
+
try {
|
|
294
|
+
listener({ ...next });
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
// ignore
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=PairingEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PairingEngine.js","sourceRoot":"","sources":["../../src/engine/PairingEngine.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,GAGlB,MAAM,yBAAyB,CAAC;AAgDjC,MAAM,UAAU,GAAuB;IACrC,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;IACd,aAAa,EAAE,KAAK;IACpB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,KAAK;IAClB,sBAAsB,EAAE,KAAK;CAC9B,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,aAAa;IAWxB,YAAY,IAAuB;QAV3B,eAAU,GAA6B,IAAI,CAAC;QAC5C,gBAAW,GAAwB,IAAI,CAAC;QACxC,UAAK,GAAuB,EAAE,GAAG,UAAU,EAAE,CAAC;QACrC,cAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;QACtD,uBAAkB,GAAqC,EAAE,CAAC;QAClE,sFAAsF;QAC9E,0BAAqB,GAAG,KAAK,CAAC;QAC9B,wBAAmB,GAAwB,IAAI,CAAC;QAItD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ;QACN,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;IAClC,CAAC;IAED,aAAa,CAAC,QAA+B;QAC3C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CA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Condition, ServerMessage, UserflowAttributes } from '@userflow-tech/protocol';
|
|
2
|
+
import type { ServerMessageHandler } from '../transport/phoenix.js';
|
|
3
|
+
import type { UserflowConfig, UserflowGroupOptions, UserflowIdentifyOptions, UserflowInitOptions, UserflowEventAttributes, UserflowTrackOptions } from '../types.js';
|
|
4
|
+
/** Overridable engine dependencies; production defaults use the Phoenix transport. */
|
|
5
|
+
export interface UserflowCoreDeps {
|
|
6
|
+
validate?: ValidateCredentialsFn;
|
|
7
|
+
createConnection?: CreateConnectionFn;
|
|
8
|
+
}
|
|
9
|
+
export interface UpsertGroupPayload {
|
|
10
|
+
groupExternalId: string;
|
|
11
|
+
groupSignature: string | null;
|
|
12
|
+
groupAttributes: UserflowAttributes;
|
|
13
|
+
membershipAttributes: UserflowAttributes;
|
|
14
|
+
}
|
|
15
|
+
/** The subset of the transport the engine depends on (injectable for tests). */
|
|
16
|
+
export interface UserflowConnection {
|
|
17
|
+
identify(userId: string, attributes: UserflowAttributes, signature?: string | null): Promise<void>;
|
|
18
|
+
ensureEndUserChannel(userId: string, signature?: string | null): Promise<void>;
|
|
19
|
+
group(payload: UpsertGroupPayload): Promise<void>;
|
|
20
|
+
send(message: ClientMessage): Promise<void>;
|
|
21
|
+
updateClientContext(clientContext: ClientContext): Promise<void>;
|
|
22
|
+
setClientContext(clientContext: ClientContext): void;
|
|
23
|
+
onServerMessage(handler: ServerMessageHandler): () => void;
|
|
24
|
+
setFlowSessionId(flowSessionId: string | null): void;
|
|
25
|
+
setClientConditions(clientConditions: JoinPayloadClientCondition[]): void;
|
|
26
|
+
disconnect(): void;
|
|
27
|
+
suspend(): void;
|
|
28
|
+
resume(): void;
|
|
29
|
+
/** Eager reconnect when connectivity returns (no-op if suspended/connected/connecting). */
|
|
30
|
+
reconnectNow(): void;
|
|
31
|
+
/** Verify the socket is alive (probe if connected, reconnect if dropped). */
|
|
32
|
+
ensureAlive(): void;
|
|
33
|
+
}
|
|
34
|
+
/** Validates credentials against the backend during `init()`. */
|
|
35
|
+
export type ValidateCredentialsFn = (clientToken: string, serverEndpoint: string) => Promise<void>;
|
|
36
|
+
/** Creates the connection used to deliver identify/upsert messages. */
|
|
37
|
+
export type CreateConnectionFn = (clientToken: string, serverEndpoint: string) => UserflowConnection;
|
|
38
|
+
/**
|
|
39
|
+
* Platform-agnostic engine that holds SDK configuration and identity state and
|
|
40
|
+
* orchestrates credential validation and user identification over the transport.
|
|
41
|
+
*/
|
|
42
|
+
export declare class UserflowCore {
|
|
43
|
+
private config;
|
|
44
|
+
private connection;
|
|
45
|
+
private userId;
|
|
46
|
+
private identitySignature;
|
|
47
|
+
private attributes;
|
|
48
|
+
private clientContext;
|
|
49
|
+
private initPromise;
|
|
50
|
+
private readonly validate;
|
|
51
|
+
private readonly createConnection;
|
|
52
|
+
constructor(deps?: UserflowCoreDeps);
|
|
53
|
+
init(options: UserflowInitOptions): Promise<UserflowConfig>;
|
|
54
|
+
identify(userId: string, attributes?: UserflowAttributes, options?: UserflowIdentifyOptions): Promise<void>;
|
|
55
|
+
group(groupId: string | number, attributes?: UserflowAttributes, options?: UserflowGroupOptions): Promise<void>;
|
|
56
|
+
track(name: string, attributes?: UserflowEventAttributes, options?: UserflowTrackOptions): Promise<void>;
|
|
57
|
+
getUserId(): string | null;
|
|
58
|
+
getAttributes(): UserflowAttributes;
|
|
59
|
+
/** Suspend the connection (e.g. when the app backgrounds). No-op before identify. */
|
|
60
|
+
suspend(): void;
|
|
61
|
+
/** Resume the connection (e.g. when the app foregrounds). No-op before identify. */
|
|
62
|
+
resume(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Eagerly reconnect after a network recovery. No-op before identify, while
|
|
65
|
+
* suspended/connecting/connected, or when the SDK does not intend to be connected.
|
|
66
|
+
*/
|
|
67
|
+
reconnectNow(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Verify the socket is alive right now and recover fast if not. Probes a
|
|
70
|
+
* connected socket (short reply deadline) or reconnects a dropped one. Used
|
|
71
|
+
* on foreground so recovery does not wait for the next scheduled heartbeat.
|
|
72
|
+
* No-op before identify. Requires no host network dependency.
|
|
73
|
+
*/
|
|
74
|
+
ensureAlive(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Ensure the end-user channel is joined after an idle/background suspend.
|
|
77
|
+
* Mirrors web `ensureConnected()`: resume if suspended, then (re)join.
|
|
78
|
+
* No-op before identify.
|
|
79
|
+
*/
|
|
80
|
+
ensureConnected(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Push a Phase 3 client message on the joined channel.
|
|
83
|
+
* Requires an active connection (after identify).
|
|
84
|
+
*/
|
|
85
|
+
send(message: ClientMessage): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Start a flow from a short-lived builder/preview token.
|
|
88
|
+
* Requires an active connection (after identify).
|
|
89
|
+
*/
|
|
90
|
+
startFlowWithToken(token: string): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Subscribe to inbound `server_message` frames.
|
|
93
|
+
* Requires an active connection (after identify).
|
|
94
|
+
*/
|
|
95
|
+
onServerMessage(handler: (message: ServerMessage) => void): () => void;
|
|
96
|
+
/**
|
|
97
|
+
* Tell the transport which flow session to resume on (re)join.
|
|
98
|
+
* No-op before identify / connection creation.
|
|
99
|
+
*/
|
|
100
|
+
setFlowSessionId(flowSessionId: string | null): void;
|
|
101
|
+
/**
|
|
102
|
+
* Tell the transport which client-condition snapshot to include on (re)join.
|
|
103
|
+
* No-op before identify / connection creation.
|
|
104
|
+
*/
|
|
105
|
+
setClientConditions(clientConditions: JoinPayloadClientCondition[]): void;
|
|
106
|
+
/**
|
|
107
|
+
* Report the active mobile location. When identified, pushes
|
|
108
|
+
* `UpdateClientContext`. Before identify, the value is remembered for the
|
|
109
|
+
* next channel join.
|
|
110
|
+
*
|
|
111
|
+
* Expo Router should pass `{ path }`; React Navigation / manual callers pass
|
|
112
|
+
* `{ screen }`. Those map to wire fields `screenPath` / `screenName`.
|
|
113
|
+
* `pageUrl` stays `""` on mobile (required by the backend, web-only otherwise).
|
|
114
|
+
*/
|
|
115
|
+
updateScreen(location: ClientLocationUpdate): Promise<void>;
|
|
116
|
+
/** Clears the current user identity and disconnects the transport. */
|
|
117
|
+
reset(): void;
|
|
118
|
+
private requireInit;
|
|
119
|
+
private requireInitForGroup;
|
|
120
|
+
private doInit;
|
|
121
|
+
private requireIdentified;
|
|
122
|
+
private doIdentify;
|
|
123
|
+
private doGroup;
|
|
124
|
+
private doTrack;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=UserflowCore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserflowCore.d.ts","sourceRoot":"","sources":["../../src/engine/UserflowCore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,0BAA0B,EAC1B,aAAa,EACb,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAQrB,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;CACvC;AAED,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,kBAAkB,CAAC;IACpC,oBAAoB,EAAE,kBAAkB,CAAC;CAC1C;AAED,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,kBAAkB,EAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GACxB,OAAO,CAAC,IAAI,CAAC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