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.
- package/README.md +454 -113
- package/lib.commonjs/convert/convertToEventForSpasmid.d.ts +4 -0
- package/lib.commonjs/convert/convertToEventForSpasmid.d.ts.map +1 -0
- package/lib.commonjs/convert/convertToEventForSpasmid.js +171 -0
- package/lib.commonjs/convert/convertToEventForSpasmid.js.map +1 -0
- package/lib.commonjs/convert/convertToSpasm.d.ts +17 -15
- package/lib.commonjs/convert/convertToSpasm.d.ts.map +1 -1
- package/lib.commonjs/convert/convertToSpasm.js +772 -265
- package/lib.commonjs/convert/convertToSpasm.js.map +1 -1
- package/lib.commonjs/convert/convertToSpasmEventDatabase.d.ts +4 -0
- package/lib.commonjs/convert/convertToSpasmEventDatabase.d.ts.map +1 -0
- package/lib.commonjs/convert/convertToSpasmEventDatabase.js +130 -0
- package/lib.commonjs/convert/convertToSpasmEventDatabase.js.map +1 -0
- package/lib.commonjs/convert/index.d.ts +2 -0
- package/lib.commonjs/convert/index.d.ts.map +1 -1
- package/lib.commonjs/convert/index.js +5 -1
- package/lib.commonjs/convert/index.js.map +1 -1
- package/lib.commonjs/id/getSpasmId.d.ts +4 -0
- package/lib.commonjs/id/getSpasmId.d.ts.map +1 -0
- package/lib.commonjs/id/getSpasmId.js +31 -0
- package/lib.commonjs/id/getSpasmId.js.map +1 -0
- package/lib.commonjs/id/index.d.ts +2 -0
- package/lib.commonjs/id/index.d.ts.map +1 -0
- package/lib.commonjs/id/index.js +6 -0
- package/lib.commonjs/id/index.js.map +1 -0
- package/lib.commonjs/identify/identifyEvent.d.ts.map +1 -1
- package/lib.commonjs/identify/identifyEvent.js +13 -5
- package/lib.commonjs/identify/identifyEvent.js.map +1 -1
- package/lib.commonjs/sort/index.d.ts +2 -0
- package/lib.commonjs/sort/index.d.ts.map +1 -0
- package/lib.commonjs/sort/index.js +6 -0
- package/lib.commonjs/sort/index.js.map +1 -0
- package/lib.commonjs/sort/sortEventForSpasmid.d.ts +3 -0
- package/lib.commonjs/sort/sortEventForSpasmid.d.ts.map +1 -0
- package/lib.commonjs/sort/sortEventForSpasmid.js +15 -0
- package/lib.commonjs/sort/sortEventForSpasmid.js.map +1 -0
- package/lib.commonjs/spasm.d.ts +5 -3
- package/lib.commonjs/spasm.d.ts.map +1 -1
- package/lib.commonjs/spasm.js +4 -5
- package/lib.commonjs/spasm.js.map +1 -1
- package/lib.commonjs/types/index.d.ts +1 -1
- package/lib.commonjs/types/index.d.ts.map +1 -1
- package/lib.commonjs/types/interfaces.d.ts +468 -90
- package/lib.commonjs/types/interfaces.d.ts.map +1 -1
- package/lib.commonjs/types/interfaces.js +2 -0
- package/lib.commonjs/types/interfaces.js.map +1 -1
- package/lib.commonjs/utils/nostrUtils.d.ts +10 -2
- package/lib.commonjs/utils/nostrUtils.d.ts.map +1 -1
- package/lib.commonjs/utils/nostrUtils.js +122 -22
- package/lib.commonjs/utils/nostrUtils.js.map +1 -1
- package/lib.commonjs/utils/utils.d.ts +26 -1
- package/lib.commonjs/utils/utils.d.ts.map +1 -1
- package/lib.commonjs/utils/utils.js +723 -3
- package/lib.commonjs/utils/utils.js.map +1 -1
- package/lib.esm/convert/convertToEventForSpasmid.d.ts +4 -0
- package/lib.esm/convert/convertToEventForSpasmid.d.ts.map +1 -0
- package/lib.esm/convert/convertToEventForSpasmid.js +168 -0
- package/lib.esm/convert/convertToEventForSpasmid.js.map +1 -0
- package/lib.esm/convert/convertToSpasm.d.ts +17 -15
- package/lib.esm/convert/convertToSpasm.d.ts.map +1 -1
- package/lib.esm/convert/convertToSpasm.js +759 -251
- package/lib.esm/convert/convertToSpasm.js.map +1 -1
- package/lib.esm/convert/convertToSpasmEventDatabase.d.ts +4 -0
- package/lib.esm/convert/convertToSpasmEventDatabase.d.ts.map +1 -0
- package/lib.esm/convert/convertToSpasmEventDatabase.js +137 -0
- package/lib.esm/convert/convertToSpasmEventDatabase.js.map +1 -0
- package/lib.esm/convert/index.d.ts +2 -0
- package/lib.esm/convert/index.d.ts.map +1 -1
- package/lib.esm/convert/index.js +2 -0
- package/lib.esm/convert/index.js.map +1 -1
- package/lib.esm/id/getSpasmId.d.ts +4 -0
- package/lib.esm/id/getSpasmId.d.ts.map +1 -0
- package/lib.esm/id/getSpasmId.js +31 -0
- package/lib.esm/id/getSpasmId.js.map +1 -0
- package/lib.esm/id/index.d.ts +2 -0
- package/lib.esm/id/index.d.ts.map +1 -0
- package/lib.esm/id/index.js +2 -0
- package/lib.esm/id/index.js.map +1 -0
- package/lib.esm/identify/identifyEvent.d.ts.map +1 -1
- package/lib.esm/identify/identifyEvent.js +13 -5
- package/lib.esm/identify/identifyEvent.js.map +1 -1
- package/lib.esm/sort/index.d.ts +2 -0
- package/lib.esm/sort/index.d.ts.map +1 -0
- package/lib.esm/sort/index.js +2 -0
- package/lib.esm/sort/index.js.map +1 -0
- package/lib.esm/sort/sortEventForSpasmid.d.ts +3 -0
- package/lib.esm/sort/sortEventForSpasmid.d.ts.map +1 -0
- package/lib.esm/sort/sortEventForSpasmid.js +17 -0
- package/lib.esm/sort/sortEventForSpasmid.js.map +1 -0
- package/lib.esm/spasm.d.ts +5 -3
- package/lib.esm/spasm.d.ts.map +1 -1
- package/lib.esm/spasm.js +4 -2
- package/lib.esm/spasm.js.map +1 -1
- package/lib.esm/types/index.d.ts +1 -1
- package/lib.esm/types/index.d.ts.map +1 -1
- package/lib.esm/types/interfaces.d.ts +468 -90
- package/lib.esm/types/interfaces.d.ts.map +1 -1
- package/lib.esm/types/interfaces.js +2 -0
- package/lib.esm/types/interfaces.js.map +1 -1
- package/lib.esm/utils/nostrUtils.d.ts +10 -2
- package/lib.esm/utils/nostrUtils.d.ts.map +1 -1
- package/lib.esm/utils/nostrUtils.js +119 -21
- package/lib.esm/utils/nostrUtils.js.map +1 -1
- package/lib.esm/utils/utils.d.ts +26 -1
- package/lib.esm/utils/utils.d.ts.map +1 -1
- package/lib.esm/utils/utils.js +701 -2
- package/lib.esm/utils/utils.js.map +1 -1
- package/package.json +9 -2
- package/src.ts/convert/convertToEventForSpasmid.ts +289 -0
- package/src.ts/convert/convertToSpasm.ts +962 -292
- package/src.ts/convert/convertToSpasmEventDatabase.ts +204 -0
- package/src.ts/convert/index.ts +2 -0
- package/src.ts/docs/architecture.md +413 -0
- package/src.ts/id/getSpasmId.ts +56 -0
- package/src.ts/id/index.ts +1 -0
- package/src.ts/identify/identifyEvent.ts +12 -5
- package/src.ts/sort/index.ts +1 -0
- package/src.ts/sort/sortEventForSpasmid.ts +30 -0
- package/src.ts/spasm.ts +5 -3
- package/src.ts/types/index.ts +1 -1
- package/src.ts/types/interfaces.ts +729 -125
- package/src.ts/utils/nostrUtils.ts +150 -22
- 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
|
|
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
|
-
|
|
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.
|
|
33
|
-
- `spasmEvent.
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
|
528
|
+
Here is a Spasm event v0 with an RSS item:
|
|
279
529
|
|
|
280
530
|
```typescript
|
|
281
|
-
const event:
|
|
282
|
-
id:
|
|
283
|
-
guid: "https://
|
|
284
|
-
source: "
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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:
|
|
542
|
+
tags: ["dark", "forest"],
|
|
292
543
|
upvote: 3,
|
|
293
544
|
downvote: null,
|
|
294
545
|
bullish: 2,
|
|
295
546
|
bearish: 0,
|
|
296
|
-
important:
|
|
547
|
+
important: 6,
|
|
297
548
|
scam: 1,
|
|
298
|
-
comments_count:
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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: "
|
|
327
|
-
content: "
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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"}
|