spasm.js 1.0.2 → 2.0.0-alpha

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 (123) hide show
  1. package/README.md +454 -113
  2. package/lib.commonjs/convert/convertToEventForSpasmid.d.ts +4 -0
  3. package/lib.commonjs/convert/convertToEventForSpasmid.d.ts.map +1 -0
  4. package/lib.commonjs/convert/convertToEventForSpasmid.js +171 -0
  5. package/lib.commonjs/convert/convertToEventForSpasmid.js.map +1 -0
  6. package/lib.commonjs/convert/convertToSpasm.d.ts +17 -15
  7. package/lib.commonjs/convert/convertToSpasm.d.ts.map +1 -1
  8. package/lib.commonjs/convert/convertToSpasm.js +772 -265
  9. package/lib.commonjs/convert/convertToSpasm.js.map +1 -1
  10. package/lib.commonjs/convert/convertToSpasmEventDatabase.d.ts +4 -0
  11. package/lib.commonjs/convert/convertToSpasmEventDatabase.d.ts.map +1 -0
  12. package/lib.commonjs/convert/convertToSpasmEventDatabase.js +130 -0
  13. package/lib.commonjs/convert/convertToSpasmEventDatabase.js.map +1 -0
  14. package/lib.commonjs/convert/index.d.ts +2 -0
  15. package/lib.commonjs/convert/index.d.ts.map +1 -1
  16. package/lib.commonjs/convert/index.js +5 -1
  17. package/lib.commonjs/convert/index.js.map +1 -1
  18. package/lib.commonjs/id/getSpasmId.d.ts +4 -0
  19. package/lib.commonjs/id/getSpasmId.d.ts.map +1 -0
  20. package/lib.commonjs/id/getSpasmId.js +31 -0
  21. package/lib.commonjs/id/getSpasmId.js.map +1 -0
  22. package/lib.commonjs/id/index.d.ts +2 -0
  23. package/lib.commonjs/id/index.d.ts.map +1 -0
  24. package/lib.commonjs/id/index.js +6 -0
  25. package/lib.commonjs/id/index.js.map +1 -0
  26. package/lib.commonjs/identify/identifyEvent.d.ts.map +1 -1
  27. package/lib.commonjs/identify/identifyEvent.js +13 -5
  28. package/lib.commonjs/identify/identifyEvent.js.map +1 -1
  29. package/lib.commonjs/sort/index.d.ts +2 -0
  30. package/lib.commonjs/sort/index.d.ts.map +1 -0
  31. package/lib.commonjs/sort/index.js +6 -0
  32. package/lib.commonjs/sort/index.js.map +1 -0
  33. package/lib.commonjs/sort/sortEventForSpasmid.d.ts +3 -0
  34. package/lib.commonjs/sort/sortEventForSpasmid.d.ts.map +1 -0
  35. package/lib.commonjs/sort/sortEventForSpasmid.js +15 -0
  36. package/lib.commonjs/sort/sortEventForSpasmid.js.map +1 -0
  37. package/lib.commonjs/spasm.d.ts +5 -3
  38. package/lib.commonjs/spasm.d.ts.map +1 -1
  39. package/lib.commonjs/spasm.js +4 -5
  40. package/lib.commonjs/spasm.js.map +1 -1
  41. package/lib.commonjs/types/index.d.ts +1 -1
  42. package/lib.commonjs/types/index.d.ts.map +1 -1
  43. package/lib.commonjs/types/interfaces.d.ts +468 -90
  44. package/lib.commonjs/types/interfaces.d.ts.map +1 -1
  45. package/lib.commonjs/types/interfaces.js +2 -0
  46. package/lib.commonjs/types/interfaces.js.map +1 -1
  47. package/lib.commonjs/utils/nostrUtils.d.ts +10 -2
  48. package/lib.commonjs/utils/nostrUtils.d.ts.map +1 -1
  49. package/lib.commonjs/utils/nostrUtils.js +122 -22
  50. package/lib.commonjs/utils/nostrUtils.js.map +1 -1
  51. package/lib.commonjs/utils/utils.d.ts +26 -1
  52. package/lib.commonjs/utils/utils.d.ts.map +1 -1
  53. package/lib.commonjs/utils/utils.js +723 -3
  54. package/lib.commonjs/utils/utils.js.map +1 -1
  55. package/lib.esm/convert/convertToEventForSpasmid.d.ts +4 -0
  56. package/lib.esm/convert/convertToEventForSpasmid.d.ts.map +1 -0
  57. package/lib.esm/convert/convertToEventForSpasmid.js +168 -0
  58. package/lib.esm/convert/convertToEventForSpasmid.js.map +1 -0
  59. package/lib.esm/convert/convertToSpasm.d.ts +17 -15
  60. package/lib.esm/convert/convertToSpasm.d.ts.map +1 -1
  61. package/lib.esm/convert/convertToSpasm.js +759 -251
  62. package/lib.esm/convert/convertToSpasm.js.map +1 -1
  63. package/lib.esm/convert/convertToSpasmEventDatabase.d.ts +4 -0
  64. package/lib.esm/convert/convertToSpasmEventDatabase.d.ts.map +1 -0
  65. package/lib.esm/convert/convertToSpasmEventDatabase.js +137 -0
  66. package/lib.esm/convert/convertToSpasmEventDatabase.js.map +1 -0
  67. package/lib.esm/convert/index.d.ts +2 -0
  68. package/lib.esm/convert/index.d.ts.map +1 -1
  69. package/lib.esm/convert/index.js +2 -0
  70. package/lib.esm/convert/index.js.map +1 -1
  71. package/lib.esm/id/getSpasmId.d.ts +4 -0
  72. package/lib.esm/id/getSpasmId.d.ts.map +1 -0
  73. package/lib.esm/id/getSpasmId.js +31 -0
  74. package/lib.esm/id/getSpasmId.js.map +1 -0
  75. package/lib.esm/id/index.d.ts +2 -0
  76. package/lib.esm/id/index.d.ts.map +1 -0
  77. package/lib.esm/id/index.js +2 -0
  78. package/lib.esm/id/index.js.map +1 -0
  79. package/lib.esm/identify/identifyEvent.d.ts.map +1 -1
  80. package/lib.esm/identify/identifyEvent.js +13 -5
  81. package/lib.esm/identify/identifyEvent.js.map +1 -1
  82. package/lib.esm/sort/index.d.ts +2 -0
  83. package/lib.esm/sort/index.d.ts.map +1 -0
  84. package/lib.esm/sort/index.js +2 -0
  85. package/lib.esm/sort/index.js.map +1 -0
  86. package/lib.esm/sort/sortEventForSpasmid.d.ts +3 -0
  87. package/lib.esm/sort/sortEventForSpasmid.d.ts.map +1 -0
  88. package/lib.esm/sort/sortEventForSpasmid.js +17 -0
  89. package/lib.esm/sort/sortEventForSpasmid.js.map +1 -0
  90. package/lib.esm/spasm.d.ts +5 -3
  91. package/lib.esm/spasm.d.ts.map +1 -1
  92. package/lib.esm/spasm.js +4 -2
  93. package/lib.esm/spasm.js.map +1 -1
  94. package/lib.esm/types/index.d.ts +1 -1
  95. package/lib.esm/types/index.d.ts.map +1 -1
  96. package/lib.esm/types/interfaces.d.ts +468 -90
  97. package/lib.esm/types/interfaces.d.ts.map +1 -1
  98. package/lib.esm/types/interfaces.js +2 -0
  99. package/lib.esm/types/interfaces.js.map +1 -1
  100. package/lib.esm/utils/nostrUtils.d.ts +10 -2
  101. package/lib.esm/utils/nostrUtils.d.ts.map +1 -1
  102. package/lib.esm/utils/nostrUtils.js +119 -21
  103. package/lib.esm/utils/nostrUtils.js.map +1 -1
  104. package/lib.esm/utils/utils.d.ts +26 -1
  105. package/lib.esm/utils/utils.d.ts.map +1 -1
  106. package/lib.esm/utils/utils.js +701 -2
  107. package/lib.esm/utils/utils.js.map +1 -1
  108. package/package.json +9 -2
  109. package/src.ts/convert/convertToEventForSpasmid.ts +289 -0
  110. package/src.ts/convert/convertToSpasm.ts +962 -292
  111. package/src.ts/convert/convertToSpasmEventDatabase.ts +204 -0
  112. package/src.ts/convert/index.ts +2 -0
  113. package/src.ts/docs/architecture.md +413 -0
  114. package/src.ts/id/getSpasmId.ts +56 -0
  115. package/src.ts/id/index.ts +1 -0
  116. package/src.ts/identify/identifyEvent.ts +12 -5
  117. package/src.ts/sort/index.ts +1 -0
  118. package/src.ts/sort/sortEventForSpasmid.ts +30 -0
  119. package/src.ts/spasm.ts +5 -3
  120. package/src.ts/types/index.ts +1 -1
  121. package/src.ts/types/interfaces.ts +729 -125
  122. package/src.ts/utils/nostrUtils.ts +150 -22
  123. package/src.ts/utils/utils.ts +1005 -4
