@atproto/syntax 0.1.0 → 0.1.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # @atproto/syntax
2
+
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`41ee177f`](https://github.com/bluesky-social/atproto/commit/41ee177f5a440490280d17acd8a89bcddaffb23b)]:
8
+ - @atproto/common-web@0.2.1
9
+
10
+ ## 0.1.1
11
+
12
+ ### Patch Changes
13
+
14
+ - [#1611](https://github.com/bluesky-social/atproto/pull/1611) [`b1dc3555`](https://github.com/bluesky-social/atproto/commit/b1dc355504f9f2e047093dc56682b8034518cf80) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Fix imports in `README.md`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-2023 Bluesky PBC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,11 +1,18 @@
1
- # Syntax
1
+ # @atproto/syntax: validation helpers for identifier strings
2
2
 
3
- Validation logic for AT identifiers - DIDs, Handles, NSIDs, and AT URIs
3
+ Validation logic for [atproto](https://atproto.com) identifiers - DIDs, Handles, NSIDs, and AT URIs.
4
+
5
+ [![NPM](https://img.shields.io/npm/v/@atproto/crypto)](https://www.npmjs.com/package/@atproto/syntax)
6
+ [![Github CI Status](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml/badge.svg)](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml)
4
7
 
5
8
  ## Usage
6
9
 
10
+ ### Handles
11
+
12
+ Syntax specification: <https://atproto.com/specs/handle>
13
+
7
14
  ```typescript
8
- import * as identifier from '@atproto/syntax'
15
+ import { isValidHandle, ensureValidHandle, isValidDid } from '@atproto/syntax'
9
16
 
10
17
  isValidHandle('alice.test') // returns true
11
18
  ensureValidHandle('alice.test') // returns void
@@ -17,24 +24,26 @@ ensureValidDid('did:method:val') // returns void
17
24
  ensureValidDid(':did:method:val') // throws
18
25
  ```
19
26
 
20
- ## NameSpaced IDs (NSID)
27
+ ### NameSpaced IDs (NSID)
28
+
29
+ Syntax specification: <https://atproto.com/specs/nsid>
21
30
 
22
31
  ```typescript
23
32
  import { NSID } from '@atproto/syntax'
24
33
 
25
34
  const id1 = NSID.parse('com.example.foo')
26
- id1.authority // => 'example.com'
27
- id1.name // => 'foo'
35
+ id1.authority // => 'example.com'
36
+ id1.name // => 'foo'
28
37
  id1.toString() // => 'com.example.foo'
29
38
 
30
39
  const id2 = NSID.create('example.com', 'foo')
31
- id2.authority // => 'example.com'
32
- id2.name // => 'foo'
40
+ id2.authority // => 'example.com'
41
+ id2.name // => 'foo'
33
42
  id2.toString() // => 'com.example.foo'
34
43
 
35
44
  const id3 = NSID.create('example.com', 'someRecord')
36
- id3.authority // => 'example.com'
37
- id3.name // => 'someRecord'
45
+ id3.authority // => 'example.com'
46
+ id3.name // => 'someRecord'
38
47
  id3.toString() // => 'com.example.someRecord'
39
48
 
40
49
  NSID.isValid('com.example.foo') // => true
@@ -43,17 +52,19 @@ NSID.isValid('example.com/foo') // => false
43
52
  NSID.isValid('foo') // => false
44
53
  ```
45
54
 
46
- ## AT URI
55
+ ### AT URI
56
+
57
+ Syntax specification: <https://atproto.com/specs/at-uri-scheme>
47
58
 
48
59
  ```typescript
49
60
  import { AtUri } from '@atproto/syntax'
50
61
 
51
62
  const uri = new AtUri('at://bob.com/com.example.post/1234')
52
- uri.protocol // => 'at:'
53
- uri.origin // => 'at://bob.com'
54
- uri.hostname // => 'bob.com'
63
+ uri.protocol // => 'at:'
64
+ uri.origin // => 'at://bob.com'
65
+ uri.hostname // => 'bob.com'
55
66
  uri.collection // => 'com.example.post'
56
- uri.rkey // => '1234'
67
+ uri.rkey // => '1234'
57
68
  ```
58
69
 
59
70
  ## License
package/dist/index.js CHANGED
@@ -58,9 +58,7 @@ var DISALLOWED_TLDS = [
58
58
  ];
59
59
  var ensureValidHandle = (handle) => {
60
60
  if (!/^[a-zA-Z0-9.-]*$/.test(handle)) {
61
- throw new InvalidHandleError(
62
- "Disallowed characters in handle (ASCII letters, digits, dashes, periods only)"
63
- );
61
+ throw new InvalidHandleError("Disallowed characters in handle (ASCII letters, digits, dashes, periods only)");
64
62
  }
65
63
  if (handle.length > 253) {
66
64
  throw new InvalidHandleError("Handle is too long (253 chars max)");
@@ -78,21 +76,15 @@ var ensureValidHandle = (handle) => {
78
76
  throw new InvalidHandleError("Handle part too long (max 63 chars)");
79
77
  }
80
78
  if (l.endsWith("-") || l.startsWith("-")) {
81
- throw new InvalidHandleError(
82
- "Handle parts can not start or end with hyphens"
83
- );
79
+ throw new InvalidHandleError("Handle parts can not start or end with hyphens");
84
80
  }
85
81
  if (i + 1 == labels.length && !/^[a-zA-Z]/.test(l)) {
86
- throw new InvalidHandleError(
87
- "Handle final component (TLD) must start with ASCII letter"
88
- );
82
+ throw new InvalidHandleError("Handle final component (TLD) must start with ASCII letter");
89
83
  }
90
84
  }
91
85
  };
92
86
  var ensureValidHandleRegex = (handle) => {
93
- if (!/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/.test(
94
- handle
95
- )) {
87
+ if (!/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/.test(handle)) {
96
88
  throw new InvalidHandleError("Handle didn't validate via regex");
97
89
  }
98
90
  if (handle.length > 253) {
@@ -133,15 +125,11 @@ var DisallowedDomainError = class extends Error {
133
125
  // src/did.ts
134
126
  var ensureValidDid = (did) => {
135
127
  if (!/^[a-zA-Z0-9._:%-]*$/.test(did)) {
136
- throw new InvalidDidError(
137
- "Disallowed characters in DID (ASCII letters, digits, and a couple other characters only)"
138
- );
128
+ throw new InvalidDidError("Disallowed characters in DID (ASCII letters, digits, and a couple other characters only)");
139
129
  }
140
130
  const parts = did.split(":");
141
131
  if (parts.length < 3) {
142
- throw new InvalidDidError(
143
- "DID requires prefix, method, and method-specific content"
144
- );
132
+ throw new InvalidDidError("DID requires prefix, method, and method-specific content");
145
133
  }
146
134
  if (parts[0] != "did") {
147
135
  throw new InvalidDidError('DID requires "did:" prefix');
@@ -202,9 +190,7 @@ var NSID = class {
202
190
  var ensureValidNsid = (nsid) => {
203
191
  const toCheck = nsid;
204
192
  if (!/^[a-zA-Z0-9.-]*$/.test(toCheck)) {
205
- throw new InvalidNsidError(
206
- "Disallowed characters in NSID (ASCII letters, digits, dashes, periods only)"
207
- );
193
+ throw new InvalidNsidError("Disallowed characters in NSID (ASCII letters, digits, dashes, periods only)");
208
194
  }
209
195
  if (toCheck.length > 253 + 1 + 63) {
210
196
  throw new InvalidNsidError("NSID is too long (317 chars max)");
@@ -233,9 +219,7 @@ var ensureValidNsid = (nsid) => {
233
219
  }
234
220
  };
235
221
  var ensureValidNsidRegex = (nsid) => {
236
- if (!/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\.[a-zA-Z]([a-zA-Z]{0,61}[a-zA-Z])?)$/.test(
237
- nsid
238
- )) {
222
+ if (!/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\.[a-zA-Z]([a-zA-Z]{0,61}[a-zA-Z])?)$/.test(nsid)) {
239
223
  throw new InvalidNsidError("NSID didn't validate via regex");
240
224
  }
241
225
  if (nsid.length > 253 + 1 + 63) {
@@ -274,29 +258,21 @@ var ensureValidAtUri = (uri) => {
274
258
  }
275
259
  if (parts.length >= 4) {
276
260
  if (parts[3].length == 0) {
277
- throw new Error(
278
- "ATURI can not have a slash after authority without a path segment"
279
- );
261
+ throw new Error("ATURI can not have a slash after authority without a path segment");
280
262
  }
281
263
  try {
282
264
  ensureValidNsid(parts[3]);
283
265
  } catch {
284
- throw new Error(
285
- "ATURI requires first path segment (if supplied) to be valid NSID"
286
- );
266
+ throw new Error("ATURI requires first path segment (if supplied) to be valid NSID");
287
267
  }
288
268
  }
289
269
  if (parts.length >= 5) {
290
270
  if (parts[4].length == 0) {
291
- throw new Error(
292
- "ATURI can not have a slash after collection, unless record key is provided"
293
- );
271
+ throw new Error("ATURI can not have a slash after collection, unless record key is provided");
294
272
  }
295
273
  }
296
274
  if (parts.length >= 6) {
297
- throw new Error(
298
- "ATURI path can have at most two parts, and no trailing slash"
299
- );
275
+ throw new Error("ATURI path can have at most two parts, and no trailing slash");
300
276
  }
301
277
  if (uriParts.length >= 2 && fragmentPart == null) {
302
278
  throw new Error("ATURI fragment must be non-empty and start with slash");
package/dist/index.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/handle.ts", "../src/did.ts", "../src/nsid.ts", "../src/aturi_validation.ts", "../src/aturi.ts"],
4
4
  "sourcesContent": ["export * from './handle'\nexport * from './did'\nexport * from './nsid'\nexport * from './aturi'\n", "export const INVALID_HANDLE = 'handle.invalid'\n\n// Currently these are registration-time restrictions, not protocol-level\n// restrictions. We have a couple accounts in the wild that we need to clean up\n// before hard-disallow.\n// See also: https://en.wikipedia.org/wiki/Top-level_domain#Reserved_domains\nexport const DISALLOWED_TLDS = [\n '.local',\n '.arpa',\n '.invalid',\n '.localhost',\n '.internal',\n // policy could concievably change on \".onion\" some day\n '.onion',\n // NOTE: .test is allowed in testing and devopment. In practical terms\n // \"should\" \"never\" actually resolve and get registered in production\n]\n\n// Handle constraints, in English:\n// - must be a possible domain name\n// - RFC-1035 is commonly referenced, but has been updated. eg, RFC-3696,\n// section 2. and RFC-3986, section 3. can now have leading numbers (eg,\n// 4chan.org)\n// - \"labels\" (sub-names) are made of ASCII letters, digits, hyphens\n// - can not start or end with a hyphen\n// - TLD (last component) should not start with a digit\n// - can't end with a hyphen (can end with digit)\n// - each segment must be between 1 and 63 characters (not including any periods)\n// - overall length can't be more than 253 characters\n// - separated by (ASCII) periods; does not start or end with period\n// - case insensitive\n// - domains (handles) are equal if they are the same lower-case\n// - punycode allowed for internationalization\n// - no whitespace, null bytes, joining chars, etc\n// - does not validate whether domain or TLD exists, or is a reserved or\n// special TLD (eg, .onion or .local)\n// - does not validate punycode\nexport const ensureValidHandle = (handle: string): void => {\n // check that all chars are boring ASCII\n if (!/^[a-zA-Z0-9.-]*$/.test(handle)) {\n throw new InvalidHandleError(\n 'Disallowed characters in handle (ASCII letters, digits, dashes, periods only)',\n )\n }\n\n if (handle.length > 253) {\n throw new InvalidHandleError('Handle is too long (253 chars max)')\n }\n const labels = handle.split('.')\n if (labels.length < 2) {\n throw new InvalidHandleError('Handle domain needs at least two parts')\n }\n for (let i = 0; i < labels.length; i++) {\n const l = labels[i]\n if (l.length < 1) {\n throw new InvalidHandleError('Handle parts can not be empty')\n }\n if (l.length > 63) {\n throw new InvalidHandleError('Handle part too long (max 63 chars)')\n }\n if (l.endsWith('-') || l.startsWith('-')) {\n throw new InvalidHandleError(\n 'Handle parts can not start or end with hyphens',\n )\n }\n if (i + 1 == labels.length && !/^[a-zA-Z]/.test(l)) {\n throw new InvalidHandleError(\n 'Handle final component (TLD) must start with ASCII letter',\n )\n }\n }\n}\n\n// simple regex translation of above constraints\nexport const ensureValidHandleRegex = (handle: string): void => {\n if (\n !/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/.test(\n handle,\n )\n ) {\n throw new InvalidHandleError(\"Handle didn't validate via regex\")\n }\n if (handle.length > 253) {\n throw new InvalidHandleError('Handle is too long (253 chars max)')\n }\n}\n\nexport const normalizeHandle = (handle: string): string => {\n return handle.toLowerCase()\n}\n\nexport const normalizeAndEnsureValidHandle = (handle: string): string => {\n const normalized = normalizeHandle(handle)\n ensureValidHandle(normalized)\n return normalized\n}\n\nexport const isValidHandle = (handle: string): boolean => {\n try {\n ensureValidHandle(handle)\n } catch (err) {\n if (err instanceof InvalidHandleError) {\n return false\n }\n throw err\n }\n\n return true\n}\n\nexport const isValidTld = (handle: string): boolean => {\n return !DISALLOWED_TLDS.some((domain) => handle.endsWith(domain))\n}\n\nexport class InvalidHandleError extends Error {}\nexport class ReservedHandleError extends Error {}\nexport class UnsupportedDomainError extends Error {}\nexport class DisallowedDomainError extends Error {}\n", "// Human-readable constraints:\n// - valid W3C DID (https://www.w3.org/TR/did-core/#did-syntax)\n// - entire URI is ASCII: [a-zA-Z0-9._:%-]\n// - always starts \"did:\" (lower-case)\n// - method name is one or more lower-case letters, followed by \":\"\n// - remaining identifier can have any of the above chars, but can not end in \":\"\n// - it seems that a bunch of \":\" can be included, and don't need spaces between\n// - \"%\" is used only for \"percent encoding\" and must be followed by two hex characters (and thus can't end in \"%\")\n// - query (\"?\") and fragment (\"#\") stuff is defined for \"DID URIs\", but not as part of identifier itself\n// - \"The current specification does not take a position on the maximum length of a DID\"\n// - in current atproto, only allowing did:plc and did:web. But not *forcing* this at lexicon layer\n// - hard length limit of 8KBytes\n// - not going to validate \"percent encoding\" here\nexport const ensureValidDid = (did: string): void => {\n // check that all chars are boring ASCII\n if (!/^[a-zA-Z0-9._:%-]*$/.test(did)) {\n throw new InvalidDidError(\n 'Disallowed characters in DID (ASCII letters, digits, and a couple other characters only)',\n )\n }\n\n const parts = did.split(':')\n if (parts.length < 3) {\n throw new InvalidDidError(\n 'DID requires prefix, method, and method-specific content',\n )\n }\n\n if (parts[0] != 'did') {\n throw new InvalidDidError('DID requires \"did:\" prefix')\n }\n\n if (!/^[a-z]+$/.test(parts[1])) {\n throw new InvalidDidError('DID method must be lower-case letters')\n }\n\n if (did.endsWith(':') || did.endsWith('%')) {\n throw new InvalidDidError('DID can not end with \":\" or \"%\"')\n }\n\n if (did.length > 2 * 1024) {\n throw new InvalidDidError('DID is too long (2048 chars max)')\n }\n}\n\nexport const ensureValidDidRegex = (did: string): void => {\n // simple regex to enforce most constraints via just regex and length.\n // hand wrote this regex based on above constraints\n if (!/^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$/.test(did)) {\n throw new InvalidDidError(\"DID didn't validate via regex\")\n }\n\n if (did.length > 2 * 1024) {\n throw new InvalidDidError('DID is too long (2048 chars max)')\n }\n}\n\nexport class InvalidDidError extends Error {}\n", "/*\nGrammar:\n\nalpha = \"a\" / \"b\" / \"c\" / \"d\" / \"e\" / \"f\" / \"g\" / \"h\" / \"i\" / \"j\" / \"k\" / \"l\" / \"m\" / \"n\" / \"o\" / \"p\" / \"q\" / \"r\" / \"s\" / \"t\" / \"u\" / \"v\" / \"w\" / \"x\" / \"y\" / \"z\" / \"A\" / \"B\" / \"C\" / \"D\" / \"E\" / \"F\" / \"G\" / \"H\" / \"I\" / \"J\" / \"K\" / \"L\" / \"M\" / \"N\" / \"O\" / \"P\" / \"Q\" / \"R\" / \"S\" / \"T\" / \"U\" / \"V\" / \"W\" / \"X\" / \"Y\" / \"Z\"\nnumber = \"1\" / \"2\" / \"3\" / \"4\" / \"5\" / \"6\" / \"7\" / \"8\" / \"9\" / \"0\"\ndelim = \".\"\nsegment = alpha *( alpha / number / \"-\" )\nauthority = segment *( delim segment )\nname = alpha *( alpha )\nnsid = authority delim name\n\n*/\n\nexport class NSID {\n segments: string[] = []\n\n static parse(nsid: string): NSID {\n return new NSID(nsid)\n }\n\n static create(authority: string, name: string): NSID {\n const segments = [...authority.split('.').reverse(), name].join('.')\n return new NSID(segments)\n }\n\n static isValid(nsid: string): boolean {\n try {\n NSID.parse(nsid)\n return true\n } catch (e) {\n return false\n }\n }\n\n constructor(nsid: string) {\n ensureValidNsid(nsid)\n this.segments = nsid.split('.')\n }\n\n get authority() {\n return this.segments\n .slice(0, this.segments.length - 1)\n .reverse()\n .join('.')\n }\n\n get name() {\n return this.segments.at(this.segments.length - 1)\n }\n\n toString() {\n return this.segments.join('.')\n }\n}\n\n// Human readable constraints on NSID:\n// - a valid domain in reversed notation\n// - followed by an additional period-separated name, which is camel-case letters\nexport const ensureValidNsid = (nsid: string): void => {\n const toCheck = nsid\n\n // check that all chars are boring ASCII\n if (!/^[a-zA-Z0-9.-]*$/.test(toCheck)) {\n throw new InvalidNsidError(\n 'Disallowed characters in NSID (ASCII letters, digits, dashes, periods only)',\n )\n }\n\n if (toCheck.length > 253 + 1 + 63) {\n throw new InvalidNsidError('NSID is too long (317 chars max)')\n }\n const labels = toCheck.split('.')\n if (labels.length < 3) {\n throw new InvalidNsidError('NSID needs at least three parts')\n }\n for (let i = 0; i < labels.length; i++) {\n const l = labels[i]\n if (l.length < 1) {\n throw new InvalidNsidError('NSID parts can not be empty')\n }\n if (l.length > 63) {\n throw new InvalidNsidError('NSID part too long (max 63 chars)')\n }\n if (l.endsWith('-') || l.startsWith('-')) {\n throw new InvalidNsidError('NSID parts can not start or end with hyphen')\n }\n if (/^[0-9]/.test(l) && i == 0) {\n throw new InvalidNsidError('NSID first part may not start with a digit')\n }\n if (!/^[a-zA-Z]+$/.test(l) && i + 1 == labels.length) {\n throw new InvalidNsidError('NSID name part must be only letters')\n }\n }\n}\n\nexport const ensureValidNsidRegex = (nsid: string): void => {\n // simple regex to enforce most constraints via just regex and length.\n // hand wrote this regex based on above constraints\n if (\n !/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\\.[a-zA-Z]([a-zA-Z]{0,61}[a-zA-Z])?)$/.test(\n nsid,\n )\n ) {\n throw new InvalidNsidError(\"NSID didn't validate via regex\")\n }\n if (nsid.length > 253 + 1 + 63) {\n throw new InvalidNsidError('NSID is too long (317 chars max)')\n }\n}\n\nexport class InvalidNsidError extends Error {}\n", "import { ensureValidHandle, ensureValidHandleRegex } from './handle'\nimport { ensureValidDid, ensureValidDidRegex } from './did'\nimport { ensureValidNsid, ensureValidNsidRegex } from './nsid'\n\n// Human-readable constraints on ATURI:\n// - following regular URLs, a 8KByte hard total length limit\n// - follows ATURI docs on website\n// - all ASCII characters, no whitespace. non-ASCII could be URL-encoded\n// - starts \"at://\"\n// - \"authority\" is a valid DID or a valid handle\n// - optionally, follow \"authority\" with \"/\" and valid NSID as start of path\n// - optionally, if NSID given, follow that with \"/\" and rkey\n// - rkey path component can include URL-encoded (\"percent encoded\"), or:\n// ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\" / \":\" / \"@\" / \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\" / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n// [a-zA-Z0-9._~:@!$&'\\(\\)*+,;=-]\n// - rkey must have at least one char\n// - regardless of path component, a fragment can follow as \"#\" and then a JSON pointer (RFC-6901)\nexport const ensureValidAtUri = (uri: string) => {\n // JSON pointer is pretty different from rest of URI, so split that out first\n const uriParts = uri.split('#')\n if (uriParts.length > 2) {\n throw new Error('ATURI can have at most one \"#\", separating fragment out')\n }\n const fragmentPart = uriParts[1] || null\n uri = uriParts[0]\n\n // check that all chars are boring ASCII\n if (!/^[a-zA-Z0-9._~:@!$&')(*+,;=%/-]*$/.test(uri)) {\n throw new Error('Disallowed characters in ATURI (ASCII)')\n }\n\n const parts = uri.split('/')\n if (parts.length >= 3 && (parts[0] != 'at:' || parts[1].length != 0)) {\n throw new Error('ATURI must start with \"at://\"')\n }\n if (parts.length < 3) {\n throw new Error('ATURI requires at least method and authority sections')\n }\n\n try {\n ensureValidHandle(parts[2])\n } catch {\n try {\n ensureValidDid(parts[2])\n } catch {\n throw new Error('ATURI authority must be a valid handle or DID')\n }\n }\n\n if (parts.length >= 4) {\n if (parts[3].length == 0) {\n throw new Error(\n 'ATURI can not have a slash after authority without a path segment',\n )\n }\n try {\n ensureValidNsid(parts[3])\n } catch {\n throw new Error(\n 'ATURI requires first path segment (if supplied) to be valid NSID',\n )\n }\n }\n\n if (parts.length >= 5) {\n if (parts[4].length == 0) {\n throw new Error(\n 'ATURI can not have a slash after collection, unless record key is provided',\n )\n }\n // would validate rkey here, but there are basically no constraints!\n }\n\n if (parts.length >= 6) {\n throw new Error(\n 'ATURI path can have at most two parts, and no trailing slash',\n )\n }\n\n if (uriParts.length >= 2 && fragmentPart == null) {\n throw new Error('ATURI fragment must be non-empty and start with slash')\n }\n\n if (fragmentPart != null) {\n if (fragmentPart.length == 0 || fragmentPart[0] != '/') {\n throw new Error('ATURI fragment must be non-empty and start with slash')\n }\n // NOTE: enforcing *some* checks here for sanity. Eg, at least no whitespace\n if (!/^\\/[a-zA-Z0-9._~:@!$&')(*+,;=%[\\]/-]*$/.test(fragmentPart)) {\n throw new Error('Disallowed characters in ATURI fragment (ASCII)')\n }\n }\n\n if (uri.length > 8 * 1024) {\n throw new Error('ATURI is far too long')\n }\n}\n\nexport const ensureValidAtUriRegex = (uri: string): void => {\n // simple regex to enforce most constraints via just regex and length.\n // hand wrote this regex based on above constraints. whew!\n const aturiRegex =\n /^at:\\/\\/(?<authority>[a-zA-Z0-9._:%-]+)(\\/(?<collection>[a-zA-Z0-9-.]+)(\\/(?<rkey>[a-zA-Z0-9._~:@!$&%')(*+,;=-]+))?)?(#(?<fragment>\\/[a-zA-Z0-9._~:@!$&%')(*+,;=\\-[\\]/\\\\]*))?$/\n const rm = uri.match(aturiRegex)\n if (!rm || !rm.groups) {\n throw new Error(\"ATURI didn't validate via regex\")\n }\n const groups = rm.groups\n\n try {\n ensureValidHandleRegex(groups.authority)\n } catch {\n try {\n ensureValidDidRegex(groups.authority)\n } catch {\n throw new Error('ATURI authority must be a valid handle or DID')\n }\n }\n\n if (groups.collection) {\n try {\n ensureValidNsidRegex(groups.collection)\n } catch {\n throw new Error('ATURI collection path segment must be a valid NSID')\n }\n }\n\n if (uri.length > 8 * 1024) {\n throw new Error('ATURI is far too long')\n }\n}\n", "export * from './aturi_validation'\n\nexport const ATP_URI_REGEX =\n // proto- --did-------------- --name---------------- --path---- --query-- --hash--\n /^(at:\\/\\/)?((?:did:[a-z0-9:%-]+)|(?:[a-z0-9][a-z0-9.:-]*))(\\/[^?#\\s]*)?(\\?[^#\\s]+)?(#[^\\s]+)?$/i\n// --path----- --query-- --hash--\nconst RELATIVE_REGEX = /^(\\/[^?#\\s]*)?(\\?[^#\\s]+)?(#[^\\s]+)?$/i\n\nexport class AtUri {\n hash: string\n host: string\n pathname: string\n searchParams: URLSearchParams\n\n constructor(uri: string, base?: string) {\n let parsed\n if (base) {\n parsed = parse(base)\n if (!parsed) {\n throw new Error(`Invalid at uri: ${base}`)\n }\n const relativep = parseRelative(uri)\n if (!relativep) {\n throw new Error(`Invalid path: ${uri}`)\n }\n Object.assign(parsed, relativep)\n } else {\n parsed = parse(uri)\n if (!parsed) {\n throw new Error(`Invalid at uri: ${uri}`)\n }\n }\n\n this.hash = parsed.hash\n this.host = parsed.host\n this.pathname = parsed.pathname\n this.searchParams = parsed.searchParams\n }\n\n static make(handleOrDid: string, collection?: string, rkey?: string) {\n let str = handleOrDid\n if (collection) str += '/' + collection\n if (rkey) str += '/' + rkey\n return new AtUri(str)\n }\n\n get protocol() {\n return 'at:'\n }\n\n get origin() {\n return `at://${this.host}`\n }\n\n get hostname() {\n return this.host\n }\n\n set hostname(v: string) {\n this.host = v\n }\n\n get search() {\n return this.searchParams.toString()\n }\n\n set search(v: string) {\n this.searchParams = new URLSearchParams(v)\n }\n\n get collection() {\n return this.pathname.split('/').filter(Boolean)[0] || ''\n }\n\n set collection(v: string) {\n const parts = this.pathname.split('/').filter(Boolean)\n parts[0] = v\n this.pathname = parts.join('/')\n }\n\n get rkey() {\n return this.pathname.split('/').filter(Boolean)[1] || ''\n }\n\n set rkey(v: string) {\n const parts = this.pathname.split('/').filter(Boolean)\n if (!parts[0]) parts[0] = 'undefined'\n parts[1] = v\n this.pathname = parts.join('/')\n }\n\n get href() {\n return this.toString()\n }\n\n toString() {\n let path = this.pathname || '/'\n if (!path.startsWith('/')) {\n path = `/${path}`\n }\n let qs = this.searchParams.toString()\n if (qs && !qs.startsWith('?')) {\n qs = `?${qs}`\n }\n let hash = this.hash\n if (hash && !hash.startsWith('#')) {\n hash = `#${hash}`\n }\n return `at://${this.host}${path}${qs}${hash}`\n }\n}\n\nfunction parse(str: string) {\n const match = ATP_URI_REGEX.exec(str)\n if (match) {\n return {\n hash: match[5] || '',\n host: match[2] || '',\n pathname: match[3] || '',\n searchParams: new URLSearchParams(match[4] || ''),\n }\n }\n return undefined\n}\n\nfunction parseRelative(str: string) {\n const match = RELATIVE_REGEX.exec(str)\n if (match) {\n return {\n hash: match[3] || '',\n pathname: match[1] || '',\n searchParams: new URLSearchParams(match[2] || ''),\n }\n }\n return undefined\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AM;AAAA,MAClB,MAAM,MAAM,MAAM;AAAA,MAClB,UAAU,MAAM,MAAM;AAAA,MACtB,cAAc,IAAI,gBAAgB,MAAM,MAAM,EAAE;AAAA,IAClD;AAAA,EACF;AACA,SAAO;AACT;AAEA,uBAAuB,KAAa;AAClC,QAAM,QAAQ,eAAe,KAAK,GAAG;AACrC,MAAI,OAAO;AACT,WAAO;AAAA,MACL,MAAM,MAAM,MAAM;AAAA,MAClB,UAAU,MAAM,MAAM;AAAA,MACtB,cAAc,IAAI,gBAAgB,MAAM,MAAM,EAAE;AAAA,IAClD;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
2
  "name": "@atproto/syntax",
3
- "version": "0.1.0",
4
- "main": "dist/index.js",
5
- "scripts": {
6
- "test": "jest",
7
- "prettier": "prettier --check src/ tests/",
8
- "prettier:fix": "prettier --write src/ tests/",
9
- "lint": "eslint . --ext .ts,.tsx",
10
- "lint:fix": "yarn lint --fix",
11
- "verify": "run-p prettier lint",
12
- "verify:fix": "yarn prettier:fix && yarn lint:fix",
13
- "build": "node ./build.js",
14
- "postbuild": "tsc --build tsconfig.build.json",
15
- "update-main-to-dist": "node ./update-pkg.js --update-main-to-dist",
16
- "update-main-to-src": "node ./update-pkg.js --update-main-to-src",
17
- "prepublish": "npm run update-main-to-dist",
18
- "postpublish": "npm run update-main-to-src"
19
- },
3
+ "version": "0.1.2",
20
4
  "license": "MIT",
5
+ "description": "Validation for atproto identifiers and formats: DID, handle, NSID, AT URI, etc",
6
+ "keywords": [
7
+ "atproto",
8
+ "did",
9
+ "nsid",
10
+ "at-uri"
11
+ ],
12
+ "homepage": "https://atproto.com",
21
13
  "repository": {
22
14
  "type": "git",
23
- "url": "https://github.com/bluesky-social/atproto.git",
15
+ "url": "https://github.com/bluesky-social/atproto",
24
16
  "directory": "packages/syntax"
25
17
  },
18
+ "main": "dist/index.js",
26
19
  "dependencies": {
27
- "@atproto/common-web": "*"
20
+ "@atproto/common-web": "^0.2.1"
28
21
  },
29
22
  "browser": {
30
23
  "dns/promises": false
31
- }
32
- }
24
+ },
25
+ "scripts": {
26
+ "test": "jest",
27
+ "build": "node ./build.js",
28
+ "postbuild": "tsc --build tsconfig.build.json",
29
+ "update-main-to-dist": "node ../../update-main-to-dist.js packages/syntax"
30
+ },
31
+ "types": "dist/index.d.ts"
32
+ }
@@ -1,4 +1,6 @@
1
1
  import { AtUri, ensureValidAtUri, ensureValidAtUriRegex } from '../src/index'
2
+ import * as readline from 'readline'
3
+ import * as fs from 'fs'
2
4
 
3
5
  describe('At Uris', () => {
4
6
  it('parses valid at uris', () => {
@@ -503,4 +505,21 @@ describe('AtUri validation', () => {
503
505
  expectValid('at://did:plc:asdf123#/;')
504
506
  expectValid('at://did:plc:asdf123#/,')
505
507
  })
508
+
509
+ it('conforms to interop valid ATURIs', () => {
510
+ const lineReader = readline.createInterface({
511
+ input: fs.createReadStream(
512
+ `${__dirname}/interop-files/aturi_syntax_valid.txt`,
513
+ ),
514
+ terminal: false,
515
+ })
516
+ lineReader.on('line', (line) => {
517
+ if (line.startsWith('#') || line.length == 0) {
518
+ return
519
+ }
520
+ expectValid(line)
521
+ })
522
+ })
523
+
524
+ // NOTE: this package is currently more permissive than spec about AT URIs, so invalid cases are not errors
506
525
  })
package/tests/did.test.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { ensureValidDid, ensureValidDidRegex, InvalidDidError } from '../src'
2
+ import * as readline from 'readline'
3
+ import * as fs from 'fs'
2
4
 
3
5
  describe('DID permissive validation', () => {
4
6
  const expectValid = (h: string) => {
@@ -64,4 +66,34 @@ describe('DID permissive validation', () => {
64
66
  expectValid('did:key:zQ3shZc2QzApp2oymGvQbzP8eKheVshBHbU4ZYjeXqwSKEn6N')
65
67
  expectValid('did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a')
66
68
  })
69
+
70
+ it('conforms to interop valid DIDs', () => {
71
+ const lineReader = readline.createInterface({
72
+ input: fs.createReadStream(
73
+ `${__dirname}/interop-files/did_syntax_valid.txt`,
74
+ ),
75
+ terminal: false,
76
+ })
77
+ lineReader.on('line', (line) => {
78
+ if (line.startsWith('#') || line.length == 0) {
79
+ return
80
+ }
81
+ expectValid(line)
82
+ })
83
+ })
84
+
85
+ it('conforms to interop invalid DIDs', () => {
86
+ const lineReader = readline.createInterface({
87
+ input: fs.createReadStream(
88
+ `${__dirname}/interop-files/did_syntax_invalid.txt`,
89
+ ),
90
+ terminal: false,
91
+ })
92
+ lineReader.on('line', (line) => {
93
+ if (line.startsWith('#') || line.length == 0) {
94
+ return
95
+ }
96
+ expectInvalid(line)
97
+ })
98
+ })
67
99
  })
@@ -4,6 +4,8 @@ import {
4
4
  ensureValidHandleRegex,
5
5
  InvalidHandleError,
6
6
  } from '../src'
7
+ import * as readline from 'readline'
8
+ import * as fs from 'fs'
7
9
 
8
10
  describe('handle validation', () => {
9
11
  const expectValid = (h: string) => {
@@ -190,6 +192,36 @@ describe('handle validation', () => {
190
192
  ]
191
193
  badStackoverflow.forEach(expectInvalid)
192
194
  })
195
+
196
+ it('conforms to interop valid handles', () => {
197
+ const lineReader = readline.createInterface({
198
+ input: fs.createReadStream(
199
+ `${__dirname}/interop-files/handle_syntax_valid.txt`,
200
+ ),
201
+ terminal: false,
202
+ })
203
+ lineReader.on('line', (line) => {
204
+ if (line.startsWith('#') || line.length == 0) {
205
+ return
206
+ }
207
+ expectValid(line)
208
+ })
209
+ })
210
+
211
+ it('conforms to interop invalid handles', () => {
212
+ const lineReader = readline.createInterface({
213
+ input: fs.createReadStream(
214
+ `${__dirname}/interop-files/handle_syntax_invalid.txt`,
215
+ ),
216
+ terminal: false,
217
+ })
218
+ lineReader.on('line', (line) => {
219
+ if (line.startsWith('#') || line.length == 0) {
220
+ return
221
+ }
222
+ expectInvalid(line)
223
+ })
224
+ })
193
225
  })
194
226
 
195
227
  describe('normalization', () => {
@@ -4,6 +4,8 @@ import {
4
4
  InvalidNsidError,
5
5
  NSID,
6
6
  } from '../src'
7
+ import * as readline from 'readline'
8
+ import * as fs from 'fs'
7
9
 
8
10
  describe('NSID parsing & creation', () => {
9
11
  it('parses valid NSIDs', () => {
@@ -123,4 +125,34 @@ describe('NSID validation', () => {
123
125
  'onion.2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.lex.deleteThing',
124
126
  )
125
127
  })
128
+
129
+ it('conforms to interop valid NSIDs', () => {
130
+ const lineReader = readline.createInterface({
131
+ input: fs.createReadStream(
132
+ `${__dirname}/interop-files/nsid_syntax_valid.txt`,
133
+ ),
134
+ terminal: false,
135
+ })
136
+ lineReader.on('line', (line) => {
137
+ if (line.startsWith('#') || line.length == 0) {
138
+ return
139
+ }
140
+ expectValid(line)
141
+ })
142
+ })
143
+
144
+ it('conforms to interop invalid NSIDs', () => {
145
+ const lineReader = readline.createInterface({
146
+ input: fs.createReadStream(
147
+ `${__dirname}/interop-files/nsid_syntax_invalid.txt`,
148
+ ),
149
+ terminal: false,
150
+ })
151
+ lineReader.on('line', (line) => {
152
+ if (line.startsWith('#') || line.length == 0) {
153
+ return
154
+ }
155
+ expectInvalid(line)
156
+ })
157
+ })
126
158
  })
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "extends": "./tsconfig.json",
3
3
  "exclude": ["**/*.spec.ts", "**/*.test.ts"]
4
- }
4
+ }
package/tsconfig.json CHANGED
@@ -5,8 +5,6 @@
5
5
  "outDir": "./dist", // Your outDir,
6
6
  "emitDeclarationOnly": true
7
7
  },
8
- "include": ["./src","__tests__/**/**.ts"],
9
- "references": [
10
- { "path": "../common/tsconfig.build.json" },
11
- ]
12
- }
8
+ "include": ["./src", "__tests__/**/**.ts"],
9
+ "references": [{ "path": "../common/tsconfig.build.json" }]
10
+ }
@@ -1 +0,0 @@
1
- {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../node_modules/typescript/lib/lib.webworker.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","./src/handle.ts","./src/did.ts","./src/nsid.ts","./src/aturi_validation.ts","./src/aturi.ts","./src/index.ts","../../node_modules/@babel/types/lib/index.d.ts","../../node_modules/@types/babel__generator/index.d.ts","../../node_modules/@babel/parser/typings/babel-parser.d.ts","../../node_modules/@types/babel__template/index.d.ts","../../node_modules/@types/babel__traverse/index.d.ts","../../node_modules/@types/babel__core/index.d.ts","../../node_modules/@types/node/ts4.8/assert.d.ts","../../node_modules/@types/node/ts4.8/assert/strict.d.ts","../../node_modules/@types/node/ts4.8/globals.d.ts","../../node_modules/@types/node/ts4.8/async_hooks.d.ts","../../node_modules/@types/node/ts4.8/buffer.d.ts","../../node_modules/@types/node/ts4.8/child_process.d.ts","../../node_modules/@types/node/ts4.8/cluster.d.ts","../../node_modules/@types/node/ts4.8/console.d.ts","../../node_modules/@types/node/ts4.8/constants.d.ts","../../node_modules/@types/node/ts4.8/crypto.d.ts","../../node_modules/@types/node/ts4.8/dgram.d.ts","../../node_modules/@types/node/ts4.8/diagnostics_channel.d.ts","../../node_modules/@types/node/ts4.8/dns.d.ts","../../node_modules/@types/node/ts4.8/dns/promises.d.ts","../../node_modules/@types/node/ts4.8/domain.d.ts","../../node_modules/@types/node/ts4.8/dom-events.d.ts","../../node_modules/@types/node/ts4.8/events.d.ts","../../node_modules/@types/node/ts4.8/fs.d.ts","../../node_modules/@types/node/ts4.8/fs/promises.d.ts","../../node_modules/@types/node/ts4.8/http.d.ts","../../node_modules/@types/node/ts4.8/http2.d.ts","../../node_modules/@types/node/ts4.8/https.d.ts","../../node_modules/@types/node/ts4.8/inspector.d.ts","../../node_modules/@types/node/ts4.8/module.d.ts","../../node_modules/@types/node/ts4.8/net.d.ts","../../node_modules/@types/node/ts4.8/os.d.ts","../../node_modules/@types/node/ts4.8/path.d.ts","../../node_modules/@types/node/ts4.8/perf_hooks.d.ts","../../node_modules/@types/node/ts4.8/process.d.ts","../../node_modules/@types/node/ts4.8/punycode.d.ts","../../node_modules/@types/node/ts4.8/querystring.d.ts","../../node_modules/@types/node/ts4.8/readline.d.ts","../../node_modules/@types/node/ts4.8/readline/promises.d.ts","../../node_modules/@types/node/ts4.8/repl.d.ts","../../node_modules/@types/node/ts4.8/stream.d.ts","../../node_modules/@types/node/ts4.8/stream/promises.d.ts","../../node_modules/@types/node/ts4.8/stream/consumers.d.ts","../../node_modules/@types/node/ts4.8/stream/web.d.ts","../../node_modules/@types/node/ts4.8/string_decoder.d.ts","../../node_modules/@types/node/ts4.8/test.d.ts","../../node_modules/@types/node/ts4.8/timers.d.ts","../../node_modules/@types/node/ts4.8/timers/promises.d.ts","../../node_modules/@types/node/ts4.8/tls.d.ts","../../node_modules/@types/node/ts4.8/trace_events.d.ts","../../node_modules/@types/node/ts4.8/tty.d.ts","../../node_modules/@types/node/ts4.8/url.d.ts","../../node_modules/@types/node/ts4.8/util.d.ts","../../node_modules/@types/node/ts4.8/v8.d.ts","../../node_modules/@types/node/ts4.8/vm.d.ts","../../node_modules/@types/node/ts4.8/wasi.d.ts","../../node_modules/@types/node/ts4.8/worker_threads.d.ts","../../node_modules/@types/node/ts4.8/zlib.d.ts","../../node_modules/@types/node/ts4.8/globals.global.d.ts","../../node_modules/@types/node/ts4.8/index.d.ts","../../node_modules/@types/bn.js/index.d.ts","../../node_modules/@types/connect/index.d.ts","../../node_modules/@types/body-parser/index.d.ts","../../node_modules/@types/cors/index.d.ts","../../node_modules/@types/elliptic/index.d.ts","../../node_modules/@types/range-parser/index.d.ts","../../node_modules/@types/qs/index.d.ts","../../node_modules/@types/express-serve-static-core/index.d.ts","../../node_modules/@types/mime/mime.d.ts","../../node_modules/@types/mime/index.d.ts","../../node_modules/@types/serve-static/index.d.ts","../../node_modules/@types/express/index.d.ts","../../node_modules/@types/graceful-fs/index.d.ts","../../node_modules/@types/http-errors/index.d.ts","../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../node_modules/@types/istanbul-lib-report/index.d.ts","../../node_modules/@types/istanbul-reports/index.d.ts","../../node_modules/@jest/expect-utils/build/index.d.ts","../../node_modules/chalk/index.d.ts","../../node_modules/@sinclair/typebox/typebox.d.ts","../../node_modules/@jest/schemas/build/index.d.ts","../../node_modules/pretty-format/build/index.d.ts","../../node_modules/jest-diff/build/index.d.ts","../../node_modules/jest-matcher-utils/build/index.d.ts","../../node_modules/expect/build/index.d.ts","../../node_modules/@types/jest/index.d.ts","../../node_modules/@types/json-schema/index.d.ts","../../node_modules/@types/jsonwebtoken/index.d.ts","../../node_modules/@types/minimatch/index.d.ts","../../node_modules/@types/minimist/index.d.ts","../../node_modules/@types/nodemailer/lib/dkim/index.d.ts","../../node_modules/@types/nodemailer/lib/mailer/mail-message.d.ts","../../node_modules/@types/nodemailer/lib/xoauth2/index.d.ts","../../node_modules/@types/nodemailer/lib/mailer/index.d.ts","../../node_modules/@types/nodemailer/lib/mime-node/index.d.ts","../../node_modules/@types/nodemailer/lib/smtp-connection/index.d.ts","../../node_modules/@types/nodemailer/lib/shared/index.d.ts","../../node_modules/@types/nodemailer/lib/json-transport/index.d.ts","../../node_modules/@types/nodemailer/lib/sendmail-transport/index.d.ts","../../node_modules/@types/nodemailer/lib/ses-transport/index.d.ts","../../node_modules/@types/nodemailer/lib/smtp-pool/index.d.ts","../../node_modules/@types/nodemailer/lib/smtp-transport/index.d.ts","../../node_modules/@types/nodemailer/lib/stream-transport/index.d.ts","../../node_modules/@types/nodemailer/index.d.ts","../../node_modules/@types/normalize-package-data/index.d.ts","../../node_modules/@types/parse-json/index.d.ts","../../node_modules/pg-types/index.d.ts","../../node_modules/pg-protocol/dist/messages.d.ts","../../node_modules/pg-protocol/dist/serializer.d.ts","../../node_modules/pg-protocol/dist/parser.d.ts","../../node_modules/pg-protocol/dist/index.d.ts","../../node_modules/@types/pg/index.d.ts","../../node_modules/@types/prettier/index.d.ts","../../node_modules/@types/sharp/index.d.ts","../../node_modules/@types/stack-utils/index.d.ts","../../node_modules/@types/ws/index.d.ts","../../node_modules/@types/yargs-parser/index.d.ts","../../node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"f20c05dbfe50a208301d2a1da37b9931bce0466eb5a1f4fe240971b4ecc82b67","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","d11a03592451da2d1065e09e61f4e2a9bf68f780f4f6623c18b57816a9679d17","aea179452def8a6152f98f63b191b84e7cbd69b0e248c91e61fb2e52328abe8c",{"version":"9b087de7268e4efc5f215347a62656663933d63c0b1d7b624913240367b999ea","affectsGlobalScope":true},{"version":"3260e3386d9535b804205bdddb5618a9a27735bd22927f48ad54363abcd23d45","affectsGlobalScope":true},{"version":"adb09ec0a64fc17dbbc4a228b3b18aa5f01db3440a6b0cbb02354df58674d584","affectsGlobalScope":true},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"55f400eec64d17e888e278f4def2f254b41b89515d3b88ad75d5e05f019daddd","affectsGlobalScope":true},{"version":"181f1784c6c10b751631b24ce60c7f78b20665db4550b335be179217bacc0d5f","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"775d9c9fd150d5de79e0450f35bc8b8f94ae64e3eb5da12725ff2a649dccc777","affectsGlobalScope":true},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"34c839eaaa6d78c8674ae2c37af2236dee6831b13db7b4ef4df3ec889a04d4f2","affectsGlobalScope":true},{"version":"34478567f8a80171f88f2f30808beb7da15eac0538ae91282dd33dce928d98ed","affectsGlobalScope":true},{"version":"ab7d58e6161a550ff92e5aff755dc37fe896245348332cd5f1e1203479fe0ed1","affectsGlobalScope":true},{"version":"6bda95ea27a59a276e46043b7065b55bd4b316c25e70e29b572958fa77565d43","affectsGlobalScope":true},{"version":"aedb8de1abb2ff1095c153854a6df7deae4a5709c37297f9d6e9948b6806fa66","affectsGlobalScope":true},{"version":"a4da0551fd39b90ca7ce5f68fb55d4dc0c1396d589b612e1902f68ee090aaada","affectsGlobalScope":true},{"version":"11ffe3c281f375fff9ffdde8bbec7669b4dd671905509079f866f2354a788064","affectsGlobalScope":true},{"version":"52d1bb7ab7a3306fd0375c8bff560feed26ed676a5b0457fa8027b563aecb9a4","affectsGlobalScope":true},{"version":"ee4dc157f27d019bef85254b1ce188935ab605bdd037c0c5052151c797f291fa","signature":"67290fc6f046543cb5798eca0d2dbf9e1d58fad0e5263371644cd40efff866c9"},{"version":"3b517cf900c258d29107284d5a63e41f6c0cb053bc3d80903b40299cb2124f7d","signature":"d20de2fdeaf85ca7debd113c71d413a266af882b94bde15d79cd638d946f01ec"},{"version":"d4e48a50f33cfdf5e5480849afd0462e43e2860b5dcf758f9a58487651d48a57","signature":"2441b33ac47cb8a3e7d58a058d7f787838f9c2c8411e9cf121e44077e7b00d58"},{"version":"fd7a16c2fd81e0686567cec9c6e4d102abb3d9ae55ac886fedde68bf87a0b0c8","signature":"03e5304310d7238c871f0f7226c58b263ee38275921fb7703bd0518b5d851461"},{"version":"1a382ec34feffcbeb6f39e288243c04210cf2edaf2e828aad37d783313b1bd96","signature":"a2b489c4135993100eed9734d099457356d46272f8a362d0d7384f215777ebcb"},{"version":"1a70fd974623f60a760b422b4fb4818f8aaa49f3d2934823066a87119ed38abd","signature":"8863deb8ff30ba7ee62f69b857529c5bb5ef21e9a8de4b0eabf4b4e7f1254618"},"c561efdf5ba0b62619745d4761fe2d9756f23db972e039367d15922fed67fd2f","cc957354aa3c94c9961ebf46282cfde1e81d107fc5785a61f62c67f1dd3ac2eb","7ec238b220ea991b6643e24191b1f552a65956d5f6de4c6144e700b9985265d8","93de1c6dab503f053efe8d304cb522bb3a89feab8c98f307a674a4fae04773e9","dae3d1adc67ac3dbd1cd471889301339ec439837b5df565982345be20c8fca9a","5426e62886b7be7806312d31a00e8f7dccd6fe63ba9bbefe99ee2eab29cc48a3","7e771891adaa85b690266bc37bd6eb43bc57eecc4b54693ead36467e7369952a","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"02873d070f9cb79f50833fbf4a9a27ac578a2edf8ddb8421eba1b37faba83bfb","affectsGlobalScope":true},"21a167fec8f933752fb8157f06d28fab6817af3ad9b0bdb1908a10762391eab9",{"version":"c0db280fa6b09d7b8d6720a19a47f485956a41ee0e6914f1b704033eb69c6058","affectsGlobalScope":true},"0c0cee62cb619aed81133b904f644515ba3064487002a7da83fd8aa07b1b4abd","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","afcc1c426b76db7ec80e563d4fb0ba9e6bcc6e63c2d7e9342e649dc56d26347f","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","489532ff54b714f0e0939947a1c560e516d3ae93d51d639ab02e907a0e950114","f30bb836526d930a74593f7b0f5c1c46d10856415a8f69e5e2fc3db80371e362","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true},{"version":"816ad2e607a96de5bcac7d437f843f5afd8957f1fa5eefa6bba8e4ed7ca8fd84","affectsGlobalScope":true},"cec36af22f514322f870e81d30675c78df82ae8bf4863f5fd4e4424c040c678d","d903fafe96674bc0b2ac38a5be4a8fc07b14c2548d1cdb165a80ea24c44c0c54","b01a80007e448d035a16c74b5c95a5405b2e81b12fabcf18b75aa9eb9ef28990","04eb6578a588d6a46f50299b55f30e3a04ef27d0c5a46c57d8fcc211cd530faa","dbe5aa5a5dd8bd1c6a8d11b1310c3f0cdabaacc78a37b394a8c7b14faeb5fb84","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"d4ac44f01d42f541631c5fc88d0ed8efac29a3a3ad9a745d9fd58f8b61ed132e","7c013aa892414a7fdcfd861ae524a668eaa3ede8c7c0acafaf611948122c8d93","b0973c3cbcdc59b37bf477731d468696ecaf442593ec51bab497a613a580fe30",{"version":"4989e92ba5b69b182d2caaea6295af52b7dc73a4f7a2e336a676722884e7139d","affectsGlobalScope":true},{"version":"b3624aed92dab6da8484280d3cb3e2f4130ec3f4ef3f8201c95144ae9e898bb6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","210d54cd652ec0fec8c8916e4af59bb341065576ecda039842f9ffb2e908507c","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","3163f47436da41706c6e2b3c1511f3b7cce9f9f3905b2f3e01246c48b4ba7d14","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","69ee23dd0d215b09907ad30d23f88b7790c93329d1faf31d7835552a10cf7cbf","44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","213fc4f2b172d8beb74b77d7c1b41488d67348066d185e4263470cbb010cd6e8",{"version":"970a90f76d4d219ad60819d61f5994514087ba94c985647a3474a5a3d12714ed","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","4c8525f256873c7ba3135338c647eaf0ca7115a1a2805ae2d0056629461186ce","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"f0900cd5d00fe1263ff41201fb8073dbeb984397e4af3b8002a5c207a30bdc33","affectsGlobalScope":true},{"version":"f7db71191aa7aac5d6bc927ed6e7075c2763d22c7238227ec0c63c8cf5cb6a8b","affectsGlobalScope":true},"06d7c42d256f0ce6afe1b2b6cfbc97ab391f29dadb00dd0ae8e8f23f5bc916c3","ec4bd1b200670fb567920db572d6701ed42a9641d09c4ff6869768c8f81b404c","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa",{"version":"da26af7362f53d122283bc69fed862b9a9fe27e01bc6a69d1d682e0e5a4df3e6","affectsGlobalScope":true},"8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"652ee9c5103e89102d87bc20d167a02a0e3e5e53665674466c8cfea8a9e418c7","01f7828047b5c6703d3c601473618b448f5506a88fcac852638b0715c3abf4eb","6d829824ead8999f87b6df21200df3c6150391b894b4e80662caa462bd48d073","afc559c1b93df37c25aef6b3dfa2d64325b0e112e887ee18bf7e6f4ec383fc90","6fbd58e4015b9ae31ea977d4d549eb24a1102cc798b57ec5d70868b542c06612","b8a427b9fe88504a6fb092e21adfe272d144394a2ced7f9e4adc3de7efa6e216","16d51f964ec125ad2024cf03f0af444b3bc3ec3614d9345cc54d09bab45c9a4c","ba601641fac98c229ccd4a303f747de376d761babb33229bb7153bed9356c9cc",{"version":"ae3fe461989bbd951344efc1f1fe932360ce7392e6126bdb225a82a1bbaf15ee","affectsGlobalScope":true},"5b9ecf7da4d71cf3832dbb8336150fa924631811f488ad4690c2dfec2b4fb1d7","951c85f75aac041dddbedfedf565886a7b494e29ec1532e2a9b4a6180560b50e","f47887b61c6cf2f48746980390d6cb5b8013518951d912cfb37fe748071942be","15c88bfd1b8dc7231ff828ae8df5d955bae5ebca4cf2bcb417af5821e52299ae","3ebae8c00411116a66fca65b08228ea0cf0b72724701f9b854442100aab55aba","f463d61cf39c3a6a5f96cdf7adfdb72a0b1d663f7b5d5b6dd042adba835430c2","8b06ac3faeacb8484d84ddb44571d8f410697f98d7bfa86c0fda60373a9f5215","7eb06594824ada538b1d8b48c3925a83e7db792f47a081a62cf3e5c4e23cf0ee","f5638f7c2f12a9a1a57b5c41b3c1ea7db3876c003bab68e6a57afd6bcc169af0","763e521cf114b80e0dd0e21ca49b9f8ae62e8999555a5e7bade8ce36b33001c2","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","3e6bbb0883148627ca0854a9f62d820aaf1a0f1842f5568176721fef156b8f23","ffcc5500e77223169833fc6eb59b3a507944a1f89574e0a1276b0ea7fc22c4a4","22f13de9e2fe5f0f4724797abd3d34a1cdd6e47ef81fc4933fea3b8bf4ad524b","e3ba509d3dce019b3190ceb2f3fc88e2610ab717122dabd91a9efaa37804040d","cda0cb09b995489b7f4c57f168cd31b83dcbaa7aad49612734fb3c9c73f6e4f2","f72f8428f3c1caa22e9c247d046603b85b442c0dae7b77a7a0bc092c18867cb7",{"version":"195f63105abc03e72b6a176e3e34dfb5ac932b55db378fdc7874b1617e24b465","affectsGlobalScope":true},"f3e604694b624fa3f83f6684185452992088f5efb2cf136b62474aa106d6f1b6","bb4ed283cfb3db7ec1d4bb79c37f5e96d39b340f1f4de995c4b0b836c8d5fa05","8841e2aa774b89bd23302dede20663306dc1b9902431ac64b24be8b8d0e3f649","209e814e8e71aec74f69686a9506dd7610b97ab59dcee9446266446f72a76d05","bb654d426b82e0846cd4bd7de91d637039ecdfd63c94447373490178f80846fe","db90f54098b237753ac9c846e39cd49aa538dcad07a2e1c68a138f3c0f8e621d","92ad68795c32309fb43576cacb38bd2677deeed38f5730dcd4a8c5e65463ae15","4b16417aab5a4b276fd4a7db95120a8c7b4d49a6d68ddfe075e9f46dcbf22f00","eecb2ea10a1500dcc6bdeff14be1fb43806f63a9b8562e16e1b4fc8baa8dfa8d","221a6ab66d611349faaf80af49c7a34d95623787610fd153fed4da0811abdcae","f3d84d6f83cf131e4db335dc8100898adbeb01dd4cf4e2fe695ab220eac98be4","6521aaade4e1d23cbc4b665083b004aeaca23f3347ba2422f88d1828968a0056","e79130cf2ba010f2b79747bf43b086252ad041b130768331a1144c0a86185877","e9709ed827c40789c669736fc78e2ab603605e8e81325d1e6d7a5eb451810dd0","dafce7a7b279977940b6b4b50017625e4f922f73094433d2875994bdc0b27e87","6fc76efbb61d3336833ef44ff3f37552667f26c2a73b368f3b4b259f19f2c234","479496e5bb48f2f5e981ef646665bc09fd9ab080e86e9ea882ca4369411604af","6c559dee3c6251c261b67df08e01d4cbc89cbd7a63300150c636705733cebfff","6fa0008bf91a4cc9c8963bace4bba0bd6865cbfa29c3e3ccc461155660fb113a","2b8264b2fefd7367e0f20e2c04eed5d3038831fe00f5efbc110ff0131aab899b","f60e3e3060207ac982da13363181fd7ee4beecc19a7c569f0d6bb034331066c2","17230b34bb564a3a2e36f9d3985372ccab4ad1722df2c43f7c5c2b553f68e5db","87ed0f84f0691d5c724b23159db96342e6b04ac69201b02c65936f4281ce1fbe","13868c5792808236b17dfe2803eafce911ea4d09d3b2fda95391891a494f988f","0dfe35191a04e8f9dc7caeb9f52f2ee07402736563d12cbccd15fb5f31ac877f","eee8abb8503852554eec94e4f77339dbe8927f5f7dfecac41d9479d64bbfc475","93c4fc5b5237c09bc9ed65cb8f0dc1d89034406ab40500b89701341994897142","9adb78bae51a473d33f40da9bdb50c0e491d1cc7a5db776665853effa0cd3374","b0d10e46cfe3f6c476b69af02eaa38e4ccc7430221ce3109ae84bb9fb8282298","77c5c7f8578d139c74102a29384f5f4f0792a12d819ddcdcaf8307185ff2d45d","70e9a18da08294f75bf23e46c7d69e67634c0765d355887b9b41f0d959e1426e","28288f5e5f8b7b895ed2abe6359c1da3e0d14a64b5aef985071285671f347c01"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"emitDeclarationOnly":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"jsx":1,"module":1,"noImplicitAny":false,"outDir":"./dist","removeComments":true,"rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"strictPropertyInitialization":false,"target":7},"fileIdsList":[[63,115],[115],[115,142],[63,64,65,66,67,115],[63,65,115],[115,122],[88,115,122,124],[88,115,122],[88,115],[115,123],[85,88,115,122,128,129],[115,125,129,130,133],[86,115,122],[115,137],[115,138],[115,144,147],[115,131],[115,132],[69,115],[72,115],[73,78,106,115],[74,85,86,93,103,114,115],[74,75,85,93,115],[76,115],[77,78,86,94,115],[78,103,111,115],[79,81,85,93,115],[80,115],[81,82,115],[85,115],[83,85,115],[85,86,87,103,114,115],[85,86,87,100,103,106,115],[115,119],[88,93,103,114,115],[85,86,88,89,93,103,111,114,115],[88,90,103,111,114,115],[69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121],[85,91,115],[92,114,115],[81,85,93,103,115],[94,115],[95,115],[72,96,115],[97,113,115,119],[98,115],[99,115],[85,100,101,115],[100,102,115,117],[73,85,103,104,105,106,115],[73,103,105,115],[103,104,115],[106,115],[107,115],[85,109,110,115],[109,110,115],[78,93,103,111,115],[112,115],[93,113,115],[73,88,99,114,115],[78,115],[103,115,116],[115,117],[115,118],[73,78,85,87,96,103,114,115,117,119],[103,115,120],[115,122,154,156,160,161,162,163,164,165],[103,115,122],[85,115,122,154,156,157,159,166],[85,93,103,114,115,122,153,154,155,157,158,159,166],[103,115,122,156,157],[103,115,122,156,158],[115,122,154,156,157,159,166],[103,115,122,158],[85,93,103,111,115,122,155,157,159],[85,115,122,154,156,157,158,159,166],[85,103,115,122,154,155,156,157,158,159,166],[85,103,115,122,154,156,157,159,166],[88,103,115,122,159],[85,103,111,115,122,169,170,173,174],[88,115,122,132],[85,88,90,103,111,114,115,120,122],[115,179],[115,140,146],[115,144],[115,141,145],[115,122,170,171,172],[103,115,122,170],[115,143],[60,115],[57,58,59,115],[57,58,59,61,115],[60],[57,58,59,61]],"referencedMap":[[65,1],[63,2],[140,2],[143,3],[142,2],[68,4],[64,1],[66,5],[67,1],[123,6],[125,7],[124,8],[126,9],[127,10],[130,11],[134,12],[135,13],[136,2],[137,2],[138,14],[139,15],[148,16],[149,2],[150,6],[132,17],[131,18],[151,2],[152,2],[69,19],[70,19],[72,20],[73,21],[74,22],[75,23],[76,24],[77,25],[78,26],[79,27],[80,28],[81,29],[82,29],[84,30],[83,31],[85,30],[86,32],[87,33],[71,34],[121,2],[88,35],[89,36],[90,37],[122,38],[91,39],[92,40],[93,41],[94,42],[95,43],[96,44],[97,45],[98,46],[99,47],[100,48],[101,48],[102,49],[103,50],[105,51],[104,52],[106,53],[107,54],[108,2],[109,55],[110,56],[111,57],[112,58],[113,59],[114,60],[115,61],[116,62],[117,63],[118,64],[119,65],[120,66],[166,67],[153,68],[160,69],[156,70],[154,71],[157,72],[161,73],[162,69],[159,74],[158,75],[163,76],[164,77],[165,78],[155,79],[167,2],[168,2],[174,80],[175,2],[129,2],[128,2],[133,81],[176,68],[177,2],[178,82],[179,2],[180,83],[141,2],[147,84],[145,85],[146,86],[173,87],[170,6],[172,88],[171,6],[169,2],[144,89],[11,2],[12,2],[15,2],[14,2],[2,2],[16,2],[17,2],[18,2],[19,2],[20,2],[21,2],[22,2],[23,2],[3,2],[4,2],[27,2],[24,2],[25,2],[26,2],[28,2],[29,2],[30,2],[5,2],[31,2],[32,2],[33,2],[34,2],[6,2],[35,2],[36,2],[37,2],[38,2],[7,2],[39,2],[44,2],[45,2],[40,2],[41,2],[42,2],[43,2],[8,2],[49,2],[46,2],[47,2],[48,2],[50,2],[9,2],[51,2],[52,2],[53,2],[54,2],[55,2],[1,2],[10,2],[56,2],[13,2],[61,90],[60,91],[58,2],[57,2],[62,92],[59,2]],"exportedModulesMap":[[65,1],[63,2],[140,2],[143,3],[142,2],[68,4],[64,1],[66,5],[67,1],[123,6],[125,7],[124,8],[126,9],[127,10],[130,11],[134,12],[135,13],[136,2],[137,2],[138,14],[139,15],[148,16],[149,2],[150,6],[132,17],[131,18],[151,2],[152,2],[69,19],[70,19],[72,20],[73,21],[74,22],[75,23],[76,24],[77,25],[78,26],[79,27],[80,28],[81,29],[82,29],[84,30],[83,31],[85,30],[86,32],[87,33],[71,34],[121,2],[88,35],[89,36],[90,37],[122,38],[91,39],[92,40],[93,41],[94,42],[95,43],[96,44],[97,45],[98,46],[99,47],[100,48],[101,48],[102,49],[103,50],[105,51],[104,52],[106,53],[107,54],[108,2],[109,55],[110,56],[111,57],[112,58],[113,59],[114,60],[115,61],[116,62],[117,63],[118,64],[119,65],[120,66],[166,67],[153,68],[160,69],[156,70],[154,71],[157,72],[161,73],[162,69],[159,74],[158,75],[163,76],[164,77],[165,78],[155,79],[167,2],[168,2],[174,80],[175,2],[129,2],[128,2],[133,81],[176,68],[177,2],[178,82],[179,2],[180,83],[141,2],[147,84],[145,85],[146,86],[173,87],[170,6],[172,88],[171,6],[169,2],[144,89],[11,2],[12,2],[15,2],[14,2],[2,2],[16,2],[17,2],[18,2],[19,2],[20,2],[21,2],[22,2],[23,2],[3,2],[4,2],[27,2],[24,2],[25,2],[26,2],[28,2],[29,2],[30,2],[5,2],[31,2],[32,2],[33,2],[34,2],[6,2],[35,2],[36,2],[37,2],[38,2],[7,2],[39,2],[44,2],[45,2],[40,2],[41,2],[42,2],[43,2],[8,2],[49,2],[46,2],[47,2],[48,2],[50,2],[9,2],[51,2],[52,2],[53,2],[54,2],[55,2],[1,2],[10,2],[56,2],[13,2],[61,93],[62,94]],"semanticDiagnosticsPerFile":[65,63,140,143,142,68,64,66,67,123,125,124,126,127,130,134,135,136,137,138,139,148,149,150,132,131,151,152,69,70,72,73,74,75,76,77,78,79,80,81,82,84,83,85,86,87,71,121,88,89,90,122,91,92,93,94,95,96,97,98,99,100,101,102,103,105,104,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,166,153,160,156,154,157,161,162,159,158,163,164,165,155,167,168,174,175,129,128,133,176,177,178,179,180,141,147,145,146,173,170,172,171,169,144,11,12,15,14,2,16,17,18,19,20,21,22,23,3,4,27,24,25,26,28,29,30,5,31,32,33,34,6,35,36,37,38,7,39,44,45,40,41,42,43,8,49,46,47,48,50,9,51,52,53,54,55,1,10,56,13,61,60,58,57,62,59],"latestChangedDtsFile":"./dist/index.d.ts"},"version":"4.8.4"}
package/update-pkg.js DELETED
@@ -1,14 +0,0 @@
1
- const pkgJson = require('@npmcli/package-json')
2
-
3
- if (process.argv.includes('--update-main-to-dist')) {
4
- return pkgJson
5
- .load(__dirname)
6
- .then((pkg) => pkg.update({ main: 'dist/index.js' }))
7
- .then((pkg) => pkg.save())
8
- }
9
- if (process.argv.includes('--update-main-to-src')) {
10
- return pkgJson
11
- .load(__dirname)
12
- .then((pkg) => pkg.update({ main: 'src/index.ts' }))
13
- .then((pkg) => pkg.save())
14
- }