@bitsocial/bitsocial-react-hooks 0.3.6 → 0.4.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 (41) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/hooks/accounts/accounts.d.ts +17 -1
  3. package/dist/hooks/accounts/accounts.d.ts.map +1 -1
  4. package/dist/hooks/accounts/accounts.js +57 -0
  5. package/dist/hooks/accounts/accounts.js.map +1 -1
  6. package/dist/index.d.ts +9 -5
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +7 -3
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/chain/author-wallet-proof.d.ts +28 -0
  11. package/dist/lib/chain/author-wallet-proof.d.ts.map +1 -0
  12. package/dist/lib/chain/author-wallet-proof.js +118 -0
  13. package/dist/lib/chain/author-wallet-proof.js.map +1 -0
  14. package/dist/lib/chain/chain.d.ts +16 -9
  15. package/dist/lib/chain/chain.d.ts.map +1 -1
  16. package/dist/lib/chain/chain.js +33 -50
  17. package/dist/lib/chain/chain.js.map +1 -1
  18. package/dist/lib/online-status.d.ts +8 -0
  19. package/dist/lib/online-status.d.ts.map +1 -0
  20. package/dist/lib/online-status.js +37 -0
  21. package/dist/lib/online-status.js.map +1 -0
  22. package/dist/lib/pseudonymity-author-tag.d.ts +24 -0
  23. package/dist/lib/pseudonymity-author-tag.d.ts.map +1 -0
  24. package/dist/lib/pseudonymity-author-tag.js +119 -0
  25. package/dist/lib/pseudonymity-author-tag.js.map +1 -0
  26. package/dist/stores/accounts/accounts-actions.d.ts.map +1 -1
  27. package/dist/stores/accounts/accounts-actions.js +1 -10
  28. package/dist/stores/accounts/accounts-actions.js.map +1 -1
  29. package/dist/stores/accounts/accounts-database.d.ts.map +1 -1
  30. package/dist/stores/accounts/accounts-database.js +68 -0
  31. package/dist/stores/accounts/accounts-database.js.map +1 -1
  32. package/dist/stores/feeds/feeds-store.d.ts.map +1 -1
  33. package/dist/stores/feeds/feeds-store.js +6 -0
  34. package/dist/stores/feeds/feeds-store.js.map +1 -1
  35. package/dist/stores/feeds/utils.d.ts.map +1 -1
  36. package/dist/stores/feeds/utils.js +2 -1
  37. package/dist/stores/feeds/utils.js.map +1 -1
  38. package/dist/types.d.ts +3 -0
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/types.js.map +1 -1
  41. package/package.json +7 -2