package/README.md CHANGED
@@ -12,7 +12,7 @@ For instance, instead of maintaining three distinct versions of the frontend (UI
12
12
  TypeScript interfaces of JSON objects of messaging formats that can be standardized with this library can be found at `./src.ts/types/interfaces.ts`.
13
13
 
14
14
  ```typescript
15
- export type UnknownEvent =
15
+ export type UnknownEventV2 =
16
16
  DmpEvent |
17
17
  DmpEventSignedClosed |
18
18
  DmpEventSignedOpened |
@@ -20,26 +20,224 @@ export type UnknownEvent =
20
20
  NostrEventSignedOpened |
21
21
  NostrSpasmEvent |
22
22
  NostrSpasmEventSignedOpened |
23
- SpasmEvent
23
+ SpasmEventV0 |
24
+ SpasmEventV2 |
25
+ SpasmEventBodyV2 |
26
+ SpasmEventEnvelopeV2 |
27
+ SpasmEventEnvelopeWithTreeV2 |
28
+ SpasmEventDatabaseV2
24
29
  ```
25
30
 
26
31
  After converting an unknown event to the Spasm event, you can now easily access common properties across most public messaging formats such as:
27
- - `spasmEvent.eventId`
28
- - `spasmEvent.author`
29
32
  - `spasmEvent.action`
30
33
  - `spasmEvent.content`
31
34
  - `spasmEvent.timestamp`
32
- - `spasmEvent.signature`
33
- - `spasmEvent.parentEvent`
35
+ - `spasmEvent.parent.ids`
36
+ - `spasmEvent.parent.ids[0].value`
37
+ - `spasmEvent.ids`
38
+ - `spasmEvent.ids[0].value`
39
+ - `spasmEvent.ids[0].format.name`
40
+ - `spasmEvent.authors`
41
+ - `spasmEvent.authors[0].addresses[0].value`
42
+ - `spasmEvent.authors[0].addresses[0].format.name`
43
+ - `spasmEvent.signatures`
44
+ - `spasmEvent.signatures[0].value`
45
+ - `spasmEvent.signatures[0].pubkey`
46
+ - `spasmEvent.signatures[0].format.name`
47
+
48
+ The Spasm event can be signed with different protocols (e.g., Spasm, Dmp, Nostr), so the original signed events are stored at:
49
+ - `spasmEvent.siblings`
50
+
51
+ See the full list of properties of `SpasmEventV2` at `./src.ts/types/interfaces.ts`.
52
+
53
+ Here is a schema of the SpasmEventV2 interface:
34
54
 
35
- The original event will be stored under:
36
- - `spasmEvent.originalEventObject`
37
- - `spasmEvent.originalEventString`
38
-
39
- The event metadata can be found under:
40
- - `spasmEvent.meta`
55
+ ```
56
+ #01 = EventForSpasmid01
57
+ SE = SpasmEvent
58
+ Body = SpasmEventBody
59
+ Env = SpasmEventEnvelope
60
+ Tree = SpasmEventEnvelopeWithTree
61
+ DB = SpasmEventDatabase
62
+
63
+ event*
64
+
65
+ ├── type --- SE Body Env Tree DB
66
+ ├── protocol (+ sibling) --- -- Body --- ---- --
67
+ │ ├── name --- -- Body --- ---- --
68
+ │ └── version --- -- Body --- ---- --
69
+ ├── root --- SE ---- --- Tree DB
70
+ │ ├── ids[] --- SE ---- --- Tree DB
71
+ │ ├── marker --- SE ---- --- Tree DB
72
+ │ ├── depth --- SE ---- --- Tree --
73
+ │ └── event* --- SE ---- --- Tree --
74
+ ├── parent #01 SE Body --- Tree DB
75
+ │ ├── ids[] #01 SE Body --- Tree DB
76
+ │ ├── marker #01 SE Body --- Tree DB
77
+ │ ├── depth --- SE ---- --- Tree --
78
+ │ └── event* --- SE ---- --- Tree --
79
+ ├── action #01 SE Body --- ---- DB
80
+ ├── title #01 SE Body --- ---- DB
81
+ ├── content #01 SE Body --- ---- DB
82
+ ├── timestamp #01 SE Body --- ---- DB
83
+ ├── authors[] #01 SE Body --- ---- DB
84
+ │ ├── addresses[] #01 SE Body --- ---- DB
85
+ │ │ ├── value #01 SE Body --- ---- DB
86
+ │ │ ├── format #01 SE Body --- ---- DB
87
+ │ │ │ ├── name #01 SE Body --- ---- DB
88
+ │ │ │ └── version #01 SE Body --- ---- DB
89
+ │ │ └── verified --- SE ---- --- ---- DB
90
+ │ └── usernames[] (eg RSS posts) #01 SE Body --- ---- DB
91
+ │ ├── value #01 SE Body --- ---- DB
92
+ │ ├── protocol #01 SE Body --- ---- DB
93
+ │ ├── proof #01 SE Body --- ---- DB
94
+ │ └── provider #01 SE Body --- ---- DB
95
+ ├── categories[] #01 SE Body --- ---- DB
96
+ │ ├── name #01 SE Body --- ---- DB
97
+ │ └── sub (recursive category) #01 SE Body --- ---- DB
98
+ ├── tips[] #01 SE Body --- ---- DB
99
+ │ ├── address #01 SE Body --- ---- DB
100
+ │ ├── text #01 SE Body --- ---- DB
101
+ │ ├── expiration #01 SE Body --- ---- DB
102
+ │ │ └── timestamp #01 SE Body --- ---- DB
103
+ │ ├── currency #01 SE Body --- ---- DB
104
+ │ │ ├── name #01 SE Body --- ---- DB
105
+ │ │ └── ticker #01 SE Body --- ---- DB
106
+ │ └── network #01 SE Body --- ---- DB
107
+ │ ├── name #01 SE Body --- ---- DB
108
+ │ └── id #01 SE Body --- ---- DB
109
+ ├── hosts[] (see hosts below) #01 SE Body --- ---- DB
110
+ ├── links[] (see link below) #01 SE Body --- ---- DB
111
+ ├── keywords[] #01 SE Body --- ---- DB
112
+ ├── tags[] #01 SE Body --- ---- DB
113
+ ├── medias[] #01 SE Body --- ---- DB
114
+ │ ├── hashes[] (see hash below) #01 SE Body --- ---- DB
115
+ │ ├── links[] (see link below) #01 SE Body --- ---- DB
116
+ │ └── type #01 SE Body --- ---- DB
117
+ ├── references[] #01 SE Body --- Tree DB
118
+ │ ├── ids[] #01 SE Body --- Tree DB
119
+ │ ├── marker #01 SE Body --- Tree DB
120
+ │ └── event* --- SE ---- --- Tree --
121
+ ├── mentions[] #01 SE Body --- ---- DB
122
+ │ ├── addresses[] #01 SE Body --- ---- DB
123
+ │ │ ├── value #01 SE Body --- ---- DB
124
+ │ │ └── format #01 SE Body --- ---- DB
125
+ │ │ ├── name #01 SE Body --- ---- DB
126
+ │ │ └── version #01 SE Body --- ---- DB
127
+ │ └── usernames[] #01 SE Body --- ---- DB
128
+ │ ├── value #01 SE Body --- ---- DB
129
+ │ ├── protocol #01 SE Body --- ---- DB
130
+ │ ├── proof #01 SE Body --- ---- DB
131
+ │ └── provider #01 SE Body --- ---- DB
132
+ ├── proofs[] #01 SE Body --- ---- DB
133
+ │ ├── value #01 SE Body --- ---- DB
134
+ │ ├── links[] #01 SE Body --- ---- DB
135
+ │ └── protocol #01 SE Body --- ---- DB
136
+ │ ├── name #01 SE Body --- ---- DB
137
+ │ └── version #01 SE Body --- ---- DB
138
+ ├── previousEvent (+ sibling) --- -- Body --- ---- --
139
+ │ ├── ids[] --- -- Body --- ---- --
140
+ │ ├── marker --- -- Body --- ---- --
141
+ │ ├── depth --- -- Body --- ---- --
142
+ │ └── event* --- -- ---- --- ---- --
143
+ ├── sequence (+ sibling) --- -- Body --- ---- --
144
+ ├── license #01 SE Body --- ---- DB
145
+ ├── language #01 SE Body --- ---- DB
146
+ ├── extra #01 SE Body --- ---- DB
147
+ ├── pows (only 1 in body) --- SE Body --- ---- DB
148
+ │ ├── nonce --- SE Body --- ---- DB
149
+ │ ├── difficulty --- SE Body --- ---- DB
150
+ │ ├── words[] --- SE Body --- ---- DB
151
+ │ └── network --- SE Body --- ---- DB
152
+ │ ├── name --- SE Body --- ---- DB
153
+ │ └── id --- SE Body --- ---- DB
154
+
155
+ ├── ids[] --- SE ---- Env Tree DB
156
+ ├── signatures[] --- SE ---- Env Tree DB
157
+ │ ├── value --- SE ---- Env Tree DB
158
+ │ ├── pubkey --- SE ---- Env Tree DB
159
+ │ └── format --- SE ---- Env Tree DB
160
+ │ ├── name --- SE ---- Env Tree DB
161
+ │ └── version --- SE ---- Env Tree DB
162
+
163
+ ├── siblings[] --- SE ---- Env Tree DB
164
+ │ ├── type --- SE ---- Env Tree DB
165
+ │ ├── signedString --- SE ---- Env Tree DB
166
+ │ ├── originalObject --- SE ---- Env Tree DB
167
+ │ ├── signatures[] --- SE ---- Env Tree DB
168
+ │ │ ├── value --- SE ---- Env Tree DB
169
+ │ │ ├── pubkey --- SE ---- Env Tree DB
170
+ │ │ └── format --- SE ---- Env Tree DB
171
+ │ │ ├── name --- SE ---- Env Tree DB
172
+ │ │ └── version --- SE ---- Env Tree DB
173
+ │ ├── sequence --- SE ---- Env Tree DB
174
+ │ ├── previousEvent --- SE ---- Env Tree DB
175
+ │ │ ├── ids[] --- SE ---- Env Tree DB
176
+ │ │ ├── marker --- SE ---- Env Tree DB
177
+ │ │ ├── depth --- SE ---- Env Tree DB
178
+ │ │ └── event* --- SE ---- --- Tree DB
179
+ │ └── protocol --- SE ---- Env Tree DB
180
+ │ ├── name --- SE ---- Env Tree DB
181
+ │ ├── version --- SE ---- Env Tree DB
182
+ │ ├── hasExtraSpasmFields --- SE ---- Env Tree DB
183
+ │ └── extraSpasmFieldsVersion --- SE ---- Env Tree DB
184
+
185
+ ├── db --- SE ---- Env Tree DB
186
+ │ ├── key --- SE ---- Env Tree DB
187
+ │ ├── addedTimestamp --- SE ---- Env Tree DB
188
+ │ ├── updatedTimestamp --- SE ---- Env Tree DB
189
+ │ └── table --- SE ---- Env Tree DB
190
+ ├── source --- SE ---- Env Tree DB
191
+ │ ├── name --- SE ---- Env Tree DB
192
+ │ ├── uiUrl --- SE ---- Env Tree DB
193
+ │ ├── apiUrl --- SE ---- Env Tree DB
194
+ │ ├── query --- SE ---- Env Tree DB
195
+ │ └── showSource --- SE ---- Env Tree DB
196
+ ├── stats[] --- SE ---- Env Tree DB
197
+ │ ├── action --- SE ---- Env Tree DB
198
+ │ ├── total --- SE ---- Env Tree DB
199
+ │ ├── latestTimestamp --- SE ---- Env Tree DB
200
+ │ ├── latestDbTimestamp --- SE ---- Env Tree DB
201
+ │ └── ...(upvote, downvote, etc.) --- SE ---- Env Tree DB
202
+ ├── sharedBy[] --- SE ---- Env Tree DB
203
+ │ └── ids[] --- SE ---- Env Tree DB
204
+
205
+ │ (Envelope with tree)
206
+ ├── root --- SE ---- Env Tree --
207
+ │ └── event --- SE ---- Env Tree --
208
+ ├── parent --- SE ---- Env Tree --
209
+ │ └── event --- SE ---- Env Tree --
210
+ ├── references[] --- SE ---- Env Tree --
211
+ │ └── event --- SE ---- Env Tree --
212
+ └── children[] --- SE ---- Env Tree --
213
+ └── SE | Env | Tree --- SE ---- Env Tree --
214
+
215
+ id
216
+ ├── value #.
217
+ ├── format #.
218
+ │ ├── name
219
+ │ └── version
220
+ └── hosts[]
221
+
222
+ hash
223
+ ├── value
224
+ ├── name
225
+ ├── length
226
+ ├── type
227
+ ├── pieceLength
228
+ └── pieces[]
229
+
230
+ link
231
+ ├── value
232
+ ├── protocol
233
+ ├── origin
234
+ ├── host
235
+ ├── pathname
236
+ ├── search
237
+ ├── port
238
+ └── originalProtocolKey
41
239
 
42
- See the full list of properties of `SpasmEvent` at `./src.ts/types/interfaces.ts`.
240
+ ```
43
241
 
44
242
  ### Features
45
243
 
@@ -158,40 +356,62 @@ const output = {
158
356
  }
159
357
  ```
160
358
 
161
- Here is how the event looks like after converting to Spasm:
359
+ Here is how the event looks like after converting to Spasm V2:
162
360
 
163
361
  ```typescript
164
- const spasmEvent: SpasmEvent = {
165
- meta: {
166
- baseProtocol: 'dmp',
167
- baseProtocolVersion: '0.0.1',
168
- hasExtraSpasmFields: false,
169
- convertedFrom: 'DmpEventSignedClosed',
170
- license: 'MIT',
171
- privateKeyType: 'ethereum'
172
- },
173
- spasmVersion: '1.0.0',
174
- parentEvent: '',
175
- action: 'post',
176
- title: 'genesis',
177
- content: 'not your keys, not your words',
362
+ const spasmEvent: SpasmEventV2 = {
363
+ type: "SpasmEventV2",
364
+ action: "post",
365
+ title: "genesis",
366
+ content: "not your keys, not your words",
178
367
  timestamp: 1641074686178,
179
- originalEventObject: {
180
- version: 'dmp_v0.0.1',
181
- time: '2022-01-01T22:04:46.178Z',
182
- action: 'post',
183
- target: '',
184
- title: 'genesis',
185
- text: 'not your keys, not your words',
186
- license: 'MIT'
187
- },
188
- originalEventString: '{"version":"dmp_v0.0.1","time":"2022-01-01T22:04:46.178Z","action":"post","target":"","title":"genesis","text":"not y
189
- our keys, not your words","license":"MIT"}',
190
- eventId: '0xbd934a01dc3bd9bb183bda807d35e61accf7396c527b8a3d029c20c00b294cf029997be953772da32483b077eea856e6bafcae7a2aff95ae572af25dd3e204a
191
- 71b',
192
- author: '0xf8553015220a857eda377a1e903c9e5afb3ac2fa',
193
- signature: '0xbd934a01dc3bd9bb183bda807d35e61accf7396c527b8a3d029c20c00b294cf029997be953772da32483b077eea856e6bafcae7a2aff95ae572af25dd3e20
194
- 4a71b'
368
+ authors: [
369
+ {
370
+ addresses: [
371
+ {
372
+ value: "0xf8553015220a857eda377a1e903c9e5afb3ac2fa",
373
+ format: { name: "ethereum-pubkey", }
374
+ }
375
+ ]
376
+ }
377
+ ],
378
+ license: "MIT",
379
+ ids: [
380
+ {
381
+ value: "0xbd934a01dc3bd9bb183bda807d35e61accf7396c527b8a3d029c20c00b294cf029997be953772da32483b077eea856e6bafcae7a2aff95ae572af25dd3e204a71b",
382
+ format: { name: "ethereum-sig", }
383
+ },
384
+ ],
385
+ signatures: [
386
+ {
387
+ value: "0xbd934a01dc3bd9bb183bda807d35e61accf7396c527b8a3d029c20c00b294cf029997be953772da32483b077eea856e6bafcae7a2aff95ae572af25dd3e204a71b",
388
+ pubkey: "0xf8553015220a857eda377a1e903c9e5afb3ac2fa",
389
+ format: { name: "ethereum-sig" }
390
+ }
391
+ ],
392
+ siblings: [
393
+ {
394
+ type: "SiblingDmpSignedV2",
395
+ protocol: {
396
+ name: "dmp",
397
+ version: "0.0.1"
398
+ },
399
+ signedString: JSON.stringify(validDmpEvent),
400
+ ids: [
401
+ {
402
+ value: "0xbd934a01dc3bd9bb183bda807d35e61accf7396c527b8a3d029c20c00b294cf029997be953772da32483b077eea856e6bafcae7a2aff95ae572af25dd3e204a71b",
403
+ format: { name: "ethereum-sig" }
404
+ },
405
+ ],
406
+ signatures: [
407
+ {
408
+ value: "0xbd934a01dc3bd9bb183bda807d35e61accf7396c527b8a3d029c20c00b294cf029997be953772da32483b077eea856e6bafcae7a2aff95ae572af25dd3e204a71b",
409
+ pubkey: "0xf8553015220a857eda377a1e903c9e5afb3ac2fa",
410
+ format: { name: "ethereum-sig" }
411
+ }
412
+ ]
413
+ }
414
+ ]
195
415
  }
196
416
  ```
197
417
 
@@ -235,67 +455,98 @@ const output = {
235
455
  }
236
456
  ```
237
457
 
238
- Here is how the event looks like after converting to Spasm:
458
+ Here is how the event looks like after converting to Spasm V2:
239
459
 
240
460
  ```typescript
241
- const spasmEvent: SpasmEvent = {
242
- meta: {
243
- baseProtocol: 'nostr',
244
- hasExtraSpasmFields: true,
245
- extraSpasmFieldsVersion: '1.0.0',
246
- convertedFrom: 'NostrSpasmEventSignedOpened',
247
- privateKeyType: 'nostr'
248
- license: 'SPDX-License-Identifier: CC0-1.0]',
249
- },
250
- spasmVersion: '1.0.0',
251
- eventId: 'db60516accfc025582bf556e3c7660c89e3982d2a656201aaea4189c6d3e3779b202c60302e55ad782ca711df20550384516abe4d7387470bc83ac757ed8f0f1'
252
- action: 'post',
253
- title: 'Nostr Spasm genesis',
254
- content: 'Walled gardens became prisons, and Spasm is the second step towards tearing down the prison walls.',
461
+ const spasmEvent: SpasmEventV2 = {
462
+ type: "SpasmEventV2",
463
+ action: "post",
464
+ title: "Nostr Spasm genesis",
465
+ content: "Walled gardens became prisons, and Spasm is the second step towards tearing down the prison walls.",
255
466
  timestamp: 1705462957,
256
- author: 'npub195ke7xdf3efncf6spe0s26322mdcl6frj0n6yy6akcadxqzgdapqjsm60y',
257
- originalEventObject: {
258
- kind: 1,
259
- created_at: 1705462957,
260
- tags:[
261
- ["license","SPDX-License-Identifier: CC0-1.0"],
262
- ["spasm_version","1.0.0"],
263
- ["spasm_action","post"],
264
- ["spasm_title","Nostr Spasm genesis"]
265
- ],
266
- content: "Walled gardens became prisons, and Spasm is the second step towards tearing down the prison walls.",
267
- pubkey: "2d2d9f19a98e533c27500e5f056a2a56db8fe92393e7a2135db63ad300486f42",
268
- id: "db300d320853b25b57fa03c586d18f69ad9786ec5e21114253fc3762b22a5651",
269
- sig: "db60516accfc025582bf556e3c7660c89e3982d2a656201aaea4189c6d3e3779b202c60302e55ad782ca711df20550384516abe4d7387470bc83ac757ed8f0f1"
270
- },
271
- originalEventString: '{"kind":1,"created_at":1705462957,"tags":[["license","SPDX-License-Identifier: CC0-1.0"],["spasm_version","1.0.0"],["spasm_action","post"],["spasm_title","Nostr Spasm genesis"]],"content":"Walled gardens became prisons, and Spasm is the second step towards tearing down the prison walls.","pubkey":"2d2d9f19a98e533c27500e5f056a2a56db8fe92393e7a2135db63ad300486f42","id":"db300d320853b25b57fa03c586d18f69ad9786ec5e21114253fc3762b22a5651","sig":"db60516accfc025582bf556e3c7660c89e3982d2a656201aaea4189c6d3e3779b202c60302e55ad782ca711df20550384516abe4d7387470bc83ac757ed8f0f1"}',
272
- signature: 'db60516accfc025582bf556e3c7660c89e3982d2a656201aaea4189c6d3e3779b202c60302e55ad782ca711df20550384516abe4d7387470bc83ac757ed8f0f1'
467
+ authors: [
468
+ {
469
+ addresses: [
470
+ {
471
+ value: "2d2d9f19a98e533c27500e5f056a2a56db8fe92393e7a2135db63ad300486f42",
472
+ format: { name: "nostr-hex" }
473
+ }
474
+ ]
475
+ }
476
+ ],
477
+ license: "SPDX-License-Identifier: CC0-1.0",
478
+ ids: [
479
+ {
480
+ value: "db300d320853b25b57fa03c586d18f69ad9786ec5e21114253fc3762b22a5651",
481
+ format: { name: "nostr-hex" }
482
+ },
483
+ {
484
+ value: "db60516accfc025582bf556e3c7660c89e3982d2a656201aaea4189c6d3e3779b202c60302e55ad782ca711df20550384516abe4d7387470bc83ac757ed8f0f1",
485
+ format: { name: "nostr-sig" }
486
+ }
487
+ ],
488
+ signatures: [
489
+ {
490
+ value: "db60516accfc025582bf556e3c7660c89e3982d2a656201aaea4189c6d3e3779b202c60302e55ad782ca711df20550384516abe4d7387470bc83ac757ed8f0f1",
491
+ pubkey: "2d2d9f19a98e533c27500e5f056a2a56db8fe92393e7a2135db63ad300486f42",
492
+ format: { name: "nostr-sig" }
493
+ }
494
+ ],
495
+ siblings: [
496
+ {
497
+ type: "SiblingNostrSpasmSignedV2",
498
+ originalObject: validNostrSpasmEventSignedOpened,
499
+ protocol: {
500
+ name: "nostr",
501
+ hasExtraSpasmFields: true,
502
+ extraSpasmFieldsVersion: "1.0.0"
503
+ },
504
+ ids: [
505
+ {
506
+ value: "db300d320853b25b57fa03c586d18f69ad9786ec5e21114253fc3762b22a5651",
507
+ format: { name: "nostr-hex" }
508
+ },
509
+ {
510
+ value: "db60516accfc025582bf556e3c7660c89e3982d2a656201aaea4189c6d3e3779b202c60302e55ad782ca711df20550384516abe4d7387470bc83ac757ed8f0f1",
511
+ format: { name: "nostr-sig" }
512
+ }
513
+ ],
514
+ signatures: [
515
+ {
516
+ value: "db60516accfc025582bf556e3c7660c89e3982d2a656201aaea4189c6d3e3779b202c60302e55ad782ca711df20550384516abe4d7387470bc83ac757ed8f0f1",
517
+ pubkey: "2d2d9f19a98e533c27500e5f056a2a56db8fe92393e7a2135db63ad300486f42",
518
+ format: { name: "nostr-sig" }
519
+ }
520
+ ]
521
+ }
522
+ ]
273
523
  }
274
524
  ```
275
525
 
276
526
  ### Convert RssItem to Spasm
277
527
 
278
- Here is a post with an RSS item:
528
+ Here is a Spasm event v0 with an RSS item:
279
529
 
280
530
  ```typescript
281
- const event: Post = {
282
- id: 7188,
283
- guid: "https://thedefiant.io/starknet-unveils-token-launch-plans",
284
- source: "thedefiant.io",
285
- tickers: "",
286
- title: "Starknet Unveils Token Launch Plans ",
287
- url: "https://thedefiant.io/starknet-unveils-token-launch-plans",
288
- description: "Ethereum Layer 2 network Starknet has allocated 900M STRK tokens to an airdrop rewarding past and present users’ contributions....",
289
- pubdate: "2023-12-08T18:56:29.000Z",
531
+ const event: SpasmEventV0 = {
532
+ id: 18081,
533
+ guid: "https://forum.degenrocket.space/?l=terraforming",
534
+ source: "degenrocket.space",
535
+ author: "stablepony",
536
+ tickers: "cookies",
537
+ title: "To the Moon!",
538
+ url: "https://forum.degenrocket.space/?b=21&t=fog&c=samourai&h=hijack",
539
+ description: "Tornado is coming back! Roger that! Starting the engine...",
540
+ pubdate: "2024-03-12T20:24:04.240Z",
290
541
  category: "defi",
291
- tags: null,
542
+ tags: ["dark", "forest"],
292
543
  upvote: 3,
293
544
  downvote: null,
294
545
  bullish: 2,
295
546
  bearish: 0,
296
- important: null,
547
+ important: 6,
297
548
  scam: 1,
298
- comments_count: 3,
549
+ comments_count: 0,
299
550
  latest_action_added_time: null
300
551
  }
301
552
  ```
@@ -311,36 +562,126 @@ const output = {
311
562
  }
312
563
  ```
313
564
 
314
- Here is how the event looks like after converting to Spasm:
565
+ Here is how the event looks like after converting to Spasm V2:
315
566
 
316
567
  ```typescript
317
568
  const spasmEvent: SpasmEvent = {
318
- meta: {
319
- hasExtraSpasmFields: false,
320
- convertedFrom: "unknown",
569
+ type: "SpasmEventV2",
570
+ ids: [
571
+ {
572
+ value: "https://forum.degenrocket.space/?b=21&t=fog&c=samourai&h=hijack",
573
+ format: { name: "url" }
574
+ },
575
+ {
576
+ value: "https://forum.degenrocket.space/?l=terraforming",
577
+ format: { name: "guid" }
578
+ }
579
+ ],
580
+ db: {
581
+ key: 18081
321
582
  },
322
- spasmVersion: "1.0.0",
323
- eventId: "https://thedefiant.io/starknet-unveils-token-launch-plans",
324
- dbId: 7188,
325
583
  action: "post",
326
- title: "Starknet Unveils Token Launch Plans ",
327
- content: "Ethereum Layer 2 network Starknet has allocated 900M STRK tokens to an airdrop rewarding past and present users’ contributions....",
328
- source: "thedefiant.io",
329
- timestamp: 1702061789000,
330
- category: "defi",
331
- links: {
332
- http: "https://thedefiant.io/starknet-unveils-token-launch-plans",
333
- guid: "https://thedefiant.io/starknet-unveils-token-launch-plans"
584
+ title: "To the Moon!",
585
+ content: "Tornado is coming back! Roger that! Starting the engine...",
586
+ timestamp: toBeTimestamp("2024-03-12T20:24:04.240Z"),
587
+ authors: [
588
+ {
589
+ usernames: [ { value: "stablepony" } ]
590
+ }
591
+ ],
592
+ categories: [ { name: "defi" } ],
593
+ links: [
594
+ {
595
+ value: "https://forum.degenrocket.space/?b=21&t=fog&c=samourai&h=hijack",
596
+ protocol: "https",
597
+ origin: "https://forum.degenrocket.space",
598
+ host: "forum.degenrocket.space",
599
+ pathname: "/",
600
+ search: "?b=21&t=fog&c=samourai&h=hijack",
601
+ originalProtocolKey: "url"
602
+ },
603
+ {
604
+ value: "https://forum.degenrocket.space/?l=terraforming",
605
+ protocol: "https",
606
+ origin: "https://forum.degenrocket.space",
607
+ host: "forum.degenrocket.space",
608
+ pathname: "/",
609
+ search: "?l=terraforming",
610
+ originalProtocolKey: "guid"
611
+ }
612
+ ],
613
+ keywords: [ "dark", "forest", "cookies" ],
614
+ source: {
615
+ name: "degenrocket.space"
334
616
  },
335
- reactions: {
336
- upvote: 3,
337
- downvote: null,
338
- bullish: 2,
339
- bearish: 0,
340
- important: null,
341
- scam: 1,
342
- comments_count: 3
343
- }
617
+ siblings: [
618
+ {
619
+ type: "SiblingWeb2V2",
620
+ protocol: { name: "web2" },
621
+ originalObject: {
622
+ id: 18081,
623
+ guid: "https://forum.degenrocket.space/?l=terraforming",
624
+ source: "degenrocket.space",
625
+ author: "stablepony",
626
+ tickers: "cookies",
627
+ title: "To the Moon!",
628
+ url: "https://forum.degenrocket.space/?b=21&t=fog&c=samourai&h=hijack",
629
+ description: "Tornado is coming back! Roger that! Starting the engine...",
630
+ pubdate: "2024-03-12T20:24:04.240Z",
631
+ category: "defi",
632
+ tags: ["dark", "forest"],
633
+ upvote: 3,
634
+ downvote: null,
635
+ bullish: 2,
636
+ bearish: 0,
637
+ important: 6,
638
+ scam: 1,
639
+ comments_count: 0,
640
+ latest_action_added_time: null
641
+ },
642
+ ids: [
643
+ {
644
+ value: "https://forum.degenrocket.space/?b=21&t=fog&c=samourai&h=hijack",
645
+ format: { name: "url" }
646
+ },
647
+ {
648
+ value: "https://forum.degenrocket.space/?l=terraforming",
649
+ format: { name: "guid" }
650
+ }
651
+ ]
652
+ }
653
+ ],
654
+ stats: [
655
+ {
656
+ action: "react",
657
+ contents: [
658
+ {
659
+ value: "upvote",
660
+ total: 3
661
+ },
662
+ {
663
+ value: "bullish",
664
+ total: 2
665
+ },
666
+ {
667
+ value: "bearish",
668
+ total: 0
669
+ },
670
+ {
671
+ value: "important",
672
+ total: 6
673
+ },
674
+ {
675
+ value: "scam",
676
+ total: 1
677
+ },
678
+ ]
679
+ },
680
+ {
681
+ action: "reply",
682
+ total: 0
683
+ }
684
+ ]
344
685
  }
345
686
  ```
346
687
 
@@ -0,0 +1,4 @@
1
+ import { UnknownEventV2, EventForSpasmid01, SpasmEventV2 } from "./../types/interfaces.js";
2
+ export declare const convertToEventForSpasmid: (unknownEvent: UnknownEventV2, idVersion?: string) => EventForSpasmid01 | null;
3
+ export declare const convertSpasmEventV2ToEventForSpasmid01: (spasmEvent: SpasmEventV2) => EventForSpasmid01 | null;
4
+ //# sourceMappingURL=convertToEventForSpasmid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertToEventForSpasmid.d.ts","sourceRoot":"","sources":["../../src.ts/convert/convertToEventForSpasmid.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAqBlC,eAAO,MAAM,wBAAwB,iBACrB,cAAc,yBAE3B,iBAAiB,GAAG,IA4BtB,CAAA;AAED,eAAO,MAAM,sCAAsC,eACrC,YAAY,KAEvB,iBAAiB,GAAG,IA4NtB,CAAA"}