@inzombieland/nuxt-common 1.20.0 → 1.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "configKey": "nuxt-common",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
2
2
  import { defineNuxtModule, createResolver, addServerHandler, addImportsDir, addPlugin, addComponent } from '@nuxt/kit';
3
3
 
4
4
  const name = "@inzombieland/nuxt-common";
5
- const version = "1.20.0";
5
+ const version = "1.20.2";
6
6
 
7
7
  const module$1 = defineNuxtModule({
8
8
  meta: {
@@ -5,6 +5,5 @@ export declare const getToken: () => string | null | undefined;
5
5
  export declare const setToken: (newToken?: string | null) => void;
6
6
  export declare const getSecretKey: () => string | undefined;
7
7
  export declare const setSecretKey: (newSecretKey?: string) => void;
8
- export declare const setVisitorId: (visitorId?: string) => void;
9
8
  export declare const flush: () => void;
10
9
  export declare const createApiFetch: (fetch: Fetch, config: FetchConfig) => (url: string, options?: FetchOptions) => Promise<any>;
@@ -27,9 +27,6 @@ export const getSecretKey = () => {
27
27
  export const setSecretKey = (newSecretKey) => {
28
28
  secretKey = newSecretKey;
29
29
  };
30
- export const setVisitorId = (visitorId = "") => {
31
- localStorage.setItem("vid", visitorId);
32
- };
33
30
  export const flush = () => {
34
31
  setToken(null);
35
32
  setUser(null);
@@ -105,8 +102,8 @@ const optionsHandler = (options = {}, config) => {
105
102
  const { platform, hostname } = visitor;
106
103
  const visitorIdentifier = useVisitor();
107
104
  if (visitorIdentifier.value) {
108
- const { id, ip, device, appName } = visitorIdentifier.value;
109
- headers.visitor = btoa(`${platform}|:|${hostname}|:|${id}|:|${ip}|:|${device}|:|${appName}`);
105
+ const { id, fid, device, appName } = visitorIdentifier.value;
106
+ headers.visitor = btoa(`${platform}|:|${hostname}|:|${id}|:|${fid}|:|${device}|:|${appName}`);
110
107
  } else {
111
108
  headers.visitor = btoa(`${platform}|:|${hostname}`);
112
109
  }
@@ -1,12 +1,12 @@
1
1
  import type { Visitor } from "../types.js";
2
2
  export declare function useVisitor(): import("vue").Ref<{
3
3
  id?: string | undefined;
4
- ip?: string | undefined;
4
+ fid?: string | undefined;
5
5
  device?: string | undefined;
6
6
  appName?: string | undefined;
7
7
  } | null | undefined, Visitor | {
8
8
  id?: string | undefined;
9
- ip?: string | undefined;
9
+ fid?: string | undefined;
10
10
  device?: string | undefined;
11
11
  appName?: string | undefined;
12
12
  } | null | undefined>;
@@ -1,6 +1,7 @@
1
1
  import { hashComponents, load } from "@fingerprintjs/fingerprintjs";
2
2
  import { useVisitor } from "./composables/index.js";
3
3
  import { createSingletonAsync, once } from "./helpers/index.js";
4
+ import { getVisitorId } from "./local-storage-utils.js";
4
5
  const setVisitor = (newVisitor) => {
5
6
  const visitor = useVisitor();
6
7
  visitor.value = !visitor.value ? newVisitor : { ...visitor.value, ...newVisitor };
@@ -13,11 +14,14 @@ const getVisitorRequest = async (config) => {
13
14
  const fp = await load();
14
15
  const result = await fp.get();
15
16
  const { canvas, colorDepth, hdr, languages, screenFrame, screenResolution, ...components } = result.components;
16
- const id = hashComponents(components);
17
- const ip = "unknown";
17
+ const fid = hashComponents(components);
18
+ let id = getVisitorId() ?? "";
19
+ if (!/^[0-9a-f]{32}$/i.test(id)) {
20
+ id = fid;
21
+ }
18
22
  const device = await config.getDevice() || "unknown";
19
23
  const appName = config.appName || "unknown";
20
- setVisitor({ id, ip, device, appName });
24
+ setVisitor({ id, fid, device, appName });
21
25
  };
22
26
  const getVisitorIdentifier = createSingletonAsync(getVisitorRequest);
23
27
  export const createApiGetVisitorIdentifier = once((config) => {
@@ -0,0 +1,2 @@
1
+ export declare const getVisitorId: () => string | null;
2
+ export declare const setVisitorId: (visitorId?: string) => void;
@@ -0,0 +1,11 @@
1
+ export const getVisitorId = () => {
2
+ if (typeof window !== "undefined") {
3
+ return window.localStorage.getItem("vid");
4
+ }
5
+ return null;
6
+ };
7
+ export const setVisitorId = (visitorId = "") => {
8
+ if (typeof window !== "undefined") {
9
+ window.localStorage.setItem("vid", visitorId);
10
+ }
11
+ };
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@inzombieland/core",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
- "main": "./index.mjs",
6
+ "main": "./index.js",
7
7
  "types": "./index.d.ts",
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
11
11
  "dependencies": {
12
- "@fingerprintjs/fingerprintjs": "^4.6.2",
12
+ "@fingerprintjs/fingerprintjs": "4.6.2",
13
13
  "@vueuse/core": "^12.8.2",
14
14
  "centrifuge": "^5.5.2",
15
15
  "cookie-es": "^2.0.0",
@@ -59,7 +59,7 @@ export type User = {
59
59
  };
60
60
  export type Visitor = {
61
61
  id?: string;
62
- ip?: string;
62
+ fid?: string;
63
63
  device?: string;
64
64
  appName?: string;
65
65
  };
@@ -1,6 +1,7 @@
1
- import { flush, setSecretKey, setVisitorId, setToken, updateUser } from "./api-client.js";
1
+ import { flush, setSecretKey, setToken, updateUser } from "./api-client.js";
2
2
  import { useUser } from "./composables/index.js";
3
3
  import { once } from "./helpers/index.js";
4
+ import { setVisitorId } from "./local-storage-utils.js";
4
5
  export const createApiUserActions = once(
5
6
  (fetch, config, getUser) => {
6
7
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@braintree/sanitize-url": "^7.1.1",
51
- "@fingerprintjs/fingerprintjs": "^4.6.2",
51
+ "@fingerprintjs/fingerprintjs": "4.6.2",
52
52
  "@inzombieland/nuxt-common": "^1.19.20",
53
53
  "@nuxt/devtools": "latest",
54
54
  "@nuxt/icon": "^1.15.0",