@@ -0,0 +1,37 @@
1
+ import assert from "./assert.js";
2
+ // Whether the device has network access. Feeds read it to decide whether an expired community cache
3
+ // may still be shown (offline) or should wait for the next community update (online).
4
+ let onlineStatus;
5
+ // The feeds store listens here: a feed computed while online has no other event to recompute it
6
+ // when the device turns out to be offline (an app that starts offline gets no community update).
7
+ const onlineStatusListeners = new Set();
8
+ /**
9
+ * Set the device's online status, for runtimes without `navigator.onLine` such as React Native
10
+ * (e.g. from NetInfo). `undefined` goes back to `navigator.onLine`. A change recomputes feeds.
11
+ */
12
+ export const setOnlineStatus = (online) => {
13
+ assert(online === undefined || typeof online === "boolean", `setOnlineStatus invalid online argument '${online}' not a boolean or undefined`);
14
+ const wasOnline = isOnline();
15
+ onlineStatus = online;
16
+ if (isOnline() !== wasOnline) {
17
+ onlineStatusListeners.forEach((listener) => listener());
18
+ }
19
+ };
20
+ // Without a signal (React Native has no navigator.onLine), assume online: reading "unknown" as
21
+ // offline would build feeds from expired caches on every device that is in fact online.
22
+ export const isOnline = () => {
23
+ var _a;
24
+ if (onlineStatus !== undefined) {
25
+ return onlineStatus;
26
+ }
27
+ const navigatorOnLine = (_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.onLine;
28
+ return typeof navigatorOnLine === "boolean" ? navigatorOnLine : true;
29
+ };
30
+ // Call `listener` whenever setOnlineStatus changes isOnline(). Returns the unsubscribe function.
31
+ export const subscribeToOnlineStatus = (listener) => {
32
+ onlineStatusListeners.add(listener);
33
+ return () => {
34
+ onlineStatusListeners.delete(listener);
35
+ };
36
+ };
37
+ //# sourceMappingURL=online-status.js.map
@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CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import assert from \"./assert\";\n\n// Whether the device has network access. Feeds read it to decide whether an expired community cache\n// may still be shown (offline) or should wait for the next community update (online).\nlet onlineStatus: boolean | undefined;\n\n// The feeds store listens here: a feed computed while online has no other event to recompute it\n// when the device turns out to be offline (an app that starts offline gets no community update).\nconst onlineStatusListeners = new Set<() => void>();\n\n/**\n * Set the device's online status, for runtimes without `navigator.onLine` such as React Native\n * (e.g. from NetInfo). `undefined` goes back to `navigator.onLine`. A change recomputes feeds.\n */\nexport const setOnlineStatus = (online: boolean | undefined) => {\n assert(\n online === undefined || typeof online === \"boolean\",\n `setOnlineStatus invalid online argument '${online}' not a boolean or undefined`,\n );\n const wasOnline = isOnline();\n onlineStatus = online;\n if (isOnline() !== wasOnline) {\n onlineStatusListeners.forEach((listener) => listener());\n }\n};\n\n// Without a signal (React Native has no navigator.onLine), assume online: reading \"unknown\" as\n// offline would build feeds from expired caches on every device that is in fact online.\nexport const isOnline = (): boolean => {\n if (onlineStatus !== undefined) {\n return onlineStatus;\n }\n const navigatorOnLine = globalThis.navigator?.onLine;\n return typeof navigatorOnLine === \"boolean\" ? navigatorOnLine : true;\n};\n\n// Call `listener` whenever setOnlineStatus changes isOnline(). Returns the unsubscribe function.\nexport const subscribeToOnlineStatus = (listener: () => void) => {\n onlineStatusListeners.add(listener);\n return () => {\n onlineStatusListeners.delete(listener);\n };\n};\n"]}
@@ -0,0 +1,24 @@
1
+ import type { Comment } from "../types.js";
2
+ type Signer = {
3
+ privateKey?: string;
4
+ publicKey?: string;
5
+ };
6
+ /** K for an author private key (32-byte ed25519 seed) and a community signing public key. */
7
+ export declare const derivePseudonymityAuthorTagKey: (authorPrivateKey: Uint8Array, communityPublicKey: Uint8Array) => Uint8Array;
8
+ /** The tag a community publishes for `cid` under K: 16 bytes, unpadded standard base64. */
9
+ export declare const getPseudonymityAuthorTag: (key: Uint8Array, cid: string) => string;
10
+ /**
11
+ * Whether the community that aliased `comment` tagged it as published by `signer`. Reads the tag
12
+ * and the community key from the same signed `raw.commentUpdate`, which must be the update of this
13
+ * comment's cid.
14
+ */
15
+ export declare const isPseudonymityAuthorTagOfSigner: (comment: Comment | undefined, signer: Signer | undefined) => boolean;
16
+ /**
17
+ * Whether `signer` published `comment` as far as its key can tell: the comment is signed by the
18
+ * signer, or, on a pseudonymous board where the community re-signed it with an alias, the
19
+ * community tagged it as the signer's. Neither signature is verified here, so the comment must come
20
+ * from pkc-js, which verifies both, or have passed validateComment.
21
+ */
22
+ export declare const isCommentBySigner: (comment: Comment | undefined, signer: Signer | undefined) => boolean;
23
+ export {};
24
+ //# sourceMappingURL=pseudonymity-author-tag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pseudonymity-author-tag.d.ts","sourceRoot":"","sources":["../../src/lib/pseudonymity-author-tag.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAYxC,KAAK,MAAM,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAc1D,6FAA6F;AAC7F,eAAO,MAAM,8BAA8B,GACzC,kBAAkB,UAAU,EAC5B,oBAAoB,UAAU,KAC7B,UAMF,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,wBAAwB,GAAI,KAAK,UAAU,EAAE,KAAK,MAAM,KAAG,MACe,CAAC;AA+BxF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,GAC1C,SAAS,OAAO,GAAG,SAAS,EAC5B,QAAQ,MAAM,GAAG,SAAS,KACzB,OAiBF,CAAC;AAoBF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,OAAO,GAAG,SAAS,EAC5B,QAAQ,MAAM,GAAG,SAAS,KACzB,OASF,CAAC"}
@@ -0,0 +1,119 @@
1
+ import { ed25519, x25519 } from "@noble/curves/ed25519.js";
2
+ import { hkdf } from "@noble/hashes/hkdf.js";
3
+ import { hmac } from "@noble/hashes/hmac.js";
4
+ import { sha256 } from "@noble/hashes/sha2.js";
5
+ import QuickLRU from "quick-lru";
6
+ import { fromString as uint8ArrayFromString } from "uint8arrays/from-string";
7
+ import { toString as uint8ArrayToString } from "uint8arrays/to-string";
8
+ // Own-post recognition on pseudonymous boards, as specified in pkc-js
9
+ // docs/protocol/pseudonymity-author-tag.md. A community that aliases a comment publishes
10
+ // commentUpdate.pseudonymityAuthorTag = base64(HMAC-SHA256(K, cid)[0..16]), where K comes from an
11
+ // X25519 exchange between the author's key and the key that signed the CommentUpdate. Any device
12
+ // holding the account key derives the same K, so it recognizes posts published from other devices.
13
+ // The label carries the derivation version; a new derivation ships under a new label.
14
+ const TAG_INFO = new TextEncoder().encode("pkc-pseudonymity-author-tag-v1");
15
+ const TAG_REGEX = /^[A-Za-z0-9+/]{22}$/;
16
+ const textEncoder = new TextEncoder();
17
+ const decodeKey = (key) => {
18
+ if (typeof key !== "string") {
19
+ return;
20
+ }
21
+ try {
22
+ const bytes = uint8ArrayFromString(key.replace(/=+$/, ""), "base64");
23
+ return bytes.length === 32 ? bytes : undefined;
24
+ }
25
+ catch (_a) {
26
+ return;
27
+ }
28
+ };
29
+ /** K for an author private key (32-byte ed25519 seed) and a community signing public key. */
30
+ export const derivePseudonymityAuthorTagKey = (authorPrivateKey, communityPublicKey) => {
31
+ const sharedSecret = x25519.getSharedSecret(ed25519.utils.toMontgomerySecret(authorPrivateKey), ed25519.utils.toMontgomery(communityPublicKey));
32
+ return hkdf(sha256, sharedSecret, new Uint8Array(0), TAG_INFO, 32);
33
+ };
34
+ /** The tag a community publishes for `cid` under K: 16 bytes, unpadded standard base64. */
35
+ export const getPseudonymityAuthorTag = (key, cid) => uint8ArrayToString(hmac(sha256, key, textEncoder.encode(cid)).slice(0, 16), "base64");
36
+ // K costs one X25519 exchange per account and community, so cache it per signer object (the
37
+ // private key never becomes a cache key) and per community key; checking a comment is then one
38
+ // HMAC. An undefined entry records a key pair that cannot derive, e.g. a malformed or small-order
39
+ // community key, which noble rejects.
40
+ const tagKeysBySigner = new WeakMap();
41
+ const getTagKey = (signer, communityPublicKey) => {
42
+ let tagKeys = tagKeysBySigner.get(signer);
43
+ if (!tagKeys) {
44
+ tagKeys = new QuickLRU({ maxSize: 1000 });
45
+ tagKeysBySigner.set(signer, tagKeys);
46
+ }
47
+ if (tagKeys.has(communityPublicKey)) {
48
+ return tagKeys.get(communityPublicKey);
49
+ }
50
+ let tagKey;
51
+ const authorPrivateKeyBytes = decodeKey(signer.privateKey);
52
+ const communityPublicKeyBytes = decodeKey(communityPublicKey);
53
+ if (authorPrivateKeyBytes && communityPublicKeyBytes) {
54
+ try {
55
+ tagKey = derivePseudonymityAuthorTagKey(authorPrivateKeyBytes, communityPublicKeyBytes);
56
+ }
57
+ catch (_a) {
58
+ tagKey = undefined;
59
+ }
60
+ }
61
+ tagKeys.set(communityPublicKey, tagKey);
62
+ return tagKey;
63
+ };
64
+ /**
65
+ * Whether the community that aliased `comment` tagged it as published by `signer`. Reads the tag
66
+ * and the community key from the same signed `raw.commentUpdate`, which must be the update of this
67
+ * comment's cid.
68
+ */
69
+ export const isPseudonymityAuthorTagOfSigner = (comment, signer) => {
70
+ var _a, _b;
71
+ const commentUpdate = (_a = comment === null || comment === void 0 ? void 0 : comment.raw) === null || _a === void 0 ? void 0 : _a.commentUpdate;
72
+ const tag = commentUpdate === null || commentUpdate === void 0 ? void 0 : commentUpdate.pseudonymityAuthorTag;
73
+ const communityPublicKey = (_b = commentUpdate === null || commentUpdate === void 0 ? void 0 : commentUpdate.signature) === null || _b === void 0 ? void 0 : _b.publicKey;
74
+ const cid = commentUpdate === null || commentUpdate === void 0 ? void 0 : commentUpdate.cid;
75
+ if (!signer ||
76
+ cid !== (comment === null || comment === void 0 ? void 0 : comment.cid) ||
77
+ typeof tag !== "string" ||
78
+ !TAG_REGEX.test(tag) ||
79
+ typeof communityPublicKey !== "string" ||
80
+ typeof cid !== "string") {
81
+ return false;
82
+ }
83
+ const tagKey = getTagKey(signer, communityPublicKey);
84
+ return Boolean(tagKey) && getPseudonymityAuthorTag(tagKey, cid) === tag;
85
+ };
86
+ // accounts imported from older backups can lack signer.publicKey, so derive it from the seed
87
+ const signerPublicKeys = new WeakMap();
88
+ const getSignerPublicKey = (signer) => {
89
+ if (typeof signer.publicKey === "string") {
90
+ return signer.publicKey;
91
+ }
92
+ if (signerPublicKeys.has(signer)) {
93
+ return signerPublicKeys.get(signer);
94
+ }
95
+ const privateKeyBytes = decodeKey(signer.privateKey);
96
+ const publicKey = privateKeyBytes
97
+ ? uint8ArrayToString(ed25519.getPublicKey(privateKeyBytes), "base64")
98
+ : undefined;
99
+ signerPublicKeys.set(signer, publicKey);
100
+ return publicKey;
101
+ };
102
+ /**
103
+ * Whether `signer` published `comment` as far as its key can tell: the comment is signed by the
104
+ * signer, or, on a pseudonymous board where the community re-signed it with an alias, the
105
+ * community tagged it as the signer's. Neither signature is verified here, so the comment must come
106
+ * from pkc-js, which verifies both, or have passed validateComment.
107
+ */
108
+ export const isCommentBySigner = (comment, signer) => {
109
+ var _a;
110
+ if (!comment || !signer) {
111
+ return false;
112
+ }
113
+ const signaturePublicKey = (_a = comment.signature) === null || _a === void 0 ? void 0 : _a.publicKey;
114
+ if (typeof signaturePublicKey === "string" && signaturePublicKey === getSignerPublicKey(signer)) {
115
+ return true;
116
+ }
117
+ return isPseudonymityAuthorTagOfSigner(comment, signer);
118
+ };
119
+ //# sourceMappingURL=pseudonymity-author-tag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pseudonymity-author-tag.js","sourceRoot":"","sources":["../../src/lib/pseudonymity-author-tag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,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,CAAC;IACD,IAAI,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACD,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,eAAe;QAC/B,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC;QACrE,CAAC,CAAC,SAAS,CAAC;IACd,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAA4B,EAC5B,MAA0B,EACjB,EAAE;;IACX,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,SAAS,0CAAE,SAAS,CAAC;IACxD,IAAI,OAAO,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChG,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,+BAA+B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC1D,CAAC,CAAC","sourcesContent":["import { ed25519, x25519 } from \"@noble/curves/ed25519.js\";\nimport { hkdf } from \"@noble/hashes/hkdf.js\";\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport QuickLRU from \"quick-lru\";\nimport { fromString as uint8ArrayFromString } from \"uint8arrays/from-string\";\nimport { toString as uint8ArrayToString } from \"uint8arrays/to-string\";\nimport type { Comment } from \"../types\";\n\n// Own-post recognition on pseudonymous boards, as specified in pkc-js\n// docs/protocol/pseudonymity-author-tag.md. A community that aliases a comment publishes\n// commentUpdate.pseudonymityAuthorTag = base64(HMAC-SHA256(K, cid)[0..16]), where K comes from an\n// X25519 exchange between the author's key and the key that signed the CommentUpdate. Any device\n// holding the account key derives the same K, so it recognizes posts published from other devices.\n// The label carries the derivation version; a new derivation ships under a new label.\nconst TAG_INFO = new TextEncoder().encode(\"pkc-pseudonymity-author-tag-v1\");\nconst TAG_REGEX = /^[A-Za-z0-9+/]{22}$/;\nconst textEncoder = new TextEncoder();\n\ntype Signer = { privateKey?: string; publicKey?: string };\n\nconst decodeKey = (key: unknown): Uint8Array | undefined => {\n if (typeof key !== \"string\") {\n return;\n }\n try {\n const bytes = uint8ArrayFromString(key.replace(/=+$/, \"\"), \"base64\");\n return bytes.length === 32 ? bytes : undefined;\n } catch {\n return;\n }\n};\n\n/** K for an author private key (32-byte ed25519 seed) and a community signing public key. */\nexport const derivePseudonymityAuthorTagKey = (\n authorPrivateKey: Uint8Array,\n communityPublicKey: Uint8Array,\n): Uint8Array => {\n const sharedSecret = x25519.getSharedSecret(\n ed25519.utils.toMontgomerySecret(authorPrivateKey),\n ed25519.utils.toMontgomery(communityPublicKey),\n );\n return hkdf(sha256, sharedSecret, new Uint8Array(0), TAG_INFO, 32);\n};\n\n/** The tag a community publishes for `cid` under K: 16 bytes, unpadded standard base64. */\nexport const getPseudonymityAuthorTag = (key: Uint8Array, cid: string): string =>\n uint8ArrayToString(hmac(sha256, key, textEncoder.encode(cid)).slice(0, 16), \"base64\");\n\n// K costs one X25519 exchange per account and community, so cache it per signer object (the\n// private key never becomes a cache key) and per community key; checking a comment is then one\n// HMAC. An undefined entry records a key pair that cannot derive, e.g. a malformed or small-order\n// community key, which noble rejects.\nconst tagKeysBySigner = new WeakMap<Signer, QuickLRU<string, Uint8Array | undefined>>();\n\nconst getTagKey = (signer: Signer, communityPublicKey: string) => {\n let tagKeys = tagKeysBySigner.get(signer);\n if (!tagKeys) {\n tagKeys = new QuickLRU({ maxSize: 1000 });\n tagKeysBySigner.set(signer, tagKeys);\n }\n if (tagKeys.has(communityPublicKey)) {\n return tagKeys.get(communityPublicKey);\n }\n let tagKey: Uint8Array | undefined;\n const authorPrivateKeyBytes = decodeKey(signer.privateKey);\n const communityPublicKeyBytes = decodeKey(communityPublicKey);\n if (authorPrivateKeyBytes && communityPublicKeyBytes) {\n try {\n tagKey = derivePseudonymityAuthorTagKey(authorPrivateKeyBytes, communityPublicKeyBytes);\n } catch {\n tagKey = undefined;\n }\n }\n tagKeys.set(communityPublicKey, tagKey);\n return tagKey;\n};\n\n/**\n * Whether the community that aliased `comment` tagged it as published by `signer`. Reads the tag\n * and the community key from the same signed `raw.commentUpdate`, which must be the update of this\n * comment's cid.\n */\nexport const isPseudonymityAuthorTagOfSigner = (\n comment: Comment | undefined,\n signer: Signer | undefined,\n): boolean => {\n const commentUpdate = comment?.raw?.commentUpdate;\n const tag = commentUpdate?.pseudonymityAuthorTag;\n const communityPublicKey = commentUpdate?.signature?.publicKey;\n const cid = commentUpdate?.cid;\n if (\n !signer ||\n cid !== comment?.cid ||\n typeof tag !== \"string\" ||\n !TAG_REGEX.test(tag) ||\n typeof communityPublicKey !== \"string\" ||\n typeof cid !== \"string\"\n ) {\n return false;\n }\n const tagKey = getTagKey(signer, communityPublicKey);\n return Boolean(tagKey) && getPseudonymityAuthorTag(tagKey!, cid) === tag;\n};\n\n// accounts imported from older backups can lack signer.publicKey, so derive it from the seed\nconst signerPublicKeys = new WeakMap<Signer, string | undefined>();\n\nconst getSignerPublicKey = (signer: Signer) => {\n if (typeof signer.publicKey === \"string\") {\n return signer.publicKey;\n }\n if (signerPublicKeys.has(signer)) {\n return signerPublicKeys.get(signer);\n }\n const privateKeyBytes = decodeKey(signer.privateKey);\n const publicKey = privateKeyBytes\n ? uint8ArrayToString(ed25519.getPublicKey(privateKeyBytes), \"base64\")\n : undefined;\n signerPublicKeys.set(signer, publicKey);\n return publicKey;\n};\n\n/**\n * Whether `signer` published `comment` as far as its key can tell: the comment is signed by the\n * signer, or, on a pseudonymous board where the community re-signed it with an alias, the\n * community tagged it as the signer's. Neither signature is verified here, so the comment must come\n * from pkc-js, which verifies both, or have passed validateComment.\n */\nexport const isCommentBySigner = (\n comment: Comment | undefined,\n signer: Signer | undefined,\n): boolean => {\n if (!comment || !signer) {\n return false;\n }\n const signaturePublicKey = comment.signature?.publicKey;\n if (typeof signaturePublicKey === \"string\" && signaturePublicKey === getSignerPublicKey(signer)) {\n return true;\n }\n return isPseudonymityAuthorTagOfSigner(comment, signer);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-actions.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/accounts-actions.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,OAAO,EAEP,qBAAqB,EAGrB,kBAAkB,EAClB,yBAAyB,EACzB,+BAA+B,EAC/B,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EAEf,cAAc,EAGf,MAAM,aAAa,CAAC;AAyYrB,sGAAsG;AACtG,eAAO,MAAM,yBAAyB,GACpC,kBAAkB,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EACvC,WAAW,MAAM,EACjB,OAAO,MAAM,EACb,SAAS,CAAC,eAAe,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,GAAG,KAAK,IAAI;;;;;;CAO/D,CAAC;AAoCF,eAAO,MAAM,0BAA0B,GAAI,mBAAmB,GAAG,EAAE,yBAAyB,GAAG,YAGtC,CAAC;AAE1D,eAAO,MAAM,yBAAyB,GAAI,mBAAmB,GAAG,QAK/D,CAAC;AAuCF,eAAO,MAAM,kCAAkC,GAC7C,wBAAwB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC3D,WAAW,MAAM,EACjB,mBAAmB,GAAG;;CAsCvB,CAAC;AAEF,eAAO,MAAM,uCAAuC,GAClD,wBAAwB,MAAM,CAAC,MAAM,EAAE,MAAM,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EF,eAAO,MAAM,UAAU,GAAU,KAAK,MAAM,EAAE,cAAc,MAAM,kBA6BjE,CAAC;AAyEF,eAAO,MAAM,WAAW,GAAU,YAAY,MAAM,EAAE,cAAc,MAAM,kBAEzE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,YAAY,MAAM,EAAE,cAAc,MAAM,kBAE3E,CAAC;AAoBF,eAAO,MAAM,cAAc,GACzB,uBAAuB,qBAAqB,EAC5C,cAAc,MAAM,4BA0mBrB,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,iCAAiC,MAAM,GAAG,MAAM,EAChD,cAAc,MAAM,kBAkCrB,CAAC;AA0CF,eAAO,MAAM,WAAW,GAAU,oBAAoB,kBAAkB,EAAE,cAAc,MAAM,kBA8N7F,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAU,YAAY,MAAM,EAAE,cAAc,MAAM,kBAiBzE,CAAC;AA4BF,eAAO,MAAM,kBAAkB,GAC7B,2BAA2B,yBAAyB,EACpD,cAAc,MAAM,kBAgJrB,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,iCAAiC,+BAA+B,EAChE,cAAc,MAAM,kBAgKrB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,kBAAkB,MAAM,EACxB,6BAA6B,2BAA2B,EACxD,cAAc,MAAM,kBAmKrB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,wBAAwB,sBAAsB,EAC9C,cAAc,MAAM,iBAmBrB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,kBAAkB,MAAM,EAAE,cAAc,MAAM,kBAsDnF,CAAC"}
@@ -25,7 +25,6 @@ import accountsDatabase from "./accounts-database.js";
25
25
  import accountGenerator from "./account-generator.js";
