jazz-react-native 0.8.6 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # jazz-browser
2
2
 
3
+ ## 0.8.8
4
+
5
+ ### Patch Changes
6
+
7
+ - b7639cf: feat(react-native): replaced react-native-mmkv with expo-secure-store and initialize it by default as kvStore in createJazzRNApp() (BREAKING)
8
+
9
+ ## 0.8.7
10
+
11
+ ### Patch Changes
12
+
13
+ - 32b05b6: weaker peer dependencies
14
+ - Updated dependencies [e82cf3d]
15
+ - cojson-transport-ws@0.8.7
16
+
3
17
  ## 0.8.6
4
18
 
5
19
  ### Patch Changes
@@ -16,7 +16,7 @@ export declare namespace RNDemoAuth {
16
16
  }
17
17
  export declare class RNDemoAuth implements AuthMethod {
18
18
  private driver;
19
- private storage;
19
+ private kvStore;
20
20
  private constructor();
21
21
  static init(driver: RNDemoAuth.Driver, seedAccounts?: {
22
22
  [name: string]: {
@@ -1,33 +1,33 @@
1
- import NativeStorageContext from "../native-storage.js";
1
+ import { KvStoreContext } from "../storage/kv-store-context.js";
2
2
  const localStorageKey = "demo-auth-logged-in-secret";
3
3
  export class RNDemoAuth {
4
4
  driver;
5
- storage;
6
- constructor(driver, storage) {
5
+ kvStore;
6
+ constructor(driver, kvStore) {
7
7
  this.driver = driver;
8
- this.storage = storage;
8
+ this.kvStore = kvStore;
9
9
  }
10
10
  static async init(driver, seedAccounts) {
11
- const storage = NativeStorageContext.getInstance().getStorage();
11
+ const kvStore = KvStoreContext.getInstance().getStorage();
12
12
  for (const [name, credentials] of Object.entries(seedAccounts || {})) {
13
13
  const storageData = JSON.stringify(credentials);
14
- if (!(await storage.get("demo-auth-existing-users"))?.split(",")?.includes(name)) {
15
- const existingUsers = await storage.get("demo-auth-existing-users");
14
+ if (!(await kvStore.get("demo-auth-existing-users"))?.split(",")?.includes(name)) {
15
+ const existingUsers = await kvStore.get("demo-auth-existing-users");
16
16
  if (existingUsers) {
17
- await storage.set("demo-auth-existing-users", existingUsers + "," + name);
17
+ await kvStore.set("demo-auth-existing-users", existingUsers + "," + name);
18
18
  }
19
19
  else {
20
- await storage.set("demo-auth-existing-users", name);
20
+ await kvStore.set("demo-auth-existing-users", name);
21
21
  }
22
22
  }
23
- await storage.set("demo-auth-existing-users-" + name, storageData);
23
+ await kvStore.set("demo-auth-existing-users-" + name, storageData);
24
24
  }
25
- return new RNDemoAuth(driver, storage);
25
+ return new RNDemoAuth(driver, kvStore);
26
26
  }
27
27
  async start() {
28
28
  try {
29
- if (await this.storage.get(localStorageKey)) {
30
- const localStorageData = JSON.parse((await this.storage.get(localStorageKey)) ?? "{}");
29
+ if (await this.kvStore.get(localStorageKey)) {
30
+ const localStorageData = JSON.parse((await this.kvStore.get(localStorageKey)) ?? "{}");
31
31
  const accountID = localStorageData.accountID;
32
32
  const secret = localStorageData.accountSecret;
33
33
  return {
@@ -40,7 +40,7 @@ export class RNDemoAuth {
40
40
  this.driver.onError(error);
41
41
  },
42
42
  logOut: async () => {
43
- void (await this.storage.delete(localStorageKey));
43
+ void (await this.kvStore.delete(localStorageKey));
44
44
  },
45
45
  };
46
46
  }
@@ -58,7 +58,7 @@ export class RNDemoAuth {
58
58
  accountSecret: credentials.secret,
59
59
  });
60
60
  // Retrieve the list of existing users
61
- const existingUsers = await this.storage.get("demo-auth-existing-users");
61
+ const existingUsers = await this.kvStore.get("demo-auth-existing-users");
62
62
  const existingUsernames = existingUsers
63
63
  ? existingUsers.split(",")
64
64
  : [];
@@ -70,14 +70,14 @@ export class RNDemoAuth {
70
70
  uniqueUsername = `${username}-${counter}`;
71
71
  }
72
72
  // Save credentials using the unique username
73
- await this.storage.set(localStorageKey, storageData);
74
- await this.storage.set("demo-auth-existing-users-" +
73
+ await this.kvStore.set(localStorageKey, storageData);
74
+ await this.kvStore.set("demo-auth-existing-users-" +
75
75
  uniqueUsername, storageData);
76
76
  // Update the list of existing users
77
77
  const updatedUsers = existingUsers
78
78
  ? `${existingUsers},${uniqueUsername}`
79
79
  : uniqueUsername;
80
- await this.storage.set("demo-auth-existing-users", updatedUsers);
80
+ await this.kvStore.set("demo-auth-existing-users", updatedUsers);
81
81
  },
82
82
  onSuccess: () => {
83
83
  this.driver.onSignedIn({ logOut });
@@ -88,16 +88,16 @@ export class RNDemoAuth {
88
88
  this.driver.onError(error);
89
89
  },
90
90
  logOut: async () => {
91
- void (await this.storage.delete(localStorageKey));
91
+ void (await this.kvStore.delete(localStorageKey));
92
92
  },
93
93
  });
94
94
  },
95
95
  getExistingUsers: async () => {
96
- return ((await this.storage.get("demo-auth-existing-users"))?.split(",") ?? []);
96
+ return ((await this.kvStore.get("demo-auth-existing-users"))?.split(",") ?? []);
97
97
  },
98
98
  logInAs: async (existingUser) => {
99
- const storageData = JSON.parse((await this.storage.get("demo-auth-existing-users-" + existingUser)) ?? "{}");
100
- await this.storage.set(localStorageKey, JSON.stringify(storageData));
99
+ const storageData = JSON.parse((await this.kvStore.get("demo-auth-existing-users-" + existingUser)) ?? "{}");
100
+ await this.kvStore.set(localStorageKey, JSON.stringify(storageData));
101
101
  resolve({
102
102
  type: "existing",
103
103
  credentials: {
@@ -111,7 +111,7 @@ export class RNDemoAuth {
111
111
  this.driver.onError(error);
112
112
  },
113
113
  logOut: async () => {
114
- void (await this.storage.delete(localStorageKey));
114
+ void (await this.kvStore.delete(localStorageKey));
115
115
  },
116
116
  });
117
117
  },
@@ -126,7 +126,7 @@ export class RNDemoAuth {
126
126
  }
127
127
  }
128
128
  async function logOut() {
129
- const storage = NativeStorageContext.getInstance().getStorage();
130
- void (await storage.delete(localStorageKey));
129
+ const kvStore = KvStoreContext.getInstance().getStorage();
130
+ void (await kvStore.delete(localStorageKey));
131
131
  }
132
132
  //# sourceMappingURL=DemoAuthMethod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DemoAuthMethod.js","sourceRoot":"","sources":["../../src/auth/DemoAuthMethod.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAuC,MAAM,sBAAsB,CAAC;AAqB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D,SAAS,EAAE,GAAG,EAAE;oCACZ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;gCACvC,CAAC;gCACD,OAAO,EAAE,CAAC,KAAqB,EAAE,EAAE;oCAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gCAC/B,CAAC;gCACD,MAAM,EAAE,KAAK,IAAI,EAAE;oCACf,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAC3B,eAAe,CAClB,CAAC,CAAC;gCACP,CAAC;6BACJ,CAAC,CAAC;wBACP,CAAC;qBACJ,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9B,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CACJ;AAED,KAAK,UAAU,MAAM;IACjB,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,CAAC;IAC1D,KAAK,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AACjD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -47,4 +47,4 @@ export declare function parseInviteLink<C extends CoValue>(inviteURL: string): {
47
47
  } | undefined;
48
48
  export * from "./provider.js";
49
49
  export * from "./auth/auth.js";
50
- export * from "./native-storage.js";
50
+ export * from "./storage/kv-store-context.js";
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { createWebSocketPeer } from "cojson-transport-ws";
6
6
  import NetInfo from "@react-native-community/netinfo";
7
7
  import * as Linking from "expo-linking";
8
8
  export { RNDemoAuth } from "./auth/DemoAuthMethod.js";
9
- import { NativeStorageContext } from "./native-storage.js";
9
+ import { KvStoreContext } from "./storage/kv-store-context.js";
10
10
  export async function createJazzRNContext(options) {
11
11
  const firstWsPeer = createWebSocketPeer({
12
12
  websocket: new WebSocket(options.peer),
@@ -91,10 +91,10 @@ export async function createJazzRNContext(options) {
91
91
  }
92
92
  export async function provideLockSession(accountID, crypto) {
93
93
  const sessionDone = () => { };
94
- const storage = NativeStorageContext.getInstance().getStorage();
95
- const sessionID = (await storage.get(accountID)) ||
94
+ const kvStore = KvStoreContext.getInstance().getStorage();
95
+ const sessionID = (await kvStore.get(accountID)) ||
96
96
  crypto.newRandomSessionID(accountID);
97
- await storage.set(accountID, sessionID);
97
+ await kvStore.set(accountID, sessionID);
98
98
  return Promise.resolve({
99
99
  sessionID,
100
100
  sessionDone,
@@ -149,5 +149,5 @@ export function parseInviteLink(inviteURL) {
149
149
  /////////
150
150
  export * from "./provider.js";
151
151
  export * from "./auth/auth.js";
152
- export * from "./native-storage.js";
152
+ export * from "./storage/kv-store-context.js";
153
153
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,sDAAsD;AACtD,OAAO,EAKH,eAAe,EAMf,iBAAiB,GAEpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,OAAO,MAAM,iCAAiC,CAAC;AACtD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAwC3D,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACrC,OAA+D;IAE/D,MAAM,WAAW,GAAG,mBAAmB,CAAC;QACpC,SAAS,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QACtC,EAAE,EAAE,OAAO,CAAC,IAAI,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,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AAChD,CAAC;AAED,SAAS;AAET,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,+BAA+B,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import { Account, AccountClass, AnonymousJazzAgent, AuthMethod, CoValue, CoValueClass, DeeplyLoaded, DepthsIn, ID } from "jazz-tools";
3
- import { NativeStorage } from "./index.js";
3
+ import { ExpoSecureStoreAdapter } from "./storage/expo-secure-store-adapter.js";
4
4
  /** @category Context & Hooks */
5
- export declare function createJazzRNApp<Acc extends Account>({ nativeStorage, AccountSchema, }: {
6
- nativeStorage: NativeStorage;
7
- AccountSchema?: AccountClass<Acc>;
5
+ export declare function createJazzRNApp<Acc extends Account>({ kvStore, AccountSchema, }?: {
6
+ kvStore?: ExpoSecureStoreAdapter | undefined;
7
+ AccountSchema?: AccountClass<Acc> | undefined;
8
8
  }): JazzReactApp<Acc>;
9
9
  /** @category Context & Hooks */
10
10
  export interface JazzReactApp<Acc extends Account> {
package/dist/provider.js CHANGED
@@ -1,11 +1,15 @@
1
1
  import React, { useEffect, useState } from "react";
2
2
  import { Account, subscribeToCoValue, } from "jazz-tools";
3
- import { createJazzRNContext, NativeStorageContext, parseInviteLink, } from "./index.js";
3
+ import { createJazzRNContext, KvStoreContext, parseInviteLink, } from "./index.js";
4
4
  import { Linking } from "react-native";
5
+ import { ExpoSecureStoreAdapter } from "./storage/expo-secure-store-adapter.js";
5
6
  /** @category Context & Hooks */
6
- export function createJazzRNApp({ nativeStorage, AccountSchema = Account, }) {
7
+ export function createJazzRNApp({ kvStore = new ExpoSecureStoreAdapter(), AccountSchema = Account, } = {}) {
7
8
  const JazzContext = React.createContext(undefined);
8
- NativeStorageContext.getInstance().initialize(nativeStorage);
9
+ if (!kvStore) {
10
+ throw new Error("kvStore is required");
11
+ }
12
+ KvStoreContext.getInstance().initialize(kvStore);
9
13
  function Provider({ children, auth, peer, storage, }) {
10
14
  const [ctx, setCtx] = useState();
11
15
  const [sessionCount, setSessionCount] = useState(0);
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EACH,OAAO,EASP,kBAAkB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAGH,mBAAmB,EACnB,oBAAoB,EAEpB,eAAe,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,gCAAgC;AAChC,MAAM,UAAU,eAAe,CAAsB,EACjD,aAAa,EACb,aAAa,GAAG,OAAuC,GAI1D;IACG,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAErC,SAAS,CAAC,CAAC;IAEb,oBAAoB,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAE7D,SAAS,QAAQ,CAAC,EACd,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,OAAO,GAMV;QACG,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,EAE3B,CAAC;QAEJ,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEpD,SAAS,CAAC,GAAG,EAAE;YACX,MAAM,uBAAuB,GAAG,mBAAmB,CAC/C,IAAI,KAAK,OAAO;gBACZ,CAAC,CAAC;oBACI,IAAI;oBACJ,OAAO;iBACV;gBACH,CAAC,CAAC;oBACI,aAAa;oBACb,IAAI,EAAE,IAAI;oBACV,IAAI;oBACJ,OAAO;iBACV,CACV,CAAC,IAAI,C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oreAdapter implements KvStore {
3
+ get(key: string): Promise<string | null>;
4
+ set(key: string, value: string): Promise<void>;
5
+ delete(key: string): Promise<void>;
6
+ clearAll(): Promise<void>;
7
+ }
@@ -0,0 +1,25 @@
1
+ import * as SecureStore from "expo-secure-store";
2
+ export class ExpoSecureStoreAdapter {
3
+ get(key) {
4
+ return SecureStore.getItemAsync(key, {
5
+ requireAuthentication: SecureStore.canUseBiometricAuthentication(),
6
+ keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK,
7
+ });
8
+ }
9
+ async set(key, value) {
10
+ return SecureStore.setItemAsync(key, value, {
11
+ requireAuthentication: SecureStore.canUseBiometricAuthentication(),
12
+ keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK,
13
+ });
14
+ }
15
+ async delete(key) {
16
+ return SecureStore.deleteItemAsync(key, {
17
+ requireAuthentication: SecureStore.canUseBiometricAuthentication(),
18
+ keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK,
19
+ });
20
+ }
21
+ async clearAll() {
22
+ throw new Error("Not implemented");
23
+ }
24
+ }
25
+ //# sourceMappingURL=expo-secure-store-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expo-secure-store-adapter.js","sourceRoot":"","sources":["../../src/storage/expo-secure-store-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAGjD,MAAM,OAAO,sBAAsB;IAC/B,GAAG,CAAC,GAAW;QACX,OAAO,WAAW,CAAC,YAAY,CAAC,GAAG,EAAE;YACjC,qBAAqB,EAAE,WAAW,CAAC,6BAA6B,EAAE;YAClE,kBAAkB,EAAE,WAAW,CAAC,kBAAkB;SACrD,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAa;QAChC,OAAO,WAAW,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE;YACxC,qBAAqB,EAAE,WAAW,CAAC,6BAA6B,EAAE;YAClE,kBAAkB,EAAE,WAAW,CAAC,kBAAkB;SACrD,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACpB,OAAO,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE;YACpC,qBAAqB,EAAE,WAAW,CAAC,6BAA6B,EAAE;YAClE,kBAAkB,EAAE,WAAW,CAAC,kBAAkB;SACrD,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ"}
@@ -0,0 +1,15 @@
1
+ export interface KvStore {
2
+ get(key: string): Promise<string | null>;
3
+ set(key: string, value: string): Promise<void>;
4
+ delete(key: string): Promise<void>;
5
+ clearAll(): Promise<void>;
6
+ }
7
+ export declare class KvStoreContext {
8
+ private static instance;
9
+ private storageInstance;
10
+ private constructor();
11
+ static getInstance(): KvStoreContext;
12
+ initialize(store: KvStore): void;
13
+ getStorage(): KvStore;
14
+ }
15
+ export default KvStoreContext;
@@ -1,16 +1,16 @@
1
- export class NativeStorageContext {
1
+ export class KvStoreContext {
2
2
  static instance;
3
3
  storageInstance = null;
4
4
  constructor() { }
5
5
  static getInstance() {
6
- if (!NativeStorageContext.instance) {
7
- NativeStorageContext.instance = new NativeStorageContext();
6
+ if (!KvStoreContext.instance) {
7
+ KvStoreContext.instance = new KvStoreContext();
8
8
  }
9
- return NativeStorageContext.instance;
9
+ return KvStoreContext.instance;
10
10
  }
11
- initialize(db) {
11
+ initialize(store) {
12
12
  if (!this.storageInstance) {
13
- this.storageInstance = db;
13
+ this.storageInstance = store;
14
14
  }
15
15
  }
16
16
  getStorage() {
@@ -20,5 +20,5 @@ export class NativeStorageContext {
20
20
  return this.storageInstance;
21
21
  }
22
22
  }
23
- export default NativeStorageContext;
24
- //# sourceMappingURL=native-storage.js.map
23
+ export default KvStoreContext;
24
+ //# sourceMappingURL=kv-store-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kv-store-context.js","sourceRoot":"","sources":["../../src/storage/kv-store-context.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,cAAc;IACf,MAAM,CAAC,QAAQ,CAAiB;IAChC,eAAe,GAAmB,IAAI,CAAC;IAE/C,gBAAuB,CAAC;IAEjB,MAAM,CAAC,WAAW;QACrB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC3B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QACnD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IACnC,CAAC;IAEM,UAAU,CAAC,KAAc;QAC5B,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QACjC,CAAC;IACL,CAAC;IAEM,UAAU;QACb,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;CACJ;AAED,eAAe,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jazz-react-native",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -18,20 +18,20 @@
18
18
  "@scure/bip39": "^1.3.0",
19
19
  "typescript": "^5.3.3",
20
20
  "cojson": "0.8.5",
21
- "jazz-tools": "0.8.5",
22
- "cojson-transport-ws": "0.8.6"
21
+ "cojson-transport-ws": "0.8.7",
22
+ "jazz-tools": "0.8.5"
23
23
  },
24
24
  "peerDependencies": {
25
- "@react-native-community/netinfo": "^11.4.1",
26
- "expo-linking": "~6.3.1",
27
- "react-native": "0.74.2",
28
- "react-native-mmkv": "3.0.1"
25
+ "@react-native-community/netinfo": "*",
26
+ "expo-linking": "*",
27
+ "expo-secure-store": "*",
28
+ "react-native": "*"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@react-native-community/netinfo": "^11.3.1",
32
32
  "expo-linking": "~6.3.1",
33
- "react-native": "~0.74.5",
34
- "react-native-mmkv": "3.0.1"
33
+ "expo-secure-store": "~13.0.2",
34
+ "react-native": "~0.74.5"
35
35
  },
36
36
  "lint-staged": {
37
37
  "*.{ts,tsx}": "eslint --fix",
@@ -1,6 +1,6 @@
1
1
  import { AgentSecret } from "cojson";
2
2
  import { Account, AuthMethod, AuthResult, ID } from "jazz-tools";
3
- import NativeStorageContext, { NativeStorage } from "../native-storage.js";
3
+ import { KvStore, KvStoreContext } from "../storage/kv-store-context.js";
4
4
 
5
5
  type StorageData = {
6
6
  accountID: ID<Account>;
@@ -26,7 +26,7 @@ const localStorageKey = "demo-auth-logged-in-secret";
26
26
  export class RNDemoAuth implements AuthMethod {
27
27
  private constructor(
28
28
  private driver: RNDemoAuth.Driver,
29
- private storage: NativeStorage,
29
+ private kvStore: KvStore,
30
30
  ) {}
31
31
 
32
32
  public static async init(
@@ -38,40 +38,40 @@ export class RNDemoAuth implements AuthMethod {
38
38
  };
39
39
  },
40
40
  ) {
41
- const storage = NativeStorageContext.getInstance().getStorage();
41
+ const kvStore = KvStoreContext.getInstance().getStorage();
42
42
  for (const [name, credentials] of Object.entries(seedAccounts || {})) {
43
43
  const storageData = JSON.stringify(
44
44
  credentials satisfies StorageData,
45
45
  );
46
46
  if (
47
47
  !(
48
- (await storage.get("demo-auth-existing-users"))?.split(
48
+ (await kvStore.get("demo-auth-existing-users"))?.split(
49
49
  ",",
50
50
  ) as string[] | undefined
51
51
  )?.includes(name)
52
52
  ) {
53
- const existingUsers = await storage.get(
53
+ const existingUsers = await kvStore.get(
54
54
  "demo-auth-existing-users",
55
55
  );
56
56
  if (existingUsers) {
57
- await storage.set(
57
+ await kvStore.set(
58
58
  "demo-auth-existing-users",
59
59
  existingUsers + "," + name,
60
60
  );
61
61
  } else {
62
- await storage.set("demo-auth-existing-users", name);
62
+ await kvStore.set("demo-auth-existing-users", name);
63
63
  }
64
64
  }
65
- await storage.set("demo-auth-existing-users-" + name, storageData);
65
+ await kvStore.set("demo-auth-existing-users-" + name, storageData);
66
66
  }
67
- return new RNDemoAuth(driver, storage);
67
+ return new RNDemoAuth(driver, kvStore);
68
68
  }
69
69
 
70
70
  async start() {
71
71
  try {
72
- if (await this.storage.get(localStorageKey)) {
72
+ if (await this.kvStore.get(localStorageKey)) {
73
73
  const localStorageData = JSON.parse(
74
- (await this.storage.get(localStorageKey)) ?? "{}",
74
+ (await this.kvStore.get(localStorageKey)) ?? "{}",
75
75
  ) as StorageData;
76
76
 
77
77
  const accountID = localStorageData.accountID as ID<Account>;
@@ -87,7 +87,7 @@ export class RNDemoAuth implements AuthMethod {
87
87
  this.driver.onError(error);
88
88
  },
89
89
  logOut: async () => {
90
- void (await this.storage.delete(localStorageKey));
90
+ void (await this.kvStore.delete(localStorageKey));
91
91
  },
92
92
  } satisfies AuthResult;
93
93
  } else {
@@ -109,7 +109,7 @@ export class RNDemoAuth implements AuthMethod {
109
109
 
110
110
  // Retrieve the list of existing users
111
111
  const existingUsers =
112
- await this.storage.get(
112
+ await this.kvStore.get(
113
113
  "demo-auth-existing-users",
114
114
  );
115
115
  const existingUsernames = existingUsers
@@ -129,11 +129,11 @@ export class RNDemoAuth implements AuthMethod {
129
129
  }
130
130
 
131
131
  // Save credentials using the unique username
132
- await this.storage.set(
132
+ await this.kvStore.set(
133
133
  localStorageKey,
134
134
  storageData,
135
135
  );
136
- await this.storage.set(
136
+ await this.kvStore.set(
137
137
  "demo-auth-existing-users-" +
138
138
  uniqueUsername,
139
139
  storageData,
@@ -143,7 +143,7 @@ export class RNDemoAuth implements AuthMethod {
143
143
  const updatedUsers = existingUsers
144
144
  ? `${existingUsers},${uniqueUsername}`
145
145
  : uniqueUsername;
146
- await this.storage.set(
146
+ await this.kvStore.set(
147
147
  "demo-auth-existing-users",
148
148
  updatedUsers,
149
149
  );
@@ -157,7 +157,7 @@ export class RNDemoAuth implements AuthMethod {
157
157
  this.driver.onError(error);
158
158
  },
159
159
  logOut: async () => {
160
- void (await this.storage.delete(
160
+ void (await this.kvStore.delete(
161
161
  localStorageKey,
162
162
  ));
163
163
  },
@@ -166,7 +166,7 @@ export class RNDemoAuth implements AuthMethod {
166
166
  getExistingUsers: async () => {
167
167
  return (
168
168
  (
169
- await this.storage.get(
169
+ await this.kvStore.get(
170
170
  "demo-auth-existing-users",
171
171
  )
172
172
  )?.split(",") ?? []
@@ -174,12 +174,12 @@ export class RNDemoAuth implements AuthMethod {
174
174
  },
175
175
  logInAs: async (existingUser) => {
176
176
  const storageData = JSON.parse(
177
- (await this.storage.get(
177
+ (await this.kvStore.get(
178
178
  "demo-auth-existing-users-" + existingUser,
179
179
  )) ?? "{}",
180
180
  ) as StorageData;
181
181
 
182
- await this.storage.set(
182
+ await this.kvStore.set(
183
183
  localStorageKey,
184
184
  JSON.stringify(storageData),
185
185
  );
@@ -197,7 +197,7 @@ export class RNDemoAuth implements AuthMethod {
197
197
  this.driver.onError(error);
198
198
  },
199
199
  logOut: async () => {
200
- void (await this.storage.delete(
200
+ void (await this.kvStore.delete(
201
201
  localStorageKey,
202
202
  ));
203
203
  },
@@ -214,6 +214,6 @@ export class RNDemoAuth implements AuthMethod {
214
214
  }
215
215
 
216
216
  async function logOut() {
217
- const storage = NativeStorageContext.getInstance().getStorage();
218
- void (await storage.delete(localStorageKey));
217
+ const kvStore = KvStoreContext.getInstance().getStorage();
218
+ void (await kvStore.delete(localStorageKey));
219
219
  }
package/src/index.ts CHANGED
@@ -18,13 +18,12 @@ import {
18
18
  import { PureJSCrypto } from "jazz-tools/native";
19
19
  import { RawAccountID } from "cojson";
20
20
  import { createWebSocketPeer } from "cojson-transport-ws";
21
- import { MMKV } from "react-native-mmkv";
22
21
  import NetInfo from "@react-native-community/netinfo";
23
22
  import * as Linking from "expo-linking";
24
23
 
25
24
  export { RNDemoAuth } from "./auth/DemoAuthMethod.js";
26
25
 
27
- import { NativeStorageContext } from "./native-storage.js";
26
+ import { KvStoreContext } from "./storage/kv-store-context.js";
28
27
 
29
28
  /** @category Context Creation */
30
29
  export type BrowserContext<Acc extends Account> = {
@@ -182,12 +181,12 @@ export async function provideLockSession(
182
181
  ) {
183
182
  const sessionDone = () => {};
184
183
 
185
- const storage = NativeStorageContext.getInstance().getStorage();
184
+ const kvStore = KvStoreContext.getInstance().getStorage();
186
185
 
187
186
  const sessionID =
188
- ((await storage.get(accountID)) as SessionID) ||
187
+ ((await kvStore.get(accountID)) as SessionID) ||
189
188
  crypto.newRandomSessionID(accountID as RawAccountID | AgentID);
190
- await storage.set(accountID, sessionID);
189
+ await kvStore.set(accountID, sessionID);
191
190
 
192
191
  return Promise.resolve({
193
192
  sessionID,
@@ -272,4 +271,4 @@ export function parseInviteLink<C extends CoValue>(
272
271
 
273
272
  export * from "./provider.js";
274
273
  export * from "./auth/auth.js";
275
- export * from "./native-storage.js";
274
+ export * from "./storage/kv-store-context.js";
package/src/provider.tsx CHANGED
@@ -16,25 +16,26 @@ import {
16
16
  BrowserContext,
17
17
  BrowserGuestContext,
18
18
  createJazzRNContext,
19
- NativeStorageContext,
20
- NativeStorage,
19
+ KvStoreContext,
21
20
  parseInviteLink,
22
21
  } from "./index.js";
23
22
  import { Linking } from "react-native";
23
+ import { ExpoSecureStoreAdapter } from "./storage/expo-secure-store-adapter.js";
24
24
 
25
25
  /** @category Context & Hooks */
26
26
  export function createJazzRNApp<Acc extends Account>({
27
- nativeStorage,
27
+ kvStore = new ExpoSecureStoreAdapter(),
28
28
  AccountSchema = Account as unknown as AccountClass<Acc>,
29
- }: {
30
- nativeStorage: NativeStorage;
31
- AccountSchema?: AccountClass<Acc>;
32
- }): JazzReactApp<Acc> {
29
+ } = {}): JazzReactApp<Acc> {
33
30
  const JazzContext = React.createContext<
34
31
  BrowserContext<Acc> | BrowserGuestContext | undefined
35
32
  >(undefined);
36
33
 
37
- NativeStorageContext.getInstance().initialize(nativeStorage);
34
+ if (!kvStore) {
35
+ throw new Error("kvStore is required");
36
+ }
37
+
38
+ KvStoreContext.getInstance().initialize(kvStore);
38
39
 
39
40
  function Provider({
40
41
  children,
@@ -0,0 +1,29 @@
1
+ import * as SecureStore from "expo-secure-store";
2
+ import type { KvStore } from "./kv-store-context.js";
3
+
4
+ export class ExpoSecureStoreAdapter implements KvStore {
5
+ get(key: string): Promise<string | null> {
6
+ return SecureStore.getItemAsync(key, {
7
+ requireAuthentication: SecureStore.canUseBiometricAuthentication(),
8
+ keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK,
9
+ });
10
+ }
11
+
12
+ async set(key: string, value: string): Promise<void> {
13
+ return SecureStore.setItemAsync(key, value, {
14
+ requireAuthentication: SecureStore.canUseBiometricAuthentication(),
15
+ keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK,
16
+ });
17
+ }
18
+
19
+ async delete(key: string): Promise<void> {
20
+ return SecureStore.deleteItemAsync(key, {
21
+ requireAuthentication: SecureStore.canUseBiometricAuthentication(),
22
+ keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK,
23
+ });
24
+ }
25
+
26
+ async clearAll(): Promise<void> {
27
+ throw new Error("Not implemented");
28
+ }
29
+ }
@@ -0,0 +1,35 @@
1
+ export interface KvStore {
2
+ get(key: string): Promise<string | null>;
3
+ set(key: string, value: string): Promise<void>;
4
+ delete(key: string): Promise<void>;
5
+ clearAll(): Promise<void>;
6
+ }
7
+
8
+ export class KvStoreContext {
9
+ private static instance: KvStoreContext;
10
+ private storageInstance: KvStore | null = null;
11
+
12
+ private constructor() {}
13
+
14
+ public static getInstance(): KvStoreContext {
15
+ if (!KvStoreContext.instance) {
16
+ KvStoreContext.instance = new KvStoreContext();
17
+ }
18
+ return KvStoreContext.instance;
19
+ }
20
+
21
+ public initialize(store: KvStore): void {
22
+ if (!this.storageInstance) {
23
+ this.storageInstance = store;
24
+ }
25
+ }
26
+
27
+ public getStorage(): KvStore {
28
+ if (!this.storageInstance) {
29
+ throw new Error("Storage instance is not initialized.");
30
+ }
31
+ return this.storageInstance;
32
+ }
33
+ }
34
+
35
+ export default KvStoreContext;
@@ -1,15 +0,0 @@
1
- export interface NativeStorage {
2
- get(key: string): Promise<string | undefined>;
3
- set(key: string, value: string): Promise<void>;
4
- delete(key: string): Promise<void>;
5
- clearAll(): Promise<void>;
6
- }
7
- export declare class NativeStorageContext {
8
- private static instance;
9
- private storageInstance;
10
- private constructor();
11
- static getInstance(): NativeStorageContext;
12
- initialize(db: NativeStorage): void;
13
- getStorage(): NativeStorage;
14
- }
15
- export default NativeStorageContext;
@@ -1 +0,0 @@
1
- {"version":3,"file":"native-storage.js","sourceRoot":"","sources":["../src/native-storage.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,oBAAoB;IACrB,MAAM,CAAC,QAAQ,CAAuB;IACtC,eAAe,GAAyB,IAAI,CAAC;IAErD,gBAAuB,CAAC;IAEjB,MAAM,CAAC,WAAW;QACrB,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC;YACjC,oBAAoB,CAAC,QAAQ,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC/D,CAAC;QACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC;IACzC,CAAC;IAEM,UAAU,CAAC,EAAiB;QAC/B,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC9B,CAAC;IACL,CAAC;IAEM,UAAU;QACb,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;CACJ;AAED,eAAe,oBAAoB,CAAC"}
@@ -1,35 +0,0 @@
1
- export interface NativeStorage {
2
- get(key: string): Promise<string | undefined>;
3
- set(key: string, value: string): Promise<void>;
4
- delete(key: string): Promise<void>;
5
- clearAll(): Promise<void>;
6
- }
7
-
8
- export class NativeStorageContext {
9
- private static instance: NativeStorageContext;
10
- private storageInstance: NativeStorage | null = null;
11
-
12
- private constructor() {}
13
-
14
- public static getInstance(): NativeStorageContext {
15
- if (!NativeStorageContext.instance) {
16
- NativeStorageContext.instance = new NativeStorageContext();
17
- }
18
- return NativeStorageContext.instance;
19
- }
20
-
21
- public initialize(db: NativeStorage): void {
22
- if (!this.storageInstance) {
23
- this.storageInstance = db;
24
- }
25
- }
26
-
27
- public getStorage(): NativeStorage {
28
- if (!this.storageInstance) {
29
- throw new Error("Storage instance is not initialized.");
30
- }
31
- return this.storageInstance;
32
- }
33
- }
34
-
35
- export default NativeStorageContext;