jazz-react-native 0.12.1 → 0.13.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.
Files changed (82) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +37 -0
  3. package/README.md +3 -229
  4. package/crypto/index.d.ts +2 -0
  5. package/crypto/index.js +2 -0
  6. package/dist/index.d.ts +3 -6
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/provider.d.ts +2 -13
  11. package/dist/provider.d.ts.map +1 -1
  12. package/dist/provider.js +8 -48
  13. package/dist/provider.js.map +1 -1
  14. package/dist/storage/mmkv-store-adapter.d.ts +8 -0
  15. package/dist/storage/mmkv-store-adapter.d.ts.map +1 -0
  16. package/dist/storage/mmkv-store-adapter.js +19 -0
  17. package/dist/storage/mmkv-store-adapter.js.map +1 -0
  18. package/dist/storage/op-sqlite-adapter.d.ts +18 -0
  19. package/dist/storage/op-sqlite-adapter.d.ts.map +1 -0
  20. package/dist/storage/op-sqlite-adapter.js +127 -0
  21. package/dist/storage/op-sqlite-adapter.js.map +1 -0
  22. package/dist/testing.d.ts +1 -1
  23. package/dist/testing.d.ts.map +1 -1
  24. package/dist/testing.js +1 -1
  25. package/dist/testing.js.map +1 -1
  26. package/package.json +13 -16
  27. package/src/index.ts +4 -7
  28. package/src/provider.tsx +12 -91
  29. package/src/storage/mmkv-store-adapter.ts +24 -0
  30. package/src/storage/op-sqlite-adapter.ts +168 -0
  31. package/src/testing.ts +1 -0
  32. package/dist/ReactNativeContextManager.d.ts +0 -30
  33. package/dist/ReactNativeContextManager.d.ts.map +0 -1
  34. package/dist/ReactNativeContextManager.js +0 -39
  35. package/dist/ReactNativeContextManager.js.map +0 -1
  36. package/dist/auth/DemoAuthUI.d.ts +0 -8
  37. package/dist/auth/DemoAuthUI.d.ts.map +0 -1
  38. package/dist/auth/DemoAuthUI.js +0 -156
  39. package/dist/auth/DemoAuthUI.js.map +0 -1
  40. package/dist/auth/auth.d.ts +0 -3
  41. package/dist/auth/auth.d.ts.map +0 -1
  42. package/dist/auth/auth.js +0 -12
  43. package/dist/auth/auth.js.map +0 -1
  44. package/dist/crypto/RNQuickCrypto.d.ts +0 -14
  45. package/dist/crypto/RNQuickCrypto.d.ts.map +0 -1
  46. package/dist/crypto/RNQuickCrypto.js +0 -31
  47. package/dist/crypto/RNQuickCrypto.js.map +0 -1
  48. package/dist/crypto/index.d.ts +0 -2
  49. package/dist/crypto/index.d.ts.map +0 -1
  50. package/dist/crypto/index.js +0 -2
  51. package/dist/crypto/index.js.map +0 -1
  52. package/dist/hooks.d.ts +0 -14
  53. package/dist/hooks.d.ts.map +0 -1
  54. package/dist/hooks.js +0 -35
  55. package/dist/hooks.js.map +0 -1
  56. package/dist/media.d.ts +0 -24
  57. package/dist/media.d.ts.map +0 -1
  58. package/dist/media.js +0 -61
  59. package/dist/media.js.map +0 -1
  60. package/dist/platform.d.ts +0 -46
  61. package/dist/platform.d.ts.map +0 -1
  62. package/dist/platform.js +0 -155
  63. package/dist/platform.js.map +0 -1
  64. package/dist/storage/expo-secure-store-adapter.d.ts +0 -8
  65. package/dist/storage/expo-secure-store-adapter.d.ts.map +0 -1
  66. package/dist/storage/expo-secure-store-adapter.js +0 -25
  67. package/dist/storage/expo-secure-store-adapter.js.map +0 -1
  68. package/dist/storage/kv-store-context.d.ts +0 -17
  69. package/dist/storage/kv-store-context.d.ts.map +0 -1
  70. package/dist/storage/kv-store-context.js +0 -27
  71. package/dist/storage/kv-store-context.js.map +0 -1
  72. package/src/ReactNativeContextManager.ts +0 -70
  73. package/src/auth/DemoAuthUI.tsx +0 -202
  74. package/src/auth/auth.ts +0 -14
  75. package/src/crypto/RNQuickCrypto.ts +0 -59
  76. package/src/crypto/index.ts +0 -1
  77. package/src/hooks.tsx +0 -72
  78. package/src/media.tsx +0 -92
  79. package/src/platform.ts +0 -238
  80. package/src/storage/expo-secure-store-adapter.ts +0 -29
  81. package/src/storage/kv-store-context.ts +0 -39
  82. package/src/testing.tsx +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jazz-react-native",