26
26
  import Logger from "@pkcprotocol/pkc-logger";
27
27
  import validator from "../../lib/validator.js";
28
- import chain from "../../lib/chain/index.js";
29
28
  import assert from "../../lib/assert.js";
30
29
  const log = Logger("bitsocial-react-hooks:accounts:stores");
31
30
  import * as accountsActionsInternal from "./accounts-actions-internal.js";
@@ -633,7 +632,6 @@ export const setActiveAccount = (accountName) => __awaiter(void 0, void 0, void
633
632
  accountsStore.setState({ activeAccountId: accountId });
634
633
  });
635
634
  export const setAccount = (account) => __awaiter(void 0, void 0, void 0, function* () {
636
- var _a;
637
635
  const { accounts } = accountsStore.getState();
638
636
  validator.validateAccountsActionsSetAccountArguments(account);
639
637
  assert(accounts === null || accounts === void 0 ? void 0 : accounts[account.id], `cannot set account with account.id '${account.id}' id does not exist in database`);
@@ -643,14 +641,7 @@ export const setAccount = (account) => __awaiter(void 0, void 0, void 0, functio
643
641
  if (account.author.address !== accounts[account.id].author.address) {
644
642
  const communities = getAccountCommunities(account, communitiesStore.getState().communities);
645
643
  account = Object.assign(Object.assign({}, account), { communities });
646
- // wallet.signature changes if author.address changes
647
- if ((_a = account.author.wallets) === null || _a === void 0 ? void 0 : _a.eth) {
648
- const pkcSignerWalletWithNewAuthorAddress = yield chain.getEthWalletFromPkcPrivateKey(account.signer.privateKey, account.author.address);
649
- // wallet is using pkc signer, redo signature with new author.address
650
- if (account.author.wallets.eth.address === (pkcSignerWalletWithNewAuthorAddress === null || pkcSignerWalletWithNewAuthorAddress === void 0 ? void 0 : pkcSignerWalletWithNewAuthorAddress.address)) {
651
- account.author.wallets = Object.assign(Object.assign({}, account.author.wallets), { eth: pkcSignerWalletWithNewAuthorAddress });
652
- }
653
- }
644
+ // wallet proofs bind the signer's key address (BSIP-22), not author.address, so they stay valid
654
645
  }
655
646
  // use this function to serialize and update all databases
656
647
  yield accountsDatabase.addAccount(account);