stated-protocol-parser 1.0.3 → 1.0.4

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 (46) hide show
  1. package/dist/constants.d.ts +1 -0
  2. package/dist/constants.d.ts.map +1 -0
  3. package/dist/constants.js +17 -19
  4. package/dist/constants.js.map +1 -0
  5. package/dist/hash.browser.d.ts +1 -0
  6. package/dist/hash.browser.d.ts.map +1 -0
  7. package/dist/hash.browser.js +6 -12
  8. package/dist/hash.browser.js.map +1 -0
  9. package/dist/hash.node.d.ts +1 -0
  10. package/dist/hash.node.d.ts.map +1 -0
  11. package/dist/hash.node.js +8 -17
  12. package/dist/hash.node.js.map +1 -0
  13. package/dist/hash.test.d.ts +2 -0
  14. package/dist/hash.test.d.ts.map +1 -0
  15. package/dist/hash.test.js +181 -0
  16. package/dist/hash.test.js.map +1 -0
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +47 -95
  20. package/dist/index.js.map +1 -0
  21. package/dist/index.test.d.ts +2 -0
  22. package/dist/index.test.d.ts.map +1 -0
  23. package/dist/index.test.js +293 -0
  24. package/dist/index.test.js.map +1 -0
  25. package/dist/types.d.ts +1 -0
  26. package/dist/types.d.ts.map +1 -0
  27. package/dist/types.js +2 -2
  28. package/dist/types.js.map +1 -0
  29. package/dist/utils.d.ts +1 -0
  30. package/dist/utils.d.ts.map +1 -0
  31. package/dist/utils.js +13 -17
  32. package/dist/utils.js.map +1 -0
  33. package/dist/v3.d.ts +1 -0
  34. package/dist/v3.d.ts.map +1 -0
  35. package/dist/v3.js +4 -7
  36. package/dist/v3.js.map +1 -0
  37. package/package.json +2 -1
  38. package/src/constants.ts +61 -0
  39. package/src/hash.browser.ts +65 -0
  40. package/src/hash.node.ts +47 -0
  41. package/src/hash.test.ts +217 -0
  42. package/src/index.test.ts +378 -0
  43. package/src/index.ts +678 -0
  44. package/src/types.ts +186 -0
  45. package/src/utils.ts +18 -0
  46. package/src/v3.ts +62 -0
