@pkcprotocol/pkc-js 0.0.13 → 0.0.15
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/README.md +60 -78
- package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +6 -0
- package/dist/browser/clients/rpc-client/schema.d.ts +7 -1
- package/dist/browser/clients/rpc-client/schema.js +11 -5
- package/dist/browser/clients/rpc-client/schema.js.map +1 -1
- package/dist/browser/errors.d.ts +1 -1
- package/dist/browser/errors.js +1 -1
- package/dist/browser/errors.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/pkc/pkc.js +19 -0
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/publications/comment/comment-client-manager.js +2 -1
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.js +4 -3
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/publications/comment/schema.d.ts +2 -2
- package/dist/browser/publications/comment/schema.js +4 -2
- package/dist/browser/publications/comment/schema.js.map +1 -1
- package/dist/browser/publications/comment-edit/schema.d.ts +59 -1
- package/dist/browser/publications/comment-edit/schema.js +2 -1
- package/dist/browser/publications/comment-edit/schema.js.map +1 -1
- package/dist/browser/publications/comment-moderation/schema.d.ts +74 -1
- package/dist/browser/publications/comment-moderation/schema.js +2 -1
- package/dist/browser/publications/comment-moderation/schema.js.map +1 -1
- package/dist/browser/publications/community-edit/schema.d.ts +158 -1
- package/dist/browser/publications/community-edit/schema.js +2 -1
- package/dist/browser/publications/community-edit/schema.js.map +1 -1
- package/dist/browser/publications/vote/schema.d.ts +49 -1
- package/dist/browser/publications/vote/schema.js +2 -1
- package/dist/browser/publications/vote/schema.js.map +1 -1
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js +1 -1
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js.map +1 -1
- package/dist/browser/runtime/node/community/db-handler.js +10 -8
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.d.ts +5 -2
- package/dist/browser/runtime/node/community/local-community.js +39 -15
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/schema/schema-util.d.ts +6 -6
- package/dist/browser/schema/schema-util.js +11 -11
- package/dist/browser/schema/schema-util.js.map +1 -1
- package/dist/browser/schema/schema.d.ts +7 -1
- package/dist/browser/schema/schema.js +6 -1
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/signer/signatures.d.ts +2 -1
- package/dist/browser/signer/signatures.js +9 -8
- package/dist/browser/signer/signatures.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +3 -1
- package/dist/browser/test/test-util.js.map +1 -1
- package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +6 -0
- package/dist/node/clients/rpc-client/schema.d.ts +7 -1
- package/dist/node/clients/rpc-client/schema.js +11 -5
- package/dist/node/clients/rpc-client/schema.js.map +1 -1
- package/dist/node/errors.d.ts +1 -1
- package/dist/node/errors.js +1 -1
- package/dist/node/errors.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/pkc/pkc.js +19 -0
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/publications/comment/comment-client-manager.js +2 -1
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.js +4 -3
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/publications/comment/schema.d.ts +2 -2
- package/dist/node/publications/comment/schema.js +4 -2
- package/dist/node/publications/comment/schema.js.map +1 -1
- package/dist/node/publications/comment-edit/schema.d.ts +59 -1
- package/dist/node/publications/comment-edit/schema.js +2 -1
- package/dist/node/publications/comment-edit/schema.js.map +1 -1
- package/dist/node/publications/comment-moderation/schema.d.ts +74 -1
- package/dist/node/publications/comment-moderation/schema.js +2 -1
- package/dist/node/publications/comment-moderation/schema.js.map +1 -1
- package/dist/node/publications/community-edit/schema.d.ts +158 -1
- package/dist/node/publications/community-edit/schema.js +2 -1
- package/dist/node/publications/community-edit/schema.js.map +1 -1
- package/dist/node/publications/vote/schema.d.ts +49 -1
- package/dist/node/publications/vote/schema.js +2 -1
- package/dist/node/publications/vote/schema.js.map +1 -1
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js +1 -1
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js.map +1 -1
- package/dist/node/runtime/node/community/db-handler.js +10 -8
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.d.ts +5 -2
- package/dist/node/runtime/node/community/local-community.js +39 -15
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/schema/schema-util.d.ts +6 -6
- package/dist/node/schema/schema-util.js +11 -11
- package/dist/node/schema/schema-util.js.map +1 -1
- package/dist/node/schema/schema.d.ts +7 -1
- package/dist/node/schema/schema.js +6 -1
- package/dist/node/schema/schema.js.map +1 -1
- package/dist/node/signer/signatures.d.ts +2 -1
- package/dist/node/signer/signatures.js +9 -8
- package/dist/node/signer/signatures.js.map +1 -1
- package/dist/node/test/test-util.d.ts +3 -1
- package/dist/node/test/test-util.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,9 @@ Note: IPFS files are immutable, fetched by their CID, which is a hash of their c
|
|
|
21
21
|
Address: string // a PKC author, community or multisub "address" can be a crypto domain like memes.bso, an IPNS name, an ethereum address, etc. How to resolve ENS names https://github.com/pkcprotocol/pkc-js/blob/master/docs/ens.md
|
|
22
22
|
Publication {
|
|
23
23
|
author: Author
|
|
24
|
-
|
|
24
|
+
communityPublicKey: string // IPNS public key of the community this publication is directed to
|
|
25
|
+
communityName?: string // optional crypto domain name of the community (e.g. 'memes.bso')
|
|
26
|
+
// note: communityAddress is available as a convenience instance property at runtime, but is not part of the wire format
|
|
25
27
|
timestamp: number // number in seconds
|
|
26
28
|
signature: Signature // sign immutable fields like author, title, content, timestamp to prevent tampering
|
|
27
29
|
protocolVersion: '1.0.0' // semantic version of the protocol https://semver.org/
|
|
@@ -81,13 +83,13 @@ CommentModeration extends Publication {
|
|
|
81
83
|
CommunityEdit extends Publication {
|
|
82
84
|
communityEdit: CreateCommunityOptions
|
|
83
85
|
}
|
|
84
|
-
MultisubEdit extends CreateMultisubOptions, Publication {}
|
|
86
|
+
MultisubEdit extends CreateMultisubOptions, Publication {} // not yet implemented
|
|
85
87
|
CommentUpdate /* (IPFS file) */ {
|
|
86
88
|
cid: string // cid of the comment, need it in signature to prevent attack
|
|
87
89
|
edit?: AuthorCommentEdit // most recent edit by comment author, commentUpdate.edit.content, commentUpdate.edit.deleted, commentUpdate.edit.flairs override Comment instance props. Validate commentUpdate.edit.signature
|
|
88
90
|
upvoteCount: number
|
|
89
91
|
downvoteCount: number
|
|
90
|
-
replies?: Pages // only preload page 1 sorted by '
|
|
92
|
+
replies?: Pages // only preload page 1 sorted by 'best', might preload more later, only provide sorting for posts (not comments) that have 100+ child comments
|
|
91
93
|
replyCount: number
|
|
92
94
|
childCount?: number // the total of direct children of the comment, does not include indirect children
|
|
93
95
|
number?: number // sequential comment number assigned by the community
|
|
@@ -151,13 +153,13 @@ Signature {
|
|
|
151
153
|
}
|
|
152
154
|
Signer {
|
|
153
155
|
privateKey?: string // 32 bytes base64 string
|
|
154
|
-
type: 'ed25519'
|
|
156
|
+
type: 'ed25519' // eip191 is only used for wallet/NFT signatures, not for Signer instances
|
|
155
157
|
publicKey?: string // 32 bytes base64 string
|
|
156
158
|
address: string // public key hash, not needed for signing
|
|
157
159
|
ipfsKey?: IpfsKey // a Key object used for importing into IpfsHttpClient https://docs.ipfs.io/reference/cli/#ipfs-key-import
|
|
158
160
|
}
|
|
159
|
-
Community /* (IPNS record
|
|
160
|
-
address: string //
|
|
161
|
+
Community /* (IPNS record, identified by community's public key) */ {
|
|
162
|
+
address: string // instance-only convenience property, not part of the IPNS record. Validate community address in signature to prevent a crypto domain resolving to an impersonated community
|
|
161
163
|
title?: string
|
|
162
164
|
description?: string
|
|
163
165
|
roles?: {[authorAddress: string]: CommunityRole} // each author address can be mapped to 1 CommunityRole
|
|
@@ -237,7 +239,7 @@ Flair {
|
|
|
237
239
|
}
|
|
238
240
|
Pages {
|
|
239
241
|
pages: {[key: PostsSortType | RepliesSortType]: Page} // e.g. community.posts.pages.hot.comments[0].cid = '12D3KooW...'
|
|
240
|
-
pageCids: {[key: PostsSortType | RepliesSortType
|
|
242
|
+
pageCids: {[key: PostsSortType | RepliesSortType]: pageCid} // e.g. community.posts.pageCids.topAll = '12D3KooW...'
|
|
241
243
|
}
|
|
242
244
|
Page {
|
|
243
245
|
nextCid: string // get next page (sorted by the same sort type)
|
|
@@ -251,9 +253,8 @@ PageIpfsComment {
|
|
|
251
253
|
comment: Comment
|
|
252
254
|
commentUpdate: CommentUpdate
|
|
253
255
|
}
|
|
254
|
-
PostsSortType: 'hot' | 'new' | 'active' | 'topHour' | 'topDay' | 'topWeek' | 'topMonth' | 'topYear' | 'topAll'
|
|
255
|
-
RepliesSortType: '
|
|
256
|
-
ModSortType: 'reports' | 'spam' | 'modqueue' | 'unmoderated' | 'edited'
|
|
256
|
+
PostsSortType: 'hot' | 'new' | 'active' | 'topHour' | 'topDay' | 'topWeek' | 'topMonth' | 'topYear' | 'topAll'
|
|
257
|
+
RepliesSortType: 'best' | 'new' | 'old' | 'newFlat' | 'oldFlat'
|
|
257
258
|
CommunityStats {
|
|
258
259
|
hourActiveUserCount: number
|
|
259
260
|
dayActiveUserCount: number
|
|
@@ -278,7 +279,7 @@ ChallengeType {
|
|
|
278
279
|
type: 'image/png' | 'text/plain' | 'chain/<chainTicker>'
|
|
279
280
|
//...other properties for more complex types later, e.g. an array of whitelisted addresses, a token address, etc,
|
|
280
281
|
}
|
|
281
|
-
Multisub /* (IPNS record Multisub.address) */ {
|
|
282
|
+
Multisub /* (IPNS record Multisub.address) (not yet implemented) */ {
|
|
282
283
|
title?: string
|
|
283
284
|
description?: string
|
|
284
285
|
communities: MultisubCommunity[]
|
|
@@ -286,7 +287,7 @@ Multisub /* (IPNS record Multisub.address) */ {
|
|
|
286
287
|
updatedAt: number
|
|
287
288
|
signature: Signature // signature of the Multisub update by the multisub owner to protect against malicious gateway
|
|
288
289
|
}
|
|
289
|
-
MultisubCommunity { // this metadata is set by the owner of the Multisub, not the owner of the community
|
|
290
|
+
MultisubCommunity { // (not yet implemented) this metadata is set by the owner of the Multisub, not the owner of the community
|
|
290
291
|
address: Address
|
|
291
292
|
title?: string
|
|
292
293
|
description?: string
|
|
@@ -295,7 +296,7 @@ MultisubCommunity { // this metadata is set by the owner of the Multisub, not th
|
|
|
295
296
|
features?: string[] // client can detect user's SFW setting and hide/show community based on it
|
|
296
297
|
tags?: string[] // arbitrary keywords used for search
|
|
297
298
|
}
|
|
298
|
-
PKCDefaults { // fetched once when app first load, a dictionary of default settings
|
|
299
|
+
PKCDefaults { // fetched once when app first load, a dictionary of default settings (not yet implemented)
|
|
299
300
|
multisubAddresses: {[multisubName: string]: Address}
|
|
300
301
|
// PKC has 3 default multisubs
|
|
301
302
|
multisubAddresses.all: Address // the default communities to show at url pkc.bso/p/all
|
|
@@ -384,10 +385,10 @@ PubsubSignature {
|
|
|
384
385
|
|
|
385
386
|
- [PKC API](#pkc-api)
|
|
386
387
|
- [`PKC(pkcOptions)`](#pkcpkcoptions)
|
|
387
|
-
- [`pkc.getMultisub(multisubAddress)`](#pkcgetmultisubmultisubaddress)
|
|
388
|
+
- [`pkc.getMultisub(multisubAddress)`](#pkcgetmultisubmultisubaddress) *(not yet implemented)*
|
|
388
389
|
- [`pkc.getCommunity({address})`](#pkcgetcommunityaddress)
|
|
389
390
|
- [`pkc.getComment({cid})`](#pkcgetcommentcid)
|
|
390
|
-
- [`pkc.createMultisub(createMultisubOptions)`](#pkccreatemultisubcreatemultisuboptions)
|
|
391
|
+
- [`pkc.createMultisub(createMultisubOptions)`](#pkccreatemultisubcreatemultisuboptions) *(not yet implemented)*
|
|
391
392
|
- [`pkc.createCommunity(createCommunityOptions)`](#pkccreatecommunitycreatecommunityoptions)
|
|
392
393
|
- [`pkc.createCommunityEdit(createCommunityEditOptions)`](#pkccreatecommunityeditcreatecommunityeditoptions)
|
|
393
394
|
- [`pkc.createComment(createCommentOptions)`](#pkccreatecommentcreatecommentoptions)
|
|
@@ -397,7 +398,7 @@ PubsubSignature {
|
|
|
397
398
|
- [`pkc.createSigner(createSignerOptions)`](#pkccreatesignercreatesigneroptions)
|
|
398
399
|
- `pkc.communities`
|
|
399
400
|
- `pkc.clients`
|
|
400
|
-
- [`pkc.getDefaults()`](#pkcgetdefaults)
|
|
401
|
+
- [`pkc.getDefaults()`](#pkcgetdefaults) *(not yet implemented)*
|
|
401
402
|
- `pkc.fetchCid({cid})`
|
|
402
403
|
- `pkc.resolveAuthorAddress({address})`
|
|
403
404
|
- `PKC.getShortAddress({address})`
|
|
@@ -536,7 +537,7 @@ An object which may have the following keys:
|
|
|
536
537
|
| pubsubKuboRpcClientsOptions | `(string \| kuboRpcClientsOptions)[]` or `undefined` | `['https://pubsubprovider.xyz/api/v0']` | Optional URLs or [kuboRpcClientsOptions](https://www.npmjs.com/package/kubo-rpc-client#options) used for pubsub publishing when `kuboRpcClientsOptions` isn't available, like in the browser |
|
|
537
538
|
| pkcRpcClientsOptions | `string[]` or `undefined` | `undefined` | Optional websocket URLs of PKC RPC servers, required to run a community from a browser/electron/webview |
|
|
538
539
|
| dataPath | `string` or `undefined` | .pkc folder in the current working directory | (Node only) Optional folder path to create/resume the user and community databases |
|
|
539
|
-
|
|
|
540
|
+
| resolveAuthorNames | `boolean` or `undefined` | `true` | Optionally disable resolving crypto domain author names, which can be done lazily later to save time |
|
|
540
541
|
|
|
541
542
|
#### Returns
|
|
542
543
|
|
|
@@ -557,7 +558,7 @@ const pkc = await PKC(options) // should be independent instance, not singleton
|
|
|
557
558
|
pkc.on('error', console.log)
|
|
558
559
|
```
|
|
559
560
|
|
|
560
|
-
### `pkc.getMultisub(multisubAddress)`
|
|
561
|
+
### `pkc.getMultisub(multisubAddress)` *(not yet implemented)*
|
|
561
562
|
|
|
562
563
|
> Get a multisub by its `Address`. A multisub is a list of communities curated by the creator of the multisub. E.g. `'pkc.bso/#/m/john.bso'` would display a feed of the multisub communities curated by `'john.bso'` (multisub `Address` `'john.bso'`).
|
|
563
564
|
|
|
@@ -655,7 +656,7 @@ Prints:
|
|
|
655
656
|
*/
|
|
656
657
|
```
|
|
657
658
|
|
|
658
|
-
### `pkc.createMultisub(createMultisubOptions)`
|
|
659
|
+
### `pkc.createMultisub(createMultisubOptions)` *(not yet implemented)*
|
|
659
660
|
|
|
660
661
|
> Create a multisub instance. A multisub is a list of communities curated by the creator of the multisub. E.g. `'pkc.bso/#/m/john.bso'` would display a feed of the multisub communities curated by `'john.bso'` (multisub `Address` `'john.bso'`).
|
|
661
662
|
|
|
@@ -809,11 +810,13 @@ An object which may have the following keys:
|
|
|
809
810
|
|
|
810
811
|
| Name | Type | Description |
|
|
811
812
|
| ---- | ---- | ----------- |
|
|
812
|
-
|
|
|
813
|
+
| communityAddress | `string` or `undefined` | `Address` of the community (derived from `communityName` or `communityPublicKey` if not provided). Providing both `communityPublicKey` and `communityName` is recommended for speed |
|
|
814
|
+
| communityPublicKey | `string` or `undefined` | IPNS public key of the community (can identify the community instead of `communityAddress`) |
|
|
815
|
+
| communityName | `string` or `undefined` | Domain name of the community, e.g. `'memes.bso'` (can identify the community instead of `communityAddress`) |
|
|
813
816
|
| timestamp | `number` or `undefined` | Time of publishing in seconds, `Math.round(Date.now() / 1000)` if undefined |
|
|
814
817
|
| author | `Author` | `author.address` of the community edit must have `community.roles` `'admin'` |
|
|
815
818
|
| signer | `Signer` | Signer of the community edit |
|
|
816
|
-
|
|
|
819
|
+
| communityEdit | `CommunityEditOptions` | The community edit options, see [`CommunityEditOptions`](#communityeditoptions) |
|
|
817
820
|
|
|
818
821
|
#### Returns
|
|
819
822
|
|
|
@@ -824,11 +827,11 @@ An object which may have the following keys:
|
|
|
824
827
|
#### Example
|
|
825
828
|
|
|
826
829
|
```js
|
|
827
|
-
const createCommunityEditOptions = {
|
|
830
|
+
const createCommunityEditOptions = {communityName: 'news.bso', communityEdit: {title: 'New title'}}
|
|
828
831
|
const communityEdit = await pkc.createCommunityEdit(createCommunityEditOptions)
|
|
829
|
-
communityEdit.on('challenge', async (challengeMessage
|
|
832
|
+
communityEdit.on('challenge', async (challengeMessage) => {
|
|
830
833
|
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
831
|
-
|
|
834
|
+
communityEdit.publishChallengeAnswers(challengeAnswers)
|
|
832
835
|
})
|
|
833
836
|
communityEdit.on('challengeverification', console.log)
|
|
834
837
|
await communityEdit.publish()
|
|
@@ -850,7 +853,9 @@ An object which may have the following keys:
|
|
|
850
853
|
|
|
851
854
|
| Name | Type | Description |
|
|
852
855
|
| ---- | ---- | ----------- |
|
|
853
|
-
| communityAddress | `string` | `Address` of the community |
|
|
856
|
+
| communityAddress | `string` or `undefined` | `Address` of the community (derived from `communityName` or `communityPublicKey` if not provided). Providing both `communityPublicKey` and `communityName` is recommended for speed |
|
|
857
|
+
| communityPublicKey | `string` or `undefined` | IPNS public key of the community (can identify the community instead of `communityAddress`) |
|
|
858
|
+
| communityName | `string` or `undefined` | Domain name of the community, e.g. `'memes.bso'` (can identify the community instead of `communityAddress`) |
|
|
854
859
|
| timestamp | `number` or `undefined` | Time of publishing in seconds, `Math.round(Date.now() / 1000)` if undefined |
|
|
855
860
|
| author | `Author` | Author of the comment |
|
|
856
861
|
| signer | `Signer` | Signer of the comment |
|
|
@@ -898,7 +903,7 @@ const comment = await pkc.createComment({
|
|
|
898
903
|
upvoteCount: 100,
|
|
899
904
|
replies: {
|
|
900
905
|
pages: {
|
|
901
|
-
|
|
906
|
+
best: {
|
|
902
907
|
nextCid: 'Qm...',
|
|
903
908
|
comments: [{content: 'My first reply', ...reply}]
|
|
904
909
|
}
|
|
@@ -909,7 +914,7 @@ const comment = await pkc.createComment({
|
|
|
909
914
|
console.log(comment.content) // prints 'My first post'
|
|
910
915
|
console.log(comment.locked) // prints true
|
|
911
916
|
console.log(comment.upvoteCount) // prints 100
|
|
912
|
-
console.log(comment.replies.pages.
|
|
917
|
+
console.log(comment.replies.pages.best.comments[0].content) // prints 'My first reply'
|
|
913
918
|
```
|
|
914
919
|
|
|
915
920
|
### `pkc.createCommentEdit(createCommentEditOptions)`
|
|
@@ -928,9 +933,11 @@ An object which may have the following keys:
|
|
|
928
933
|
|
|
929
934
|
| Name | Type | Description |
|
|
930
935
|
| ---- | ---- | ----------- |
|
|
931
|
-
| communityAddress | `string` | `Address` of the community |
|
|
936
|
+
| communityAddress | `string` or `undefined` | `Address` of the community (derived from `communityName` or `communityPublicKey` if not provided). Providing both `communityPublicKey` and `communityName` is recommended for speed |
|
|
937
|
+
| communityPublicKey | `string` or `undefined` | IPNS public key of the community (can identify the community instead of `communityAddress`) |
|
|
938
|
+
| communityName | `string` or `undefined` | Domain name of the community, e.g. `'memes.bso'` (can identify the community instead of `communityAddress`) |
|
|
932
939
|
| commentCid | `string` | The comment CID to be edited (don't use 'cid' because eventually CommentEdit.cid will exist) |
|
|
933
|
-
| timestamp | `number` or `undefined` | Time of publishing in
|
|
940
|
+
| timestamp | `number` or `undefined` | Time of publishing in seconds, `Math.round(Date.now() / 1000)` if undefined |
|
|
934
941
|
| author | `Author` | Author of the `CommentEdit` publication, must be original author. Not used to edit the `comment.author` property, only to authenticate the `CommentEdit` publication |
|
|
935
942
|
| signer | `Signer` | Signer of the edit, must be original author |
|
|
936
943
|
| content | `string` or `undefined` | Edited content of the comment |
|
|
@@ -959,9 +966,9 @@ An object which may have the following keys:
|
|
|
959
966
|
|
|
960
967
|
```js
|
|
961
968
|
const commentEdit = await pkc.createCommentEdit(createCommentEditOptions)
|
|
962
|
-
commentEdit.on('challenge', async (challengeMessage
|
|
969
|
+
commentEdit.on('challenge', async (challengeMessage) => {
|
|
963
970
|
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
964
|
-
|
|
971
|
+
commentEdit.publishChallengeAnswers(challengeAnswers)
|
|
965
972
|
})
|
|
966
973
|
commentEdit.on('challengeverification', console.log)
|
|
967
974
|
await commentEdit.publish()
|
|
@@ -983,9 +990,11 @@ An object which may have the following keys:
|
|
|
983
990
|
|
|
984
991
|
| Name | Type | Description |
|
|
985
992
|
| ---- | ---- | ----------- |
|
|
986
|
-
| communityAddress | `string` | `Address` of the community |
|
|
993
|
+
| communityAddress | `string` or `undefined` | `Address` of the community (derived from `communityName` or `communityPublicKey` if not provided). Providing both `communityPublicKey` and `communityName` is recommended for speed |
|
|
994
|
+
| communityPublicKey | `string` or `undefined` | IPNS public key of the community (can identify the community instead of `communityAddress`) |
|
|
995
|
+
| communityName | `string` or `undefined` | Domain name of the community, e.g. `'memes.bso'` (can identify the community instead of `communityAddress`) |
|
|
987
996
|
| commentCid | `string` | The comment CID to be edited (don't use 'cid' because eventually CommentEdit.cid will exist) |
|
|
988
|
-
| timestamp | `number` or `undefined` | Time of publishing in
|
|
997
|
+
| timestamp | `number` or `undefined` | Time of publishing in seconds, `Math.round(Date.now() / 1000)` if undefined |
|
|
989
998
|
| author | `Author` | Author of the `CommentModeration` publication, must be moderator. Not used to edit the `comment.author` property, only to authenticate the `CommentModeration` publication |
|
|
990
999
|
| signer | `Signer` | Signer of the edit, must be moderator |
|
|
991
1000
|
| commentModeration | `CommentModerationOptions` | The comment moderation options |
|
|
@@ -1028,9 +1037,9 @@ An object which may have the following keys:
|
|
|
1028
1037
|
|
|
1029
1038
|
```js
|
|
1030
1039
|
const commentModeration = await pkc.createCommentModeration(createCommentModerationOptions)
|
|
1031
|
-
commentModeration.on('challenge', async (challengeMessage
|
|
1040
|
+
commentModeration.on('challenge', async (challengeMessage) => {
|
|
1032
1041
|
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
1033
|
-
|
|
1042
|
+
commentModeration.publishChallengeAnswers(challengeAnswers)
|
|
1034
1043
|
})
|
|
1035
1044
|
commentModeration.on('challengeverification', console.log)
|
|
1036
1045
|
await commentModeration.publish()
|
|
@@ -1052,9 +1061,11 @@ An object which may have the following keys:
|
|
|
1052
1061
|
|
|
1053
1062
|
| Name | Type | Description |
|
|
1054
1063
|
| ---- | ---- | ----------- |
|
|
1055
|
-
| communityAddress | `string` | `Address` of the community |
|
|
1064
|
+
| communityAddress | `string` or `undefined` | `Address` of the community (derived from `communityName` or `communityPublicKey` if not provided). Providing both `communityPublicKey` and `communityName` is recommended for speed |
|
|
1065
|
+
| communityPublicKey | `string` or `undefined` | IPNS public key of the community (can identify the community instead of `communityAddress`) |
|
|
1066
|
+
| communityName | `string` or `undefined` | Domain name of the community, e.g. `'memes.bso'` (can identify the community instead of `communityAddress`) |
|
|
1056
1067
|
| commentCid | `string` | The comment or post to vote on |
|
|
1057
|
-
| timestamp | `number` or `undefined` | Time of publishing in
|
|
1068
|
+
| timestamp | `number` or `undefined` | Time of publishing in seconds, `Math.round(Date.now() / 1000)` if undefined |
|
|
1058
1069
|
| author | `Author` | Author of the comment, will be needed for voting with NFTs or tokens |
|
|
1059
1070
|
| vote | `1` or `0` or `-1` | 0 is for resetting a vote |
|
|
1060
1071
|
| signer | `Signer` | Signer of the vote |
|
|
@@ -1079,9 +1090,9 @@ An object which may have the following keys:
|
|
|
1079
1090
|
|
|
1080
1091
|
```js
|
|
1081
1092
|
const vote = await pkc.createVote(createVoteOptions)
|
|
1082
|
-
vote.on('challenge', async (challengeMessage
|
|
1093
|
+
vote.on('challenge', async (challengeMessage) => {
|
|
1083
1094
|
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
1084
|
-
|
|
1095
|
+
vote.publishChallengeAnswers(challengeAnswers)
|
|
1085
1096
|
})
|
|
1086
1097
|
vote.on('challengeverification', console.log)
|
|
1087
1098
|
await vote.publish()
|
|
@@ -1119,28 +1130,21 @@ const newRandomSigner = await pkc.createSigner()
|
|
|
1119
1130
|
const signerFromPrivateKey = await pkc.createSigner({privateKey: 'AbCd...', type: 'ed25519'})
|
|
1120
1131
|
```
|
|
1121
1132
|
|
|
1122
|
-
### `pkc.
|
|
1133
|
+
### `pkc.communities`
|
|
1123
1134
|
|
|
1124
|
-
>
|
|
1125
|
-
|
|
1126
|
-
#### Returns
|
|
1127
|
-
|
|
1128
|
-
| Type | Description |
|
|
1129
|
-
| -------- | -------- |
|
|
1130
|
-
| `Promise<Address[]>` | An array of `Address` strings |
|
|
1135
|
+
> A `string[]` of community addresses stored locally. Updates when communities are created or deleted. Listen for changes with the `communitieschange` event.
|
|
1131
1136
|
|
|
1132
1137
|
#### Example
|
|
1133
1138
|
|
|
1134
1139
|
```js
|
|
1135
1140
|
// start all the communities you own and have stored locally
|
|
1136
|
-
const
|
|
1137
|
-
for (const address of communityAddresses) {
|
|
1141
|
+
for (const address of pkc.communities) {
|
|
1138
1142
|
const community = await pkc.createCommunity({address})
|
|
1139
1143
|
await community.start()
|
|
1140
1144
|
}
|
|
1141
1145
|
```
|
|
1142
1146
|
|
|
1143
|
-
### `pkc.getDefaults()`
|
|
1147
|
+
### `pkc.getDefaults()` *(not yet implemented)*
|
|
1144
1148
|
|
|
1145
1149
|
> Get the default global PKC settings, e.g. the default multisubs like p/all, p/dao, etc.
|
|
1146
1150
|
|
|
@@ -1329,28 +1333,6 @@ Object is of the form:
|
|
|
1329
1333
|
{ // ...TODO }
|
|
1330
1334
|
```
|
|
1331
1335
|
|
|
1332
|
-
### `challengerequest`
|
|
1333
|
-
|
|
1334
|
-
> When the user publishes a comment, he makes a `'challengerequest'` to the pubsub, the community owner will send back a `challenge`, eg. a captcha that the user must complete.
|
|
1335
|
-
|
|
1336
|
-
#### Emits
|
|
1337
|
-
|
|
1338
|
-
| Type | Description |
|
|
1339
|
-
| -------- | -------- |
|
|
1340
|
-
| `ChallengeRequestMessage` | The comment of the user and the challenge request |
|
|
1341
|
-
|
|
1342
|
-
Object is of the form:
|
|
1343
|
-
|
|
1344
|
-
```js
|
|
1345
|
-
{ // ...TODO }
|
|
1346
|
-
```
|
|
1347
|
-
|
|
1348
|
-
#### Example
|
|
1349
|
-
|
|
1350
|
-
```js
|
|
1351
|
-
{ // ...TODO }
|
|
1352
|
-
```
|
|
1353
|
-
|
|
1354
1336
|
### `statechange`
|
|
1355
1337
|
|
|
1356
1338
|
> `Community.state` property changed.
|
|
@@ -1505,9 +1487,9 @@ Object is of the form:
|
|
|
1505
1487
|
|
|
1506
1488
|
```js
|
|
1507
1489
|
const comment = await pkc.createComment(commentObject)
|
|
1508
|
-
comment.on('challenge', async (challengeMessage
|
|
1490
|
+
comment.on('challenge', async (challengeMessage) => {
|
|
1509
1491
|
const challengeAnswers = await askUserForChallengeAnswers(challengeMessage.challenges)
|
|
1510
|
-
|
|
1492
|
+
comment.publishChallengeAnswers(challengeAnswers)
|
|
1511
1493
|
})
|
|
1512
1494
|
comment.on('challengeverification', console.log)
|
|
1513
1495
|
await comment.publish()
|
|
@@ -1522,7 +1504,7 @@ await comment.publish()
|
|
|
1522
1504
|
| Type | Description |
|
|
1523
1505
|
| -------- | -------- |
|
|
1524
1506
|
| `ChallengeVerificationMessage` | The challenge verification result |
|
|
1525
|
-
| `Comment` | The `Comment` instance,
|
|
1507
|
+
| `Comment` or `undefined` | The `Comment` instance if the publication is a comment and the verification contains comment data, otherwise `undefined` |
|
|
1526
1508
|
|
|
1527
1509
|
Object is of the form:
|
|
1528
1510
|
|
|
@@ -1577,7 +1559,7 @@ The pages API for scrolling pages of a community or replies to a post/comment. `
|
|
|
1577
1559
|
|
|
1578
1560
|
### `pages.getPage({cid})`
|
|
1579
1561
|
|
|
1580
|
-
> Get a `Page` instance using an IPFS CID from `Pages.pageCids[sortType]`, e.g. `Community.posts.pageCids.hot` or `Comment.replies.pageCids.
|
|
1562
|
+
> Get a `Page` instance using an IPFS CID from `Pages.pageCids[sortType]`, e.g. `Community.posts.pageCids.hot` or `Comment.replies.pageCids.best`.
|
|
1581
1563
|
|
|
1582
1564
|
#### Parameters
|
|
1583
1565
|
|
|
@@ -1611,9 +1593,9 @@ post.on('update', async updatedPost => {
|
|
|
1611
1593
|
replies = repliesPageSortedByNew.comments
|
|
1612
1594
|
}
|
|
1613
1595
|
else {
|
|
1614
|
-
// the '
|
|
1596
|
+
// the 'best' sort type is always preloaded by default on replies and can be used as fallback
|
|
1615
1597
|
// on community.posts only 'hot' is preloaded by default
|
|
1616
|
-
replies = updatedPost.replies.pages.
|
|
1598
|
+
replies = updatedPost.replies.pages.best.comments
|
|
1617
1599
|
}
|
|
1618
1600
|
console.log(replies)
|
|
1619
1601
|
})
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const parseRpcCidParam: (params: unknown) => {
|
|
2
2
|
[x: string]: unknown;
|
|
3
3
|
cid: string;
|
|
4
|
+
communityPublicKey?: string | undefined;
|
|
5
|
+
communityName?: string | undefined;
|
|
4
6
|
};
|
|
5
7
|
export declare const parseRpcCommunityAddressParam: (params: unknown) => {
|
|
6
8
|
[x: string]: unknown;
|
|
@@ -22,6 +24,8 @@ export declare const parseRpcCommunityPageParam: (params: unknown) => {
|
|
|
22
24
|
communityAddress: string;
|
|
23
25
|
type: "posts" | "modqueue";
|
|
24
26
|
pageMaxSize: number;
|
|
27
|
+
communityPublicKey?: string | undefined;
|
|
28
|
+
communityName?: string | undefined;
|
|
25
29
|
};
|
|
26
30
|
export declare const parseRpcCommentRepliesPageParam: (params: unknown) => {
|
|
27
31
|
[x: string]: unknown;
|
|
@@ -29,6 +33,8 @@ export declare const parseRpcCommentRepliesPageParam: (params: unknown) => {
|
|
|
29
33
|
cid: string;
|
|
30
34
|
pageMaxSize: number;
|
|
31
35
|
commentCid: string;
|
|
36
|
+
communityPublicKey?: string | undefined;
|
|
37
|
+
communityName?: string | undefined;
|
|
32
38
|
};
|
|
33
39
|
export declare const parseRpcEditCommunityParam: (params: unknown) => {
|
|
34
40
|
address: string;
|
|
@@ -69,7 +69,7 @@ export declare const RpcCommentEventResultSchema: z.ZodObject<{
|
|
|
69
69
|
"per-reply": "per-reply";
|
|
70
70
|
"per-author": "per-author";
|
|
71
71
|
}>>;
|
|
72
|
-
}, z.core.$
|
|
72
|
+
}, z.core.$loose>;
|
|
73
73
|
runtimeFields: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
74
74
|
}, z.core.$strip>;
|
|
75
75
|
export declare const RpcCommentUpdateResultSchema: z.ZodObject<{
|
|
@@ -271,6 +271,8 @@ export declare const RpcChallengeVerificationEventResultSchema: z.ZodObject<{
|
|
|
271
271
|
}, z.core.$strip>;
|
|
272
272
|
export declare const RpcCidParamSchema: z.ZodObject<{
|
|
273
273
|
cid: z.ZodString;
|
|
274
|
+
communityPublicKey: z.ZodOptional<z.ZodString>;
|
|
275
|
+
communityName: z.ZodOptional<z.ZodString>;
|
|
274
276
|
}, z.core.$loose>;
|
|
275
277
|
export declare const RpcCommunityAddressParamSchema: z.ZodObject<{
|
|
276
278
|
address: z.ZodString;
|
|
@@ -285,6 +287,8 @@ export declare const RpcAuthorNameParamSchema: z.ZodObject<{
|
|
|
285
287
|
}, z.core.$strip>;
|
|
286
288
|
export declare const RpcCommunityPageParamSchema: z.ZodObject<{
|
|
287
289
|
cid: z.ZodString;
|
|
290
|
+
communityPublicKey: z.ZodOptional<z.ZodString>;
|
|
291
|
+
communityName: z.ZodOptional<z.ZodString>;
|
|
288
292
|
communityAddress: z.ZodString;
|
|
289
293
|
type: z.ZodEnum<{
|
|
290
294
|
posts: "posts";
|
|
@@ -294,6 +298,8 @@ export declare const RpcCommunityPageParamSchema: z.ZodObject<{
|
|
|
294
298
|
}, z.core.$loose>;
|
|
295
299
|
export declare const RpcCommentRepliesPageParamSchema: z.ZodObject<{
|
|
296
300
|
communityAddress: z.ZodString;
|
|
301
|
+
communityPublicKey: z.ZodOptional<z.ZodString>;
|
|
302
|
+
communityName: z.ZodOptional<z.ZodString>;
|
|
297
303
|
cid: z.ZodString;
|
|
298
304
|
pageMaxSize: z.ZodNumber;
|
|
299
305
|
commentCid: z.ZodString;
|
|
@@ -4,18 +4,24 @@ import { AuthorAddressSchema, ChallengeAnswersSchema, CidStringSchema, Community
|
|
|
4
4
|
import { CommunityEditOptionsSchema } from "../../community/schema.js";
|
|
5
5
|
export const SubscriptionIdSchema = z.number().positive().int();
|
|
6
6
|
export const RpcCommentEventResultSchema = z.object({
|
|
7
|
-
comment: CommentIpfsSchema,
|
|
8
|
-
runtimeFields: z.object({}).
|
|
7
|
+
comment: CommentIpfsSchema.loose(),
|
|
8
|
+
runtimeFields: z.object({}).loose().optional()
|
|
9
9
|
});
|
|
10
10
|
export const RpcCommentUpdateResultSchema = z.object({
|
|
11
11
|
commentUpdate: CommentUpdateSchema,
|
|
12
|
-
runtimeFields: z.object({}).
|
|
12
|
+
runtimeFields: z.object({}).loose().optional()
|
|
13
13
|
});
|
|
14
14
|
export const RpcChallengeVerificationEventResultSchema = z.object({
|
|
15
15
|
challengeVerification: z.custom(),
|
|
16
|
-
runtimeFields: z.object({}).
|
|
16
|
+
runtimeFields: z.object({}).loose().optional()
|
|
17
17
|
});
|
|
18
|
-
export const RpcCidParamSchema = z
|
|
18
|
+
export const RpcCidParamSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
cid: CidStringSchema,
|
|
21
|
+
communityPublicKey: z.string().min(1).optional(),
|
|
22
|
+
communityName: z.string().min(1).optional()
|
|
23
|
+
})
|
|
24
|
+
.loose();
|
|
19
25
|
export const RpcCommunityAddressParamSchema = z.object({ address: CommunityAddressSchema });
|
|
20
26
|
export const RpcCommunityLookupParamSchema = z
|
|
21
27
|
.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/clients/rpc-client/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA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AC;AACzE,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC"}
|
package/dist/browser/errors.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare enum messages {
|
|
|
12
12
|
ERR_COMMENT_MISSING_CID = "Comment is missing cid",
|
|
13
13
|
ERR_COMMENT_MISSING_IPFS = "Comment is missing CommentIpfs props",
|
|
14
14
|
ERR_COMMENT_MISSING_UPDATE = "Comment is missing CommentUpdate props",
|
|
15
|
-
|
|
15
|
+
ERR_COMMENT_IPFS_COMMUNITY_NAME_MISMATCH = "CommentIpfs community name does not match the expected community name",
|
|
16
16
|
ERR_NEED_TO_STOP_UPDATING_COMMUNITY_BEFORE_STARTING = "You need to stop updating the community before starting it",
|
|
17
17
|
ERR_HELIAS_STOPPING_OR_STOPPED = "Helia is stopping or stopped already. You can't use any helia functions",
|
|
18
18
|
ERR_FAILED_TO_DIAL_ANY_PUBSUB_PEERS_FROM_DELEGATED_ROUTERS = "Failed to dial and connect to any IPNS-Over-Pubsub peers from delegated routers",
|
package/dist/browser/errors.js
CHANGED
|
@@ -13,7 +13,7 @@ export var messages;
|
|
|
13
13
|
messages["ERR_COMMENT_MISSING_CID"] = "Comment is missing cid";
|
|
14
14
|
messages["ERR_COMMENT_MISSING_IPFS"] = "Comment is missing CommentIpfs props";
|
|
15
15
|
messages["ERR_COMMENT_MISSING_UPDATE"] = "Comment is missing CommentUpdate props";
|
|
16
|
-
messages["
|
|
16
|
+
messages["ERR_COMMENT_IPFS_COMMUNITY_NAME_MISMATCH"] = "CommentIpfs community name does not match the expected community name";
|
|
17
17
|
messages["ERR_NEED_TO_STOP_UPDATING_COMMUNITY_BEFORE_STARTING"] = "You need to stop updating the community before starting it";
|
|
18
18
|
messages["ERR_HELIAS_STOPPING_OR_STOPPED"] = "Helia is stopping or stopped already. You can't use any helia functions";
|
|
19
19
|
messages["ERR_FAILED_TO_DIAL_ANY_PUBSUB_PEERS_FROM_DELEGATED_ROUTERS"] = "Failed to dial and connect to any IPNS-Over-Pubsub peers from delegated routers";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,QA8WX;AA9WD,WAAY,QAAQ;IAChB,gFAAoE,CAAA;IACpE,yHAA6G,CAAA;IAC7G,6EAAiE,CAAA;IACjE,4FAAgF,CAAA;IAChF,4HAAgH,CAAA;IAChH,8HAAkH,CAAA;IAClH,iDAAqC,CAAA;IACrC,0GAA8F,CAAA;IAC9F,2KAA+J,CAAA;IAC/J,oGAAwF,CAAA;IACxF,8DAAkD,CAAA;IAClD,6EAAiE,CAAA;IACjE,iFAAqE,CAAA;IACrE,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,QA8WX;AA9WD,WAAY,QAAQ;IAChB,gFAAoE,CAAA;IACpE,yHAA6G,CAAA;IAC7G,6EAAiE,CAAA;IACjE,4FAAgF,CAAA;IAChF,4HAAgH,CAAA;IAChH,8HAAkH,CAAA;IAClH,iDAAqC,CAAA;IACrC,0GAA8F,CAAA;IAC9F,2KAA+J,CAAA;IAC/J,oGAAwF,CAAA;IACxF,8DAAkD,CAAA;IAClD,6EAAiE,CAAA;IACjE,iFAAqE,CAAA;IACrE,8HAAkH,CAAA;IAClH,8HAAkH,CAAA;IAClH,sHAA0G,CAAA;IAC1G,0JAA8I,CAAA;IAC9I,mJAAuI,CAAA;IACvI,kHAAsG,CAAA;IACtG,iFAAqE,CAAA;IACrE,gHAAoG,CAAA;IACpG,4IAAgI,CAAA;IAChI,yFAA6E,CAAA;IAC7E,aAAa;IACb,+GAAmG,CAAA;IACnG,uGAA2F,CAAA;IAC3F,4HAAgH,CAAA;IAChH,qFAAyE,CA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CAAA;IACxG,mHAAuG,CAAA;IACvG,mGAAuF,CAAA;IACvF,mFAAuE,CAAA;IACvE,qHAAyG,CAAA;IACzG,0JAA8I,CAAA;IAC9I,6NAAiN,CAAA;IACjN,iOAAqN,CAAA;IACrN,0IAA8H,CAAA;IAC9H,kGAAsF,CAAA;IACtF,2LAA+K,CAAA;IAC/K,2IAA+H,CAAA;IAC/H,gBAAgB;IAChB,4EAAgE,CAAA;IAChE,gFAAoE,CAAA;IACpE,wEAA4D,CAAA;IAC5D,0JAA8I,CAAA;IAC9I,4HAAgH,CAAA;IAChH,wKAA4J,CAAA;IAC5J,sHAA0G,CAAA;IAE1G,aAAa;IACb,+LAAmL,CAAA;IACnL,qFAAyE,CAAA;IACzE,wFAA4E,CAAA;IAC5E,uHAA2G,CAAA;IAC3G,kJAAsI,CAAA;IACtI,kHAAsG,CAAA;IACtG,gHAAoG,CAAA;IACpG,oHAAwG,CAAA;IACxG,yHAA6G,CAAA;IAC7G,2LAA+K,CAAA;AACnL,CAAC,EA9WW,QAAQ,KAAR,QAAQ,QA8WnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.14";
|
package/dist/browser/pkc/pkc.js
CHANGED
|
@@ -306,8 +306,12 @@ export class PKC extends PKCTypedEmitter {
|
|
|
306
306
|
const filledTimestamp = typeof finalOptions.timestamp !== "number" ? timestamp() : finalOptions.timestamp;
|
|
307
307
|
const filledSigner = await this.createSigner(finalOptions.signer);
|
|
308
308
|
const filledProtocolVersion = finalOptions.protocolVersion || env.PROTOCOL_VERSION;
|
|
309
|
+
// Derive communityAddress from communityName or communityPublicKey if not explicitly provided
|
|
310
|
+
// The refinement schema guarantees at least one of these is present
|
|
311
|
+
const communityAddress = (finalOptions.communityAddress || finalOptions.communityName || finalOptions.communityPublicKey);
|
|
309
312
|
return {
|
|
310
313
|
...finalOptions,
|
|
314
|
+
communityAddress,
|
|
311
315
|
timestamp: filledTimestamp,
|
|
312
316
|
signer: filledSigner,
|
|
313
317
|
author: cleanedAuthor,
|
|
@@ -320,6 +324,16 @@ export class PKC extends PKCTypedEmitter {
|
|
|
320
324
|
commentInstance.setCid(options.cid);
|
|
321
325
|
if (options.communityAddress)
|
|
322
326
|
commentInstance.setCommunityAddress(options.communityAddress);
|
|
327
|
+
if (options.communityPublicKey)
|
|
328
|
+
commentInstance.communityPublicKey = options.communityPublicKey;
|
|
329
|
+
if (options.communityName)
|
|
330
|
+
commentInstance.communityName = options.communityName;
|
|
331
|
+
// Derive communityAddress from communityName/communityPublicKey when not explicitly provided
|
|
332
|
+
if (!commentInstance.communityAddress) {
|
|
333
|
+
const derived = options.communityName || options.communityPublicKey;
|
|
334
|
+
if (derived)
|
|
335
|
+
commentInstance.setCommunityAddress(derived);
|
|
336
|
+
}
|
|
323
337
|
if (options.raw?.commentUpdate?.cid)
|
|
324
338
|
commentInstance.setCid(options.raw?.commentUpdate?.cid);
|
|
325
339
|
if ("pubsubMessageToPublish" in options.raw && options.raw.pubsubMessageToPublish && "signer" in options && options.signer)
|
|
@@ -361,6 +375,11 @@ export class PKC extends PKCTypedEmitter {
|
|
|
361
375
|
commentInstance.setCommunityAddress(parseCommunityAddressWithPKCErrorIfItFails(options.communityAddress));
|
|
362
376
|
else if ("subplebbitAddress" in options && options.subplebbitAddress)
|
|
363
377
|
commentInstance.setCommunityAddress(parseCommunityAddressWithPKCErrorIfItFails(options.subplebbitAddress));
|
|
378
|
+
// Derive communityAddress from communityName or communityPublicKey if not provided
|
|
379
|
+
else if ("communityName" in options && typeof options.communityName === "string")
|
|
380
|
+
commentInstance.setCommunityAddress(options.communityName);
|
|
381
|
+
else if ("communityPublicKey" in options && typeof options.communityPublicKey === "string")
|
|
382
|
+
commentInstance.setCommunityAddress(options.communityPublicKey);
|
|
364
383
|
if ("communityPublicKey" in options && typeof options.communityPublicKey === "string")
|
|
365
384
|
commentInstance.communityPublicKey = options.communityPublicKey;
|
|
366
385
|
else if (commentInstance.communityAddress && !isStringDomain(commentInstance.communityAddress))
|