@evolu/react-native 12.0.1-preview.6 → 12.0.1-preview.7

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.
@@ -1,5 +1,5 @@
1
- import { FC } from 'react';
2
- import { OwnerId } from '@evolu/common';
1
+ import { FC } from "react";
2
+ import { OwnerId } from "@evolu/common";
3
3
  export declare const EvoluAvatar: FC<{
4
4
  id: OwnerId;
5
5
  size?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"EvoluAvatar.d.ts","sourceRoot":"","sources":["../../src/components/EvoluAvatar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAgBA,CAAA"}
1
+ {"version":3,"file":"EvoluAvatar.d.ts","sourceRoot":"","sources":["../../src/components/EvoluAvatar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAcA,CAAC"}
@@ -1,14 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { View } from 'react-native';
3
- import { SvgXml } from 'react-native-svg';
4
- import { useMemo } from 'react';
5
- import { bloSvg } from 'blo';
2
+ import { View } from "react-native";
3
+ import { SvgXml } from "react-native-svg";
4
+ import { useMemo } from "react";
5
+ import { bloSvg } from "blo";
6
6
  export const EvoluAvatar = ({ id, size = 32, borderRadius = 3 }) => {
7
7
  const svg = useMemo(() => bloSvg(`0x${id}`), [id]);
8
8
  return id ? (_jsx(View, { style: {
9
9
  width: size,
10
10
  height: size,
11
11
  borderRadius,
12
- overflow: 'hidden',
12
+ overflow: "hidden",
13
13
  }, children: _jsx(SvgXml, { xml: svg, width: size, height: size }) })) : null;
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"LocalAuth.d.ts","sourceRoot":"","sources":["../../src/utils/LocalAuth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,aAAa,EAAqD,MAAM,eAAe,CAAC;AAExH,eAAO,MAAM,iBAAiB,QAAO,aAwDpC,CAAC"}
1
+ {"version":3,"file":"LocalAuth.d.ts","sourceRoot":"","sources":["../../src/utils/LocalAuth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,aAAa,EAId,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,iBAAiB,QAAO,aAqEpC,CAAC"}
@@ -1,19 +1,19 @@
1
- import KVStore from 'expo-sqlite/kv-store';
2
- import * as SecureStore from 'expo-secure-store';
3
- import { AUTH_DEFAULT_OPTIONS } from '@evolu/common';
1
+ import KVStore from "expo-sqlite/kv-store";
2
+ import * as SecureStore from "expo-secure-store";
3
+ import { AUTH_DEFAULT_OPTIONS } from "@evolu/common";
4
4
  export const createSecureStore = () => {
5
5
  const store = {
6
6
  setItem: async (key, value, options) => {
7
7
  const rnsiOpts = convertOptions(options);
8
- const service = options?.service ?? 'default';
9
- const metadata = createMetadata(options?.accessControl === 'none');
10
- await KVStore.setItem(`${service}-${key}`, '1');
8
+ const service = options?.service ?? "default";
9
+ const metadata = createMetadata(options?.accessControl === "none");
10
+ await KVStore.setItem(`${service}-${key}`, "1");
11
11
  await SecureStore.setItemAsync(key, JSON.stringify({ value, metadata }), rnsiOpts);
12
12
  return { metadata };
13
13
  },
14
14
  getItem: async (key, options) => {
15
15
  const rnsiOpts = convertOptions(options);
16
- const service = options?.service ?? 'default';
16
+ const service = options?.service ?? "default";
17
17
  let data;
18
18
  try {
19
19
  const result = await SecureStore.getItemAsync(key, rnsiOpts);
@@ -28,7 +28,7 @@ export const createSecureStore = () => {
28
28
  },
29
29
  deleteItem: async (key, options) => {
30
30
  const rnsiOpts = convertOptions(options);
31
- const service = options?.service ?? 'default';
31
+ const service = options?.service ?? "default";
32
32
  await Promise.all([
33
33
  KVStore.removeItemAsync(`${service}-${key}`),
34
34
  SecureStore.deleteItemAsync(key, rnsiOpts),
@@ -37,17 +37,21 @@ export const createSecureStore = () => {
37
37
  },
38
38
  getAllItems: async (options) => {
39
39
  const keys = await KVStore.getAllKeysAsync();
40
- const service = options?.service ?? 'default';
41
- const metadata = createMetadata(options?.accessControl === 'none');
40
+ const service = options?.service ?? "default";
41
+ const metadata = createMetadata(options?.accessControl === "none");
42
42
  return keys
43
- .filter(key => key.startsWith(`${service}-`))
44
- .map(key => ({ key: key.slice(service.length + 1), service, metadata }));
43
+ .filter((key) => key.startsWith(`${service}-`))
44
+ .map((key) => ({
45
+ key: key.slice(service.length + 1),
46
+ service,
47
+ metadata,
48
+ }));
45
49
  },
46
50
  clearService: async (options) => {
47
51
  const rnsiOpts = convertOptions(options);
48
- const service = options?.service ?? 'default';
52
+ const service = options?.service ?? "default";
49
53
  const items = await store.getAllItems(options);
50
- await KVStore.multiRemove(items.map(item => `${service}-${item.key}`));
54
+ await KVStore.multiRemove(items.map((item) => `${service}-${item.key}`));
51
55
  await Promise.all(items.map(async (item) => {
52
56
  await SecureStore.deleteItemAsync(item.key, rnsiOpts);
53
57
  }));
@@ -68,24 +72,20 @@ const createMetadata = (isSecure = true) => {
68
72
  };
69
73
  };
70
74
  function convertOptions(options) {
71
- const accessGroup = options?.keychainGroup
72
- ?? AUTH_DEFAULT_OPTIONS.keychainGroup
73
- ?? '';
74
- const keychainService = options?.service
75
- ?? AUTH_DEFAULT_OPTIONS.service
76
- ?? '';
77
- const keychainAccessible = convertKeychainAccessible(options?.accessControl
78
- ?? AUTH_DEFAULT_OPTIONS.accessControl
79
- ?? 'biometryCurrentSet');
80
- const authenticationPrompt = options?.authenticationPrompt?.title
81
- ?? AUTH_DEFAULT_OPTIONS.authenticationPrompt?.title
82
- ?? '';
75
+ const accessGroup = options?.keychainGroup ?? AUTH_DEFAULT_OPTIONS.keychainGroup ?? "";
76
+ const keychainService = options?.service ?? AUTH_DEFAULT_OPTIONS.service ?? "";
77
+ const keychainAccessible = convertKeychainAccessible(options?.accessControl ??
78
+ AUTH_DEFAULT_OPTIONS.accessControl ??
79
+ "biometryCurrentSet");
80
+ const authenticationPrompt = options?.authenticationPrompt?.title ??
81
+ AUTH_DEFAULT_OPTIONS.authenticationPrompt?.title ??
82
+ "";
83
83
  return {
84
84
  accessGroup,
85
85
  keychainService,
86
86
  keychainAccessible,
87
87
  authenticationPrompt,
88
- requireAuthentication: options?.accessControl !== 'none',
88
+ requireAuthentication: options?.accessControl !== "none",
89
89
  };
90
90
  }
91
91
  function convertKeychainAccessible(accessControl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evolu/react-native",
3
- "version": "12.0.1-preview.6",
3
+ "version": "12.0.1-preview.7",
4
4
  "description": "Evolu for React Native and Expo",
5
5
  "keywords": [
6
6
  "evolu",
@@ -47,6 +47,9 @@
47
47
  "src/**",
48
48
  "README.md"
49
49
  ],
50
+ "dependencies": {
51
+ "blo": "^2.0.0"
52
+ },
50
53
  "devDependencies": {
51
54
  "@op-engineering/op-sqlite": "^15.0.3",
52
55
  "expo": "^54.0.10",
@@ -59,12 +62,12 @@
59
62
  "shx": "^0.4.0",
60
63
  "typescript": "^5.9.2",
61
64
  "vitest": "^4.0.4",
62
- "@evolu/common": "6.0.1-preview.23",
65
+ "@evolu/common": "6.0.1-preview.25",
63
66
  "@evolu/react": "9.0.1-preview.6",
64
67
  "@evolu/tsconfig": "0.0.2"
65
68
  },
66
69
  "peerDependencies": {
67
- "@evolu/common": "^6.0.1-preview.23",
70
+ "@evolu/common": "^6.0.1-preview.25",
68
71
  "@evolu/react": "^9.0.1-preview.6",
69
72
  "@op-engineering/op-sqlite": ">=12",
70
73
  "expo": ">=54",
@@ -1,8 +1,8 @@
1
- import { View } from 'react-native';
2
- import { SvgXml } from 'react-native-svg';
3
- import { FC, useMemo } from 'react';
4
- import { bloSvg } from 'blo';
5
- import { OwnerId } from '@evolu/common';
1
+ import { View } from "react-native";
2
+ import { SvgXml } from "react-native-svg";
3
+ import { FC, useMemo } from "react";
4
+ import { bloSvg } from "blo";
5
+ import { OwnerId } from "@evolu/common";
6
6
 
7
7
  export const EvoluAvatar: FC<{
8
8
  id: OwnerId;
@@ -11,17 +11,15 @@ export const EvoluAvatar: FC<{
11
11
  }> = ({ id, size = 32, borderRadius = 3 }) => {
12
12
  const svg = useMemo(() => bloSvg(`0x${id}`), [id]);
13
13
  return id ? (
14
- <View style={{
15
- width: size,
16
- height: size,
17
- borderRadius,
18
- overflow: 'hidden',
19
- }}>
20
- <SvgXml
21
- xml={svg}
22
- width={size}
23
- height={size}
24
- />
14
+ <View
15
+ style={{
16
+ width: size,
17
+ height: size,
18
+ borderRadius,
19
+ overflow: "hidden",
20
+ }}
21
+ >
22
+ <SvgXml xml={svg} width={size} height={size} />
25
23
  </View>
26
24
  ) : null;
27
- }
25
+ };
@@ -1,28 +1,41 @@
1
- import KVStore from 'expo-sqlite/kv-store';
2
- import * as SecureStore from 'expo-secure-store';
3
- import { AUTH_DEFAULT_OPTIONS } from '@evolu/common';
1
+ import KVStore from "expo-sqlite/kv-store";
2
+ import * as SecureStore from "expo-secure-store";
3
+ import { AUTH_DEFAULT_OPTIONS } from "@evolu/common";
4
4
 
5
- import type { LocalAuthOptions, SecureStorage, SensitiveInfoItem, StorageMetadata, AccessControl } from "@evolu/common";
5
+ import type {
6
+ LocalAuthOptions,
7
+ SecureStorage,
8
+ SensitiveInfoItem,
9
+ StorageMetadata,
10
+ AccessControl,
11
+ } from "@evolu/common";
6
12
 
7
13
  export const createSecureStore = (): SecureStorage => {
8
14
  const store: SecureStorage = {
9
15
  setItem: async (key, value, options) => {
10
16
  const rnsiOpts = convertOptions(options);
11
- const service = options?.service ?? 'default';
12
- const metadata = createMetadata(options?.accessControl === 'none');
13
- await KVStore.setItem(`${service}-${key}`, '1');
14
- await SecureStore.setItemAsync(key, JSON.stringify({value, metadata}), rnsiOpts);
17
+ const service = options?.service ?? "default";
18
+ const metadata = createMetadata(options?.accessControl === "none");
19
+ await KVStore.setItem(`${service}-${key}`, "1");
20
+ await SecureStore.setItemAsync(
21
+ key,
22
+ JSON.stringify({ value, metadata }),
23
+ rnsiOpts,
24
+ );
15
25
  return { metadata };
16
26
  },
17
27
 
18
28
  getItem: async (key, options) => {
19
29
  const rnsiOpts = convertOptions(options);
20
- const service = options?.service ?? 'default';
21
- let data: {value: string; metadata: StorageMetadata};
30
+ const service = options?.service ?? "default";
31
+ let data: { value: string; metadata: StorageMetadata };
22
32
  try {
23
33
  const result = await SecureStore.getItemAsync(key, rnsiOpts);
24
34
  if (!result) return null;
25
- data = JSON.parse(result) as {value: string; metadata: StorageMetadata};
35
+ data = JSON.parse(result) as {
36
+ value: string;
37
+ metadata: StorageMetadata;
38
+ };
26
39
  } catch (_error) {
27
40
  return null;
28
41
  }
@@ -31,7 +44,7 @@ export const createSecureStore = (): SecureStorage => {
31
44
 
32
45
  deleteItem: async (key, options) => {
33
46
  const rnsiOpts = convertOptions(options);
34
- const service = options?.service ?? 'default';
47
+ const service = options?.service ?? "default";
35
48
  await Promise.all([
36
49
  KVStore.removeItemAsync(`${service}-${key}`),
37
50
  SecureStore.deleteItemAsync(key, rnsiOpts),
@@ -41,21 +54,27 @@ export const createSecureStore = (): SecureStorage => {
41
54
 
42
55
  getAllItems: async (options) => {
43
56
  const keys = await KVStore.getAllKeysAsync();
44
- const service = options?.service ?? 'default';
45
- const metadata = createMetadata(options?.accessControl === 'none');
57
+ const service = options?.service ?? "default";
58
+ const metadata = createMetadata(options?.accessControl === "none");
46
59
  return keys
47
- .filter(key => key.startsWith(`${service}-`))
48
- .map(key => ({ key: key.slice(service.length + 1), service, metadata }));
60
+ .filter((key) => key.startsWith(`${service}-`))
61
+ .map((key) => ({
62
+ key: key.slice(service.length + 1),
63
+ service,
64
+ metadata,
65
+ }));
49
66
  },
50
67
 
51
68
  clearService: async (options) => {
52
69
  const rnsiOpts = convertOptions(options);
53
- const service = options?.service ?? 'default';
70
+ const service = options?.service ?? "default";
54
71
  const items = await store.getAllItems(options);
55
- await KVStore.multiRemove(items.map(item => `${service}-${item.key}`));
56
- await Promise.all(items.map(async (item) => {
57
- await SecureStore.deleteItemAsync(item.key, rnsiOpts);
58
- }));
72
+ await KVStore.multiRemove(items.map((item) => `${service}-${item.key}`));
73
+ await Promise.all(
74
+ items.map(async (item) => {
75
+ await SecureStore.deleteItemAsync(item.key, rnsiOpts);
76
+ }),
77
+ );
59
78
  },
60
79
  };
61
80
 
@@ -75,29 +94,34 @@ const createMetadata = (isSecure = true): SensitiveInfoItem["metadata"] => {
75
94
  };
76
95
  };
77
96
 
78
- function convertOptions(options?: LocalAuthOptions): SecureStore.SecureStoreOptions {
79
- const accessGroup = options?.keychainGroup
80
- ?? AUTH_DEFAULT_OPTIONS.keychainGroup
81
- ?? '';
82
- const keychainService = options?.service
83
- ?? AUTH_DEFAULT_OPTIONS.service
84
- ?? '';
85
- const keychainAccessible = convertKeychainAccessible(options?.accessControl
86
- ?? AUTH_DEFAULT_OPTIONS.accessControl
87
- ?? 'biometryCurrentSet');
88
- const authenticationPrompt = options?.authenticationPrompt?.title
89
- ?? AUTH_DEFAULT_OPTIONS.authenticationPrompt?.title
90
- ?? '';
97
+ function convertOptions(
98
+ options?: LocalAuthOptions,
99
+ ): SecureStore.SecureStoreOptions {
100
+ const accessGroup =
101
+ options?.keychainGroup ?? AUTH_DEFAULT_OPTIONS.keychainGroup ?? "";
102
+ const keychainService =
103
+ options?.service ?? AUTH_DEFAULT_OPTIONS.service ?? "";
104
+ const keychainAccessible = convertKeychainAccessible(
105
+ options?.accessControl ??
106
+ AUTH_DEFAULT_OPTIONS.accessControl ??
107
+ "biometryCurrentSet",
108
+ );
109
+ const authenticationPrompt =
110
+ options?.authenticationPrompt?.title ??
111
+ AUTH_DEFAULT_OPTIONS.authenticationPrompt?.title ??
112
+ "";
91
113
  return {
92
114
  accessGroup,
93
115
  keychainService,
94
116
  keychainAccessible,
95
117
  authenticationPrompt,
96
- requireAuthentication: options?.accessControl !== 'none',
118
+ requireAuthentication: options?.accessControl !== "none",
97
119
  };
98
120
  }
99
121
 
100
- function convertKeychainAccessible(accessControl: AccessControl): SecureStore.KeychainAccessibilityConstant {
122
+ function convertKeychainAccessible(
123
+ accessControl: AccessControl,
124
+ ): SecureStore.KeychainAccessibilityConstant {
101
125
  switch (accessControl) {
102
126
  case "none":
103
127
  // eslint-disable-next-line @typescript-eslint/no-deprecated
@@ -111,8 +135,9 @@ function convertKeychainAccessible(accessControl: AccessControl): SecureStore.Ke
111
135
  case "secureEnclaveBiometry":
112
136
  return SecureStore.AFTER_FIRST_UNLOCK;
113
137
  // Exhaustive check
114
- default: accessControl satisfies never;
115
- // Default (for typescript, should never hit)
116
- return SecureStore.AFTER_FIRST_UNLOCK;
138
+ default:
139
+ accessControl satisfies never;
140
+ // Default (for typescript, should never hit)
141
+ return SecureStore.AFTER_FIRST_UNLOCK;
117
142
  }
118
143
  }