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
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertSpasmEventV2ToEventForSpasmid01 = exports.convertToEventForSpasmid = void 0;
4
+ const convertToSpasm_js_1 = require("./convertToSpasm.js");
5
+ const utils_js_1 = require("./../utils/utils.js");
6
+ // Spasm V2
7
+ const convertToEventForSpasmid = (unknownEvent, idVersion = "01") => {
8
+ let spasmEventV2 = {
9
+ type: "SpasmEventV2"
10
+ };
11
+ // SpasmEventV2
12
+ if ('type' in unknownEvent &&
13
+ unknownEvent.type === "SpasmEventV2") {
14
+ spasmEventV2 = unknownEvent;
15
+ }
16
+ else {
17
+ spasmEventV2 = (0, convertToSpasm_js_1.convertToSpasm)(unknownEvent, "2.0.0");
18
+ }
19
+ if (!spasmEventV2)
20
+ return null;
21
+ if (idVersion === "01") {
22
+ const eventForSpasmid01 = (0, exports.convertSpasmEventV2ToEventForSpasmid01)(spasmEventV2);
23
+ return eventForSpasmid01;
24
+ }
25
+ return null;
26
+ };
27
+ exports.convertToEventForSpasmid = convertToEventForSpasmid;
28
+ const convertSpasmEventV2ToEventForSpasmid01 = (spasmEvent) => {
29
+ if (!(0, utils_js_1.isObjectWithValues)(spasmEvent))
30
+ return null;
31
+ if (spasmEvent.type !== "SpasmEventV2")
32
+ return null;
33
+ const eventForSpasmid = {};
34
+ if (spasmEvent.parent) {
35
+ // Only 'ids' and 'marker' of a parent are used for Spasm ID
36
+ const cleanParent = (0, utils_js_1.keepTheseKeysInObject)(spasmEvent.parent, ["ids", "marker"]);
37
+ const sortedParent = (0, utils_js_1.sortParentForSpasmid01)(cleanParent);
38
+ eventForSpasmid.parent = sortedParent;
39
+ }
40
+ if (spasmEvent.action) {
41
+ eventForSpasmid.action = spasmEvent.action;
42
+ }
43
+ if (spasmEvent.title) {
44
+ eventForSpasmid.title = spasmEvent.title;
45
+ }
46
+ if (spasmEvent.content) {
47
+ eventForSpasmid.content = spasmEvent.content;
48
+ }
49
+ if (spasmEvent.timestamp) {
50
+ eventForSpasmid.timestamp = spasmEvent.timestamp;
51
+ }
52
+ if (spasmEvent.authors) {
53
+ /**
54
+ * The 'hosts' key is not used for the Spasm ID, because
55
+ * a user might submit an already signed event to a new
56
+ * instance with different hosts.
57
+ */
58
+ const cleanAuthors = (0, utils_js_1.keepTheseKeysInObjectsInArray)(spasmEvent.authors, ["addresses", "usernames", "marker"]);
59
+ const sortedAuthors = (0, utils_js_1.sortAuthorsForSpasmid01)(cleanAuthors);
60
+ eventForSpasmid.authors = sortedAuthors;
61
+ }
62
+ if (spasmEvent.tips) {
63
+ eventForSpasmid.tips = (0, utils_js_1.sortArrayOfObjects)(spasmEvent.tips, "address");
64
+ }
65
+ if (spasmEvent.hosts) {
66
+ const cleanHosts = (0, utils_js_1.keepTheseKeysInObjectsInArray)(spasmEvent.hosts, ["value", "marker"]);
67
+ const sortedHosts = (0, utils_js_1.sortHostsForSpasmid01)(cleanHosts);
68
+ eventForSpasmid.hosts = sortedHosts;
69
+ }
70
+ if (spasmEvent.links) {
71
+ const cleanLinks = (0, utils_js_1.keepTheseKeysInObjectsInArray)(spasmEvent.links, ["value", "marker"]);
72
+ const sortedLinks = (0, utils_js_1.sortLinksForSpasmid01)(cleanLinks);
73
+ eventForSpasmid.links = sortedLinks;
74
+ }
75
+ if (spasmEvent.keywords) {
76
+ eventForSpasmid.keywords =
77
+ (0, utils_js_1.sortArrayOfStringsAndNumbers)(spasmEvent.keywords);
78
+ }
79
+ if (spasmEvent.tags) {
80
+ eventForSpasmid.tags = (0, utils_js_1.sortTagsForSpasmid01)(spasmEvent.tags);
81
+ }
82
+ if (spasmEvent.medias) {
83
+ const sortedMedias = (0, utils_js_1.sortMediasForSpasmid01)(spasmEvent.medias);
84
+ eventForSpasmid.medias = sortedMedias;
85
+ }
86
+ if (spasmEvent.references) {
87
+ const cleanReferences = (0, utils_js_1.keepTheseKeysInObjectsInArray)(spasmEvent.references, ["ids", "marker"]);
88
+ const sortedReferences = (0, utils_js_1.sortReferencesForSpasmid01)(cleanReferences);
89
+ eventForSpasmid.references = sortedReferences;
90
+ }
91
+ if (spasmEvent.mentions) {
92
+ /**
93
+ * The 'hosts' key is not used for the Spasm ID, because
94
+ * a user might submit an already signed event to a new
95
+ * instance with different hosts.
96
+ */
97
+ const cleanMentions = (0, utils_js_1.keepTheseKeysInObjectsInArray)(spasmEvent.mentions, ["addresses", "usernames", "marker"]);
98
+ // Mentions is the same as authors in V2
99
+ const sortedMentions = (0, utils_js_1.sortAuthorsForSpasmid01)(cleanMentions);
100
+ eventForSpasmid.mentions = sortedMentions;
101
+ }
102
+ if (spasmEvent.proofs) {
103
+ eventForSpasmid.proofs = (0, utils_js_1.sortArrayOfObjects)(spasmEvent.proofs, "value");
104
+ // Sort proofs.links
105
+ eventForSpasmid.proofs.forEach((proof, index) => {
106
+ if (proof && proof.links &&
107
+ Array.isArray(proof.links) &&
108
+ proof.links[0]) {
109
+ const cleanLinks = (0, utils_js_1.keepTheseKeysInObjectsInArray)(proof.links, ["value", "marker"]);
110
+ const sortedLinks = (0, utils_js_1.sortLinksForSpasmid01)(cleanLinks);
111
+ if (eventForSpasmid.proofs &&
112
+ Array.isArray(eventForSpasmid.proofs)) {
113
+ eventForSpasmid.proofs[index].links = sortedLinks;
114
+ }
115
+ }
116
+ });
117
+ }
118
+ if (spasmEvent.license) {
119
+ eventForSpasmid.license = spasmEvent.license;
120
+ }
121
+ if (spasmEvent.language) {
122
+ eventForSpasmid.language = spasmEvent.language;
123
+ }
124
+ if (spasmEvent.extra) {
125
+ eventForSpasmid.extra = spasmEvent.extra;
126
+ }
127
+ /*
128
+ * Only one POW is used to calculate the Spasm ID,
129
+ * other POWs might be attached to satistify requirements
130
+ * on certain instances/relays, but they should not affect
131
+ * the Spasm ID, because a user can sign many siblings for
132
+ * the same event with many different POW values.
133
+ */
134
+ if (spasmEvent.pows &&
135
+ Array.isArray(spasmEvent.pows) &&
136
+ spasmEvent.pows[0]) {
137
+ // Find a POW with "spasmid01" marker
138
+ spasmEvent.pows.forEach(pow => {
139
+ if (pow && "marker" in pow &&
140
+ pow.marker === "spasmid01") {
141
+ // If multple spasmid01 are found, then keep
142
+ // the one with the highest difficulty.
143
+ if (!eventForSpasmid.pows) {
144
+ eventForSpasmid.pows = [pow];
145
+ }
146
+ else if (eventForSpasmid.pows &&
147
+ Array.isArray(eventForSpasmid.pows) &&
148
+ eventForSpasmid.pows[0] &&
149
+ eventForSpasmid.pows[0].difficulty &&
150
+ typeof (eventForSpasmid.pows[0].difficulty) === "number" &&
151
+ pow.difficulty &&
152
+ typeof (pow.difficulty) === "number" &&
153
+ eventForSpasmid.pows[0].difficulty < pow.difficulty) {
154
+ eventForSpasmid.pows = [pow];
155
+ }
156
+ }
157
+ });
158
+ // Sort words inside POW
159
+ if (eventForSpasmid.pows &&
160
+ Array.isArray(eventForSpasmid.pows) &&
161
+ eventForSpasmid.pows[0] &&
162
+ eventForSpasmid.pows[0].words &&
163
+ Array.isArray(eventForSpasmid.pows[0].words)) {
164
+ eventForSpasmid.pows[0].words =
165
+ (0, utils_js_1.sortArrayOfStringsAndNumbers)(eventForSpasmid.pows[0].words);
166
+ }
167
+ }
168
+ return eventForSpasmid;
169
+ };
170
+ exports.convertSpasmEventV2ToEventForSpasmid01 = convertSpasmEventV2ToEventForSpasmid01;
171
+ //# sourceMappingURL=convertToEventForSpasmid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertToEventForSpasmid.js","sourceRoot":"","sources":["../../src.ts/convert/convertToEventForSpasmid.ts"],"names":[],"mappings":";;;AAaA,2DAAoD;AAEpD,kDAc6B;AAE7B,WAAW;AACJ,MAAM,wBAAwB,GAAG,CACtC,YAA4B,EAC5B,SAAS,GAAG,IAAI,EACU,EAAE;IAE5B,IAAI,YAAY,GAAwB;QACtC,IAAI,EAAE,cAAc;KACrB,CAAA;IAED,eAAe;IACf,IACE,MAAM,IAAI,YAAY;QACtB,YAAY,CAAC,IAAI,KAAK,cAAc,EACpC,CAAC;QACD,YAAY,GAAG,YAAY,CAAA;IAC7B,CAAC;SAAM,CAAC;QACN,YAAY,GAAG,IAAA,kCAAc,EAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IACtD,CAAC;IAED,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAA;IAE9B,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,iBAAiB,GACrB,IAAA,8CAAsC,EACpC,YAAY,CAEf,CAAA;QACD,OAAO,iBAAiB,CAAA;IAC1B,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AA/BY,QAAA,wBAAwB,4BA+BpC;AAEM,MAAM,sCAAsC,GAAG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CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,EACnD,CAAC;oBACD,eAAe,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;QACF,wBAAwB;QACxB,IACE,eAAe,CAAC,IAAI;YACpB,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC;YACnC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;YACvB,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK;YAC7B,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAC5C,CAAC;YACD,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK;gBAC3B,IAAA,uCAA4B,EAC1B,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CACpB,CAAA;QACf,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA;AA/NY,QAAA,sCAAsC,0CA+NlD"}
@@ -1,16 +1,18 @@
1
- import { KnownPostOrEventInfo, UnknownPostOrEvent, DmpEvent, DmpEventSignedClosed, DmpEventSignedOpened, NostrEvent, NostrEventSignedOpened, NostrSpasmEvent, NostrSpasmEventSignedOpened, Post, SpasmEvent, SpasmEventSigned } from "./../types/interfaces.js";
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;
1
+ import { KnownPostOrEventInfo, DmpEvent, DmpEventSignedClosed, DmpEventSignedOpened, NostrEvent, NostrEventSignedOpened, NostrSpasmEvent, NostrSpasmEventSignedOpened, UnknownEventV2, SpasmEventV2, SpasmEventV0 } from "./../types/interfaces.js";
2
+ export declare const convertToSpasm: (unknownEvent: UnknownEventV2, version?: string, spasmIdVersions?: string[]) => SpasmEventV2 | null;
3
+ export declare const assignSpasmId: (spasmEventV2: SpasmEventV2, spasmIdVersions?: string[]) => SpasmEventV2 | null;
4
+ export declare const standardizeEventV2: (unknownEvent: UnknownEventV2, version?: string, info?: KnownPostOrEventInfo) => SpasmEventV2 | null;
5
+ export declare const standardizeDmpEventV2: (event: DmpEvent) => SpasmEventV2 | null;
6
+ export declare const standardizeDmpEventSignedClosedV2: (event: DmpEventSignedClosed) => SpasmEventV2 | null;
7
+ export declare const standardizeDmpEventSignedOpenedV2: (event: DmpEventSignedOpened) => SpasmEventV2 | null;
8
+ export declare const standardizeNostrEventV2: (event: NostrEvent) => SpasmEventV2 | null;
9
+ export declare const standardizeNostrSpasmEventV2: (event: NostrSpasmEvent) => SpasmEventV2 | null;
10
+ export declare const standardizeNostrEventSignedOpenedV2: (event: NostrEventSignedOpened) => SpasmEventV2 | null;
11
+ export declare const standardizeNostrSpasmEventSignedOpenedV2: (event: NostrSpasmEventSignedOpened) => SpasmEventV2 | null;
12
+ export declare const standardizeSpasmDmpEventSignedClosedV0_V2: (spasmEventV0: SpasmEventV0) => SpasmEventV2 | null;
13
+ export declare const standardizeSpasmNostrEventSignedOpenedV0_V2: (spasmEventV0: SpasmEventV0) => SpasmEventV2 | null;
14
+ export declare const standardizeSpasmNostrSpasmEventSignedOpenedV0_V2: (spasmEventV0: SpasmEventV0) => SpasmEventV2 | null;
15
+ export declare const standardizeSpasmWithRssItemV0_V2: (spasmEventV0: SpasmEventV0) => SpasmEventV2 | null;
16
+ export declare const addFieldsFromEnvelopeSpasmEventV0_V2: (spasmEventV0: SpasmEventV0, spasmEventV2: SpasmEventV2) => SpasmEventV2;
17
+ export declare const convertToSpasmStatus: () => void;
16
18
  //# sourceMappingURL=convertToSpasm.d.ts.map
@@ -1 +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,0BAA0B,CAAC;AAmBlC,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,C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