spasm.js 0.1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +349 -0
- package/jest.config.js +7 -0
- package/lib.commonjs/convert/convertToSpasm.d.ts +16 -0
- package/lib.commonjs/convert/convertToSpasm.d.ts.map +1 -0
- package/lib.commonjs/convert/convertToSpasm.js +505 -0
- package/lib.commonjs/convert/convertToSpasm.js.map +1 -0
- package/lib.commonjs/convert/index.d.ts +2 -0
- package/lib.commonjs/convert/index.d.ts.map +1 -0
- package/lib.commonjs/convert/index.js +6 -0
- package/lib.commonjs/convert/index.js.map +1 -0
- package/lib.commonjs/identify/identifyEvent.d.ts +64 -0
- package/lib.commonjs/identify/identifyEvent.d.ts.map +1 -0
- package/lib.commonjs/{identifyEvent.js → identify/identifyEvent.js} +118 -183
- package/lib.commonjs/identify/identifyEvent.js.map +1 -0
- package/lib.commonjs/identify/index.d.ts +2 -0
- package/lib.commonjs/identify/index.d.ts.map +1 -0
- package/lib.commonjs/identify/index.js +6 -0
- package/lib.commonjs/identify/index.js.map +1 -0
- package/lib.commonjs/index.d.ts +4 -0
- package/lib.commonjs/index.d.ts.map +1 -0
- package/lib.commonjs/index.js +30 -4
- package/lib.commonjs/index.js.map +1 -1
- package/lib.commonjs/spasm.d.ts +5 -0
- package/lib.commonjs/spasm.d.ts.map +1 -0
- package/lib.commonjs/spasm.js +23 -0
- package/lib.commonjs/spasm.js.map +1 -0
- package/lib.commonjs/types/index.d.ts +2 -0
- package/lib.commonjs/types/index.d.ts.map +1 -0
- package/lib.commonjs/types/index.js +3 -0
- package/lib.commonjs/types/index.js.map +1 -0
- package/lib.commonjs/types/interfaces.d.ts +234 -0
- package/lib.commonjs/types/interfaces.d.ts.map +1 -0
- package/lib.commonjs/types/interfaces.js.map +1 -0
- package/lib.commonjs/utils/index.d.ts +3 -0
- package/lib.commonjs/utils/index.d.ts.map +1 -0
- package/lib.commonjs/utils/index.js +19 -0
- package/lib.commonjs/utils/index.js.map +1 -0
- package/lib.commonjs/utils/nostrUtils.d.ts +8 -0
- package/lib.commonjs/utils/nostrUtils.d.ts.map +1 -0
- package/lib.commonjs/utils/nostrUtils.js +176 -0
- package/lib.commonjs/utils/nostrUtils.js.map +1 -0
- package/lib.commonjs/utils/utils.d.ts +8 -0
- package/lib.commonjs/utils/utils.d.ts.map +1 -0
- package/lib.commonjs/utils/utils.js +124 -0
- package/lib.commonjs/utils/utils.js.map +1 -0
- package/lib.esm/convert/convertToSpasm.d.ts +16 -0
- package/lib.esm/convert/convertToSpasm.d.ts.map +1 -0
- package/lib.esm/convert/convertToSpasm.js +488 -0
- package/lib.esm/convert/convertToSpasm.js.map +1 -0
- package/lib.esm/convert/index.d.ts +2 -0
- package/lib.esm/convert/index.d.ts.map +1 -0
- package/lib.esm/convert/index.js +2 -0
- package/lib.esm/convert/index.js.map +1 -0
- package/lib.esm/identify/identifyEvent.d.ts +64 -0
- package/lib.esm/identify/identifyEvent.d.ts.map +1 -0
- package/lib.esm/{identifyEvent.js → identify/identifyEvent.js} +116 -174
- package/lib.esm/identify/identifyEvent.js.map +1 -0
- package/lib.esm/identify/index.d.ts +2 -0
- package/lib.esm/identify/index.d.ts.map +1 -0
- package/lib.esm/identify/index.js +2 -0
- package/lib.esm/identify/index.js.map +1 -0
- package/lib.esm/index.d.ts +4 -0
- package/lib.esm/index.d.ts.map +1 -0
- package/lib.esm/index.js +3 -2
- package/lib.esm/index.js.map +1 -1
- package/lib.esm/spasm.d.ts +5 -0
- package/lib.esm/spasm.d.ts.map +1 -0
- package/lib.esm/spasm.js +4 -0
- package/lib.esm/spasm.js.map +1 -0
- package/lib.esm/types/index.d.ts +2 -0
- package/lib.esm/types/index.d.ts.map +1 -0
- package/lib.esm/types/index.js +2 -0
- package/lib.esm/types/index.js.map +1 -0
- package/lib.esm/types/interfaces.d.ts +234 -0
- package/lib.esm/types/interfaces.d.ts.map +1 -0
- package/lib.esm/types/interfaces.js.map +1 -0
- package/lib.esm/utils/index.d.ts +3 -0
- package/lib.esm/utils/index.d.ts.map +1 -0
- package/lib.esm/utils/index.js +3 -0
- package/lib.esm/utils/index.js.map +1 -0
- package/lib.esm/utils/nostrUtils.d.ts +8 -0
- package/lib.esm/utils/nostrUtils.d.ts.map +1 -0
- package/lib.esm/utils/nostrUtils.js +167 -0
- package/lib.esm/utils/nostrUtils.js.map +1 -0
- package/lib.esm/utils/utils.d.ts +8 -0
- package/lib.esm/utils/utils.d.ts.map +1 -0
- package/lib.esm/utils/utils.js +115 -0
- package/lib.esm/utils/utils.js.map +1 -0
- package/package.json +23 -2
- package/src.ts/convert/convertToSpasm.ts +687 -0
- package/src.ts/convert/index.ts +1 -0
- package/src.ts/{identifyEvent.ts → identify/identifyEvent.ts} +38 -296
- package/src.ts/identify/index.ts +1 -0
- package/src.ts/index.ts +4 -2
- package/src.ts/spasm.ts +6 -0
- package/src.ts/types/index.ts +1 -0
- package/src.ts/{interfaces.ts → types/interfaces.ts} +89 -19
- package/src.ts/utils/index.ts +3 -0
- package/src.ts/utils/nostrUtils.ts +223 -0
- package/src.ts/utils/utils.ts +145 -0
- package/lib.commonjs/identifyEvent.js.map +0 -1
- package/lib.commonjs/interfaces.js.map +0 -1
- package/lib.commonjs/utils.js +0 -36
- package/lib.commonjs/utils.js.map +0 -1
- package/lib.esm/identifyEvent.js.map +0 -1
- package/lib.esm/interfaces.js.map +0 -1
- package/lib.esm/utils.js +0 -31
- package/lib.esm/utils.js.map +0 -1
- package/src.ts/utils.ts +0 -33
- /package/lib.commonjs/{interfaces.js → types/interfaces.js} +0 -0
- /package/lib.esm/{interfaces.js → types/interfaces.js} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
Signer and Protocol Agnostic Social Media (SPASM)
|
|
2
|
+
=================================================
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
|
|
6
|
+
The future of social media is agnostic to signing keys, messaging formats, transport protocols and storage infrastructure. However, such design places significant burden on developers, who must maintain a myriad of protocols, formats, and architectures.
|
|
7
|
+
|
|
8
|
+
This library simplifies the process by encapsulating the complexities of various messaging formats into a single, standardized JSON object. By abstracting the underlying differences between these formats, it provides a unified interface for developers to work with, ensuring consistency and reducing the need for custom handling of each format.
|
|
9
|
+
|
|
10
|
+
For instance, instead of maintaining three distinct versions of the frontend (UI) and three separate database tables for three different messaging formats, developers can leverage this library to standardize all messages into a single format. This approach simplifies the architecture by consolidating the database tables into one and requiring only a single version of the UI, with minor adjustments as needed.
|
|
11
|
+
|
|
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
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
export type UnknownEvent =
|
|
16
|
+
DmpEvent |
|
|
17
|
+
DmpEventSignedClosed |
|
|
18
|
+
DmpEventSignedOpened |
|
|
19
|
+
NostrEvent |
|
|
20
|
+
NostrEventSignedOpened |
|
|
21
|
+
NostrSpasmEvent |
|
|
22
|
+
NostrSpasmEventSignedOpened |
|
|
23
|
+
SpasmEvent
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
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
|
+
- `spasmEvent.action`
|
|
30
|
+
- `spasmEvent.content`
|
|
31
|
+
- `spasmEvent.timestamp`
|
|
32
|
+
- `spasmEvent.signature`
|
|
33
|
+
- `spasmEvent.parentEvent`
|
|
34
|
+
|
|
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`
|
|
41
|
+
|
|
42
|
+
See the full list of properties of `SpasmEvent` at `./src.ts/types/interfaces.ts`.
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
- identify web2 posts and web3 events
|
|
47
|
+
|
|
48
|
+
- convert web2 posts and web3 events to Spasm event
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install spasm.js
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
#### CommonJS (require)
|
|
59
|
+
|
|
60
|
+
Option 1. Import separate functions:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
const {identifyObject} = require('spasm.js')
|
|
64
|
+
const {convertToSpasm} = require('spasm.js')
|
|
65
|
+
|
|
66
|
+
const event = {
|
|
67
|
+
// some event
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Identify the event
|
|
71
|
+
const info = identifyObject(event)
|
|
72
|
+
|
|
73
|
+
// Convert to Spasm
|
|
74
|
+
const spasmEvent = convertToSpasm(event)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Option 2. Import all functions:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
const spasm = require('spasm.js')
|
|
81
|
+
|
|
82
|
+
const event = {
|
|
83
|
+
// some event
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Identify the event
|
|
87
|
+
const info = spasm.identifyObject(event)
|
|
88
|
+
|
|
89
|
+
// Convert to Spasm
|
|
90
|
+
const spasmEvent = spasm.convertToSpasm(event)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### ESM (import)
|
|
94
|
+
|
|
95
|
+
Option 1. Import separate functions:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
import {identifyObject} from 'spasm.js'
|
|
99
|
+
import {convertToSpasm} from 'spasm.js'
|
|
100
|
+
|
|
101
|
+
const event = {
|
|
102
|
+
// some event
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Identify the event
|
|
106
|
+
const info = identifyObject(event)
|
|
107
|
+
|
|
108
|
+
// Convert to Spasm
|
|
109
|
+
const spasmEvent = convertToSpasm(event)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Option 2. Import all functions:
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
import * as spasm from 'spasm.js'
|
|
116
|
+
|
|
117
|
+
const event = {
|
|
118
|
+
// some event
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Identify the event
|
|
122
|
+
const info = spasm.identifyObject(event)
|
|
123
|
+
|
|
124
|
+
// Convert to Spasm
|
|
125
|
+
const spasmEvent = spasm.convertToSpasm(event)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Examples
|
|
129
|
+
|
|
130
|
+
### Convert DmpEventSignedClosed to Spasm
|
|
131
|
+
|
|
132
|
+
Here is a signed DMP event:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
const event: DmpEventSignedClosed = {
|
|
136
|
+
signer: "0xf8553015220a857eda377a1e903c9e5afb3ac2fa",
|
|
137
|
+
signature: "0xbd934a01dc3bd9bb183bda807d35e61accf7396c527b8a3d029c20c00b294cf029997be953772da32483b077eea856e6bafcae7a2aff95ae572af25dd3e204a71b",
|
|
138
|
+
signedString: "{\"version\":\"dmp_v0.0.1\",\"time\":\"2022-01-01T22:04:46.178Z\",\"action\":\"post\",\"target\":\"\",\"title\":\"genesis\",\"text\":\"not your keys, not your words\",\"license\":\"MIT\"}"
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Here is the result of `identifyEvent(event)`
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
const output = {
|
|
146
|
+
eventInfo: {
|
|
147
|
+
baseProtocol: "dmp",
|
|
148
|
+
hasExtraSpasmFields: false,
|
|
149
|
+
hasSignature: true,
|
|
150
|
+
isSpasmCompatible: true,
|
|
151
|
+
license: "MIT",
|
|
152
|
+
privateKeyType: "ethereum",
|
|
153
|
+
type: "DmpEventSignedClosed"
|
|
154
|
+
},
|
|
155
|
+
eventIsSealed: false,
|
|
156
|
+
eventIsSealedUnderKeyName: false,
|
|
157
|
+
webType: "web3"
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Here is how the event looks like after converting to Spasm:
|
|
162
|
+
|
|
163
|
+
```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',
|
|
178
|
+
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'
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Convert NostrSpasmEventSignedOpened to Spasm
|
|
199
|
+
|
|
200
|
+
Here is a signed Nostr event with extra Spasm tags:
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
export const event: NostrSpasmEventSignedOpened = {
|
|
204
|
+
kind: 1,
|
|
205
|
+
created_at: 1705462957,
|
|
206
|
+
tags:[
|
|
207
|
+
["license","SPDX-License-Identifier: CC0-1.0"],
|
|
208
|
+
["spasm_version","1.0.0"],
|
|
209
|
+
["spasm_action","post"],
|
|
210
|
+
["spasm_title","Nostr Spasm genesis"]
|
|
211
|
+
],
|
|
212
|
+
content: "Walled gardens became prisons, and Spasm is the second step towards tearing down the prison walls.",
|
|
213
|
+
pubkey: "2d2d9f19a98e533c27500e5f056a2a56db8fe92393e7a2135db63ad300486f42",
|
|
214
|
+
id: "db300d320853b25b57fa03c586d18f69ad9786ec5e21114253fc3762b22a5651",
|
|
215
|
+
sig: "db60516accfc025582bf556e3c7660c89e3982d2a656201aaea4189c6d3e3779b202c60302e55ad782ca711df20550384516abe4d7387470bc83ac757ed8f0f1"
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Here is the result of `identifyEvent(event)`
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
const output = {
|
|
223
|
+
eventInfo: {
|
|
224
|
+
baseProtocol: "nostr",
|
|
225
|
+
hasExtraSpasmFields: true,
|
|
226
|
+
hasSignature: true,
|
|
227
|
+
isSpasmCompatible: true,
|
|
228
|
+
license: "SPDX-License-Identifier: CC0-1.0",
|
|
229
|
+
privateKeyType: "nostr",
|
|
230
|
+
type: "NostrSpasmEventSignedOpened"
|
|
231
|
+
},
|
|
232
|
+
eventIsSealed: false,
|
|
233
|
+
eventIsSealedUnderKeyName: false,
|
|
234
|
+
webType: "web3"
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Here is how the event looks like after converting to Spasm:
|
|
239
|
+
|
|
240
|
+
```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.',
|
|
255
|
+
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'
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Convert RssItem to Spasm
|
|
277
|
+
|
|
278
|
+
Here is a post with an RSS item:
|
|
279
|
+
|
|
280
|
+
```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",
|
|
290
|
+
category: "defi",
|
|
291
|
+
tags: null,
|
|
292
|
+
upvote: 3,
|
|
293
|
+
downvote: null,
|
|
294
|
+
bullish: 2,
|
|
295
|
+
bearish: 0,
|
|
296
|
+
important: null,
|
|
297
|
+
scam: 1,
|
|
298
|
+
comments_count: 3,
|
|
299
|
+
latest_action_added_time: null
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Here is the result of `identifyEvent(event)`
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
const output = {
|
|
307
|
+
eventInfo: false,
|
|
308
|
+
eventIsSealed: false,
|
|
309
|
+
eventIsSealedUnderKeyName: false,
|
|
310
|
+
webType: "web2"
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Here is how the event looks like after converting to Spasm:
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
const spasmEvent: SpasmEvent = {
|
|
318
|
+
meta: {
|
|
319
|
+
hasExtraSpasmFields: false,
|
|
320
|
+
convertedFrom: "unknown",
|
|
321
|
+
},
|
|
322
|
+
spasmVersion: "1.0.0",
|
|
323
|
+
eventId: "https://thedefiant.io/starknet-unveils-token-launch-plans",
|
|
324
|
+
dbId: 7188,
|
|
325
|
+
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"
|
|
334
|
+
},
|
|
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
|
+
}
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## License
|
|
348
|
+
|
|
349
|
+
MIT License
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { KnownPostOrEventInfo, UnknownPostOrEvent, DmpEvent, DmpEventSignedClosed, DmpEventSignedOpened, NostrEvent, NostrEventSignedOpened, NostrSpasmEvent, NostrSpasmEventSignedOpened, Post, SpasmEvent, SpasmEventSigned } from "./../types/interfaces";
|
|
2
|
+
export declare const standardizePostOrEvent: (unknownPostOrEvent: UnknownPostOrEvent, info?: KnownPostOrEventInfo) => SpasmEvent | null;
|
|
3
|
+
export declare const standardizeDmpEvent: (event: DmpEvent) => SpasmEvent | null;
|
|
4
|
+
export declare const standardizeDmpEventSignedClosed: (event: DmpEventSignedClosed) => SpasmEventSigned | null;
|
|
5
|
+
export declare const standardizeDmpEventSignedOpened: (event: DmpEventSignedOpened) => SpasmEvent | null;
|
|
6
|
+
export declare const standardizeNostrEvent: (event: NostrEvent) => SpasmEvent | null;
|
|
7
|
+
export declare const standardizeNostrSpasmEvent: (event: NostrSpasmEvent) => SpasmEvent | null;
|
|
8
|
+
export declare const standardizeNostrEventSignedOpened: (event: NostrEventSignedOpened) => SpasmEvent | null;
|
|
9
|
+
export declare const standardizeNostrSpasmEventSignedOpened: (event: NostrSpasmEventSignedOpened) => SpasmEvent | null;
|
|
10
|
+
export declare const standardizePostWithDmpEventSignedClosed: (post: Post) => SpasmEvent | null;
|
|
11
|
+
export declare const standardizePostWithNostrEventSignedOpened: (post: Post) => SpasmEvent | null;
|
|
12
|
+
export declare const standardizePostWithNostrSpasmEventSignedOpened: (post: Post) => SpasmEvent | null;
|
|
13
|
+
export declare const standardizePostWithRssItem: (post: Post) => SpasmEvent | null;
|
|
14
|
+
export declare const addFieldsFromEnvelopePost: (post: Post, spasmEvent: SpasmEvent) => SpasmEvent;
|
|
15
|
+
export declare const convertToSpasm: (unknownPostOrEvent: UnknownPostOrEvent) => SpasmEvent | null;
|
|
16
|
+
//# sourceMappingURL=convertToSpasm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertToSpasm.d.ts","sourceRoot":"","sources":["../../src.ts/convert/convertToSpasm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,2BAA2B,EAC3B,IAAI,EACJ,UAAU,EACV,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAmB/B,eAAO,MAAM,sBAAsB,uBACb,kBAAkB,SAC/B,oBAAoB,KAC1B,UAAU,GAAG,IAoKf,CAAA;AAGD,eAAO,MAAM,mBAAmB,UACvB,QAAQ,KACd,UAAU,GAAG,IA2Bf,CAAA;AAGD,eAAO,MAAM,+BAA+B,UACnC,oBAAoB,KAC1B,gBAAgB,GAAG,IAiCrB,CAAA;AAGD,eAAO,MAAM,+BAA+B,UACnC,oBAAoB,KAC1B,UAAU,GAAG,IA4Bf,CAAA;AAGD,eAAO,MAAM,qBAAqB,UACzB,UAAU,KAChB,UAAU,GAAG,IAiDf,CAAA;AAGD,eAAO,MAAM,0BAA0B,UAC9B,eAAe,KACrB,UAAU,GAAG,IAiEf,CAAA;AAGD,eAAO,MAAM,iCAAiC,UACrC,sBAAsB,KAC5B,UAAU,GAAG,IA4Bf,CAAA;AAGD,eAAO,MAAM,sCAAsC,UAC1C,2BAA2B,KACjC,UAAU,GAAG,IA6Bf,CAAA;AAGD,eAAO,MAAM,uCAAuC,SAC5C,IAAI,KACT,UAAU,GAAG,IA4Bf,CAAA;AAGD,eAAO,MAAM,yCAAyC,SAC9C,IAAI,KACT,UAAU,GAAG,IAef,CAAA;AAGD,eAAO,MAAM,8CAA8C,SACnD,IAAI,KACT,UAAU,GAAG,IAef,CAAA;AAGD,eAAO,MAAM,0BAA0B,SAC/B,IAAI,KACT,UAAU,GAAG,IAsCf,CAAA;AAED,eAAO,MAAM,yBAAyB,SAC9B,IAAI,cACE,UAAU,KACrB,UAkEF,CAAA;AAED,eAAO,MAAM,cAAc,uBACL,kBAAkB,KACrC,UAAU,GAAG,IAEf,CAAA"}
|