@@ -0,0 +1,293 @@
1
+ import { parseRating, parseStatement, parseOrganisationVerification, parsePersonVerification, parsePoll, parseQuotation, buildRating, buildStatement, buildPersonVerificationContent, buildPollContent, buildQuotationContent, buildOrganisationVerificationContent, } from './index';
2
+ const randomUnicodeString = () => Array.from({ length: 20 }, () => String.fromCharCode(Math.floor(Math.random() * 65536)))
3
+ .join('')
4
+ .replace(/[\n;>=<"''\\]/g, '');
5
+ test('parse statement', () => {
6
+ const statement = `Publishing domain: localhost
7
+ Author: chris
8
+ Time: Tue, 18 Apr 2023 18:20:26 GMT
9
+ Tags: hashtag1, hashtag2
10
+ Format version: 4
11
+ Statement content: hi
12
+ `;
13
+ const parsedStatement = parseStatement({ statement });
14
+ expect(parsedStatement.content).toBe(`hi
15
+ `);
16
+ });
17
+ test('statement build & parse function compatibility: input=parse(build(input))', () => {
18
+ const [domain, author, representative, content, supersededStatement] = Array.from({ length: 5 }, randomUnicodeString);
19
+ const tags = Array.from({ length: 4 }, randomUnicodeString);
20
+ const contentWithTrailingNewline = content + (content.match(/\n$/) ? '' : '\n');
21
+ const time = new Date('Sun, 04 Sep 2022 14:48:50 GMT');
22
+ const statementContent = buildStatement({
23
+ domain,
24
+ author,
25
+ time,
26
+ content: contentWithTrailingNewline,
27
+ representative,
28
+ supersededStatement,
29
+ tags,
30
+ });
31
+ const parsedStatement = parseStatement({ statement: statementContent });
32
+ expect(parsedStatement.domain).toBe(domain);
33
+ expect(parsedStatement.author).toBe(author);
34
+ expect(parsedStatement.time?.toUTCString()).toBe(time.toUTCString());
35
+ expect(parsedStatement.content).toBe(contentWithTrailingNewline);
36
+ expect(parsedStatement.representative).toBe(representative);
37
+ expect(parsedStatement.supersededStatement).toBe(supersededStatement);
38
+ expect(parsedStatement.tags?.sort()).toStrictEqual(tags.sort());
39
+ });
40
+ test('parse quotation', () => {
41
+ let quotation = `Publishing domain: rixdata.net
42
+ Author: Example Inc.
43
+ Time: Sun, 04 Sep 2022 14:48:50 GMT
44
+ Format version: 4
45
+ Statement content:
46
+ Type: Quotation
47
+ Original author: XYZ Company Inc.
48
+ Author verification: eXoVsm2CdF5Ri-SEAr33RNkG3DBuehvFoDBQ_pO9CXE
49
+ Original publication time: Sun, 04 Sep 2022 14:48:50 GMT
50
+ Source: https://www.facebook.com/companyxzy/posts/XXXX
51
+ Picture proof: 5HKiyQXGV4xavq-Nn9RXi_ndUH-2BEux3ccFIjaSk_8
52
+ Confidence: 0.9
53
+ Quotation: we give example.com a 2/5 star rating
54
+ Paraphrased statement:
55
+ Type: Rating
56
+ Organisation name: example
57
+ Organisation domain: example.com
58
+ Our rating: 2/5 Stars
59
+ `;
60
+ const parsedStatement = parseStatement({ statement: quotation });
61
+ const parsedQuotation = parseQuotation(parsedStatement.content);
62
+ const type = parsedQuotation.type;
63
+ expect(type).toBe('rating');
64
+ });
65
+ test('quotation build & parse function compatibility: input=parse(build(input))', () => {
66
+ const [originalAuthor, source, picture, quotation, paraphrasedStatement] = Array.from({ length: 6 }, randomUnicodeString);
67
+ const authorVerification = 'yXoVsm2CdF5Ri-SEAr33RNkG3DBuehvFoDBQ_pO9CXE';
68
+ const originalTime = 'Sun, 04 Sep 2022 14:48:50 GMT';
69
+ const confidence = '' + Math.random();
70
+ const quotationContent = buildQuotationContent({
71
+ originalAuthor,
72
+ authorVerification,
73
+ originalTime,
74
+ source,
75
+ picture,
76
+ confidence,
77
+ quotation,
78
+ paraphrasedStatement,
79
+ });
80
+ const parsedQuotation = parseQuotation(quotationContent);
81
+ expect(parsedQuotation.originalAuthor).toBe(originalAuthor);
82
+ expect(parsedQuotation.originalTime).toBe(originalTime);
83
+ expect(parsedQuotation.source).toBe(source);
84
+ expect(parsedQuotation.picture).toBe(picture);
85
+ expect(parsedQuotation.confidence).toBe(confidence);
86
+ expect(parsedQuotation.quotation).toBe(quotation);
87
+ expect(parsedQuotation.paraphrasedStatement?.replace(/\n$/, '')).toBe(paraphrasedStatement);
88
+ expect(parsedQuotation.authorVerification).toBe(authorVerification);
89
+ });
90
+ test('parse organisation verification', () => {
91
+ let organisationVerification = `Publishing domain: rixdata.net
92
+ Author: Example Inc.
93
+ Time: Sun, 04 Sep 2022 14:48:50 GMT
94
+ Format version: 4
95
+ Statement content:
96
+ Type: Organisation verification
97
+ Description: We verified the following information about an organisation.
98
+ Name: Walmart Inc.
99
+ Country: United States of America
100
+ Legal entity: corporation
101
+ Owner of the domain: walmart.com
102
+ Province or state: Arkansas
103
+ City: Bentonville
104
+ `;
105
+ const parsedStatement = parseStatement({
106
+ statement: organisationVerification,
107
+ });
108
+ const parsedOVerification = parseOrganisationVerification(parsedStatement.content);
109
+ const name = parsedOVerification.name;
110
+ expect(name).toBe('Walmart Inc.');
111
+ });
112
+ test('organisation verification build & parse function compatibility: input=parse(build(input))', () => {
113
+ const [name, englishName, city, domain, foreignDomain, serialNumber, reliabilityPolicy, pictureHash,] = Array.from({ length: 8 }, randomUnicodeString);
114
+ const country = 'Germany';
115
+ const province = 'Bayern';
116
+ const legalForm = 'corporation';
117
+ const employeeCount = '100-1000';
118
+ const confidence = 0.8;
119
+ const verificationContent = buildOrganisationVerificationContent({
120
+ name,
121
+ englishName,
122
+ country,
123
+ city,
124
+ province,
125
+ legalForm,
126
+ domain,
127
+ pictureHash,
128
+ foreignDomain,
129
+ serialNumber,
130
+ confidence,
131
+ reliabilityPolicy,
132
+ employeeCount,
133
+ });
134
+ const parsedVerification = parseOrganisationVerification(verificationContent);
135
+ expect(parsedVerification.name).toBe(name);
136
+ expect(parsedVerification.englishName).toBe(englishName);
137
+ expect(parsedVerification.country).toBe(country);
138
+ expect(parsedVerification.city).toBe(city);
139
+ expect(parsedVerification.province).toBe(province);
140
+ expect(parsedVerification.legalForm).toBe(legalForm);
141
+ expect(parsedVerification.domain).toBe(domain);
142
+ expect(parsedVerification.foreignDomain).toBe(foreignDomain);
143
+ expect(parsedVerification.serialNumber).toBe(serialNumber);
144
+ expect(parsedVerification.confidence).toBe(confidence);
145
+ expect(parsedVerification.pictureHash).toBe(pictureHash);
146
+ expect(parsedVerification.reliabilityPolicy).toBe(reliabilityPolicy);
147
+ expect(parsedVerification.employeeCount).toBe(employeeCount);
148
+ });
149
+ test('parse person verification', () => {
150
+ let personVerification = `Publishing domain: rixdata.net
151
+ Author: Example Inc.
152
+ Time: Sun, 04 Sep 2022 14:48:50 GMT
153
+ Format version: 4
154
+ Statement content:
155
+ Type: Person verification
156
+ Description: We verified the following information about a person.
157
+ Name: Barack Hossein Obama II
158
+ Date of birth: 4 Aug 1961
159
+ City of birth: Honolulu
160
+ Country of birth: United States of America
161
+ Owner of the domain: barackobama.com
162
+ `;
163
+ const parsedStatement = parseStatement({ statement: personVerification });
164
+ const parsedPVerification = parsePersonVerification(parsedStatement.content);
165
+ const name = parsedPVerification.name;
166
+ expect(name).toBe('Barack Hossein Obama II');
167
+ });
168
+ test('person verification build & parse function compatibility: input=parse(build(input))', () => {
169
+ const [name, ownDomain, foreignDomain, jobTitle, employer, verificationMethod, picture, reliabilityPolicy,] = Array.from({ length: 12 }, randomUnicodeString);
170
+ const countryOfBirth = 'Germany';
171
+ const cityOfBirth = 'Berlin';
172
+ const confidence = Math.random();
173
+ const dateOfBirth = new Date(0);
174
+ const personVerificationContent = buildPersonVerificationContent({
175
+ name,
176
+ countryOfBirth,
177
+ cityOfBirth,
178
+ ownDomain,
179
+ foreignDomain,
180
+ dateOfBirth,
181
+ jobTitle,
182
+ employer,
183
+ verificationMethod,
184
+ confidence,
185
+ picture,
186
+ reliabilityPolicy,
187
+ });
188
+ const parsedVerification = parsePersonVerification(personVerificationContent);
189
+ expect(parsedVerification.name).toBe(name);
190
+ expect(parsedVerification.ownDomain).toBe(ownDomain);
191
+ expect(parsedVerification.foreignDomain).toBe(foreignDomain);
192
+ expect(parsedVerification.dateOfBirth.toUTCString()).toBe(dateOfBirth.toUTCString());
193
+ expect(parsedVerification.jobTitle).toBe(jobTitle);
194
+ expect(parsedVerification.employer).toBe(employer);
195
+ expect(parsedVerification.verificationMethod).toBe(verificationMethod);
196
+ expect(parsedVerification.confidence).toBe(confidence);
197
+ expect(parsedVerification.picture).toBe(picture);
198
+ expect(parsedVerification.reliabilityPolicy).toBe(reliabilityPolicy);
199
+ expect(parsedVerification.countryOfBirth).toBe(countryOfBirth);
200
+ expect(parsedVerification.cityOfBirth).toBe(cityOfBirth);
201
+ });
202
+ test('parse rating', () => {
203
+ let rating = `Publishing domain: localhost
204
+ Author: chris
205
+ Time: Tue, 18 Apr 2023 18:20:26 GMT
206
+ Format version: 4
207
+ Statement content:
208
+ Type: Rating
209
+ Subject name: AMBOSS GmbH
210
+ URL that identifies the subject: amboss.com
211
+ Rated quality: AI safety
212
+ Our rating: 5/5 Stars
213
+ `;
214
+ const parsedStatement = parseStatement({ statement: rating });
215
+ const parsedRating = parseRating(parsedStatement.content);
216
+ const ratingNumber = parsedRating.rating;
217
+ expect(ratingNumber).toBe(5);
218
+ const subjectName = parsedRating.subjectName;
219
+ expect(subjectName).toBe('AMBOSS GmbH');
220
+ const subjectReference = parsedRating.subjectReference;
221
+ expect(subjectReference).toBe('amboss.com');
222
+ const quality = parsedRating.quality;
223
+ expect(quality).toBe('AI safety');
224
+ });
225
+ test('rating build & parse function compatibility: input=parse(build(input))', () => {
226
+ const [subjectName, subjectReference, comment, quality] = Array.from({ length: 4 }, randomUnicodeString);
227
+ const rating = Math.ceil(Math.random() * 5);
228
+ const ratingContent = buildRating({ subjectName, subjectReference, rating, comment, quality });
229
+ const parsedRating = parseRating(ratingContent);
230
+ expect(parsedRating.subjectName).toBe(subjectName);
231
+ expect(parsedRating.subjectReference).toBe(subjectReference);
232
+ expect(parsedRating.quality).toBe(quality);
233
+ expect(parsedRating.rating).toBe(rating);
234
+ expect(parsedRating.comment).toBe(comment);
235
+ });
236
+ test('parse poll v4', () => {
237
+ let poll = `Publishing domain: rixdata.net
238
+ Author: Example Inc.
239
+ Time: Thu, 17 Nov 2022 13:38:20 GMT
240
+ Format version: 4
241
+ Statement content:
242
+ Type: Poll
243
+ The poll outcome is finalized when the following nodes agree: rixdata.net
244
+ Voting deadline: Thu, 01 Dec 2022 13:38:26 GMT
245
+ Poll: Should the UK join the EU
246
+ Option 1: Yes
247
+ Option 2: No
248
+ Who can vote:
249
+ Description: All universities with a ROR ID
250
+ Legal form scope: corporation
251
+ All entities with the following property: ROR ID
252
+ As observed by: Rix Data NL B.V.@rixdata.net
253
+ Link to query defining who can vote: https://stated.rixdata.net/?search_query=%09Observed%20property:%20ROR%20ID%0A%09&domain=rixdata.net&author=Rix%20Data%20NL%20B.V.
254
+ `;
255
+ const parsedStatement = parseStatement({ statement: poll });
256
+ const parsedPoll = parsePoll(parsedStatement.content);
257
+ const pollTitle = parsedPoll.poll;
258
+ expect(pollTitle).toBe('Should the UK join the EU');
259
+ expect(parsedPoll.options[0]).toBe('Yes');
260
+ expect(parsedPoll.options[1]).toBe('No');
261
+ expect(parsedPoll.deadline?.toUTCString()).toBe('Thu, 01 Dec 2022 13:38:26 GMT');
262
+ expect(parsedPoll.scopeDescription).toBe('All universities with a ROR ID');
263
+ expect(parsedPoll.legalEntity).toBe('corporation');
264
+ expect(parsedPoll.requiredProperty).toBe('ROR ID');
265
+ expect(parsedPoll.requiredPropertyObserver).toBe('Rix Data NL B.V.@rixdata.net');
266
+ expect(parsedPoll.scopeQueryLink).toBe('https://stated.rixdata.net/?search_query=%09Observed%20property:%20ROR%20ID%0A%09&domain=rixdata.net&author=Rix%20Data%20NL%20B.V.');
267
+ });
268
+ test('poll build & parse function compatibility: input=parse(build(input))', () => {
269
+ const [country, city, legalEntity, judges, poll, scopeDescription] = Array.from({ length: 6 }, randomUnicodeString);
270
+ const options = Array.from({ length: 2 }, randomUnicodeString);
271
+ const domainScope = ['rixdata.net'];
272
+ const deadline = new Date('Thu, 01 Dec 2022 13:38:26 GMT');
273
+ const pollContent = buildPollContent({
274
+ country,
275
+ city,
276
+ legalEntity,
277
+ domainScope,
278
+ judges,
279
+ deadline,
280
+ poll,
281
+ options,
282
+ scopeDescription,
283
+ });
284
+ const parsedPoll = parsePoll(pollContent);
285
+ expect(parsedPoll.poll).toBe(poll);
286
+ expect(parsedPoll.country).toBe(country);
287
+ expect(parsedPoll.legalEntity).toBe(legalEntity);
288
+ expect(parsedPoll.judges).toBe(judges);
289
+ expect(parsedPoll.deadline?.toUTCString()).toBe(deadline.toUTCString());
290
+ expect(parsedPoll.options[0]).toEqual(options[0]);
291
+ expect(parsedPoll.options[1]).toEqual(options[1]);
292
+ });
293
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,cAAc,EACd,6BAA6B,EAE7B,uBAAuB,EAIvB,SAAS,EACT,cAAc,EAMd,WAAW,EACX,cAAc,EAKd,8BAA8B,EAC9B,gBAAgB,EAChB,qBAAqB,EAErB,oCAAoC,GAGvC,MAAM,SAAS,CAAA;AAEhB,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAC7B,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAC5B,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CACzD;KACI,IAAI,CAAC,EAAE,CAAC;KACR,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;AAEtC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE;IACzB,MAAM,SAAS,GAAG;;;;;;CAMrB,CAAA;IACG,MAAM,eAAe,GAAG,cAAc,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;IACrD,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;CACxC,CAAC,CAAA;AACF,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,2EAA2E,EAAE,GAAG,EAAE;IACnF,MAAM,CAAC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EAAE,CAAC,CAAA;IACvE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;IACjD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC,CAAC,CAAA"}
package/dist/types.d.ts CHANGED
@@ -146,3 +146,4 @@ export type Boycott = {
146
146
  subject: string;
147
147
  subjectReference?: string;
148
148
  };
149
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GACxB,WAAW,GACX,WAAW,GACX,2BAA2B,GAC3B,qBAAqB,GACrB,MAAM,GACN,MAAM,GACN,UAAU,GACV,2BAA2B,GAC3B,gCAAgC,GAChC,SAAS,GACT,aAAa,GACb,QAAQ,GACR,UAAU,GACV,QAAQ,CAAA;AAEd,MAAM,MAAM,SAAS,GAAG;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7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/B,WAAW,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,IAAI,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA"}
package/dist/types.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export declare const minPeopleCountToRange: (n: number) => string | undefined;
2
2
  export declare const monthIndex: (month: string) => number;
3
3
  export declare const birthDateFormat: RegExp;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,GAAI,GAAG,MAAM,KAAG,MAAM,GAAG,SAS1D,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAEO,CAAA;AAElD,eAAO,MAAM,eAAe,EAAE,MAAgG,CAAA"}
package/dist/utils.js CHANGED
@@ -1,27 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.birthDateFormat = exports.monthIndex = exports.minPeopleCountToRange = void 0;
4
- const constants_1 = require("./constants");
5
- const minPeopleCountToRange = (n) => {
1
+ import { peopleCountBuckets } from './constants';
2
+ export const minPeopleCountToRange = (n) => {
6
3
  if (n >= 10000000)
7
- return constants_1.peopleCountBuckets["10000000"];
4
+ return peopleCountBuckets["10000000"];
8
5
  if (n >= 1000000)
9
- return constants_1.peopleCountBuckets["1000000"];
6
+ return peopleCountBuckets["1000000"];
10
7
  if (n >= 100000)
11
- return constants_1.peopleCountBuckets["100000"];
8
+ return peopleCountBuckets["100000"];
12
9
  if (n >= 10000)
13
- return constants_1.peopleCountBuckets["10000"];
10
+ return peopleCountBuckets["10000"];
14
11
  if (n >= 1000)
15
- return constants_1.peopleCountBuckets["1000"];
12
+ return peopleCountBuckets["1000"];
16
13
  if (n >= 100)
17
- return constants_1.peopleCountBuckets["100"];
14
+ return peopleCountBuckets["100"];
18
15
  if (n >= 10)
19
- return constants_1.peopleCountBuckets["10"];
16
+ return peopleCountBuckets["10"];
20
17
  if (n >= 0)
21
- return constants_1.peopleCountBuckets["0"];
18
+ return peopleCountBuckets["0"];
22
19
  };
23
- exports.minPeopleCountToRange = minPeopleCountToRange;
24
- const monthIndex = (month) => ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
20
+ export const monthIndex = (month) => ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
25
21
  .indexOf(month.toLowerCase().substr(0, 3));
26
- exports.monthIndex = monthIndex;
27
- exports.birthDateFormat = /(?<d>\d{1,2})\s(?<month>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?<y>\d{4})/;
22
+ export const birthDateFormat = /(?<d>\d{1,2})\s(?<month>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?<y>\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CHANGED
@@ -2,3 +2,4 @@ import { Poll } from './types';
2
2
  export declare const parsePollV3: (s: string, version?: string) => Poll & {
3
3
  pollType: string;
4
4
  };
5
+ //# sourceMappingURL=v3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3.d.ts","sourceRoot":"","sources":["../src/v3.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,EAAE,UAAU,MAAM,KAAG,IAAI,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CA0DlF,CAAA"}
package/dist/v3.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parsePollV3 = void 0;
4
- const constants_1 = require("./constants");
5
- const parsePollV3 = (s, version) => {
1
+ import { UTCFormat } from './constants';
2
+ export const parsePollV3 = (s, version) => {
6
3
  const pollRegex = new RegExp(''
7
4
  + /^\n\tType: Poll\n/.source
8
5
  + /(?:\tPoll type: (?<pollType>[^\n]+?)\n)?/.source
@@ -44,7 +41,7 @@ const parsePollV3 = (s, version) => {
44
41
  const options = [m.option1, m.option2, m.option3, m.option4, m.option5].filter(o => o);
45
42
  const domainScope = m.domainScope?.split(', ');
46
43
  const deadlineStr = m.deadline;
47
- if (!deadlineStr.match(constants_1.UTCFormat))
44
+ if (!deadlineStr.match(UTCFormat))
48
45
  throw new Error("Invalid poll, deadline must be in UTC: " + deadlineStr);
49
46
  return {
50
47
  pollType: m['pollType'],
@@ -60,4 +57,4 @@ const parsePollV3 = (s, version) => {
60
57
  options
61
58
  };
62
59
  };
63
- exports.parsePollV3 = parsePollV3;
60
+ //# sourceMappingURL=v3.js.map
package/dist/v3.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3.js","sourceRoot":"","sources":["../src/v3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,C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@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stated-protocol-parser",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Parser and formatter for the Stated protocol - a decentralized statement verification system",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "files": [
48
48
  "dist",
49
+ "src",
49
50
  "README.md",
50
51
  "LICENSE"
51
52
  ],
@@ -0,0 +1,61 @@
1
+ export const legalForms = {
2
+ local_government: 'local government',
3
+ state_government: 'state government',
4
+ foreign_affairs_ministry: 'foreign affairs ministry',
5
+ corporation: 'corporation',
6
+ }
7
+
8
+ export const statementTypes = {
9
+ statement: 'statement',
10
+ quotation: 'quotation',
11
+ organisationVerification: 'organisation_verification',
12
+ personVerification: 'person_verification',
13
+ poll: 'poll',
14
+ vote: 'vote',
15
+ response: 'response',
16
+ disputeContent: 'dispute_statement_content',
17
+ disputeAuthenticity: 'dispute_statement_authenticity',
18
+ boycott: 'boycott',
19
+ observation: 'observation',
20
+ rating: 'rating',
21
+ signPdf: "sign_pdf",
22
+ bounty: "bounty",
23
+ unsupported: "unsupported",
24
+ }
25
+
26
+ export const peopleCountBuckets = {
27
+ "0": "0-10",
28
+ "10": "10-100",
29
+ "100": "100-1000",
30
+ "1000": "1000-10,000",
31
+ "10000": "10,000-100,000",
32
+ "100000": "100,000+",
33
+ "1000000": "1,000,000+",
34
+ "10000000": "10,000,000+",
35
+ }
36
+
37
+ export const UTCFormat: RegExp = /(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT/
38
+
39
+ export const pollKeys = /(Type: |The poll outcome is finalized when the following nodes agree: |Voting deadline: |Poll: |Option 1: |Option 2: |Option 3: |Option 4: |Option 5: |Allow free text votes: |Who can vote: |Description: |Country scope: |City scope: |Legal form scope: |Domain scope: |All entities with the following property: |As observed by: |Link to query defining who can vote: )/g
40
+
41
+ export const organisationVerificationKeys = /(Type: |Description: |Name: |English name: |Country: |Legal entity: |Legal form: |Department using the domain: |Owner of the domain: |Foreign domain used for publishing statements: |Province or state: |Business register number: |City: |Longitude: |Latitude: |Population: |Logo: |Employee count: |Reliability policy: |Confidence: )/g
42
+
43
+ export const personVerificationKeys = /(Type: |Description: |Name: |Date of birth: |City of birth: |Country of birth: |Job title: |Employer: |Owner of the domain: |Foreign domain used for publishing statements: |Picture: |Verification method: |Confidence: |Reliability policy: )/g
44
+
45
+ export const voteKeys = /(Type: |Poll id: |Poll: |Option: )/g
46
+
47
+ export const disputeAuthenticityKeys = /(Type: |Description: |Hash of referenced statement: |Confidence: |Reliability policy: )/g
48
+
49
+ export const disputeContentKeys = /(Type: |Description: |Hash of referenced statement: |Confidence: |Reliability policy: )/g
50
+
51
+ export const responseKeys = /(Type: |Hash of referenced statement: |Response: )/
52
+
53
+ export const PDFSigningKeys = /(Type: |Description: |PDF file hash: )/
54
+
55
+ export const ratingKeys = /(Type: |Subject type: |Subject name: |URL that identifies the subject: |Document file hash: |Rated quality: |Our rating: |Comment: )/
56
+
57
+ export const BountyKeys = /(Type: |In order to: |We will reward any entity that: |The reward is: |In case of dispute, bounty claims are judged by: |The judge will be paid per investigated case with a maxium of: )/
58
+
59
+ export const ObservationKeys = /(Type: |Approach: |Confidence: |Reliability policy: |Subject: |Subject identity reference: |Observation reference: |Observed property: |Observed value: )/
60
+
61
+ export const BoycottKeys = /(Type: |Description: |Subject: |Subject identity reference: )/
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Browser-compatible hash utilities using Web Crypto API
3
+ * Async operations for client-side use
4
+ */
5
+
6
+ /**
7
+ * Compute SHA-256 hash of a string and return it as URL-safe base64
8
+ * Works in both browser and Node.js environments
9
+ * @param input - The string or buffer to hash
10
+ * @returns URL-safe base64 encoded hash
11
+ */
12
+ export const sha256 = async (input: string | Uint8Array): Promise<string> => {
13
+ let data: Uint8Array;
14
+
15
+ if (typeof input === 'string') {
16
+ const encoder = new TextEncoder();
17
+ data = encoder.encode(input);
18
+ } else {
19
+ data = input;
20
+ }
21
+
22
+ // Use Web Crypto API (available in both modern browsers and Node.js 15+)
23
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data);
24
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
25
+
26
+ // Convert to base64
27
+ const base64 = btoa(String.fromCharCode(...hashArray));
28
+
29
+ // Make URL-safe: remove padding and replace + with - and / with _
30
+ const urlSafe = base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
31
+
32
+ return urlSafe;
33
+ }
34
+
35
+ /**
36
+ * Verify that content matches a given hash
37
+ * @param content - The content to verify
38
+ * @param hash - The expected hash
39
+ * @returns True if the hash matches
40
+ */
41
+ export const verify = async (content: string | Uint8Array, hash: string): Promise<boolean> => {
42
+ const computed = await sha256(content);
43
+ return computed === hash;
44
+ }
45
+
46
+ /**
47
+ * Convert URL-safe base64 back to standard base64
48
+ * @param urlSafe - URL-safe base64 string
49
+ * @returns Standard base64 string with padding
50
+ */
51
+ export const fromUrlSafeBase64 = (urlSafe: string): string => {
52
+ const base64 = urlSafe.replace(/-/g, '+').replace(/_/g, '/');
53
+ // Add padding if needed
54
+ const padding = '='.repeat((4 - (base64.length % 4)) % 4);
55
+ return base64 + padding;
56
+ }
57
+
58
+ /**
59
+ * Convert standard base64 to URL-safe base64
60
+ * @param base64 - Standard base64 string
61
+ * @returns URL-safe base64 string without padding
62
+ */
63
+ export const toUrlSafeBase64 = (base64: string): string => {
64
+ return base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
65
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Node.js-specific hash utilities using native crypto module
3
+ * Synchronous operations for server-side use
4
+ */
5
+
6
+ import crypto from 'crypto'
7
+
8
+ /**
9
+ * Compute SHA-256 hash and return as URL-safe base64 (Node.js)
10
+ * @param input - String or buffer to hash
11
+ * @returns URL-safe base64 encoded hash
12
+ */
13
+ export const sha256 = (input: crypto.BinaryLike): string => {
14
+ const base64 = crypto.createHash('sha256').update(input).digest('base64')
15
+ const urlSafe = base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_')
16
+ return urlSafe
17
+ }
18
+
19
+ /**
20
+ * Verify that content matches a given hash
21
+ * @param content - Content to verify
22
+ * @param hash - Expected hash
23
+ * @returns True if hash matches
24
+ */
25
+ export const verify = (content: crypto.BinaryLike, hash: string): boolean => {
26
+ return hash === sha256(content)
27
+ }
28
+
29
+ /**
30
+ * Convert URL-safe base64 back to standard base64
31
+ * @param urlSafe - URL-safe base64 string
32
+ * @returns Standard base64 string with padding
33
+ */
34
+ export const fromUrlSafeBase64 = (urlSafe: string): string => {
35
+ const base64 = urlSafe.replace(/-/g, '+').replace(/_/g, '/');
36
+ const padding = '='.repeat((4 - (base64.length % 4)) % 4);
37
+ return base64 + padding;
38
+ }
39
+
40
+ /**
41
+ * Convert standard base64 to URL-safe base64
42
+ * @param base64 - Standard base64 string
43
+ * @returns URL-safe base64 string without padding
44
+ */
45
+ export const toUrlSafeBase64 = (base64: string): string => {
46
+ return base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
47
+ }