jazz-react-native 0.8.46 → 0.8.47
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/auth/DemoAuthMethod.d.ts +2 -1
- package/dist/auth/DemoAuthMethod.js +2 -2
- package/dist/auth/DemoAuthMethod.js.map +1 -1
- package/dist/auth/DemoAuthUI.d.ts +3 -1
- package/dist/auth/DemoAuthUI.js +13 -4
- package/dist/auth/DemoAuthUI.js.map +1 -1
- package/package.json +1 -1
- package/src/auth/DemoAuthMethod.ts +2 -1
- package/src/auth/DemoAuthUI.tsx +14 -2
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { AgentSecret } from "cojson";
|
2
2
|
import { Account, AuthMethod, AuthResult, ID } from "jazz-tools";
|
3
|
+
import { KvStore } from "../storage/kv-store-context.js";
|
3
4
|
/** @category Auth Providers */
|
4
5
|
export declare namespace RNDemoAuth {
|
5
6
|
interface Driver {
|
@@ -23,6 +24,6 @@ export declare class RNDemoAuth implements AuthMethod {
|
|
23
24
|
accountID: ID<Account>;
|
24
25
|
accountSecret: AgentSecret;
|
25
26
|
};
|
26
|
-
}): Promise<RNDemoAuth>;
|
27
|
+
}, store?: KvStore | undefined): Promise<RNDemoAuth>;
|
27
28
|
start(): Promise<AuthResult>;
|
28
29
|
}
|
@@ -56,8 +56,8 @@ export class RNDemoAuth {
|
|
56
56
|
this.driver = driver;
|
57
57
|
this.kvStore = kvStore;
|
58
58
|
}
|
59
|
-
static async init(driver, seedAccounts) {
|
60
|
-
const kvStore = KvStoreContext.getInstance().getStorage();
|
59
|
+
static async init(driver, seedAccounts, store) {
|
60
|
+
const kvStore = store ? store : KvStoreContext.getInstance().getStorage();
|
61
61
|
await migrateExistingUsersKeys(kvStore);
|
62
62
|
for (const [name, credentials] of Object.entries(seedAccounts || {})) {
|
63
63
|
const storageData = JSON.stringify(credentials);
|
@@ -1 +1 @@
|
|
1
|
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AC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,KAAK,UAAU,MAAM;IACnB,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,CAAC;IAC1D,KAAK,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { AgentSecret } from "cojson";
|
2
2
|
import { Account, ID } from "jazz-tools";
|
3
3
|
import React from "react";
|
4
|
+
import { KvStore } from "../storage/kv-store-context.js";
|
4
5
|
import { RNDemoAuth } from "./DemoAuthMethod.js";
|
5
6
|
type DemoAuthState = ({
|
6
7
|
state: "uninitialized";
|
@@ -18,13 +19,14 @@ type DemoAuthState = ({
|
|
18
19
|
errors: string[];
|
19
20
|
};
|
20
21
|
/** @category Auth Providers */
|
21
|
-
export declare function useDemoAuth({ seedAccounts, }?: {
|
22
|
+
export declare function useDemoAuth({ seedAccounts, store, }?: {
|
22
23
|
seedAccounts?: {
|
23
24
|
[name: string]: {
|
24
25
|
accountID: ID<Account>;
|
25
26
|
accountSecret: AgentSecret;
|
26
27
|
};
|
27
28
|
};
|
29
|
+
store?: KvStore;
|
28
30
|
}): readonly [RNDemoAuth | null, DemoAuthState];
|
29
31
|
export declare const DemoAuthBasicUI: ({ appName, state, }: {
|
30
32
|
appName: string;
|
package/dist/auth/DemoAuthUI.js
CHANGED
@@ -2,7 +2,7 @@ import React, { useMemo, useState, useEffect } from "react";
|
|
2
2
|
import { StyleSheet, Text, TextInput, TouchableOpacity, View, } from "react-native";
|
3
3
|
import { RNDemoAuth } from "./DemoAuthMethod.js";
|
4
4
|
/** @category Auth Providers */
|
5
|
-
export function useDemoAuth({ seedAccounts, } = {}) {
|
5
|
+
export function useDemoAuth({ seedAccounts, store, } = {}) {
|
6
6
|
const [state, setState] = useState({
|
7
7
|
state: "loading",
|
8
8
|
errors: [],
|
@@ -29,12 +29,21 @@ export function useDemoAuth({ seedAccounts, } = {}) {
|
|
29
29
|
errors: [...current.errors, error.toString()],
|
30
30
|
}));
|
31
31
|
},
|
32
|
-
}, seedAccounts);
|
32
|
+
}, seedAccounts, store);
|
33
33
|
}, [seedAccounts]);
|
34
34
|
useEffect(() => {
|
35
35
|
async function init() {
|
36
|
-
|
37
|
-
|
36
|
+
try {
|
37
|
+
const auth = await authMethodPromise;
|
38
|
+
setAuthMethod(auth);
|
39
|
+
}
|
40
|
+
catch (e) {
|
41
|
+
const err = e;
|
42
|
+
setState((current) => ({
|
43
|
+
...current,
|
44
|
+
errors: [...current.errors, err.toString()],
|
45
|
+
}));
|
46
|
+
}
|
38
47
|
}
|
39
48
|
if (authMethod)
|
40
49
|
return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DemoAuthUI.js","sourceRoot":"","sources":["../../src/auth/DemoAuthUI.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,IAAI,EACJ,SAAS,EACT,gBAAgB,EAChB,IAAI,GACL,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"DemoAuthUI.js","sourceRoot":"","sources":["../../src/auth/DemoAuthUI.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,IAAI,EACJ,SAAS,EACT,gBAAgB,EAChB,IAAI,GACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAuBjD,+BAA+B;AAC/B,MAAM,UAAU,WAAW,CAAC,EAC1B,YAAY,EACZ,KAAK,MAMH,EAAE;IACJ,MAAM,CAAC,KAAK,E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iB,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"}
|
package/package.json
CHANGED
@@ -100,8 +100,9 @@ export class RNDemoAuth implements AuthMethod {
|
|
100
100
|
accountSecret: AgentSecret;
|
101
101
|
};
|
102
102
|
},
|
103
|
+
store?: KvStore | undefined,
|
103
104
|
) {
|
104
|
-
const kvStore = KvStoreContext.getInstance().getStorage();
|
105
|
+
const kvStore = store ? store : KvStoreContext.getInstance().getStorage();
|
105
106
|
|
106
107
|
await migrateExistingUsersKeys(kvStore);
|
107
108
|
|
package/src/auth/DemoAuthUI.tsx
CHANGED
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
TouchableOpacity,
|
9
9
|
View,
|
10
10
|
} from "react-native";
|
11
|
+
import { KvStore } from "../storage/kv-store-context.js";
|
11
12
|
import { RNDemoAuth } from "./DemoAuthMethod.js";
|
12
13
|
|
13
14
|
type DemoAuthState = (
|
@@ -34,10 +35,12 @@ type DemoAuthState = (
|
|
34
35
|
/** @category Auth Providers */
|
35
36
|
export function useDemoAuth({
|
36
37
|
seedAccounts,
|
38
|
+
store,
|
37
39
|
}: {
|
38
40
|
seedAccounts?: {
|
39
41
|
[name: string]: { accountID: ID<Account>; accountSecret: AgentSecret };
|
40
42
|
};
|
43
|
+
store?: KvStore;
|
41
44
|
} = {}) {
|
42
45
|
const [state, setState] = useState<DemoAuthState>({
|
43
46
|
state: "loading",
|
@@ -70,13 +73,22 @@ export function useDemoAuth({
|
|
70
73
|
},
|
71
74
|
},
|
72
75
|
seedAccounts,
|
76
|
+
store,
|
73
77
|
);
|
74
78
|
}, [seedAccounts]);
|
75
79
|
|
76
80
|
useEffect(() => {
|
77
81
|
async function init() {
|
78
|
-
|
79
|
-
|
82
|
+
try {
|
83
|
+
const auth = await authMethodPromise;
|
84
|
+
setAuthMethod(auth);
|
85
|
+
} catch (e: unknown) {
|
86
|
+
const err = e as Error;
|
87
|
+
setState((current) => ({
|
88
|
+
...current,
|
89
|
+
errors: [...current.errors, err.toString()],
|
90
|
+
}));
|
91
|
+
}
|
80
92
|
}
|
81
93
|
if (authMethod) return;
|
82
94
|
void init();
|