@simplr-ai/vue 1.0.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/LICENSE +21 -0
- package/README.md +261 -0
- package/dist/index.cjs +617 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +385 -0
- package/dist/index.d.ts +385 -0
- package/dist/index.js +536 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Simplr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# @simplr-ai/vue
|
|
2
|
+
|
|
3
|
+
Idiomatic **Vue 3** adapter for the [Simplr](https://docs.simplr.so/docs/sdks/) platform.
|
|
4
|
+
|
|
5
|
+
This package is a **thin adapter** over the browser core SDK
|
|
6
|
+
[`@simplr-ai/js`](../simplr-js-sdk). It does **not** reimplement any
|
|
7
|
+
feature — it exposes the core SDK's full surface through Vue primitives: a
|
|
8
|
+
plugin, composables, components and a directive. Every client feature of the
|
|
9
|
+
core SDK has an idiomatic Vue binding:
|
|
10
|
+
|
|
11
|
+
| Feature | Vue binding |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| Device fingerprint | `useDeviceSignals()`, `useSimplr().collectDeviceSignals()` |
|
|
14
|
+
| Behavioral biometrics | `useSimplr()`, `<SimplrProtectedInput>`, `v-simplr-protect` |
|
|
15
|
+
| Fraud/identity collect | `useSimplr().collect()`, `<SimplrProtectedForm>` |
|
|
16
|
+
| Feature flags (local eval) | `useFeatureFlag()`, `useFeatureFlags()` |
|
|
17
|
+
| Profiles / identify | `useProfiles().identify()` |
|
|
18
|
+
| Order scoring | `useProfiles().submitOrder()` |
|
|
19
|
+
| RUM (full) | `useRum()`, `useTrackView()`, `useTrackAction()`, `useTrackError()`, `useRumUser()`, `useRumAttributes()`, `useRumLogger()`, `useTrackAsync()`, `<RumView>`, `<RumErrorBoundary>`, `installRumErrorHandler()` |
|
|
20
|
+
| AI delegation | `useAIDelegation()`, `useDelegations()` |
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm i @simplr-ai/vue @simplr-ai/js vue
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`vue` (`^3.3`) and `@simplr-ai/js` are **peer dependencies**.
|
|
29
|
+
|
|
30
|
+
## Plugin setup
|
|
31
|
+
|
|
32
|
+
Create the plugin with `createSimplr(config)` and install it with `app.use()`.
|
|
33
|
+
It builds the configured core SDK instances (`SimplrFraud`, `SimplrFlags`,
|
|
34
|
+
`SimplrProfiles`, `SimplrRUM`, `SimplrAI`) and provides them via Vue's
|
|
35
|
+
`provide`/`inject`.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// main.ts
|
|
39
|
+
import { createApp } from "vue";
|
|
40
|
+
import { createSimplr, installRumErrorHandler } from "@simplr-ai/vue";
|
|
41
|
+
import App from "./App.vue";
|
|
42
|
+
|
|
43
|
+
const app = createApp(App);
|
|
44
|
+
|
|
45
|
+
app.use(
|
|
46
|
+
createSimplr({
|
|
47
|
+
apiKey: "pk_live_…", // public key — safe for the client
|
|
48
|
+
flags: true, // enable feature flags (initialize() runs automatically)
|
|
49
|
+
profiles: true, // enable anonymous profiles + order scoring
|
|
50
|
+
rum: { apiKey: "pk_live_…", applicationId: "my-web-app" },
|
|
51
|
+
ai: true, // enable AI delegation
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// Optional: forward uncaught Vue errors to RUM.
|
|
56
|
+
installRumErrorHandler(app);
|
|
57
|
+
|
|
58
|
+
app.mount("#app");
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Any sub-feature you omit simply isn't created — `createSimplr({ apiKey })`
|
|
62
|
+
gives you just the core fraud client.
|
|
63
|
+
|
|
64
|
+
The plugin also registers the global `v-simplr-protect` directive.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Device signals
|
|
69
|
+
|
|
70
|
+
```vue
|
|
71
|
+
<script setup lang="ts">
|
|
72
|
+
import { useDeviceSignals } from "@simplr-ai/vue";
|
|
73
|
+
|
|
74
|
+
const { signals, loading, error, refresh } = useDeviceSignals();
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<pre v-if="signals">{{ signals.fingerprint }}</pre>
|
|
79
|
+
<button @click="refresh" :disabled="loading">Re-collect</button>
|
|
80
|
+
</template>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`useSimplr()` gives you the raw client plus `collect()`, `reset()`,
|
|
84
|
+
`startTracking()`, `stopTracking()` and `trackInput()`.
|
|
85
|
+
|
|
86
|
+
## Feature flags
|
|
87
|
+
|
|
88
|
+
Flags are evaluated **locally** with the same murmurhash bucketing as every
|
|
89
|
+
other Simplr SDK. The composables re-evaluate reactively as flags load/refresh.
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<script setup lang="ts">
|
|
93
|
+
import { useFeatureFlag, useFeatureFlags } from "@simplr-ai/vue";
|
|
94
|
+
|
|
95
|
+
const { enabled, isReady } = useFeatureFlag("new-checkout", {
|
|
96
|
+
userId: "user_123",
|
|
97
|
+
attributes: { plan: "pro" },
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Or the whole map:
|
|
101
|
+
const { flags, isEnabled, setUser } = useFeatureFlags();
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<template>
|
|
105
|
+
<NewCheckout v-if="enabled" />
|
|
106
|
+
</template>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Profiles & order scoring
|
|
110
|
+
|
|
111
|
+
Device fingerprint auto-attach is wired for you by the plugin.
|
|
112
|
+
|
|
113
|
+
```vue
|
|
114
|
+
<script setup lang="ts">
|
|
115
|
+
import { useProfiles } from "@simplr-ai/vue";
|
|
116
|
+
|
|
117
|
+
const { identify, submitOrder, getProfileRisk, reportOutcome, loading } =
|
|
118
|
+
useProfiles();
|
|
119
|
+
|
|
120
|
+
async function checkout() {
|
|
121
|
+
await identify("user_123");
|
|
122
|
+
const result = await submitOrder({
|
|
123
|
+
external_order_id: "ord_1",
|
|
124
|
+
external_id: "user_123",
|
|
125
|
+
amount_cents: 4999,
|
|
126
|
+
currency: "USD",
|
|
127
|
+
});
|
|
128
|
+
if (result.risk.flagged_for_review) {
|
|
129
|
+
await reportOutcome("user_123", "fraud");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
</script>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## RUM (Real User Monitoring)
|
|
136
|
+
|
|
137
|
+
```vue
|
|
138
|
+
<script setup lang="ts">
|
|
139
|
+
import {
|
|
140
|
+
useTrackView,
|
|
141
|
+
useTrackAction,
|
|
142
|
+
useTrackError,
|
|
143
|
+
useRumUser,
|
|
144
|
+
useRumLogger,
|
|
145
|
+
} from "@simplr-ai/vue";
|
|
146
|
+
|
|
147
|
+
useTrackView("Dashboard"); // tracks a view on mount
|
|
148
|
+
|
|
149
|
+
const track = useTrackAction();
|
|
150
|
+
const trackError = useTrackError();
|
|
151
|
+
const { setUser } = useRumUser();
|
|
152
|
+
const log = useRumLogger();
|
|
153
|
+
|
|
154
|
+
setUser("user_123", { plan: "pro" });
|
|
155
|
+
log.info("dashboard loaded");
|
|
156
|
+
|
|
157
|
+
function onBuy() {
|
|
158
|
+
track("Buy clicked", "click");
|
|
159
|
+
}
|
|
160
|
+
</script>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Declarative helpers:
|
|
164
|
+
|
|
165
|
+
```vue
|
|
166
|
+
<template>
|
|
167
|
+
<RumView name="Checkout">
|
|
168
|
+
<RumErrorBoundary @error="report">
|
|
169
|
+
<template #fallback="{ error }">Oops: {{ error.message }}</template>
|
|
170
|
+
<CheckoutForm />
|
|
171
|
+
</RumErrorBoundary>
|
|
172
|
+
</RumView>
|
|
173
|
+
</template>
|
|
174
|
+
|
|
175
|
+
<script setup lang="ts">
|
|
176
|
+
import { RumView, RumErrorBoundary } from "@simplr-ai/vue";
|
|
177
|
+
function report(e: Error) { /* … */ }
|
|
178
|
+
</script>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## AI delegation
|
|
182
|
+
|
|
183
|
+
OAuth-like AI authentication.
|
|
184
|
+
|
|
185
|
+
```vue
|
|
186
|
+
<script setup lang="ts">
|
|
187
|
+
import { useAIDelegation, useDelegations } from "@simplr-ai/vue";
|
|
188
|
+
|
|
189
|
+
const { connect, createDelegation, validate, revoke, stats } = useAIDelegation();
|
|
190
|
+
const { delegations, refresh, revoke: revokeOne } = useDelegations(undefined, "user_123");
|
|
191
|
+
|
|
192
|
+
async function link() {
|
|
193
|
+
const res = await connect({ userId: "user_123", binding: "verified_device" });
|
|
194
|
+
if (res.success) console.log(res.delegationId);
|
|
195
|
+
}
|
|
196
|
+
</script>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Protected form & input
|
|
200
|
+
|
|
201
|
+
`<SimplrProtectedForm>` collects device + behavioral signals on submit and
|
|
202
|
+
emits them; `<SimplrProtectedInput>` auto-attaches keystroke tracking.
|
|
203
|
+
|
|
204
|
+
```vue
|
|
205
|
+
<script setup lang="ts">
|
|
206
|
+
import { ref } from "vue";
|
|
207
|
+
import {
|
|
208
|
+
SimplrProtectedForm,
|
|
209
|
+
SimplrProtectedInput,
|
|
210
|
+
} from "@simplr-ai/vue";
|
|
211
|
+
import type { CollectedSignals } from "@simplr-ai/vue";
|
|
212
|
+
|
|
213
|
+
const email = ref("");
|
|
214
|
+
|
|
215
|
+
async function onSubmit(signals: CollectedSignals) {
|
|
216
|
+
await fetch("/api/signup", {
|
|
217
|
+
method: "POST",
|
|
218
|
+
body: JSON.stringify({ email: email.value, signals }),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
</script>
|
|
222
|
+
|
|
223
|
+
<template>
|
|
224
|
+
<SimplrProtectedForm @submit="onSubmit">
|
|
225
|
+
<SimplrProtectedInput v-model="email" field="email" type="email" />
|
|
226
|
+
<button type="submit">Sign up</button>
|
|
227
|
+
</SimplrProtectedForm>
|
|
228
|
+
</template>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The `v-simplr-protect` directive marks any input with `data-simplr-field` and
|
|
232
|
+
(when given a `trackInput` factory) attaches keystroke handlers:
|
|
233
|
+
|
|
234
|
+
```vue
|
|
235
|
+
<template>
|
|
236
|
+
<input v-simplr-protect="'email'" />
|
|
237
|
+
<!-- or wire the core tracker explicitly: -->
|
|
238
|
+
<input v-simplr-protect="{ field: 'email', trackInput }" />
|
|
239
|
+
</template>
|
|
240
|
+
|
|
241
|
+
<script setup lang="ts">
|
|
242
|
+
import { useSimplr } from "@simplr-ai/vue";
|
|
243
|
+
const { trackInput } = useSimplr();
|
|
244
|
+
</script>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## What this package wraps
|
|
248
|
+
|
|
249
|
+
Everything here delegates to `@simplr-ai/js`. The full core surface —
|
|
250
|
+
`SimplrFraud`, `SimplrFlags`, `SimplrProfiles`, `SimplrRUM`, `SimplrAI`, plus
|
|
251
|
+
helpers like `getDeviceId`, `murmurHash3`, `createFingerprintHash` and all
|
|
252
|
+
types — is **re-exported** from `@simplr-ai/vue` so you can import everything
|
|
253
|
+
from one place.
|
|
254
|
+
|
|
255
|
+
## Docs
|
|
256
|
+
|
|
257
|
+
Full documentation: <https://docs.simplr.so/docs/sdks/> (see the **Vue** page).
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
MIT
|