@formless63/registrar 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +13 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/testing.d.ts +11 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +61 -0
- package/dist/testing.js.map +1 -0
- package/package.json +42 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 formless63
|
|
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,3 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @formless63/registrar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The contract a registrar adapter implements. Types only, plus a conformance kit.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import type { Registrar, RegistrarDomain } from "@formless63/registrar";
|
|
7
|
+
import { assertRegistrarConformance } from "@formless63/registrar/testing";
|
|
8
|
+
|
|
9
|
+
// In any test runner, against an adapter with a stubbed transport:
|
|
10
|
+
await assertRegistrarConformance(myAdapter, { knownDomain: "example.com" });
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`null` fields mean "not stated"; `capabilities` says what an API can report at all. Money is a decimal string
|
|
14
|
+
with a currency, never a float. The contract is read-only.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"7.0.2","root":[[64,65]],"packageJsons":["../package.json"],"fileNames":["lib.es5.d.ts","lib.es2015.d.ts","lib.es2016.d.ts","lib.es2017.d.ts","lib.es2018.d.ts","lib.es2019.d.ts","lib.es2020.d.ts","lib.es2021.d.ts","lib.es2022.d.ts","lib.es2023.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts","lib.es2015.core.d.ts","lib.es2015.collection.d.ts","lib.es2015.generator.d.ts","lib.es2015.iterable.d.ts","lib.es2015.promise.d.ts","lib.es2015.proxy.d.ts","lib.es2015.reflect.d.ts","lib.es2015.symbol.d.ts","lib.es2015.symbol.wellknown.d.ts","lib.es2016.array.include.d.ts","lib.es2016.intl.d.ts","lib.es2017.arraybuffer.d.ts","lib.es2017.date.d.ts","lib.es2017.object.d.ts","lib.es2017.sharedmemory.d.ts","lib.es2017.string.d.ts","lib.es2017.intl.d.ts","lib.es2017.typedarrays.d.ts","lib.es2018.asyncgenerator.d.ts","lib.es2018.asynciterable.d.ts","lib.es2018.intl.d.ts","lib.es2018.promise.d.ts","lib.es2018.regexp.d.ts","lib.es2019.array.d.ts","lib.es2019.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2019.intl.d.ts","lib.es2020.bigint.d.ts","lib.es2020.date.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2020.intl.d.ts","lib.es2020.number.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.es2021.intl.d.ts","lib.es2022.array.d.ts","lib.es2022.error.d.ts","lib.es2022.intl.d.ts","lib.es2022.object.d.ts","lib.es2022.string.d.ts","lib.es2022.regexp.d.ts","lib.es2023.array.d.ts","lib.es2023.collection.d.ts","lib.es2023.intl.d.ts","lib.decorators.d.ts","lib.decorators.legacy.d.ts","../src/index.ts","../src/testing.ts"],"fileInfos":[{"version":"16934abaab7026ac114da441aabea1a0","affectsGlobalScope":true,"impliedNodeFormat":1},"d4306fb2e47f74835e8674ffac07d76f","e437c5c1302869326c3bb93da85bbbcf","e4324975a566567b21d350615f1fc6ac","333b1b9a2a9ac3b8497dba5c63b5ba50","6cffacd662b6eb5fa7a36aa2ea366bfa","b4c34f9c23304dbef2d23698637ed638","e5cb86a5fc491796ecd1d2dd348d208f","feb6c6fb19cdb246a5d8acb36a6901c7","9443a7f109277ffaa79d893ed2549995",{"version":"aae8996e8b5684814785a42cbbefcd79","affectsGlobalScope":true,"impliedNodeFormat":1},"abad6dd56cc8caf095c165df8124d237",{"version":"926204c28cd3d073865348473ae28d2e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f25e42c801b2cb3cf2b39792006a9beb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6344b55f26a4e81d9608777dbfb877dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3c0ed28e53d3695b363e256ec1c023fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4c2761daba7f17141c25baa0821ac5da","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b87656acabd63e69379ff6ffcfe52fc7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"597469522da047a5af5222cc6989f405","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1708ea4d34dc37fadadc63ca01127e80","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"55d97a8c6fbf34a30450a7b1e5f7a298","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0ee05eb59426d33e374226d8dcfa708b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e347c14030993906efcfbb88915b6a05","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b0231263857c9b6a03641acdc9280ceb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3b15c4a83b598cacb4067676e6f0abed","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b417d97b7934cef63b1889abec0bbfbf","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"09a6cf4032ebba60ce22a501e663f881","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2b056277dd138e8f5650fc04e20eaa8d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e22cc07e3f3cc242ba52fa3f8ea1fc58","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2c45da767a1bfbb220848df1bc4029e4","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b44c3e0fbaf2130cdcf6ac38b120ffa1","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b612fb5cf8e5d964b92063a75207632a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"02705151a5e1551b9162a9ed8ab763f7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"41025e398be9215d32e4337335da8f0b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"52684c2b1f353a5538e4f275182a54cd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6dedb6a4f90d1df3a6fbe5693e44886c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ca3f36fe3562c07e0f0d71c2bebd3f6d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"409974d6129befbb8226ddd1c6558568","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4d9cfde2a1ae1b4925f1f9bc10848e5d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7e1daecc66dd564144e3bb1a0266b5fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a8e1d9bb35fd0637f2f9fd2b2a54f2ec","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4f168501772a6543182765bfd5f2fbfe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a19c80aad1b2162103496f5ba293a732","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b69afa63cd5d059851c78adb2856ee09","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ae2fc5d954e9b0f5feee3d481b953c27","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1cfd3091a071d8b6feec15277643bafe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1da2c1f258970fd3cc91184f69e91a9d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a0d87491913d843139e0c993650a3235","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4ef72aa378127e7b7abba915b0110b1e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3ec74c6a7d4463f0254db3a74cf75646","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"84c2bdfa470d075526cce6322d81b0b6","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0b3844c2b8c73e4e1ab91431411cad11","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4fc71cf4a15b8d99675a31df77f26e07","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d1b49564ddaeca3df5b6dbae925d2242","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6a25be566d60ccfc2d6e8b7bfdeefa83","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8a20e27646985dfd58c57ca6566553dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9969f02ad3cdcbf4f709405cda44167f","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9c9be4792a7a4f42c15ae7360bf28779","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8cf777fe00349b71ee9c4b6f3fe7fd19","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"74f96bc192530c9723f572bfff3d3078","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1df91c56b25955c56387426f378173c5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f64453cbf9671f28158677fa5c43967a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"33f317af5428801f944a478d2c1e38e5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ff3d91f52017193a61a658e2e3b79d19","signature":"6115e71cef3bd03daf272bcadc869e7e","impliedNodeFormat":99},{"version":"2a31a9fc096d4b3906222ae8e80ae11a","signature":"593bdddc04de4b524e5bee63721a457e","impliedNodeFormat":99}],"fileIdsList":[[64]],"options":{"allowImportingTsExtensions":true,"composite":true,"declaration":true,"declarationMap":true,"erasableSyntaxOnly":true,"exactOptionalPropertyTypes":true,"module":199,"noUncheckedIndexedAccess":true,"outDir":"./","rewriteRelativeImportExtensions":true,"rootDir":"../src","skipLibCheck":true,"strict":true,"sourceMap":true,"target":10,"tsBuildInfoFile":"./.tsbuildinfo","verbatimModuleSyntax":true},"referencedMap":[[65,1]],"latestChangedDtsFile":"./testing.d.ts"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract a registrar adapter implements. Types only: adapters and
|
|
3
|
+
* applications share this shape without sharing code.
|
|
4
|
+
*/
|
|
5
|
+
/** One domain as a registrar account sees it. `null` means "not stated". */
|
|
6
|
+
export interface RegistrarDomain {
|
|
7
|
+
/** Lower-case ASCII (A-label), no trailing dot. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** ISO calendar dates (UTC). */
|
|
10
|
+
registeredOn: string | null;
|
|
11
|
+
expiresOn: string | null;
|
|
12
|
+
autoRenew: boolean | null;
|
|
13
|
+
/** Whether the registrant's details are hidden from public data. */
|
|
14
|
+
privacy: boolean | null;
|
|
15
|
+
transferLock: boolean | null;
|
|
16
|
+
/** Normalized, de-duplicated, sorted. */
|
|
17
|
+
nameservers: string[];
|
|
18
|
+
/** RDAP wording (RFC 8056), e.g. `client transfer prohibited`. Sorted. */
|
|
19
|
+
status: string[];
|
|
20
|
+
/** One-year renewal price. A decimal string, never a float. */
|
|
21
|
+
renewalPrice: Money | null;
|
|
22
|
+
/** Whether DNS is hosted by the registrar itself. */
|
|
23
|
+
usesRegistrarDns: boolean | null;
|
|
24
|
+
expired: boolean | null;
|
|
25
|
+
/** The registrar's own lifecycle word, verbatim and lower-cased. */
|
|
26
|
+
lifecycle: string | null;
|
|
27
|
+
premium: boolean | null;
|
|
28
|
+
}
|
|
29
|
+
export interface Money {
|
|
30
|
+
/** Decimal string such as `10.98`. */
|
|
31
|
+
amount: string;
|
|
32
|
+
/** ISO 4217, upper-case. */
|
|
33
|
+
currency: string;
|
|
34
|
+
}
|
|
35
|
+
/** What this adapter's API can actually report, so absence is not read as "no". */
|
|
36
|
+
export interface RegistrarCapabilities {
|
|
37
|
+
renewalPrice: boolean;
|
|
38
|
+
status: boolean;
|
|
39
|
+
nameservers: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface RequestOptions {
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}
|
|
44
|
+
export interface Registrar {
|
|
45
|
+
/** Stable machine id, e.g. `spaceship`. */
|
|
46
|
+
readonly id: string;
|
|
47
|
+
/** Display name, e.g. `Spaceship`. */
|
|
48
|
+
readonly label: string;
|
|
49
|
+
readonly capabilities: RegistrarCapabilities;
|
|
50
|
+
/** Every domain in the account, or an error: never a silently truncated list. */
|
|
51
|
+
listDomains(options?: RequestOptions): Promise<RegistrarDomain[]>;
|
|
52
|
+
/** Rejects with kind `not_found` when the account does not hold the name. */
|
|
53
|
+
getDomain(name: string, options?: RequestOptions): Promise<RegistrarDomain>;
|
|
54
|
+
/** The cheapest authenticated read, to check a credential. */
|
|
55
|
+
probe(options?: RequestOptions): Promise<{
|
|
56
|
+
domains: number;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,oEAAoE;IACpE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,yCAAyC;IACzC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+DAA+D;IAC/D,YAAY,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3B,qDAAqD;IACrD,gBAAgB,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,oEAAoE;IACpE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,KAAK;IACpB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mFAAmF;AACnF,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,qBAAqB,CAAC;IAC7C,iFAAiF;IACjF,WAAW,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAClE,6EAA6E;IAC7E,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC5E,8DAA8D;IAC9D,KAAK,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/D"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Registrar, RegistrarDomain } from './index.ts';
|
|
2
|
+
/** Problems with one record's shape; empty when it honours the contract. */
|
|
3
|
+
export declare function checkRegistrarDomain(domain: RegistrarDomain): string[];
|
|
4
|
+
/**
|
|
5
|
+
* Exercises an adapter against the contract and throws one Error listing every
|
|
6
|
+
* problem. Works in any test runner; point it at a stubbed adapter.
|
|
7
|
+
*/
|
|
8
|
+
export declare function assertRegistrarConformance(registrar: Registrar, { knownDomain }: {
|
|
9
|
+
knownDomain: string;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAM7D,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,EAAE,CA+BtE;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,SAAS,EAAE,SAAS,EACpB,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GACvC,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const NAME = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9-]{2,63}$/;
|
|
2
|
+
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
3
|
+
const AMOUNT = /^\d{1,12}(?:\.\d{1,4})?$/;
|
|
4
|
+
/** Problems with one record's shape; empty when it honours the contract. */
|
|
5
|
+
export function checkRegistrarDomain(domain) {
|
|
6
|
+
const problems = [];
|
|
7
|
+
const expect = (ok, message) => {
|
|
8
|
+
if (!ok)
|
|
9
|
+
problems.push(`${domain.name || '(unnamed)'}: ${message}`);
|
|
10
|
+
};
|
|
11
|
+
const sortedUnique = (values) => values.every((value, index) => index === 0 || values[index - 1] < value);
|
|
12
|
+
expect(NAME.test(domain.name), 'name is not a normalized domain name');
|
|
13
|
+
for (const field of ['registeredOn', 'expiresOn']) {
|
|
14
|
+
expect(domain[field] === null || DATE.test(domain[field]), `${field} is not an ISO date`);
|
|
15
|
+
}
|
|
16
|
+
for (const field of ['nameservers', 'status']) {
|
|
17
|
+
expect(sortedUnique(domain[field]), `${field} is not sorted and unique`);
|
|
18
|
+
expect(domain[field].every((value) => value !== '' && value === value.trim().toLowerCase()), `${field} has unnormalized values`);
|
|
19
|
+
}
|
|
20
|
+
expect(domain.nameservers.every((host) => !host.endsWith('.')), 'a nameserver has a trailing dot');
|
|
21
|
+
expect(domain.status.every((status) => !/[A-Z_]/.test(status) && status !== 'ok'), 'status is not in RDAP wording');
|
|
22
|
+
if (domain.renewalPrice) {
|
|
23
|
+
expect(AMOUNT.test(domain.renewalPrice.amount), 'renewalPrice.amount is not a decimal string');
|
|
24
|
+
expect(/^[A-Z]{3}$/.test(domain.renewalPrice.currency), 'renewalPrice.currency is not ISO 4217');
|
|
25
|
+
}
|
|
26
|
+
return problems;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Exercises an adapter against the contract and throws one Error listing every
|
|
30
|
+
* problem. Works in any test runner; point it at a stubbed adapter.
|
|
31
|
+
*/
|
|
32
|
+
export async function assertRegistrarConformance(registrar, { knownDomain }) {
|
|
33
|
+
const problems = [];
|
|
34
|
+
if (!/^[a-z][a-z0-9-]*$/.test(registrar.id))
|
|
35
|
+
problems.push('id is not a machine id');
|
|
36
|
+
if (registrar.label.trim() === '')
|
|
37
|
+
problems.push('label is empty');
|
|
38
|
+
const listed = await registrar.listDomains();
|
|
39
|
+
const names = listed.map((domain) => domain.name);
|
|
40
|
+
if (new Set(names).size !== names.length)
|
|
41
|
+
problems.push('listDomains returned duplicates');
|
|
42
|
+
for (const domain of [...listed, await registrar.getDomain(knownDomain)]) {
|
|
43
|
+
problems.push(...checkRegistrarDomain(domain));
|
|
44
|
+
if (!registrar.capabilities.renewalPrice && domain.renewalPrice !== null) {
|
|
45
|
+
problems.push(`${domain.name}: renewalPrice reported without the capability`);
|
|
46
|
+
}
|
|
47
|
+
if (!registrar.capabilities.status && domain.status.length > 0) {
|
|
48
|
+
problems.push(`${domain.name}: status reported without the capability`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!names.includes(knownDomain))
|
|
52
|
+
problems.push('listDomains did not include knownDomain');
|
|
53
|
+
for (const bad of ['', 'not a domain', '../x']) {
|
|
54
|
+
const kind = await registrar.getDomain(bad).then(() => 'resolved', (error) => error?.kind);
|
|
55
|
+
if (kind !== 'invalid_input')
|
|
56
|
+
problems.push(`getDomain(${JSON.stringify(bad)}) gave ${String(kind)}`);
|
|
57
|
+
}
|
|
58
|
+
if (problems.length > 0)
|
|
59
|
+
throw new Error(`Registrar contract violated:\n- ${problems.join('\n- ')}`);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAEA,MAAM,IAAI,GAAG,8DAA8D,CAAC;AAC5E,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG,0BAA0B,CAAC;AAE1C,4EAA4E;AAC5E,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IAC1D,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,CAAC,EAAW,EAAE,OAAe,EAAQ,EAAE;QACpD,IAAI,CAAC,EAAE;YAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,WAAW,KAAK,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IACF,MAAM,YAAY,GAAG,CAAC,MAAgB,EAAW,EAAE,CACjD,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,CAAE,GAAG,KAAK,CAAC,CAAC;IAC5E,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,sCAAsC,CAAC,CAAC;IACvE,KAAK,MAAM,KAAK,IAAI,CAAC,cAAc,EAAE,WAAW,CAAU,EAAE,CAAC;QAC3D,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,KAAK,qBAAqB,CA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cAAc,EAAE,MAAM,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAC9C,GAAG,EAAE,CAAC,UAAU,EAChB,CAAC,KAAc,EAAE,EAAE,CAAE,KAAmC,EAAE,IAAI,CAC/D,CAAC;QACF,IAAI,IAAI,KAAK,eAAe;YAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxG,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACvG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formless63/registrar",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A provider-neutral contract for reading a domain registrar account, with a conformance suite.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"registrar",
|
|
7
|
+
"domain",
|
|
8
|
+
"adapter"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/formless63/netlibs.git",
|
|
14
|
+
"directory": "packages/registrar"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/formless63/netlibs/tree/main/packages/registrar#readme",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/formless63/netlibs/issues"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./testing": {
|
|
36
|
+
"types": "./dist/testing.d.ts",
|
|
37
|
+
"default": "./dist/testing.js"
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|