3
- "version": "0.12.1",
3
+ "version": "0.13.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -13,9 +13,9 @@
13
13
  "default": "./dist/index.js"
14
14
  },
15
15
  "./crypto": {
16
- "react-native": "./dist/crypto/index.js",
17
- "types": "./dist/crypto/index.d.ts",
18
- "default": "./dist/crypto/index.js"
16
+ "react-native": "./crypto/index.js",
17
+ "types": "./crypto/index.d.ts",
18
+ "default": "./crypto/index.js"
19
19
  },
20
20
  "./testing": {
21
21
  "react-native": "./dist/testing.js",
@@ -25,25 +25,22 @@
25
25
  },
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
+ "@op-engineering/op-sqlite": "^11.4.8",
28
29
  "@scure/base": "1.2.1",
29
- "react-native-nitro-modules": "0.21.0",
30
- "react-native-quick-crypto": "1.0.0-beta.12",
31
- "cojson": "0.12.1",
32
- "cojson-storage-rn-sqlite": "0.12.1",
33
- "cojson-transport-ws": "0.12.1",
34
- "jazz-react-core": "0.12.1",
35
- "jazz-tools": "0.12.1",
36
- "jazz-react-native-media-images": "0.12.1"
30
+ "react-native-mmkv": "^3.2.0",
31
+ "cojson": "0.13.0",
32
+ "cojson-storage": "0.13.0",
33
+ "jazz-react-native-core": "0.13.0",
34
+ "jazz-tools": "0.13.0"
37
35
  },
38
36
  "peerDependencies": {
39
37
  "@react-native-community/netinfo": "*",
40
- "expo-secure-store": "*",
41
38
  "react-native": "*"
42
39
  },
43
40
  "devDependencies": {
44
- "@react-native-community/netinfo": "^11.4.1",
45
- "expo-secure-store": "~14.0.0",
46
- "react-native": "~0.76.3",
41
+ "@react-native-community/netinfo": "11.4.1",
42
+ "react": "18.3.1",
43
+ "react-native": "0.76.7",
47
44
  "typescript": "~5.6.2"
48
45
  },
49
46
  "gitHead": "33c27053293b4801b968c61d5c4c989f93a67d13",
package/src/index.ts CHANGED
@@ -1,8 +1,5 @@
1
- export * from "./provider.js";
2
- export * from "./auth/auth.js";
3
- export * from "./storage/kv-store-context.js";
4
- export * from "./hooks.js";
5
- export * from "./media.js";
1
+ export * from "jazz-react-native-core";
6
2
 
7
- export { parseInviteLink } from "jazz-tools";
8
- export { createInviteLink, setupKvStore } from "./platform.js";
3
+ export * from "./provider.js";
4
+ export * from "./storage/mmkv-store-adapter.js";
5
+ export * from "./storage/op-sqlite-adapter.js";
package/src/provider.tsx CHANGED
@@ -1,96 +1,17 @@
1
- import { JazzContext, JazzContextManagerContext } from "jazz-react-core";
2
- import { Account, JazzContextType, KvStore } from "jazz-tools";
3
- import React, { useEffect, useRef } from "react";
4
- import { JazzContextManagerProps } from "./ReactNativeContextManager.js";
5
- import { ReactNativeContextManager } from "./ReactNativeContextManager.js";
6
- import { setupKvStore } from "./platform.js";
1
+ import { JazzProviderCore, JazzProviderProps } from "jazz-react-native-core";
2
+ import React from "react";
3
+ import { MMKVStore } from "./storage/mmkv-store-adapter.js";
4
+ import { OPSQLiteAdapter } from "./storage/op-sqlite-adapter.js";
7
5
 
