@nostrify/react 0.2.9 → 0.2.11
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +17 -0
- package/dist/NostrContext.js +2 -5
- package/dist/NostrContext.js.map +1 -1
- package/dist/example/test-helpers.js +4 -7
- package/dist/example/test-helpers.js.map +1 -1
- package/dist/example/useAuthor.js +7 -10
- package/dist/example/useAuthor.js.map +1 -1
- package/dist/example/useCurrentUser.js +12 -15
- package/dist/example/useCurrentUser.js.map +1 -1
- package/dist/example/useLoginActions.js +8 -11
- package/dist/example/useLoginActions.js.map +1 -1
- package/dist/example/useSocialFeed.js +5 -8
- package/dist/example/useSocialFeed.js.map +1 -1
- package/dist/login/NLogin.js +11 -15
- package/dist/login/NLogin.js.map +1 -1
- package/dist/login/NUser.d.ts +1 -1
- package/dist/login/NUser.d.ts.map +1 -1
- package/dist/login/NUser.js +9 -13
- package/dist/login/NUser.js.map +1 -1
- package/dist/login/NostrLoginContext.d.ts +1 -1
- package/dist/login/NostrLoginContext.d.ts.map +1 -1
- package/dist/login/NostrLoginContext.js +2 -5
- package/dist/login/NostrLoginContext.js.map +1 -1
- package/dist/login/NostrLoginProvider.js +6 -10
- package/dist/login/NostrLoginProvider.js.map +1 -1
- package/dist/login/mod.d.ts +4 -4
- package/dist/login/mod.d.ts.map +1 -1
- package/dist/login/mod.js +4 -11
- package/dist/login/mod.js.map +1 -1
- package/dist/login/nostrLoginReducer.d.ts +1 -1
- package/dist/login/nostrLoginReducer.d.ts.map +1 -1
- package/dist/login/nostrLoginReducer.js +1 -4
- package/dist/login/nostrLoginReducer.js.map +1 -1
- package/dist/login/useNostrLogin.d.ts +1 -1
- package/dist/login/useNostrLogin.d.ts.map +1 -1
- package/dist/login/useNostrLogin.js +4 -7
- package/dist/login/useNostrLogin.js.map +1 -1
- package/dist/login/useNostrLoginReducer.d.ts +2 -2
- package/dist/login/useNostrLoginReducer.d.ts.map +1 -1
- package/dist/login/useNostrLoginReducer.js +5 -8
- package/dist/login/useNostrLoginReducer.js.map +1 -1
- package/dist/mod.d.ts +2 -2
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +2 -7
- package/dist/mod.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useNostr.d.ts +1 -1
- package/dist/useNostr.d.ts.map +1 -1
- package/dist/useNostr.js +4 -7
- package/dist/useNostr.js.map +1 -1
- package/example/useAuthor.ts +1 -1
- package/example/useCurrentUser.ts +2 -2
- package/example/useSocialFeed.ts +1 -1
- package/login/NUser.ts +1 -1
- package/login/NostrLoginContext.ts +1 -1
- package/login/NostrLoginProvider.ts +2 -2
- package/login/mod.ts +4 -4
- package/login/nostrLoginReducer.ts +1 -1
- package/login/useNostrLogin.ts +1 -1
- package/login/useNostrLoginReducer.ts +2 -2
- package/mod.ts +2 -2
- package/package.json +11 -6
- package/useNostr.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @nostrify/react
|
|
2
2
|
|
|
3
|
+
## 0.2.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix imports in workspace packages
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @nostrify/nostrify@0.46.7
|
|
10
|
+
- @nostrify/types@0.36.3
|
|
11
|
+
|
|
12
|
+
## 0.2.10
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fix typescript config so it outputs ESM not CJS built files
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @nostrify/nostrify@0.46.6
|
|
19
|
+
|
|
3
20
|
## 0.2.9
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/NostrContext.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NostrContext = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
1
|
+
import { createContext } from 'react';
|
|
5
2
|
/**
|
|
6
3
|
* React context for Nostr functionality.
|
|
7
4
|
* Use this with useContext or the useNostr hook to access Nostr features.
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const NostrContext = createContext(undefined);
|
|
10
7
|
//# sourceMappingURL=NostrContext.js.map
|
package/dist/NostrContext.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NostrContext.js","sourceRoot":"","sources":["../NostrContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NostrContext.js","sourceRoot":"","sources":["../NostrContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,aAAa,EAAE,MAAM,OAAO,CAAC;AAUpD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAA0C,aAAa,CAC9E,SAAS,CACV,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const happy_dom_1 = require("happy-dom");
|
|
5
|
-
function polyfillDOM() {
|
|
6
|
-
const window = new happy_dom_1.Window();
|
|
1
|
+
import { PropertySymbol, Window } from 'happy-dom';
|
|
2
|
+
export function polyfillDOM() {
|
|
3
|
+
const window = new Window();
|
|
7
4
|
const document = window.document;
|
|
8
|
-
const browserWindow = document[
|
|
5
|
+
const browserWindow = document[PropertySymbol.window];
|
|
9
6
|
const setInnerHTML = (html) => document.documentElement.innerHTML = html;
|
|
10
7
|
const cancelAsync = () => window.happyDOM.abort();
|
|
11
8
|
Object.assign(globalThis, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../example/test-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../example/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EA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
|
|
6
|
-
const
|
|
7
|
-
function useAuthor(pubkey) {
|
|
8
|
-
const { nostr } = (0, useNostr_1.useNostr)();
|
|
9
|
-
const { data } = (0, react_query_1.useSuspenseQuery)({
|
|
1
|
+
import { NSchema as n } from '@nostrify/nostrify';
|
|
2
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
3
|
+
import { useNostr } from '../useNostr.js';
|
|
4
|
+
export function useAuthor(pubkey) {
|
|
5
|
+
const { nostr } = useNostr();
|
|
6
|
+
const { data } = useSuspenseQuery({
|
|
10
7
|
queryKey: ['author', pubkey ?? ''],
|
|
11
8
|
queryFn: async ({ signal }) => {
|
|
12
9
|
if (!pubkey) {
|
|
@@ -17,7 +14,7 @@ function useAuthor(pubkey) {
|
|
|
17
14
|
return {};
|
|
18
15
|
}
|
|
19
16
|
try {
|
|
20
|
-
const metadata =
|
|
17
|
+
const metadata = n.json().pipe(n.metadata()).parse(event.content);
|
|
21
18
|
return { ...metadata, event };
|
|
22
19
|
}
|
|
23
20
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthor.js","sourceRoot":"","sources":["../../example/useAuthor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuthor.js","sourceRoot":"","sources":["../../example/useAuthor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,OAAO,IAAI,CAAC,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,UAAU,SAAS,CACvB,MAA0B;IAE1B,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE7B,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAyC;QACxE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAC;QAClC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,KAAK,CAAC,KAAK,CAC/B,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,MAAO,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAC9C,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAChE,CAAC;YAEF,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAClE,OAAO,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC;YAChC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
function useCurrentUser() {
|
|
9
|
-
const { nostr } = (0, useNostr_1.useNostr)();
|
|
10
|
-
const { logins } = (0, login_1.useNostrLogin)();
|
|
1
|
+
import { NUser, useNostrLogin } from '@nostrify/react/login';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useAuthor } from './useAuthor.js';
|
|
4
|
+
import { useNostr } from '../useNostr.js';
|
|
5
|
+
export function useCurrentUser() {
|
|
6
|
+
const { nostr } = useNostr();
|
|
7
|
+
const { logins } = useNostrLogin();
|
|
11
8
|
function loginToUser(login) {
|
|
12
9
|
switch (login.type) {
|
|
13
10
|
case 'nsec':
|
|
14
|
-
return
|
|
11
|
+
return NUser.fromNsecLogin(login);
|
|
15
12
|
case 'bunker':
|
|
16
|
-
return
|
|
13
|
+
return NUser.fromBunkerLogin(login, nostr);
|
|
17
14
|
case 'extension':
|
|
18
|
-
return
|
|
15
|
+
return NUser.fromExtensionLogin(login);
|
|
19
16
|
default:
|
|
20
17
|
// Learn how to define other login types: https://nostrify.dev/react/logins#custom-login-types
|
|
21
18
|
throw new Error(`Unsupported login type: ${login.type}`);
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
const users =
|
|
21
|
+
const users = useMemo(() => {
|
|
25
22
|
const users = [];
|
|
26
23
|
for (const login of logins) {
|
|
27
24
|
try {
|
|
@@ -35,7 +32,7 @@ function useCurrentUser() {
|
|
|
35
32
|
return users;
|
|
36
33
|
}, [logins, nostr]);
|
|
37
34
|
const user = users[0];
|
|
38
|
-
const metadata =
|
|
35
|
+
const metadata = useAuthor(user?.pubkey);
|
|
39
36
|
return {
|
|
40
37
|
user,
|
|
41
38
|
users,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentUser.js","sourceRoot":"","sources":["../../example/useCurrentUser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrentUser.js","sourceRoot":"","sources":["../../example/useCurrentUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,UAAU,cAAc;IAC5B,MAAM,EAAE,KAAK,E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
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
function useLoginActions() {
|
|
7
|
-
const { nostr } = (0, react_1.useNostr)();
|
|
8
|
-
const { addLogin } = (0, login_1.useNostrLogin)();
|
|
1
|
+
import { useNostr } from '@nostrify/react';
|
|
2
|
+
import { NLogin, useNostrLogin } from '@nostrify/react/login';
|
|
3
|
+
export function useLoginActions() {
|
|
4
|
+
const { nostr } = useNostr();
|
|
5
|
+
const { addLogin } = useNostrLogin();
|
|
9
6
|
return {
|
|
10
7
|
nsec(nsec) {
|
|
11
|
-
const login =
|
|
8
|
+
const login = NLogin.fromNsec(nsec);
|
|
12
9
|
addLogin(login);
|
|
13
10
|
},
|
|
14
11
|
async bunker(uri) {
|
|
15
|
-
const login = await
|
|
12
|
+
const login = await NLogin.fromBunker(uri, nostr);
|
|
16
13
|
addLogin(login);
|
|
17
14
|
},
|
|
18
15
|
async extension() {
|
|
19
|
-
const login = await
|
|
16
|
+
const login = await NLogin.fromExtension();
|
|
20
17
|
addLogin(login);
|
|
21
18
|
},
|
|
22
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoginActions.js","sourceRoot":"","sources":["../../example/useLoginActions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLoginActions.js","sourceRoot":"","sources":["../../example/useLoginActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,UAAU,eAAe;IAC7B,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC7B,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;IAErC,OAAO;QACL,IAAI,CAAC,IAAY;YACf,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACpC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,GAAW;YACtB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAClD,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;QACD,KAAK,CAAC,SAAS;YACb,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;YAC3C,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
function useSocialFeed() {
|
|
7
|
-
const { nostr } = (0, useNostr_1.useNostr)();
|
|
8
|
-
return (0, react_query_1.useSuspenseQuery)({
|
|
1
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useNostr } from '../useNostr.js';
|
|
3
|
+
export function useSocialFeed() {
|
|
4
|
+
const { nostr } = useNostr();
|
|
5
|
+
return useSuspenseQuery({
|
|
9
6
|
queryKey: ['social-feed'],
|
|
10
7
|
queryFn: () => nostr.query([{ kinds: [1], limit: 5 }], { signal: AbortSignal.timeout(5000) }),
|
|
11
8
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSocialFeed.js","sourceRoot":"","sources":["../../example/useSocialFeed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSocialFeed.js","sourceRoot":"","sources":["../../example/useSocialFeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA+B,MAAM,uBAAuB,CAAC;AAEtF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,MAAM,UAAU,aAAa;IAC3B,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE7B,OAAO,gBAAgB,CAAC;QACtB,QAAQ,EAAE,CAAC,aAAa,CAAC;QACzB,OAAO,EAAE,GAAG,EAAE,CACZ,KAAK,CAAC,KAAK,CACT,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAC1B,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CACtC;KACJ,CAAC,CAAC;AACL,CAAC"}
|
package/dist/login/NLogin.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.NLogin = void 0;
|
|
4
|
-
const nostrify_1 = require("@nostrify/nostrify");
|
|
5
|
-
const nostr_tools_1 = require("nostr-tools");
|
|
1
|
+
import { BunkerURI, NConnectSigner, NSecSigner } from '@nostrify/nostrify';
|
|
2
|
+
import { generateSecretKey, getPublicKey, nip19 } from 'nostr-tools';
|
|
6
3
|
/** Class representing Nostr login credentials. */
|
|
7
|
-
class NLogin {
|
|
4
|
+
export class NLogin {
|
|
8
5
|
id;
|
|
9
6
|
type;
|
|
10
7
|
pubkey;
|
|
@@ -19,26 +16,26 @@ class NLogin {
|
|
|
19
16
|
}
|
|
20
17
|
/** Create a login object from an nsec. */
|
|
21
18
|
static fromNsec(nsec) {
|
|
22
|
-
const decoded =
|
|
19
|
+
const decoded = nip19.decode(nsec);
|
|
23
20
|
if (decoded.type !== 'nsec') {
|
|
24
21
|
throw new Error('Invalid nsec');
|
|
25
22
|
}
|
|
26
23
|
const sk = decoded.data;
|
|
27
|
-
const pubkey =
|
|
24
|
+
const pubkey = getPublicKey(sk);
|
|
28
25
|
return new NLogin('nsec', pubkey, {
|
|
29
|
-
nsec:
|
|
26
|
+
nsec: nip19.nsecEncode(sk),
|
|
30
27
|
});
|
|
31
28
|
}
|
|
32
29
|
/** Create a login object from a bunker URI. */
|
|
33
30
|
static async fromBunker(uri, pool) {
|
|
34
|
-
const { pubkey: bunkerPubkey, secret, relays } = new
|
|
31
|
+
const { pubkey: bunkerPubkey, secret, relays } = new BunkerURI(uri);
|
|
35
32
|
if (!relays.length) {
|
|
36
33
|
throw new Error('No relay provided');
|
|
37
34
|
}
|
|
38
|
-
const sk =
|
|
39
|
-
const nsec =
|
|
40
|
-
const clientSigner = new
|
|
41
|
-
const signer = new
|
|
35
|
+
const sk = generateSecretKey();
|
|
36
|
+
const nsec = nip19.nsecEncode(sk);
|
|
37
|
+
const clientSigner = new NSecSigner(sk);
|
|
38
|
+
const signer = new NConnectSigner({
|
|
42
39
|
relay: pool.group(relays),
|
|
43
40
|
pubkey: bunkerPubkey,
|
|
44
41
|
signer: clientSigner,
|
|
@@ -72,5 +69,4 @@ class NLogin {
|
|
|
72
69
|
};
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
|
-
exports.NLogin = NLogin;
|
|
76
72
|
//# sourceMappingURL=NLogin.js.map
|
package/dist/login/NLogin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NLogin.js","sourceRoot":"","sources":["../../login/NLogin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NLogin.js","sourceRoot":"","sources":["../../login/NLogin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAgC,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAkCrE,kDAAkD;AAClD,MAAM,OAAO,MAAM;IACV,EAAE,CAAS;IACX,IAAI,CAAI;IACR,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,IAAI,CAAI;IAEf,YAAY,IAAO,EAAE,MAAc,EAAE,IAAO;QAC1C,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,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,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;QAE3C,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE;YAClC,YAAY;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,sDAAsD;IACtD,MAAM,CAAC,KAAK,CAAC,aAAa;QACxB,MAAM,YAAY,GAAI,UAAiD,CAAC,KAAK,CAAC;QAE9E,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,YAAY,EAAE,CAAC;QAEjD,OAAO,IAAI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,6CAA6C;IAC7C,MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;CACF"}
|
package/dist/login/NUser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NostrSigner, type NPool } from '@nostrify/nostrify';
|
|
2
|
-
import type { NLoginBunker, NLoginExtension, NLoginNsec } from './NLogin';
|
|
2
|
+
import type { NLoginBunker, NLoginExtension, NLoginNsec } from './NLogin.js';
|
|
3
3
|
/** Represents a Nostr user with authentication credentials. */
|
|
4
4
|
export declare class NUser {
|
|
5
5
|
/** The authentication method used for this user */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NUser.d.ts","sourceRoot":"","sources":["../../login/NUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,WAAW,EAAE,KAAK,KAAK,EAAc,MAAM,oBAAoB,CAAC;AAG9G,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"NUser.d.ts","sourceRoot":"","sources":["../../login/NUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,WAAW,EAAE,KAAK,KAAK,EAAc,MAAM,oBAAoB,CAAC;AAG9G,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7E,+DAA+D;AAC/D,qBAAa,KAAK;IAEd,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,MAAM,EAAE;IAChE,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,WAAW;;IAL5B,mDAAmD;IAC1C,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,MAAM,EAAE;IAChE,gDAAgD;IACvC,MAAM,EAAE,MAAM;IACvB,8DAA8D;IACrD,MAAM,EAAE,WAAW;IAG9B,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK;IAa9C,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,KAAK;IAmB/D,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK;CAOzD"}
|
package/dist/login/NUser.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.NUser = void 0;
|
|
4
|
-
const nostrify_1 = require("@nostrify/nostrify");
|
|
5
|
-
const nostr_tools_1 = require("nostr-tools");
|
|
1
|
+
import { NBrowserSigner, NConnectSigner, NSecSigner } from '@nostrify/nostrify';
|
|
2
|
+
import { nip19 } from 'nostr-tools';
|
|
6
3
|
/** Represents a Nostr user with authentication credentials. */
|
|
7
|
-
class NUser {
|
|
4
|
+
export class NUser {
|
|
8
5
|
method;
|
|
9
6
|
pubkey;
|
|
10
7
|
signer;
|
|
@@ -20,13 +17,13 @@ class NUser {
|
|
|
20
17
|
this.signer = signer;
|
|
21
18
|
}
|
|
22
19
|
static fromNsecLogin(login) {
|
|
23
|
-
const sk =
|
|
24
|
-
return new NUser(login.type, login.pubkey, new
|
|
20
|
+
const sk = nip19.decode(login.data.nsec);
|
|
21
|
+
return new NUser(login.type, login.pubkey, new NSecSigner(sk.data));
|
|
25
22
|
}
|
|
26
23
|
static fromBunkerLogin(login, pool) {
|
|
27
|
-
const clientSk =
|
|
28
|
-
const clientSigner = new
|
|
29
|
-
return new NUser(login.type, login.pubkey, new
|
|
24
|
+
const clientSk = nip19.decode(login.data.clientNsec);
|
|
25
|
+
const clientSigner = new NSecSigner(clientSk.data);
|
|
26
|
+
return new NUser(login.type, login.pubkey, new NConnectSigner({
|
|
30
27
|
relay: pool.group(login.data.relays),
|
|
31
28
|
pubkey: login.pubkey,
|
|
32
29
|
signer: clientSigner,
|
|
@@ -34,8 +31,7 @@ class NUser {
|
|
|
34
31
|
}));
|
|
35
32
|
}
|
|
36
33
|
static fromExtensionLogin(login) {
|
|
37
|
-
return new NUser(login.type, login.pubkey, new
|
|
34
|
+
return new NUser(login.type, login.pubkey, new NBrowserSigner());
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
|
-
exports.NUser = NUser;
|
|
41
37
|
//# sourceMappingURL=NUser.js.map
|
package/dist/login/NUser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NUser.js","sourceRoot":"","sources":["../../login/NUser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NUser.js","sourceRoot":"","sources":["../../login/N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AI,KAAK,CACd,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,MAAM,EACZ,IAAI,cAAc,EAAE,CACrB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Context } from 'react';
|
|
2
|
-
import type { NLoginType } from './NLogin';
|
|
2
|
+
import type { NLoginType } from './NLogin.js';
|
|
3
3
|
/**
|
|
4
4
|
* NostrLoginContextType defines the shape of the context that will be provided
|
|
5
5
|
* to components that need access to the Nostr login state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NostrLoginContext.d.ts","sourceRoot":"","sources":["../../login/NostrLoginContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"NostrLoginContext.d.ts","sourceRoot":"","sources":["../../login/NostrLoginContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,gCAAgC;IAChC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IAC9B,sDAAsD;IACtD,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,2DAA2D;IAC3D,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iGAAiG;IACjG,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,mDAAmD;IACnD,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAE7D,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NostrLoginContext = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
1
|
+
import { createContext } from 'react';
|
|
5
2
|
/**
|
|
6
3
|
* NostrLoginContext is a React context that provides access to the Nostr login state and
|
|
7
4
|
* a dispatch function to update the state.
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const NostrLoginContext = createContext(undefined);
|
|
10
7
|
//# sourceMappingURL=NostrLoginContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NostrLoginContext.js","sourceRoot":"","sources":["../../login/NostrLoginContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NostrLoginContext.js","sourceRoot":"","sources":["../../login/NostrLoginContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,aAAa,EAAE,MAAM,OAAO,CAAC;AAqBpD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA+C,aAAa,CAExF,SAAS,CAAC,CAAC"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const NostrLoginContext_1 = require("./NostrLoginContext");
|
|
6
|
-
const useNostrLoginReducer_1 = require("./useNostrLoginReducer");
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { NostrLoginContext } from './NostrLoginContext.js';
|
|
3
|
+
import { useNostrLoginReducer } from './useNostrLoginReducer.js';
|
|
7
4
|
/**
|
|
8
5
|
* NostrLoginProvider is a React component that provides a context for managing Nostr logins.
|
|
9
6
|
* It uses a reducer to handle the state of logins and stores them in localStorage.
|
|
10
7
|
*/
|
|
11
|
-
const NostrLoginProvider = ({ children, storageKey }) => {
|
|
12
|
-
const [logins, dispatch] =
|
|
8
|
+
export const NostrLoginProvider = ({ children, storageKey }) => {
|
|
9
|
+
const [logins, dispatch] = useNostrLoginReducer(storageKey);
|
|
13
10
|
const value = {
|
|
14
11
|
logins,
|
|
15
12
|
addLogin: (login) => dispatch({ type: 'login.add', login }),
|
|
@@ -17,7 +14,6 @@ const NostrLoginProvider = ({ children, storageKey }) => {
|
|
|
17
14
|
setLogin: (id) => dispatch({ type: 'login.set', id }),
|
|
18
15
|
clearLogins: () => dispatch({ type: 'login.clear' }),
|
|
19
16
|
};
|
|
20
|
-
return
|
|
17
|
+
return jsx(NostrLoginContext.Provider, { value, children });
|
|
21
18
|
};
|
|
22
|
-
exports.NostrLoginProvider = NostrLoginProvider;
|
|
23
19
|
//# sourceMappingURL=NostrLoginProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NostrLoginProvider.js","sourceRoot":"","sources":["../../login/NostrLoginProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NostrLoginProvider.js","sourceRoot":"","sources":["../../login/NostrLoginProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAyB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAYjE;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAgC,CAC7D,EAAE,QAAQ,EAAE,UAAU,EAA2B,EACjD,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,KAAK,GAA0B;QACnC,MAAM;QACN,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;QAC3D,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;QAC3D,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;QACrD,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KACrD,CAAC;IAEF,OAAO,GAAG,CAAC,iBAAiB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC9D,CAAC,CAAC"}
|
package/dist/login/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { NLogin, type NLoginType } from './NLogin';
|
|
2
|
-
export { NostrLoginProvider } from './NostrLoginProvider';
|
|
3
|
-
export { NUser } from './NUser';
|
|
4
|
-
export { useNostrLogin } from './useNostrLogin';
|
|
1
|
+
export { NLogin, type NLoginType } from './NLogin.js';
|
|
2
|
+
export { NostrLoginProvider } from './NostrLoginProvider.js';
|
|
3
|
+
export { NUser } from './NUser.js';
|
|
4
|
+
export { useNostrLogin } from './useNostrLogin.js';
|
|
5
5
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/login/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../login/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../login/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/login/mod.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "NLogin", { enumerable: true, get: function () { return NLogin_1.NLogin; } });
|
|
6
|
-
var NostrLoginProvider_1 = require("./NostrLoginProvider");
|
|
7
|
-
Object.defineProperty(exports, "NostrLoginProvider", { enumerable: true, get: function () { return NostrLoginProvider_1.NostrLoginProvider; } });
|
|
8
|
-
var NUser_1 = require("./NUser");
|
|
9
|
-
Object.defineProperty(exports, "NUser", { enumerable: true, get: function () { return NUser_1.NUser; } });
|
|
10
|
-
var useNostrLogin_1 = require("./useNostrLogin");
|
|
11
|
-
Object.defineProperty(exports, "useNostrLogin", { enumerable: true, get: function () { return useNostrLogin_1.useNostrLogin; } });
|
|
1
|
+
export { NLogin } from './NLogin.js';
|
|
2
|
+
export { NostrLoginProvider } from './NostrLoginProvider.js';
|
|
3
|
+
export { NUser } from './NUser.js';
|
|
4
|
+
export { useNostrLogin } from './useNostrLogin.js';
|
|
12
5
|
//# sourceMappingURL=mod.js.map
|
package/dist/login/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../login/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../login/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nostrLoginReducer.d.ts","sourceRoot":"","sources":["../../login/nostrLoginReducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"nostrLoginReducer.d.ts","sourceRoot":"","sources":["../../login/nostrLoginReducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAE5B,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,UAAU,EAAE,EACnB,MAAM,EAAE,YAAY,GACnB,UAAU,EAAE,CA8Bd"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nostrLoginReducer = nostrLoginReducer;
|
|
4
|
-
function nostrLoginReducer(state, action) {
|
|
1
|
+
export function nostrLoginReducer(state, action) {
|
|
5
2
|
switch (action.type) {
|
|
6
3
|
case 'login.add': {
|
|
7
4
|
const filtered = state.filter((login) => login.id !== action.login.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nostrLoginReducer.js","sourceRoot":"","sources":["../../login/nostrLoginReducer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nostrLoginReducer.js","sourceRoot":"","sources":["../../login/nostrLoginReducer.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,iBAAiB,CAC/B,KAAmB,EACnB,MAAoB;IAEpB,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAA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.ts","sourceRoot":"","sources":["../../login/useNostrLogin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEvF,wBAAgB,aAAa,IAAI,qBAAqB,CAQrD"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const NostrLoginContext_1 = require("./NostrLoginContext");
|
|
6
|
-
function useNostrLogin() {
|
|
7
|
-
const context = (0, react_1.useContext)(NostrLoginContext_1.NostrLoginContext);
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { NostrLoginContext } from './NostrLoginContext.js';
|
|
3
|
+
export function useNostrLogin() {
|
|
4
|
+
const context = useContext(NostrLoginContext);
|
|
8
5
|
if (!context) {
|
|
9
6
|
throw new Error('useNostrLogin must be used within a NostrLoginProvider');
|
|
10
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNostrLogin.js","sourceRoot":"","sources":["../../login/useNostrLogin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNostrLogin.js","sourceRoot":"","sources":["../../login/useNostrLogin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAA8B,MAAM,wBAAwB,CAAC;AAEvF,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE9C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type NLoginAction } from './nostrLoginReducer';
|
|
2
|
-
import type { NLoginType } from './NLogin';
|
|
1
|
+
import { type NLoginAction } from './nostrLoginReducer.js';
|
|
2
|
+
import type { NLoginType } from './NLogin.js';
|
|
3
3
|
export declare function useNostrLoginReducer(storageKey: string): [state: NLoginType[], dispatch: (action: NLoginAction) => void];
|
|
4
4
|
//# sourceMappingURL=useNostrLoginReducer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNostrLoginReducer.d.ts","sourceRoot":"","sources":["../../login/useNostrLoginReducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,
|
|
1
|
+
{"version":3,"file":"useNostrLoginReducer.d.ts","sourceRoot":"","sources":["../../login/useNostrLoginReducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AAE9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,GACjB,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC,CAWjE"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const nostrLoginReducer_1 = require("./nostrLoginReducer");
|
|
6
|
-
function useNostrLoginReducer(storageKey) {
|
|
7
|
-
const [state, dispatch] = (0, react_1.useReducer)(nostrLoginReducer_1.nostrLoginReducer, [], () => {
|
|
1
|
+
import { useEffect, useReducer } from 'react';
|
|
2
|
+
import { nostrLoginReducer } from './nostrLoginReducer.js';
|
|
3
|
+
export function useNostrLoginReducer(storageKey) {
|
|
4
|
+
const [state, dispatch] = useReducer(nostrLoginReducer, [], () => {
|
|
8
5
|
const stored = localStorage.getItem(storageKey);
|
|
9
6
|
return stored ? JSON.parse(stored) : [];
|
|
10
7
|
});
|
|
11
|
-
|
|
8
|
+
useEffect(() => {
|
|
12
9
|
localStorage.setItem(storageKey, JSON.stringify(state));
|
|
13
10
|
}, [state]);
|
|
14
11
|
return [state, dispatch];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNostrLoginReducer.js","sourceRoot":"","sources":["../../login/useNostrLoginReducer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNostrLoginReducer.js","sourceRoot":"","sources":["../../login/useNostrLoginReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAqB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAI9E,MAAM,UAAU,oBAAoB,CAClC,UAAkB;IAElB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,iBAAiB,EAAE,EAAE,EAAE,GAAG,EAAE;QAC/D,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAChD,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1D,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC"}
|