@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,266 @@
|
|
|
1
|
+
import { assertValidAttributeNames, assertValidEventName } from '../attributes.js';
|
|
2
|
+
import { DEFAULT_SERVER_ENDPOINT } from '../constants.js';
|
|
3
|
+
import { normalizeTrackEventAttributes } from '../eventAttributes.js';
|
|
4
|
+
import { UserflowAuthError } from '../errors.js';
|
|
5
|
+
import { PhoenixConnection, validateCredentials } from '../transport/phoenix.js';
|
|
6
|
+
const DEFAULT_CLIENT_CONTEXT = {
|
|
7
|
+
pageUrl: '',
|
|
8
|
+
viewportWidth: 390,
|
|
9
|
+
viewportHeight: 844,
|
|
10
|
+
};
|
|
11
|
+
function requireField(value, name) {
|
|
12
|
+
const trimmed = value?.trim();
|
|
13
|
+
if (!trimmed)
|
|
14
|
+
throw new UserflowAuthError(`Missing ${name}`);
|
|
15
|
+
return trimmed;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Platform-agnostic engine that holds SDK configuration and identity state and
|
|
19
|
+
* orchestrates credential validation and user identification over the transport.
|
|
20
|
+
*/
|
|
21
|
+
export class UserflowCore {
|
|
22
|
+
constructor(deps = {}) {
|
|
23
|
+
this.config = null;
|
|
24
|
+
this.connection = null;
|
|
25
|
+
this.userId = null;
|
|
26
|
+
this.identitySignature = null;
|
|
27
|
+
this.attributes = {};
|
|
28
|
+
this.clientContext = { ...DEFAULT_CLIENT_CONTEXT };
|
|
29
|
+
this.initPromise = null;
|
|
30
|
+
this.validate =
|
|
31
|
+
deps.validate ??
|
|
32
|
+
((clientToken, serverEndpoint) => validateCredentials(clientToken, serverEndpoint));
|
|
33
|
+
this.createConnection =
|
|
34
|
+
deps.createConnection ??
|
|
35
|
+
((clientToken, serverEndpoint) => new PhoenixConnection(clientToken, serverEndpoint));
|
|
36
|
+
}
|
|
37
|
+
init(options) {
|
|
38
|
+
if (this.initPromise)
|
|
39
|
+
return this.initPromise;
|
|
40
|
+
this.initPromise = this.doInit(options).catch((error) => {
|
|
41
|
+
this.initPromise = null;
|
|
42
|
+
throw error;
|
|
43
|
+
});
|
|
44
|
+
return this.initPromise;
|
|
45
|
+
}
|
|
46
|
+
identify(userId, attributes = {}, options = {}) {
|
|
47
|
+
return this.doIdentify(userId, attributes, options);
|
|
48
|
+
}
|
|
49
|
+
group(groupId, attributes = {}, options = {}) {
|
|
50
|
+
return this.doGroup(groupId, attributes, options);
|
|
51
|
+
}
|
|
52
|
+
track(name, attributes = {}, options = {}) {
|
|
53
|
+
return this.doTrack(name, attributes, options);
|
|
54
|
+
}
|
|
55
|
+
getUserId() {
|
|
56
|
+
return this.userId;
|
|
57
|
+
}
|
|
58
|
+
getAttributes() {
|
|
59
|
+
return { ...this.attributes };
|
|
60
|
+
}
|
|
61
|
+
/** Suspend the connection (e.g. when the app backgrounds). No-op before identify. */
|
|
62
|
+
suspend() {
|
|
63
|
+
this.connection?.suspend();
|
|
64
|
+
}
|
|
65
|
+
/** Resume the connection (e.g. when the app foregrounds). No-op before identify. */
|
|
66
|
+
resume() {
|
|
67
|
+
this.connection?.resume();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Eagerly reconnect after a network recovery. No-op before identify, while
|
|
71
|
+
* suspended/connecting/connected, or when the SDK does not intend to be connected.
|
|
72
|
+
*/
|
|
73
|
+
reconnectNow() {
|
|
74
|
+
this.connection?.reconnectNow();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Verify the socket is alive right now and recover fast if not. Probes a
|
|
78
|
+
* connected socket (short reply deadline) or reconnects a dropped one. Used
|
|
79
|
+
* on foreground so recovery does not wait for the next scheduled heartbeat.
|
|
80
|
+
* No-op before identify. Requires no host network dependency.
|
|
81
|
+
*/
|
|
82
|
+
ensureAlive() {
|
|
83
|
+
this.connection?.ensureAlive();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Ensure the end-user channel is joined after an idle/background suspend.
|
|
87
|
+
* Mirrors web `ensureConnected()`: resume if suspended, then (re)join.
|
|
88
|
+
* No-op before identify.
|
|
89
|
+
*/
|
|
90
|
+
async ensureConnected() {
|
|
91
|
+
if (!this.userId || !this.config)
|
|
92
|
+
return;
|
|
93
|
+
if (!this.connection) {
|
|
94
|
+
this.connection = this.createConnection(this.config.clientToken, this.config.serverEndpoint);
|
|
95
|
+
this.connection.setClientContext(this.clientContext);
|
|
96
|
+
}
|
|
97
|
+
this.connection.resume();
|
|
98
|
+
await this.connection.ensureEndUserChannel(this.userId, this.identitySignature);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Push a Phase 3 client message on the joined channel.
|
|
102
|
+
* Requires an active connection (after identify).
|
|
103
|
+
*/
|
|
104
|
+
async send(message) {
|
|
105
|
+
if (!this.connection) {
|
|
106
|
+
return Promise.reject(new UserflowAuthError('Call Userflow.identify() before send()'));
|
|
107
|
+
}
|
|
108
|
+
await this.ensureConnected();
|
|
109
|
+
return this.connection.send(message);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Start a flow from a short-lived builder/preview token.
|
|
113
|
+
* Requires an active connection (after identify).
|
|
114
|
+
*/
|
|
115
|
+
async startFlowWithToken(token) {
|
|
116
|
+
const trimmed = token.trim();
|
|
117
|
+
if (!trimmed) {
|
|
118
|
+
throw new UserflowAuthError('Missing preview token');
|
|
119
|
+
}
|
|
120
|
+
await this.send({ kind: 'StartFlowWithToken', token: trimmed });
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Subscribe to inbound `server_message` frames.
|
|
124
|
+
* Requires an active connection (after identify).
|
|
125
|
+
*/
|
|
126
|
+
onServerMessage(handler) {
|
|
127
|
+
if (!this.connection) {
|
|
128
|
+
throw new UserflowAuthError('Call Userflow.identify() before onServerMessage()');
|
|
129
|
+
}
|
|
130
|
+
return this.connection.onServerMessage(handler);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Tell the transport which flow session to resume on (re)join.
|
|
134
|
+
* No-op before identify / connection creation.
|
|
135
|
+
*/
|
|
136
|
+
setFlowSessionId(flowSessionId) {
|
|
137
|
+
this.connection?.setFlowSessionId(flowSessionId);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Tell the transport which client-condition snapshot to include on (re)join.
|
|
141
|
+
* No-op before identify / connection creation.
|
|
142
|
+
*/
|
|
143
|
+
setClientConditions(clientConditions) {
|
|
144
|
+
this.connection?.setClientConditions(clientConditions);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Report the active mobile location. When identified, pushes
|
|
148
|
+
* `UpdateClientContext`. Before identify, the value is remembered for the
|
|
149
|
+
* next channel join.
|
|
150
|
+
*
|
|
151
|
+
* Expo Router should pass `{ path }`; React Navigation / manual callers pass
|
|
152
|
+
* `{ screen }`. Those map to wire fields `screenPath` / `screenName`.
|
|
153
|
+
* `pageUrl` stays `""` on mobile (required by the backend, web-only otherwise).
|
|
154
|
+
*/
|
|
155
|
+
async updateScreen(location) {
|
|
156
|
+
const next = 'path' in location
|
|
157
|
+
? {
|
|
158
|
+
...this.clientContext,
|
|
159
|
+
pageUrl: this.clientContext.pageUrl || '',
|
|
160
|
+
screenPath: location.path,
|
|
161
|
+
screenName: null,
|
|
162
|
+
}
|
|
163
|
+
: {
|
|
164
|
+
...this.clientContext,
|
|
165
|
+
pageUrl: this.clientContext.pageUrl || '',
|
|
166
|
+
screenPath: null,
|
|
167
|
+
screenName: location.screen,
|
|
168
|
+
};
|
|
169
|
+
this.clientContext = next;
|
|
170
|
+
if (!this.connection || !this.userId) {
|
|
171
|
+
this.connection?.setClientContext(next);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
await this.ensureConnected();
|
|
175
|
+
await this.connection.updateClientContext(next);
|
|
176
|
+
}
|
|
177
|
+
/** Clears the current user identity and disconnects the transport. */
|
|
178
|
+
reset() {
|
|
179
|
+
this.userId = null;
|
|
180
|
+
this.identitySignature = null;
|
|
181
|
+
this.attributes = {};
|
|
182
|
+
this.clientContext = { ...DEFAULT_CLIENT_CONTEXT };
|
|
183
|
+
this.connection?.disconnect();
|
|
184
|
+
this.connection = null;
|
|
185
|
+
}
|
|
186
|
+
requireInit() {
|
|
187
|
+
if (!this.config) {
|
|
188
|
+
throw new UserflowAuthError('Call Userflow.init() before identify()');
|
|
189
|
+
}
|
|
190
|
+
return this.config;
|
|
191
|
+
}
|
|
192
|
+
requireInitForGroup() {
|
|
193
|
+
if (!this.config) {
|
|
194
|
+
throw new UserflowAuthError('Call Userflow.init() before group()');
|
|
195
|
+
}
|
|
196
|
+
return this.config;
|
|
197
|
+
}
|
|
198
|
+
async doInit(options) {
|
|
199
|
+
const clientToken = requireField(options.clientToken, 'clientToken');
|
|
200
|
+
const serverEndpoint = (options.serverEndpoint ?? DEFAULT_SERVER_ENDPOINT).replace(/\/$/, '');
|
|
201
|
+
await this.validate(clientToken, serverEndpoint);
|
|
202
|
+
this.connection?.disconnect();
|
|
203
|
+
this.connection = null;
|
|
204
|
+
this.config = { clientToken, serverEndpoint };
|
|
205
|
+
this.userId = null;
|
|
206
|
+
this.identitySignature = null;
|
|
207
|
+
this.attributes = {};
|
|
208
|
+
return this.config;
|
|
209
|
+
}
|
|
210
|
+
requireIdentified() {
|
|
211
|
+
if (!this.userId) {
|
|
212
|
+
throw new UserflowAuthError('Call Userflow.identify() before group()');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async doIdentify(userId, attributes, options) {
|
|
216
|
+
const config = this.requireInit();
|
|
217
|
+
const externalId = requireField(userId, 'userId');
|
|
218
|
+
assertValidAttributeNames('user', attributes);
|
|
219
|
+
if (this.userId && externalId !== this.userId) {
|
|
220
|
+
this.reset();
|
|
221
|
+
}
|
|
222
|
+
const signature = options.signature ?? null;
|
|
223
|
+
if (!this.connection) {
|
|
224
|
+
this.connection = this.createConnection(config.clientToken, config.serverEndpoint);
|
|
225
|
+
}
|
|
226
|
+
// Seed join payload with the latest screen before the channel join.
|
|
227
|
+
this.connection.setClientContext(this.clientContext);
|
|
228
|
+
await this.connection.identify(externalId, attributes, signature);
|
|
229
|
+
const isSameUser = this.userId === externalId;
|
|
230
|
+
this.userId = externalId;
|
|
231
|
+
this.identitySignature = signature;
|
|
232
|
+
this.attributes = isSameUser ? { ...this.attributes, ...attributes } : { ...attributes };
|
|
233
|
+
}
|
|
234
|
+
async doGroup(groupId, attributes, options) {
|
|
235
|
+
this.requireInitForGroup();
|
|
236
|
+
this.requireIdentified();
|
|
237
|
+
const externalId = requireField(typeof groupId === 'number' ? String(groupId) : groupId, 'groupId');
|
|
238
|
+
assertValidAttributeNames('group', attributes);
|
|
239
|
+
assertValidAttributeNames('group_membership', options.membership ?? {});
|
|
240
|
+
const signature = options.signature ?? null;
|
|
241
|
+
await this.ensureConnected();
|
|
242
|
+
await this.connection.group({
|
|
243
|
+
groupExternalId: externalId,
|
|
244
|
+
groupSignature: signature,
|
|
245
|
+
groupAttributes: attributes ?? {},
|
|
246
|
+
membershipAttributes: options.membership ?? {},
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
async doTrack(name, attributes, options) {
|
|
250
|
+
if (!this.config) {
|
|
251
|
+
throw new UserflowAuthError('Call Userflow.init() before track()');
|
|
252
|
+
}
|
|
253
|
+
if (!this.userId) {
|
|
254
|
+
throw new UserflowAuthError('Call Userflow.identify() before track()');
|
|
255
|
+
}
|
|
256
|
+
const eventName = requireField(name, 'name');
|
|
257
|
+
assertValidEventName(eventName);
|
|
258
|
+
await this.send({
|
|
259
|
+
kind: 'TrackEvent',
|
|
260
|
+
userOnly: !!options.userOnly,
|
|
261
|
+
name: eventName,
|
|
262
|
+
attributes: normalizeTrackEventAttributes(attributes),
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=UserflowCore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserflowCore.js","sourceRoot":"","sources":["../../src/engine/UserflowCore.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO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BAA6B,CAAC,UAAU,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FlowActionFragment, FlowSessionFragment, FlowStepFragment } from '@userflow-tech/protocol';
|
|
2
|
+
import { EndFlowReasonInput } from '@userflow-tech/protocol';
|
|
3
|
+
/** Narrow surface handleActions needs from FlowSessionEngine (avoids a circular import). */
|
|
4
|
+
export interface FlowActionRunner {
|
|
5
|
+
goToStep(step: FlowStepFragment): Promise<void>;
|
|
6
|
+
endFlow(endReason: EndFlowReasonInput): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface HandleActionsDeps {
|
|
9
|
+
engine: FlowActionRunner;
|
|
10
|
+
onOpenExternalUrl?: (url: string) => void;
|
|
11
|
+
warn?: (message: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* MVP port of web `handleActions`: GO_TO_STEP, CLOSE_FLOW, NAVIGATE.
|
|
15
|
+
* Ordering matches userflowjs — NEW_TAB navigate sync, other actions in parallel,
|
|
16
|
+
* SAME_TAB navigate last.
|
|
17
|
+
*/
|
|
18
|
+
export declare function handleActions(session: FlowSessionFragment, actions: FlowActionFragment[], deps: HandleActionsDeps): Promise<void>;
|
|
19
|
+
//# sourceMappingURL=handleActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleActions.d.ts","sourceRoot":"","sources":["../../src/engine/handleActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAGnB,MAAM,yBAAyB,CAAC;AAIjC,4FAA4F;AAC5F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,gBAAgB,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,kBAAkB,EAAE,EAC7B,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { EndFlowReasonInput, FlowActionNavigateTarget, FlowActionType, } from '@userflow-tech/protocol';
|
|
2
|
+
import { interpolateSessionData } from './interpolateSessionData.js';
|
|
3
|
+
/**
|
|
4
|
+
* MVP port of web `handleActions`: GO_TO_STEP, CLOSE_FLOW, NAVIGATE.
|
|
5
|
+
* Ordering matches userflowjs — NEW_TAB navigate sync, other actions in parallel,
|
|
6
|
+
* SAME_TAB navigate last.
|
|
7
|
+
*/
|
|
8
|
+
export async function handleActions(session, actions, deps) {
|
|
9
|
+
const syncActions = [];
|
|
10
|
+
const regularActions = [];
|
|
11
|
+
const postActions = [];
|
|
12
|
+
for (const action of actions) {
|
|
13
|
+
if (action.type === FlowActionType.NAVIGATE) {
|
|
14
|
+
if (action.navigateTarget === FlowActionNavigateTarget.NEW_TAB) {
|
|
15
|
+
syncActions.push(action);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
postActions.push(action);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
regularActions.push(action);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
for (const action of syncActions) {
|
|
26
|
+
await handleAction(session, action, deps);
|
|
27
|
+
}
|
|
28
|
+
await Promise.all(regularActions.map((action) => handleAction(session, action, deps)));
|
|
29
|
+
for (const action of postActions) {
|
|
30
|
+
await handleAction(session, action, deps);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function handleAction(session, action, deps) {
|
|
34
|
+
const { engine, onOpenExternalUrl, warn = console.warn } = deps;
|
|
35
|
+
switch (action.type) {
|
|
36
|
+
case FlowActionType.CLOSE_FLOW:
|
|
37
|
+
if (session.kind === 'flow') {
|
|
38
|
+
await engine.endFlow(EndFlowReasonInput.ACTION);
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
case FlowActionType.GO_TO_STEP: {
|
|
42
|
+
if (session.kind !== 'flow')
|
|
43
|
+
return;
|
|
44
|
+
const step = session.version.steps.find(({ crossVersionId }) => crossVersionId === action.stepCvid);
|
|
45
|
+
if (!step) {
|
|
46
|
+
throw new Error(`Action points to unknown step: ${action.stepCvid}`);
|
|
47
|
+
}
|
|
48
|
+
await engine.goToStep(step);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
case FlowActionType.NAVIGATE: {
|
|
52
|
+
if (!action.url) {
|
|
53
|
+
warn('Userflow: NAVIGATE action is missing url property');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const url = interpolateSessionData(action.url, session.data);
|
|
57
|
+
onOpenExternalUrl?.(url);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
case FlowActionType.EVAL_JS:
|
|
61
|
+
case FlowActionType.SET_ATTRIBUTE:
|
|
62
|
+
case FlowActionType.SNOOZE:
|
|
63
|
+
case FlowActionType.START_FLOW:
|
|
64
|
+
case FlowActionType.TRACK_BUTTON_EVENT:
|
|
65
|
+
warn(`Userflow: action type ${action.type} is not supported on mobile yet`);
|
|
66
|
+
return;
|
|
67
|
+
default:
|
|
68
|
+
warn(`Userflow: unknown action type ${action.type}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=handleActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleActions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C,aAAa,CAAC;QAClC,KAAK,cAAc,CAAC,MAAM,CAAC;QAC3B,KAAK,cAAc,CAAC,UAAU,CAAC;QAC/B,KAAK,cAAc,CAAC,kBAAkB;YACpC,IAAI,CAAC,yBAAyB,MAAM,CAAC,IAAI,iCAAiC,CAAC,CAAC;YAC5E,OAAO;QAET;YACE,IAAI,CAAC,iCAAkC,MAA6B,CAAC,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SessionDataFragment } from '@userflow-tech/protocol';
|
|
2
|
+
/** Port of web `interpolateVariables` for `{{attribute}}` templates. */
|
|
3
|
+
export declare function interpolateVariables(content: string, lookup: (name: string) => string | null): string;
|
|
4
|
+
export declare function genSessionDataLookup(data: SessionDataFragment[]): (fqn: string) => string | null;
|
|
5
|
+
/** Resolve `{{name}}` placeholders against flow session data. */
|
|
6
|
+
export declare function interpolateSessionData(content: string, data: SessionDataFragment[]): string;
|
|
7
|
+
//# sourceMappingURL=interpolateSessionData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolateSessionData.d.ts","sourceRoot":"","sources":["../../src/engine/interpolateSessionData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,wEAAwE;AACxE,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GACtC,MAAM,CAWR;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAWhG;AAED,iEAAiE;AACjE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAG3F"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const VARIABLE_REGEX = /(\\*)\{\{([a-zA-Z0-9_.\\/]+)\}\}/g;
|
|
2
|
+
/** Port of web `interpolateVariables` for `{{attribute}}` templates. */
|
|
3
|
+
export function interpolateVariables(content, lookup) {
|
|
4
|
+
return (content || '').replace(VARIABLE_REGEX, (_fullMatch, backslashes, name) => {
|
|
5
|
+
const backslashCount = backslashes.length;
|
|
6
|
+
if (backslashCount % 2 === 0) {
|
|
7
|
+
return '\\'.repeat(backslashCount / 2) + (lookup(name) || '');
|
|
8
|
+
}
|
|
9
|
+
return '\\'.repeat((backslashCount - 1) / 2) + '{{' + name + '}}';
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function genSessionDataLookup(data) {
|
|
13
|
+
let dataMap = null;
|
|
14
|
+
return (fqn) => {
|
|
15
|
+
if (!dataMap) {
|
|
16
|
+
dataMap = new Map();
|
|
17
|
+
for (const { name, value } of data) {
|
|
18
|
+
dataMap.set(name, Array.isArray(value) ? (value[0] ?? '') : value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return dataMap.get(fqn) || null;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Resolve `{{name}}` placeholders against flow session data. */
|
|
25
|
+
export function interpolateSessionData(content, data) {
|
|
26
|
+
const lookup = genSessionDataLookup(data);
|
|
27
|
+
return interpolateVariables(content, (name) => lookup(name));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=interpolateSessionData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolateSessionData.js","sourceRoot":"","sources":["../../src/engine/interpolateSessionData.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAE3D,wEAAwE;AACxE,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,MAAuC;IAEvC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAC5B,cAAc,EACd,CAAC,UAAU,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AAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Error thrown for init/identify/transport failures in the SDK. */
|
|
2
|
+
export declare class UserflowAuthError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/** Error thrown when outbound client-message rate limits are exceeded. */
|
|
6
|
+
export declare class UserflowRateLimitError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED,0EAA0E;AAC1E,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Error thrown for init/identify/transport failures in the SDK. */
|
|
2
|
+
export class UserflowAuthError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = 'UserflowAuthError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Error thrown when outbound client-message rate limits are exceeded. */
|
|
9
|
+
export class UserflowRateLimitError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'UserflowRateLimitError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,0EAA0E;AAC1E,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EventAttributes, UserflowAttributes } from '@userflow-tech/protocol';
|
|
2
|
+
/**
|
|
3
|
+
* Validates and normalizes event attributes for {@link TrackEvent}.
|
|
4
|
+
* Mobile SDK: literal `string | number | boolean | null` only (no web ops).
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeTrackEventAttributes(input?: UserflowAttributes): EventAttributes;
|
|
7
|
+
//# sourceMappingURL=eventAttributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventAttributes.d.ts","sourceRoot":"","sources":["../src/eventAttributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAKnF;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,CAAC,EAAE,kBAAkB,GAAG,eAAe,CA2BzF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { assertValidAttributeNames } from './attributes.js';
|
|
2
|
+
import { UserflowAuthError } from './errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates and normalizes event attributes for {@link TrackEvent}.
|
|
5
|
+
* Mobile SDK: literal `string | number | boolean | null` only (no web ops).
|
|
6
|
+
*/
|
|
7
|
+
export function normalizeTrackEventAttributes(input) {
|
|
8
|
+
if (input == null) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
if (typeof input !== 'object' || Array.isArray(input)) {
|
|
12
|
+
throw new UserflowAuthError(`'attributes' must be an object.`);
|
|
13
|
+
}
|
|
14
|
+
assertValidAttributeNames('event', input);
|
|
15
|
+
const output = {};
|
|
16
|
+
for (const name of Object.keys(input)) {
|
|
17
|
+
if (!Object.prototype.hasOwnProperty.call(input, name)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const value = input[name];
|
|
21
|
+
if (value !== null &&
|
|
22
|
+
typeof value !== 'string' &&
|
|
23
|
+
typeof value !== 'number' &&
|
|
24
|
+
typeof value !== 'boolean') {
|
|
25
|
+
throw new UserflowAuthError(`Invalid value for '${name}' attribute.`);
|
|
26
|
+
}
|
|
27
|
+
output[name] = value;
|
|
28
|
+
}
|
|
29
|
+
return output;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=eventAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventAttributes.js","sourceRoot":"","sources":["../src/eventAttributes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAAC,KAA0B;IACtE,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,iBAAiB,CAAC,iCAAiC,CAAC,CAAC;IACjE,CAAC;IAED,yBAAyB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;YACvD,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,IACE,KAAK,KAAK,IAAI;YACd,OAAO,KAAK,KAAK,QAAQ;YACzB,OAAO,KAAK,KAAK,QAAQ;YACzB,OAAO,KAAK,KAAK,SAAS,EAC1B,CAAC;YACD,MAAM,IAAI,iBAAiB,CAAC,sBAAsB,IAAI,cAAc,CAAC,CAAC;QACxE,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @userflow-tech/core — platform-agnostic engine for the Userflow RN SDK.
|
|
3
|
+
*
|
|
4
|
+
* Hosts the Phoenix websocket transport and the `UserflowCore` engine that
|
|
5
|
+
* validates credentials and identifies users. The React Native binding wraps
|
|
6
|
+
* this engine to expose the public `Userflow` API.
|
|
7
|
+
*/
|
|
8
|
+
export { PROTOCOL_VERSION } from '@userflow-tech/protocol';
|
|
9
|
+
export type { UserflowAttributes, UserflowAttributeValue } from '@userflow-tech/protocol';
|
|
10
|
+
export { assertValidAttributeNames, assertValidEventName, isAttributeNameSoftValid, MAX_ATTRIBUTE_NAME_LENGTH, MAX_EVENT_NAME_LENGTH, validateAttributeName, } from './attributes.js';
|
|
11
|
+
export type { AttributeScope } from './attributes.js';
|
|
12
|
+
export { DEFAULT_PAIRING_ENDPOINT, DEFAULT_SERVER_ENDPOINT } from './constants.js';
|
|
13
|
+
export { UserflowAuthError, UserflowRateLimitError } from './errors.js';
|
|
14
|
+
export { FlowSessionEngine } from './engine/FlowSessionEngine.js';
|
|
15
|
+
export type { FlowSessionEngineDeps, FlowSessionEngineEvent, FlowSessionEngineListener, FlowTransport, } from './engine/FlowSessionEngine.js';
|
|
16
|
+
export { ClientConditionEngine } from './engine/ClientConditionEngine.js';
|
|
17
|
+
export type { ClientConditionEngineDeps, ClientConditionTransport, ConditionEvaluator, } from './engine/ClientConditionEngine.js';
|
|
18
|
+
export { PairingEngine } from './engine/PairingEngine.js';
|
|
19
|
+
export type { PairingEngineDeps, PairingEngineListener, PairingEngineState, PairingEngineStatus, } from './engine/PairingEngine.js';
|
|
20
|
+
export { UserflowCore } from './engine/UserflowCore.js';
|
|
21
|
+
export type { CreateConnectionFn, UserflowConnection, UserflowCoreDeps, ValidateCredentialsFn, } from './engine/UserflowCore.js';
|
|
22
|
+
export { PhoenixConnection, buildWsUrl, validateCredentials } from './transport/phoenix.js';
|
|
23
|
+
export type { ConnectionState, PhoenixConnectionOptions, ServerMessageHandler, WebSocketCtor, WebSocketLike, } from './transport/phoenix.js';
|
|
24
|
+
export { PairingConnection, buildPairingWsUrl } from './transport/pairing.js';
|
|
25
|
+
export type { PairingConnectionEvent, PairingConnectionListener, PairingConnectionOptions, } from './transport/pairing.js';
|
|
26
|
+
export type { UserflowConfig, UserflowCredentials, UserflowEventAttributes, UserflowGroupOptions, UserflowIdentifyOptions, UserflowInitOptions, UserflowTrackOptions, } from './types.js';
|
|
27
|
+
export { normalizeTrackEventAttributes } from './eventAttributes.js';
|
|
28
|
+
export { genSessionDataLookup, interpolateSessionData, interpolateVariables, } from './engine/interpolateSessionData.js';
|
|
29
|
+
export { CORE_VERSION } from './version.js';
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAE1F,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE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,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @userflow-tech/core — platform-agnostic engine for the Userflow RN SDK.
|
|
3
|
+
*
|
|
4
|
+
* Hosts the Phoenix websocket transport and the `UserflowCore` engine that
|
|
5
|
+
* validates credentials and identifies users. The React Native binding wraps
|
|
6
|
+
* this engine to expose the public `Userflow` API.
|
|
7
|
+
*/
|
|
8
|
+
export { PROTOCOL_VERSION } from '@userflow-tech/protocol';
|
|
9
|
+
export { assertValidAttributeNames, assertValidEventName, isAttributeNameSoftValid, MAX_ATTRIBUTE_NAME_LENGTH, MAX_EVENT_NAME_LENGTH, validateAttributeName, } from './attributes.js';
|
|
10
|
+
export { DEFAULT_PAIRING_ENDPOINT, DEFAULT_SERVER_ENDPOINT } from './constants.js';
|
|
11
|
+
export { UserflowAuthError, UserflowRateLimitError } from './errors.js';
|
|
12
|
+
export { FlowSessionEngine } from './engine/FlowSessionEngine.js';
|
|
13
|
+
export { ClientConditionEngine } from './engine/ClientConditionEngine.js';
|
|
14
|
+
export { PairingEngine } from './engine/PairingEngine.js';
|
|
15
|
+
export { UserflowCore } from './engine/UserflowCore.js';
|
|
16
|
+
export { PhoenixConnection, buildWsUrl, validateCredentials } from './transport/phoenix.js';
|
|
17
|
+
export { PairingConnection, buildPairingWsUrl } from './transport/pairing.js';
|
|
18
|
+
export { normalizeTrackEventAttributes } from './eventAttributes.js';
|
|
19
|
+
export { genSessionDataLookup, interpolateSessionData, interpolateVariables, } from './engine/interpolateSessionData.js';
|
|
20
|
+
export { CORE_VERSION } from './version.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAOlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAM1E,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO1D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAOxD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQ5F,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAe9E,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The reconnect backoff ladder (milliseconds); the last value is the cap. */
|
|
2
|
+
export declare const RECONNECT_LADDER_MS: readonly number[];
|
|
3
|
+
/** Walks a delay ladder, capping at the final entry, until `reset()`. */
|
|
4
|
+
export interface Backoff {
|
|
5
|
+
/** The next delay to wait, advancing (and capping at) the ladder. */
|
|
6
|
+
nextDelay(): number;
|
|
7
|
+
/** Reset back to the first rung (call after a successful connection). */
|
|
8
|
+
reset(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createBackoff(ladder?: readonly number[]): Backoff;
|
|
11
|
+
//# sourceMappingURL=backoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backoff.d.ts","sourceRoot":"","sources":["../../src/transport/backoff.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAAkC,CAAC;AAEpF,yEAAyE;AACzE,MAAM,WAAW,OAAO;IACtB,qEAAqE;IACrE,SAAS,IAAI,MAAM,CAAC;IACpB,yEAAyE;IACzE,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,MAAM,GAAE,SAAS,MAAM,EAAwB,GAAG,OAAO,CAatF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The reconnect backoff ladder (milliseconds); the last value is the cap. */
|
|
2
|
+
export const RECONNECT_LADDER_MS = [100, 500, 1000, 5000, 10000];
|
|
3
|
+
export function createBackoff(ladder = RECONNECT_LADDER_MS) {
|
|
4
|
+
const rungs = ladder.length > 0 ? ladder : RECONNECT_LADDER_MS;
|
|
5
|
+
let attempt = 0;
|
|
6
|
+
return {
|
|
7
|
+
nextDelay() {
|
|
8
|
+
const index = Math.min(attempt, rungs.length - 1);
|
|
9
|
+
attempt += 1;
|
|
10
|
+
return rungs[index] ?? rungs[rungs.length - 1] ?? 0;
|
|
11
|
+
},
|
|
12
|
+
reset() {
|
|
13
|
+
attempt = 0;
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=backoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backoff.js","sourceRoot":"","sources":["../../src/transport/backoff.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAUpF,MAAM,UAAU,aAAa,CAAC,SAA4B,mBAAmB;IAC3E,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAC/D,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,OAAO;QACL,SAAS;YACP,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAClD,OAAO,IAAI,CAAC,CAAC;YACb,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC;QACD,KAAK;YACH,OAAO,GAAG,CAAC,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|