8
- export interface Register {}
9
-
10
- export type RegisteredAccount = Register extends { Account: infer Acc }
11
- ? Acc
12
- : Account;
13
-
14
- export type JazzProviderProps<Acc extends Account = RegisteredAccount> = {
15
- children: React.ReactNode;
16
- kvStore?: KvStore;
17
- } & JazzContextManagerProps<Acc>;
18
-
19
- /** @category Context & Hooks */
20
- export function JazzProvider<Acc extends Account = RegisteredAccount>({
21
- children,
22
- guestMode,
23
- sync,
24
- storage,
25
- AccountSchema,
26
- defaultProfileName,
27
- onLogOut,
28
- kvStore,
29
- onAnonymousAccountDiscarded,
30
- CryptoProvider,
31
- }: JazzProviderProps<Acc>) {
32
- setupKvStore(kvStore);
33
-
34
- const [contextManager] = React.useState(
35
- () => new ReactNativeContextManager<Acc>(),
36
- );
37
-
38
- const onAnonymousAccountDiscardedRefCallback = useRefCallback(
39
- onAnonymousAccountDiscarded,
40
- );
41
- const onLogOutRefCallback = useRefCallback(onLogOut);
42
-
43
- const value = React.useSyncExternalStore<JazzContextType<Acc> | undefined>(
44
- React.useCallback(
45
- (callback) => {
46
- const props = {
47
- AccountSchema,
48
- guestMode,
49
- sync,
50
- storage,
51
- defaultProfileName,
52
- onLogOut: onLogOutRefCallback,
53
- onAnonymousAccountDiscarded: onAnonymousAccountDiscardedRefCallback,
54
- CryptoProvider,
55
- };
56
- if (contextManager.propsChanged(props)) {
57
- contextManager.createContext(props).catch((error) => {
58
- console.log(error.stack);
59
- console.error("Error creating Jazz context:", error);
60
- });
61
- }
62
-
63
- return contextManager.subscribe(callback);
64
- },
65
- [sync, guestMode].concat(storage as any),
66
- ),
67
- () => contextManager.getCurrentValue(),
68
- () => contextManager.getCurrentValue(),
69
- );
70
-
71
- useEffect(() => {
72
- // In development mode we don't return a cleanup function because otherwise
73
- // the double effect execution would mark the context as done immediately.
74
- if (process.env.NODE_ENV === "development") return;
75
-
76
- return () => {
77
- contextManager.done();
78
- };
79
- }, []);
6
+ export function JazzProvider(props: JazzProviderProps) {
7
+ // Destructure kvStore and pass everything else via rest
8
+ const { kvStore, storage, ...rest } = props;
80
9
 
81
10
  return (
82
- <JazzContext.Provider value={value}>
83
- <JazzContextManagerContext.Provider value={contextManager}>
84
- {value && children}
85
- </JazzContextManagerContext.Provider>
86
- </JazzContext.Provider>
11
+ <JazzProviderCore
12
+ {...rest}
13
+ storage={storage ?? new OPSQLiteAdapter()}
14
+ kvStore={kvStore ?? new MMKVStore()}
15
+ />
87
16
  );
88
17
  }
89
-
90
- function useRefCallback<T extends (...args: any[]) => any>(callback?: T) {
91
- const callbackRef = React.useRef(callback);
92
- callbackRef.current = callback;
93
- return useRef(
94
- (...args: Parameters<T>): ReturnType<T> => callbackRef.current?.(...args),
95
- ).current;
96
- }
@@ -0,0 +1,24 @@
1
+ import { KvStore } from "jazz-react-native-core";
2
+ import { MMKV } from "react-native-mmkv";
3
+
4
+ const storage = new MMKV({
5
+ id: "jazz-react-native.default",
6
+ });
7
+
8
+ export class MMKVStore implements KvStore {
9
+ async get(key: string): Promise<string | null> {
10
+ return storage.getString(key) ?? null;
11
+ }
12
+
13
+ async set(key: string, value: string): Promise<void> {
14
+ return storage.set(key, value);
15
+ }
16
+
17
+ async delete(key: string): Promise<void> {
18
+ return storage.delete(key);
19
+ }
20
+
21
+ async clearAll(): Promise<void> {
22
+ return storage.clearAll();
23
+ }
24
+ }
@@ -0,0 +1,168 @@
1
+ import * as opSQLite from "@op-engineering/op-sqlite";
2
+ import {
3
+ ANDROID_DATABASE_PATH,
4
+ IOS_LIBRARY_PATH,
5
+ } from "@op-engineering/op-sqlite";
6
+ import type { SQLResult, SQLRow, SQLiteAdapter } from "jazz-react-native-core";
7
+ import { Platform } from "react-native";
8
+
9
+ type OPSQLiteDB = ReturnType<typeof opSQLite.open>;
10
+
11
+ export class OPSQLiteAdapter implements SQLiteAdapter {
12
+ private db: OPSQLiteDB | null = null;
13
+ private dbName: string;
14
+ private dbPath: string;
15
+ private initializationPromise: Promise<void> | null = null;
16
+ private isInitialized = false;
17
+
18
+ public constructor(dbName: string = "jazz-storage") {
19
+ this.dbName = dbName;
20
+ this.dbPath =
21
+ Platform.OS === "ios" ? IOS_LIBRARY_PATH : ANDROID_DATABASE_PATH;
22
+ }
23
+
24
+ private async initializeInternal() {
25
+ try {
26
+ // Open database first
27
+ this.db = opSQLite.open({
28
+ name: this.dbName,
29
+ location: this.dbPath,
30
+ });
31
+
32
+ // Direct database operations during initialization - don't use execute()
33
+ const db = this.db;
34
+ if (!db) throw new Error("Failed to open database");
35
+
36
+ await db.execute("PRAGMA journal_mode=WAL");
37
+ const { rows } = await db.execute("PRAGMA user_version");
38
+ const oldVersion = Number(rows[0]?.user_version) ?? 0;
39
+
40
+ if (oldVersion === 0) {
41
+ await db.execute(
42
+ `CREATE TABLE IF NOT EXISTS transactions (
43
+ ses INTEGER,
44
+ idx INTEGER,
45
+ tx TEXT NOT NULL,
46
+ PRIMARY KEY (ses, idx)
47
+ ) WITHOUT ROWID;`,
48
+ );
49
+
50
+ await db.execute(
51
+ `CREATE TABLE IF NOT EXISTS sessions (
52
+ rowID INTEGER PRIMARY KEY,
53
+ coValue INTEGER NOT NULL,
54
+ sessionID TEXT NOT NULL,
55
+ lastIdx INTEGER,
56
+ lastSignature TEXT,
57
+ UNIQUE (sessionID, coValue)
58
+ );`,
59
+ );
60
+
61
+ await db.execute(
62
+ `CREATE INDEX IF NOT EXISTS sessionsByCoValue ON sessions (coValue);`,
63
+ );
64
+
65
+ await db.execute(
66
+ `CREATE TABLE IF NOT EXISTS coValues (
67
+ rowID INTEGER PRIMARY KEY,
68
+ id TEXT NOT NULL UNIQUE,
69
+ header TEXT NOT NULL UNIQUE
70
+ );`,
71
+ );
72
+
73
+ await db.execute(
74
+ `CREATE INDEX IF NOT EXISTS coValuesByID ON coValues (id);`,
75
+ );
76
+
77
+ await db.execute("PRAGMA user_version = 1");
78
+ }
79
+
80
+ if (oldVersion <= 2) {
81
+ await db.execute(
82
+ `CREATE TABLE IF NOT EXISTS signatureAfter (
83
+ ses INTEGER,
84
+ idx INTEGER,
85
+ signature TEXT NOT NULL,
86
+ PRIMARY KEY (ses, idx)
87
+ ) WITHOUT ROWID;`,
88
+ );
89
+
90
+ await db.execute(
91
+ `ALTER TABLE sessions ADD COLUMN bytesSinceLastSignature INTEGER;`,
92
+ );
93
+
94
+ await db.execute("PRAGMA user_version = 3");
95
+ }
96
+
97
+ console.log("[OPSQLiteAdapter] initialization complete");
98
+ } catch (e) {
99
+ console.error("[OPSQLiteAdapter] initialization failed:", e);
100
+ throw new Error(
101
+ `Failed to initialize OPSQLiteAdapter: ${e instanceof Error ? e.message : String(e)}`,
102
+ );
103
+ }
104
+ }
105
+
106
+ private async ensureInitialized() {
107
+ if (this.isInitialized) return;
108
+
109
+ if (!this.initializationPromise) {
110
+ this.initializationPromise = (async () => {
111
+ try {
112
+ await this.initializeInternal();
113
+ this.isInitialized = true;
114
+ } catch (error) {
115
+ this.initializationPromise = null;
116
+ throw error;
117
+ }
118
+ })();
119
+ }
120
+
121
+ await this.initializationPromise;
122
+ }
123
+
124
+ public async initialize(): Promise<void> {
125
+ await this.ensureInitialized();
126
+ }
127
+
128
+ public async execute(sql: string, params?: unknown[]): Promise<SQLResult> {
129
+ await this.ensureInitialized();
130
+
131
+ const db = this.db;
132
+ if (!db) {
133
+ throw new Error("Database not available after initialization");
134
+ }
135
+
136
+ try {
137
+ const result = await db.execute(sql, params as any[]);
138
+ return {
139
+ rows: result.rows as SQLRow[],
140
+ insertId:
141
+ result.rowsAffected > 0
142
+ ? (result.rows[0]?.rowid as number)
143
+ : undefined,
144
+ rowsAffected: result.rowsAffected,
145
+ };
146
+ } catch (error) {
147
+ console.error("[OPSQLiteAdapter] SQL execution error:", error);
148
+ throw error;
149
+ }
150
+ }
151
+
152
+ public executeSync(sql: string, params?: unknown[]): { rows: SQLRow[] } {
153
+ if (!this.isInitialized || !this.db) {
154
+ throw new Error("Database not initialized. Call initialize() first.");
155
+ }
156
+ const result = this.db.executeSync(sql, params as any[]);
157
+ return {
158
+ rows: result.rows as SQLRow[],
159
+ };
160
+ }
161
+
162
+ public async transaction(callback: () => Promise<void>): Promise<void> {
163
+ if (!this.db) {
164
+ await this.ensureInitialized();
165
+ }
166
+ await this.db!.transaction(callback);
167
+ }
168
+ }
package/src/testing.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "jazz-react-native-core/dist/testing";
@@ -1,30 +0,0 @@
1
- import { Account, AccountClass, JazzContextManager, KvStore, SyncConfig } from "jazz-tools";
2
- import { JazzContextManagerAuthProps } from "jazz-tools";
3
- import { BaseReactNativeContextOptions } from "./platform.js";
4
- export type JazzContextManagerProps<Acc extends Account> = {
5
- guestMode?: boolean;
6
- sync: SyncConfig;
7
- onLogOut?: () => void;
8
- storage?: BaseReactNativeContextOptions["storage"];
9
- AccountSchema?: AccountClass<Acc>;
10
- defaultProfileName?: string;
11
- onAnonymousAccountDiscarded?: (anonymousAccount: Acc) => Promise<void>;
12
- CryptoProvider?: BaseReactNativeContextOptions["CryptoProvider"];
13
- };
14
- export declare class ReactNativeContextManager<Acc extends Account> extends JazzContextManager<Acc, JazzContextManagerProps<Acc>> {
15
- getNewContext(props: JazzContextManagerProps<Acc>, authProps?: JazzContextManagerAuthProps): Promise<{
16
- guest: import("jazz-tools").AnonymousJazzAgent;
17
- node: import("cojson").LocalNode;
18
- done: () => void;
19
- logOut: () => Promise<void>;
20
- } | {
21
- me: Acc;
22
- node: import("cojson").LocalNode;
23
- authSecretStorage: import("jazz-tools").AuthSecretStorage;
24
- done: () => void;
25
- logOut: () => Promise<void>;
26
- }>;
27
- getKvStore(): KvStore;
28
- propsChanged(props: JazzContextManagerProps<Acc>): boolean;
29
- }
30
- //# sourceMappingURL=ReactNativeContextManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReactNativeContextManager.d.ts","sourceRoot":"","sources":["../src/ReactNativeContextManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,OAAO,EACP,UAAU,EACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,6BAA6B,EAG9B,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,uBAAuB,CAAC,GAAG,SAAS,OAAO,IAAI;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,6BAA6B,CAAC,SAAS,CAAC,CAAC;IACnD,aAAa,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IAClC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,2BAA2B,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,cAAc,CAAC,EAAE,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;CAClE,CAAC;AAEF,qBAAa,yBAAyB,CACpC,GAAG,SAAS,OAAO,CACnB,SAAQ,kBAAkB,CAAC,GAAG,EAAE,uBAAuB,CAAC,GAAG,CAAC,CAAC;IACvD,aAAa,CACjB,KAAK,EAAE,uBAAuB,CAAC,GAAG,CAAC,EACnC,SAAS,CAAC,EAAE,2BAA2B;;;;;;;;;;;;IAuBzC,UAAU,IAAI,OAAO;IAIrB,YAAY,CAAC,KAAK,EAAE,uBAAuB,CAAC,GAAG,CAAC;CAWjD"}
@@ -1,39 +0,0 @@
1
- import { JazzContextManager, } from "jazz-tools";
2
- import { createJazzReactNativeContext, createJazzReactNativeGuestContext, } from "./platform.js";
3
- import { KvStoreContext } from "./storage/kv-store-context.js";
4
- export class ReactNativeContextManager extends JazzContextManager {
5
- async getNewContext(props, authProps) {
6
- if (props.guestMode) {
7
- return createJazzReactNativeGuestContext({
8
- sync: props.sync,
9
- storage: props.storage,
10
- authSecretStorage: this.authSecretStorage,
11
- CryptoProvider: props.CryptoProvider,
12
- });
13
- }
14
- else {
15
- return createJazzReactNativeContext({
16
- sync: props.sync,
17
- storage: props.storage,
18
- AccountSchema: props.AccountSchema,
19
- credentials: authProps?.credentials,
20
- newAccountProps: authProps?.newAccountProps,
21
- defaultProfileName: props.defaultProfileName,
22
- authSecretStorage: this.authSecretStorage,
23
- CryptoProvider: props.CryptoProvider,
24
- });
25
- }
26
- }
27
- getKvStore() {
28
- return KvStoreContext.getInstance().getStorage();
29
- }
30
- propsChanged(props) {
31
- if (!this.props) {
32
- return true;
33
- }
34
- return (this.props.sync.when !== props.sync.when ||
35
- this.props.sync.peer !== props.sync.peer ||
36
- this.props.guestMode !== props.guestMode);
37
- }
38
- }
39
- //# sourceMappingURL=ReactNativeContextManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReactNativeCont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,CAAC,IAAI;YACxC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI;YACxC,IAAI,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,CACzC,CAAC;IACJ,CAAC;CACF"}
@@ -1,8 +0,0 @@
1
- import { useDemoAuth } from "jazz-react-core";
2
- import React from "react";
3
- export declare const DemoAuthBasicUI: ({ appName, auth, children, }: {
4
- appName: string;
5
- auth: ReturnType<typeof useDemoAuth>;
6
- children: React.ReactNode;
7
- }) => string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
8
- //# sourceMappingURL=DemoAuthUI.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DemoAuthUI.d.ts","sourceRoot":"","sources":["../../src/auth/DemoAuthUI.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAmB,MAAM,OAAO,CAAC;AAUxC,eAAO,MAAM,eAAe,iCAIzB;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,iGAyFA,CAAC"}
@@ -1,156 +0,0 @@
1
- import React, { useState } from "react";
2
- import { StyleSheet, Text, TextInput, TouchableOpacity, View, useColorScheme, } from "react-native";
3
- export const DemoAuthBasicUI = ({ appName, auth, children, }) => {
4
- const colorScheme = useColorScheme();
5
- const darkMode = colorScheme === "dark";
6
- const [username, setUsername] = useState("");
7
- const [errorMessage, setErrorMessage] = useState(null);
8
- const handleSignUp = () => {
9
- setErrorMessage(null);
10
- auth.signUp(username).catch((error) => {
11
- setErrorMessage(error.message);
12
- });
13
- };
14
- const handleLogIn = (username) => {
15
- setErrorMessage(null);
16
- auth.logIn(username).catch((error) => {
17
- setErrorMessage(error.message);
18
- });
19
- };
20
- if (auth.state === "signedIn") {
21
- return children;
22
- }
23
- return (<View style={[
24
- styles.container,
25
- darkMode ? styles.darkBackground : styles.lightBackground,
26
- ]}>
27
- <View style={styles.formContainer}>
28
- <Text style={[
29
- styles.headerText,
30
- darkMode ? styles.darkText : styles.lightText,
31
- ]}>
32
- {appName}
33
- </Text>
34
-
35
- {errorMessage && <Text style={styles.errorText}>{errorMessage}</Text>}
36
-
37
- <TextInput placeholder="Display name" value={username} onChangeText={setUsername} placeholderTextColor={darkMode ? "#fff" : "#000"} style={[
38
- styles.textInput,
39
- darkMode ? styles.darkInput : styles.lightInput,
40
- ]}/>
41
-
42
- <TouchableOpacity onPress={handleSignUp} style={[
43
- styles.button,
44
- darkMode ? styles.darkButton : styles.lightButton,
45
- ]}>
46
- <Text style={darkMode ? styles.darkButtonText : styles.lightButtonText}>
47
- Sign Up as new account
48
- </Text>
49
- </TouchableOpacity>
50
-
51
- <View style={styles.existingUsersContainer}>
52
- {auth.existingUsers.map((user) => (<TouchableOpacity key={user} onPress={() => handleLogIn(user)} style={[
53
- styles.existingUserButton,
54
- darkMode ? styles.darkUserButton : styles.lightUserButton,
55
- ]}>
56
- <Text style={darkMode ? styles.darkText : styles.lightText}>
57
- Log In as "{user}"
58
- </Text>
59
- </TouchableOpacity>))}
60
- </View>
61
- </View>
62
- </View>);
63
- };
64
- const styles = StyleSheet.create({
65
- container: {
66
- flex: 1,
67
- justifyContent: "center",
68
- alignItems: "center",
69
- padding: 20,
70
- },
71
- formContainer: {
72
- width: "80%",
73
- alignItems: "center",
74
- justifyContent: "center",
75
- },
76
- headerText: {
77
- fontSize: 24,
78
- marginBottom: 20,
79
- },
80
- errorText: {
81
- color: "red",
82
- marginVertical: 5,
83
- textAlign: "center",
84
- },
85
- textInput: {
86
- borderWidth: 1,
87
- padding: 10,
88
- marginVertical: 10,
89
- width: "100%",
90
- borderRadius: 6,
91
- },
92
- darkInput: {
93
- borderColor: "#444",
94
- backgroundColor: "#000",
95
- color: "#fff",
96
- },
97
- lightInput: {
98
- borderColor: "#ddd",
99
- backgroundColor: "#fff",
100
- color: "#000",
101
- },
102
- button: {
103
- paddingVertical: 15,
104
- paddingHorizontal: 10,
105
- borderRadius: 6,
106
- width: "100%",
107
- marginVertical: 10,
108
- },
109
- darkButton: {
110
- backgroundColor: "#444",
111
- },
112
- lightButton: {
113
- backgroundColor: "#ddd",
114
- },
115
- darkButtonText: {
116
- color: "#fff",
117
- textAlign: "center",
118
- },
119
- lightButtonText: {
120
- color: "#000",
121
- textAlign: "center",
122
- },
123
- existingUsersContainer: {
124
- width: "100%",
125
- marginTop: 20,
126
- },
127
- existingUserButton: {
128
- paddingVertical: 15,
129
- paddingHorizontal: 10,
130
- borderRadius: 6,
131
- marginVertical: 5,
132
- },
133
- darkUserButton: {
134
- backgroundColor: "#222",
135
- },
136
- lightUserButton: {
137
- backgroundColor: "#eee",
138
- },
139
- loadingText: {
140
- fontSize: 18,
141
- color: "#888",
142
- },
143
- darkText: {
144
- color: "#fff",
145
- },
146
- lightText: {
147
- color: "#000",
148
- },
149
- darkBackground: {
150
- backgroundColor: "#000",
151
- },
152
- lightBackground: {
153
- backgroundColor: "#fff",
154
- },
155
- });
156
- //# sourceMappingURL=DemoAuthUI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DemoAuthUI.js","sourceRoot":"","sources":["../../src/auth/DemoAuthUI.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EACL,UAAU,EACV,IAAI,EACJ,SAAS,EACT,gBAAgB,EAChB,IAAI,EACJ,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,OAAO,EACP,IAAI,EACJ,QAAQ,GAKT,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,WAAW,KAAK,MAAM,CAAC;IACxC,MAAM,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AAE,CAAC;QACf,KAAK,EAAE,MAAM;QACb,cAAc,EAAE,EAAE;KACnB;IACD,UAAU,EAAE;QACV,eAAe,EAAE,MAAM;KACxB;IACD,WAAW,EAAE;QACX,eAAe,EAAE,MAAM;KACxB;IACD,cAAc,EAAE;QACd,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,QAAQ;KACpB;IACD,eAAe,EAAE;QACf,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,QAAQ;KACpB;IACD,sBAAsB,EAAE;QACtB,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,EAAE;KACd;IACD,kBAAkB,EAAE;QAClB,eAAe,EAAE,EAAE;QACnB,iBAAiB,EAAE,EAAE;QACrB,YAAY,EAAE,CAAC;QACf,cAAc,EAAE,CAAC;KAClB;IACD,cAAc,EAAE;QACd,eAAe,EAAE,MAAM;KACxB;IACD,eAAe,EAAE;QACf,eAAe,EAAE,MAAM;KACxB;IACD,WAAW,EAAE;QACX,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,MAAM;KACd;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM;KACd;IACD,SAAS,EAAE;QACT,KAAK,EAAE,MAAM;KACd;IACD,cAAc,EAAE;QACd,eAAe,EAAE,MAAM;KACxB;IACD,eAAe,EAAE;QACf,eAAe,EAAE,MAAM;KACxB;CACF,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from "./DemoAuthUI.js";
2
- export declare function clearUserCredentials(): Promise<[void, void, void]>;
3
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth/auth.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC;AAEhC,wBAAgB,oBAAoB,gCASnC"}
package/dist/auth/auth.js DELETED
@@ -1,12 +0,0 @@
1
- import KvStoreContext from "../storage/kv-store-context.js";
2
- export * from "./DemoAuthUI.js";
3
- export function clearUserCredentials() {
4
- const kvStore = KvStoreContext.getInstance().getStorage();
5
- // TODO: Migrate the Auth methods to use the same storage key/interface
6
- return Promise.all([
7
- kvStore.delete("demo-auth-logged-in-secret"),
8
- kvStore.delete("jazz-clerk-auth"),
9
- kvStore.delete("jazz-logged-in-secret"),
10
- ]);
11
- }
12
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth/auth.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAE5D,cAAc,iBAAiB,CAAC;AAEhC,MAAM,UAAU,oBAAoB;IAClC,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,CAAC;IAE1D,uEAAuE;IACvE,OAAO,OAAO,CAAC,GAAG,CAAC;QACjB,OAAO,CAAC,MAAM,CAAC,4BAA4B,CAAC;QAC5C,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC;QACjC,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC;KACxC,CAAC,CAAC;AACL,CAAC"}