@comms-id/sanctions 0.2.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 +15 -0
- package/README.md +33 -0
- package/dist/browser.d.ts +5 -0
- package/dist/browser.js +6 -0
- package/dist/descriptor.d.ts +11 -0
- package/dist/descriptor.js +15 -0
- package/dist/fixtures.d.ts +5 -0
- package/dist/fixtures.js +10 -0
- package/dist/generated/client.d.ts +8 -0
- package/dist/generated/client.js +6 -0
- package/dist/generated/fixtures.d.ts +2 -0
- package/dist/generated/fixtures.js +44 -0
- package/dist/generated/operations.d.ts +6 -0
- package/dist/generated/operations.js +258 -0
- package/dist/generated/types.d.ts +39 -0
- package/dist/generated/types.js +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/runtime/browser-core.d.ts +23 -0
- package/dist/runtime/browser-core.js +41 -0
- package/dist/runtime/environment.d.ts +5 -0
- package/dist/runtime/environment.js +30 -0
- package/dist/runtime/errors.d.ts +29 -0
- package/dist/runtime/errors.js +40 -0
- package/dist/runtime/fixture-core.d.ts +7 -0
- package/dist/runtime/fixture-core.js +26 -0
- package/dist/runtime/http.d.ts +34 -0
- package/dist/runtime/http.js +165 -0
- package/dist/runtime/server-core.d.ts +26 -0
- package/dist/runtime/server-core.js +39 -0
- package/dist/runtime/sign.d.ts +22 -0
- package/dist/runtime/sign.js +41 -0
- package/dist/runtime/validate.d.ts +57 -0
- package/dist/runtime/validate.js +175 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.js +8 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Copyright (c) 2026 COMMS.ID PTY LTD. Proprietary software; not open source.
|
|
2
|
+
|
|
3
|
+
Subject to the Comms.ID policy agreement, you may install, copy, bundle, run and
|
|
4
|
+
deliver this client or component within your applications, adapt the supplied
|
|
5
|
+
component source, and use the designated local functions and fixtures offline.
|
|
6
|
+
Hosted operations are provided by the Comms.ID service.
|
|
7
|
+
|
|
8
|
+
You may keep replies for your own customers and transactions, and your registered
|
|
9
|
+
application may relay requests for its own users.
|
|
10
|
+
|
|
11
|
+
You may not republish these packages as a standalone offering, resell access, offer
|
|
12
|
+
a substitute lookup service, or harvest replies to reconstruct or redistribute a
|
|
13
|
+
source dataset.
|
|
14
|
+
|
|
15
|
+
Preserve this notice and any applicable third-party notices.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @comms-id/sanctions
|
|
2
|
+
|
|
3
|
+
Typed client for the Comms.ID Sanctions API (`https://api.comms.id/sanctions/v1`): screening of one individual, entity or vessel against the Australian Sanctions Consolidated List.
|
|
4
|
+
|
|
5
|
+
`src/` is generated from the Sanctions contract (`packages/dfat-consolidated-list/openapi/sanctions.v1.json`) by `@comms-id/forge-transformers`. Do not edit it: change the contract and run `pnpm --filter @comms-id/forge-transformers generate`.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createSanctionsClient } from "@comms-id/sanctions/server";
|
|
9
|
+
|
|
10
|
+
const client = createSanctionsClient({
|
|
11
|
+
clientId: process.env.COMMS_ID_CLIENT_ID!,
|
|
12
|
+
privateJwk: JSON.parse(process.env.COMMS_ID_PRIVATE_JWK!),
|
|
13
|
+
});
|
|
14
|
+
const reply = await client.screen({"type": "Individual", "name": "Example Person", "dateOfBirth": "1970-06-15"});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Operations
|
|
18
|
+
|
|
19
|
+
- `screen`: Screen one individual, entity or vessel against the Australian Sanctions Consolidated List (DFAT): exact names and aliases, optionally narrowed by date and place of birth. The reply carries every possible match with its evidence, the list generation and its freshness. It refuses to answer from a stale list.
|
|
20
|
+
|
|
21
|
+
Every operation is a read, safe to repeat, and is retried after a retryable failure. A reply that is not a match is one of the outcomes of the reply convention: an error with `outcomeOf(error)` of `no-match`, `source-unavailable` or `failed`; an outage is never a "no match".
|
|
22
|
+
|
|
23
|
+
## Test it first
|
|
24
|
+
|
|
25
|
+
`createSanctionsFixtureClient()` from `@comms-id/sanctions/fixtures` answers from the contract's own examples with no network and says so (`fixture: true`). To call the TEST service (synthetic replies, your development app's key), pass `environment: "test"`; going live changes only the environment and the key.
|
|
26
|
+
|
|
27
|
+
## Server only
|
|
28
|
+
|
|
29
|
+
Sanctions screening is not open to a browser holding no credential: call it from your own server, or through a relay (`@comms-id/relay`). `./browser` takes your relay route and never signs.
|
|
30
|
+
|
|
31
|
+
Entries: `.` (types and errors, safe in a browser), `./server` (signs each call), `./browser` (your relay route; never signs), `./fixtures` (LOCAL FIXTURES, no network), `./descriptor` (what `@comms-id/relay` may forward).
|
|
32
|
+
|
|
33
|
+
The package is private until the publishing path exists (#515). `LICENSE` is the consumer client licence.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type SanctionsClient } from "./generated/client.js";
|
|
2
|
+
import { type BrowserOptions } from "./runtime/browser-core.js";
|
|
3
|
+
export type { Environment } from "./runtime/environment.js";
|
|
4
|
+
export type { BrowserOptions, CapabilityOptions, RelayOptions } from "./runtime/browser-core.js";
|
|
5
|
+
export declare const createSanctionsBrowserClient: (options: BrowserOptions) => SanctionsClient;
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Generated by @comms-id/forge-transformers from the service's OpenAPI contract. Do not edit: change the contract and regenerate.
|
|
2
|
+
// Browser entry: it never signs and holds no secret. Use the consumer's relay route, or a
|
|
3
|
+
// short-lived capability that the caller supplies.
|
|
4
|
+
import { buildClient } from "./generated/client.js";
|
|
5
|
+
import { createBrowserTransport } from "./runtime/browser-core.js";
|
|
6
|
+
export const createSanctionsBrowserClient = (options) => buildClient(createBrowserTransport(options));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const sanctionsProduct: {
|
|
2
|
+
readonly product: "sanctions";
|
|
3
|
+
readonly audience: "dfat-consolidated-list";
|
|
4
|
+
readonly scope: "dfat-consolidated-list:read";
|
|
5
|
+
readonly maxBodyBytes: 16384;
|
|
6
|
+
readonly operations: readonly [{
|
|
7
|
+
readonly name: "screen";
|
|
8
|
+
readonly method: "POST";
|
|
9
|
+
readonly path: "/sanctions/v1/screen";
|
|
10
|
+
}];
|
|
11
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Generated by @comms-id/forge-transformers from the service's OpenAPI contract. Do not edit: change the contract and regenerate.
|
|
2
|
+
// The product descriptor that @comms-id/relay reads: which operations may be forwarded.
|
|
3
|
+
export const sanctionsProduct = {
|
|
4
|
+
product: "sanctions",
|
|
5
|
+
audience: "dfat-consolidated-list",
|
|
6
|
+
scope: "dfat-consolidated-list:read",
|
|
7
|
+
maxBodyBytes: 16_384,
|
|
8
|
+
operations: [
|
|
9
|
+
{
|
|
10
|
+
"name": "screen",
|
|
11
|
+
"method": "POST",
|
|
12
|
+
"path": "/sanctions/v1/screen"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
};
|
package/dist/fixtures.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by @comms-id/forge-transformers from the service's OpenAPI contract. Do not edit: change the contract and regenerate.
|
|
2
|
+
// LOCAL FIXTURES: no network. The client runs the same request and reply checks as a real call.
|
|
3
|
+
import { buildClient } from "./generated/client.js";
|
|
4
|
+
import { fixtures } from "./generated/fixtures.js";
|
|
5
|
+
import { createFixtureTransport } from "./runtime/fixture-core.js";
|
|
6
|
+
export { FIXTURE_HEADER, FIXTURE_NOTICE } from "./runtime/fixture-core.js";
|
|
7
|
+
export const createSanctionsFixtureClient = () => ({
|
|
8
|
+
...buildClient(createFixtureTransport(fixtures)),
|
|
9
|
+
fixture: true,
|
|
10
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CallOptions, type TransportConfig } from "../runtime/http.js";
|
|
2
|
+
import type { ScreenRequest, ScreenResponse } from "./types.js";
|
|
3
|
+
/** The client of Comms.ID Sanctions: one method for each operation. */
|
|
4
|
+
export interface SanctionsClient {
|
|
5
|
+
/** Screen one individual, entity or vessel against the Australian Sanctions Consolidated List (DFAT): exact names and aliases, optionally narrowed by date and place of birth. The reply carries every possible match with its evidence, the list generation and its freshness. It refuses to answer from a stale list. */
|
|
6
|
+
readonly screen: (input: ScreenRequest, options?: CallOptions) => Promise<ScreenResponse>;
|
|
7
|
+
}
|
|
8
|
+
export declare const buildClient: (transport: TransportConfig) => SanctionsClient;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Generated by @comms-id/forge-transformers from the service's OpenAPI contract. Do not edit: change the contract and regenerate.
|
|
2
|
+
import { call } from "../runtime/http.js";
|
|
3
|
+
import { operations } from "./operations.js";
|
|
4
|
+
export const buildClient = (transport) => ({
|
|
5
|
+
screen: (input, options) => call(transport, operations.screen, input, options),
|
|
6
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Generated by @comms-id/forge-transformers from the service's OpenAPI contract. Do not edit: change the contract and regenerate.
|
|
2
|
+
// Every reply is the example in the contract.
|
|
3
|
+
/** LOCAL FIXTURES: one canned reply for each operation path. Fake data. */
|
|
4
|
+
export const fixtures = {
|
|
5
|
+
"/sanctions/v1/screen": {
|
|
6
|
+
"format": 2,
|
|
7
|
+
"generation": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
|
|
8
|
+
"checkedAt": "2026-10-03T00:00:00.000Z",
|
|
9
|
+
"sourceLastModified": "Mon, 22 Sep 2026 03:10:00 GMT",
|
|
10
|
+
"candidates": [
|
|
11
|
+
{
|
|
12
|
+
"record": {
|
|
13
|
+
"reference": "1234",
|
|
14
|
+
"name": "EXAMPLE PERSON",
|
|
15
|
+
"type": "Individual",
|
|
16
|
+
"nameType": "Primary Name",
|
|
17
|
+
"dobRanges": [
|
|
18
|
+
[
|
|
19
|
+
"1970-01-01",
|
|
20
|
+
"1970-12-31"
|
|
21
|
+
]
|
|
22
|
+
],
|
|
23
|
+
"placeOfBirth": [
|
|
24
|
+
"Example City"
|
|
25
|
+
],
|
|
26
|
+
"raw": {
|
|
27
|
+
"Reference": "1234",
|
|
28
|
+
"Name of Individual or Entity": "EXAMPLE PERSON"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"nameMatch": true,
|
|
32
|
+
"dobMatch": true,
|
|
33
|
+
"pobMatch": null
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"freshness": {
|
|
37
|
+
"status": "ready",
|
|
38
|
+
"lastSuccess": "2026-10-02T20:00:00.000Z",
|
|
39
|
+
"lastChecked": "2026-10-03T00:00:00.000Z",
|
|
40
|
+
"expiresAt": "2026-10-04T20:00:00.000Z",
|
|
41
|
+
"lastFailure": null
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Operation } from "../runtime/http.js";
|
|
2
|
+
export type OperationName = "screen";
|
|
3
|
+
/** The operations of Comms.ID Sanctions, with the schemas the client checks. */
|
|
4
|
+
export declare const operations: Readonly<Record<OperationName, Operation>>;
|
|
5
|
+
/** The error codes the contract documents for each operation. */
|
|
6
|
+
export declare const errorCodes: Readonly<Record<OperationName, readonly string[]>>;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// Generated by @comms-id/forge-transformers from the service's OpenAPI contract. Do not edit: change the contract and regenerate.
|
|
2
|
+
/** The operations of Comms.ID Sanctions, with the schemas the client checks. */
|
|
3
|
+
export const operations = {
|
|
4
|
+
screen: {
|
|
5
|
+
name: "screen",
|
|
6
|
+
method: "POST",
|
|
7
|
+
path: "/sanctions/v1/screen",
|
|
8
|
+
safeToRetry: true,
|
|
9
|
+
request: {
|
|
10
|
+
"t": "obj",
|
|
11
|
+
"props": {
|
|
12
|
+
"type": {
|
|
13
|
+
"t": "str",
|
|
14
|
+
"values": [
|
|
15
|
+
"Individual",
|
|
16
|
+
"Entity",
|
|
17
|
+
"Vessel"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"name": {
|
|
21
|
+
"t": "str",
|
|
22
|
+
"min": 1,
|
|
23
|
+
"max": 1024
|
|
24
|
+
},
|
|
25
|
+
"dateOfBirth": {
|
|
26
|
+
"t": "str",
|
|
27
|
+
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
|
|
28
|
+
},
|
|
29
|
+
"placeOfBirth": {
|
|
30
|
+
"t": "str",
|
|
31
|
+
"min": 1,
|
|
32
|
+
"max": 1024
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"req": [
|
|
36
|
+
"type",
|
|
37
|
+
"name"
|
|
38
|
+
],
|
|
39
|
+
"extra": false
|
|
40
|
+
},
|
|
41
|
+
response: {
|
|
42
|
+
"t": "obj",
|
|
43
|
+
"props": {
|
|
44
|
+
"format": {
|
|
45
|
+
"t": "num",
|
|
46
|
+
"values": [
|
|
47
|
+
2
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"generation": {
|
|
51
|
+
"t": "str",
|
|
52
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
53
|
+
},
|
|
54
|
+
"checkedAt": {
|
|
55
|
+
"t": "str"
|
|
56
|
+
},
|
|
57
|
+
"sourceLastModified": {
|
|
58
|
+
"t": "any_of",
|
|
59
|
+
"of": [
|
|
60
|
+
{
|
|
61
|
+
"t": "str"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"t": "null"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"candidates": {
|
|
69
|
+
"t": "arr",
|
|
70
|
+
"of": {
|
|
71
|
+
"t": "obj",
|
|
72
|
+
"props": {
|
|
73
|
+
"record": {
|
|
74
|
+
"t": "obj",
|
|
75
|
+
"props": {
|
|
76
|
+
"reference": {
|
|
77
|
+
"t": "str",
|
|
78
|
+
"min": 1,
|
|
79
|
+
"max": 1024
|
|
80
|
+
},
|
|
81
|
+
"name": {
|
|
82
|
+
"t": "str",
|
|
83
|
+
"min": 1,
|
|
84
|
+
"max": 1024
|
|
85
|
+
},
|
|
86
|
+
"type": {
|
|
87
|
+
"t": "str",
|
|
88
|
+
"values": [
|
|
89
|
+
"Individual",
|
|
90
|
+
"Entity",
|
|
91
|
+
"Vessel"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
"nameType": {
|
|
95
|
+
"t": "str"
|
|
96
|
+
},
|
|
97
|
+
"dobRanges": {
|
|
98
|
+
"t": "arr",
|
|
99
|
+
"of": {
|
|
100
|
+
"t": "tup",
|
|
101
|
+
"of": [
|
|
102
|
+
{
|
|
103
|
+
"t": "str",
|
|
104
|
+
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"t": "str",
|
|
108
|
+
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"placeOfBirth": {
|
|
114
|
+
"t": "arr",
|
|
115
|
+
"of": {
|
|
116
|
+
"t": "str"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"raw": {
|
|
120
|
+
"t": "map",
|
|
121
|
+
"of": {
|
|
122
|
+
"t": "str"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"req": [
|
|
127
|
+
"reference",
|
|
128
|
+
"name",
|
|
129
|
+
"type",
|
|
130
|
+
"nameType",
|
|
131
|
+
"dobRanges",
|
|
132
|
+
"placeOfBirth",
|
|
133
|
+
"raw"
|
|
134
|
+
],
|
|
135
|
+
"extra": false
|
|
136
|
+
},
|
|
137
|
+
"nameMatch": {
|
|
138
|
+
"t": "bool"
|
|
139
|
+
},
|
|
140
|
+
"dobMatch": {
|
|
141
|
+
"t": "any_of",
|
|
142
|
+
"of": [
|
|
143
|
+
{
|
|
144
|
+
"t": "bool"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"t": "null"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"pobMatch": {
|
|
152
|
+
"t": "any_of",
|
|
153
|
+
"of": [
|
|
154
|
+
{
|
|
155
|
+
"t": "bool"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"t": "null"
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"req": [
|
|
164
|
+
"record",
|
|
165
|
+
"nameMatch",
|
|
166
|
+
"dobMatch",
|
|
167
|
+
"pobMatch"
|
|
168
|
+
],
|
|
169
|
+
"extra": false
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"freshness": {
|
|
173
|
+
"t": "obj",
|
|
174
|
+
"props": {
|
|
175
|
+
"status": {
|
|
176
|
+
"t": "str",
|
|
177
|
+
"values": [
|
|
178
|
+
"ready",
|
|
179
|
+
"degraded"
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
"lastSuccess": {
|
|
183
|
+
"t": "str"
|
|
184
|
+
},
|
|
185
|
+
"lastChecked": {
|
|
186
|
+
"t": "str"
|
|
187
|
+
},
|
|
188
|
+
"expiresAt": {
|
|
189
|
+
"t": "str"
|
|
190
|
+
},
|
|
191
|
+
"lastFailure": {
|
|
192
|
+
"t": "any_of",
|
|
193
|
+
"of": [
|
|
194
|
+
{
|
|
195
|
+
"t": "obj",
|
|
196
|
+
"props": {
|
|
197
|
+
"at": {
|
|
198
|
+
"t": "str"
|
|
199
|
+
},
|
|
200
|
+
"code": {
|
|
201
|
+
"t": "str",
|
|
202
|
+
"values": [
|
|
203
|
+
"INVALID_INPUT",
|
|
204
|
+
"INVALID_DATASET",
|
|
205
|
+
"UNAVAILABLE",
|
|
206
|
+
"STALE",
|
|
207
|
+
"CONFLICT",
|
|
208
|
+
"CANCELLED",
|
|
209
|
+
"UNAUTHORISED"
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
"stage": {
|
|
213
|
+
"t": "str",
|
|
214
|
+
"values": [
|
|
215
|
+
"download",
|
|
216
|
+
"validation",
|
|
217
|
+
"publication"
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
"req": [
|
|
222
|
+
"at",
|
|
223
|
+
"code"
|
|
224
|
+
],
|
|
225
|
+
"extra": false
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"t": "null"
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
"req": [
|
|
234
|
+
"status",
|
|
235
|
+
"lastSuccess",
|
|
236
|
+
"lastChecked",
|
|
237
|
+
"expiresAt",
|
|
238
|
+
"lastFailure"
|
|
239
|
+
],
|
|
240
|
+
"extra": false
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
"req": [
|
|
244
|
+
"format",
|
|
245
|
+
"generation",
|
|
246
|
+
"checkedAt",
|
|
247
|
+
"sourceLastModified",
|
|
248
|
+
"candidates",
|
|
249
|
+
"freshness"
|
|
250
|
+
],
|
|
251
|
+
"extra": false
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
/** The error codes the contract documents for each operation. */
|
|
256
|
+
export const errorCodes = {
|
|
257
|
+
screen: ["INVALID_INPUT", "UNAUTHORIZED", "VERSION_RETIRED", "FAIR_USE_CEILING", "UNAVAILABLE"],
|
|
258
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** The body of screen. */
|
|
2
|
+
export type ScreenRequest = {
|
|
3
|
+
readonly type: "Individual" | "Entity" | "Vessel";
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly dateOfBirth?: string;
|
|
6
|
+
readonly placeOfBirth?: string;
|
|
7
|
+
};
|
|
8
|
+
/** The reply of screen. */
|
|
9
|
+
export type ScreenResponse = {
|
|
10
|
+
readonly format: 2;
|
|
11
|
+
readonly generation: string;
|
|
12
|
+
readonly checkedAt: string;
|
|
13
|
+
readonly sourceLastModified: string | null;
|
|
14
|
+
readonly candidates: ReadonlyArray<{
|
|
15
|
+
readonly record: {
|
|
16
|
+
readonly reference: string;
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly type: "Individual" | "Entity" | "Vessel";
|
|
19
|
+
readonly nameType: string;
|
|
20
|
+
readonly dobRanges: ReadonlyArray<readonly [string, string]>;
|
|
21
|
+
readonly placeOfBirth: readonly string[];
|
|
22
|
+
readonly raw: Readonly<Record<string, string>>;
|
|
23
|
+
};
|
|
24
|
+
readonly nameMatch: boolean;
|
|
25
|
+
readonly dobMatch: boolean | null;
|
|
26
|
+
readonly pobMatch: boolean | null;
|
|
27
|
+
}>;
|
|
28
|
+
readonly freshness: {
|
|
29
|
+
readonly status: "ready" | "degraded";
|
|
30
|
+
readonly lastSuccess: string;
|
|
31
|
+
readonly lastChecked: string;
|
|
32
|
+
readonly expiresAt: string;
|
|
33
|
+
readonly lastFailure: {
|
|
34
|
+
readonly at: string;
|
|
35
|
+
readonly code: "INVALID_INPUT" | "INVALID_DATASET" | "UNAVAILABLE" | "STALE" | "CONFLICT" | "CANCELLED" | "UNAUTHORISED";
|
|
36
|
+
readonly stage?: "download" | "validation" | "publication";
|
|
37
|
+
} | null;
|
|
38
|
+
};
|
|
39
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { SanctionsClient } from "./generated/client.js";
|
|
2
|
+
export { errorCodes, operations } from "./generated/operations.js";
|
|
3
|
+
export type { OperationName } from "./generated/operations.js";
|
|
4
|
+
export type { ScreenRequest, ScreenResponse } from "./generated/types.js";
|
|
5
|
+
export { CommsIdError, isCommsIdError, outcomeOf } from "./runtime/errors.js";
|
|
6
|
+
export type { Outcome } from "./runtime/errors.js";
|
|
7
|
+
export type { CallOptions } from "./runtime/http.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Generated by @comms-id/forge-transformers from the service's OpenAPI contract. Do not edit: change the contract and regenerate.
|
|
2
|
+
// Browser-safe entry: types, errors and the operation table. No signing code is imported here.
|
|
3
|
+
export { errorCodes, operations } from "./generated/operations.js";
|
|
4
|
+
export { CommsIdError, isCommsIdError, outcomeOf } from "./runtime/errors.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Environment } from "./environment.js";
|
|
2
|
+
import type { TransportConfig } from "./http.js";
|
|
3
|
+
interface Common {
|
|
4
|
+
readonly deadlineMs?: number;
|
|
5
|
+
readonly fetch?: typeof fetch;
|
|
6
|
+
readonly maxRetries?: number;
|
|
7
|
+
}
|
|
8
|
+
/** Calls the consumer's own server route, which signs for the app (the relay). */
|
|
9
|
+
export interface RelayOptions extends Common {
|
|
10
|
+
/** For example "/api/comms-id/address". The operation name is appended. */
|
|
11
|
+
readonly relayUrl: string;
|
|
12
|
+
}
|
|
13
|
+
/** Calls the hosted service with a short-lived capability that the caller supplies. */
|
|
14
|
+
export interface CapabilityOptions extends Common {
|
|
15
|
+
/** Another host. It wins over `environment`. */
|
|
16
|
+
readonly baseUrl?: string;
|
|
17
|
+
/** "live" (the default) or "test". */
|
|
18
|
+
readonly environment?: Environment;
|
|
19
|
+
readonly getCapability: () => Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
export type BrowserOptions = RelayOptions | CapabilityOptions;
|
|
22
|
+
export declare const createBrowserTransport: (options: BrowserOptions) => TransportConfig;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Runtime template: copied into every generated client package as src/runtime/browser-core.ts.
|
|
2
|
+
// Browser entry: it never signs and never holds a secret. It either calls the consumer's own
|
|
3
|
+
// relay route, or sends a short-lived capability that the caller obtains by other means.
|
|
4
|
+
import { resolveBaseUrl } from "./environment.js";
|
|
5
|
+
import { CommsIdError } from "./errors.js";
|
|
6
|
+
const TRAILING_SLASHES = /\/+$/;
|
|
7
|
+
const passThrough = (options) => ({
|
|
8
|
+
...(options.fetch === undefined ? {} : { fetch: options.fetch }),
|
|
9
|
+
...(options.deadlineMs === undefined ? {} : { deadlineMs: options.deadlineMs }),
|
|
10
|
+
...(options.maxRetries === undefined ? {} : { maxRetries: options.maxRetries }),
|
|
11
|
+
});
|
|
12
|
+
/** A browser client with neither a relay nor a capability source has no identified caller. */
|
|
13
|
+
const requireCaller = (options) => {
|
|
14
|
+
const relay = options.relayUrl;
|
|
15
|
+
const capability = options.getCapability;
|
|
16
|
+
if ((typeof relay !== "string" || relay === "") && typeof capability !== "function") {
|
|
17
|
+
throw new CommsIdError({
|
|
18
|
+
code: "NOT_CONFIGURED",
|
|
19
|
+
message: "Set relayUrl (your server route) or getCapability: the browser holds no credential of its own.",
|
|
20
|
+
status: 0,
|
|
21
|
+
retryable: false,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export const createBrowserTransport = (options) => {
|
|
26
|
+
requireCaller(options);
|
|
27
|
+
if ("relayUrl" in options) {
|
|
28
|
+
const relay = options.relayUrl.replace(TRAILING_SLASHES, "");
|
|
29
|
+
return {
|
|
30
|
+
urlFor: (operation) => `${relay}/${operation.name}`,
|
|
31
|
+
headers: () => Promise.resolve({}),
|
|
32
|
+
...passThrough(options),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const base = resolveBaseUrl(options.environment, options.baseUrl).replace(TRAILING_SLASHES, "");
|
|
36
|
+
return {
|
|
37
|
+
urlFor: (operation) => `${base}${operation.path}`,
|
|
38
|
+
headers: async () => ({ authorization: `Bearer ${await options.getCapability()}` }),
|
|
39
|
+
...passThrough(options),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type Environment = "live" | "test";
|
|
2
|
+
export declare const BASE_URLS: Readonly<Record<Environment, string>>;
|
|
3
|
+
export declare const isEnvironment: (value: unknown) => value is Environment;
|
|
4
|
+
/** The base URL: an explicit one wins, then the environment (live by default). */
|
|
5
|
+
export declare const resolveBaseUrl: (environment: unknown, baseUrl: string | undefined) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Runtime template: copied into every generated client package as src/runtime/environment.ts.
|
|
2
|
+
// The two environments of the hosted API (platform #515, T4). They differ in the base URL and in
|
|
3
|
+
// the keys the service knows: TEST answers with synthetic replies for apps registered in the
|
|
4
|
+
// development directory; LIVE answers with real data for apps registered in production. The API,
|
|
5
|
+
// the errors and the authentication are the same, so going live changes only the environment and
|
|
6
|
+
// the key.
|
|
7
|
+
import { CommsIdError } from "./errors.js";
|
|
8
|
+
export const BASE_URLS = {
|
|
9
|
+
live: "https://api.comms.id",
|
|
10
|
+
test: "https://api-test.comms.id",
|
|
11
|
+
};
|
|
12
|
+
export const isEnvironment = (value) => value === "live" || value === "test";
|
|
13
|
+
/** The base URL: an explicit one wins, then the environment (live by default). */
|
|
14
|
+
export const resolveBaseUrl = (environment, baseUrl) => {
|
|
15
|
+
if (baseUrl !== undefined) {
|
|
16
|
+
return baseUrl;
|
|
17
|
+
}
|
|
18
|
+
if (environment === undefined) {
|
|
19
|
+
return BASE_URLS.live;
|
|
20
|
+
}
|
|
21
|
+
if (!isEnvironment(environment)) {
|
|
22
|
+
throw new CommsIdError({
|
|
23
|
+
code: "NOT_CONFIGURED",
|
|
24
|
+
message: 'environment must be "test" or "live".',
|
|
25
|
+
status: 0,
|
|
26
|
+
retryable: false,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return BASE_URLS[environment];
|
|
30
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** The three results a lookup can have besides a match. */
|
|
2
|
+
export type Outcome = "no-match" | "source-unavailable" | "failed";
|
|
3
|
+
export interface ErrorInit {
|
|
4
|
+
/** The reply's own body, when the service answered an error status with a structured reply instead of an error body. */
|
|
5
|
+
readonly body?: unknown;
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
readonly requestId?: string | undefined;
|
|
9
|
+
readonly retryable: boolean;
|
|
10
|
+
/** The HTTP status, or 0 when no reply was received or the call never left the client. */
|
|
11
|
+
readonly status: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Every failure of a call. The service sends `code`, `message`, `retryable` and `requestId`.
|
|
15
|
+
* The client adds the codes INVALID_REQUEST (refused before any request), NETWORK, TIMEOUT,
|
|
16
|
+
* ABORTED and INVALID_RESPONSE.
|
|
17
|
+
*/
|
|
18
|
+
export declare class CommsIdError extends Error {
|
|
19
|
+
readonly code: string;
|
|
20
|
+
readonly status: number;
|
|
21
|
+
readonly retryable: boolean;
|
|
22
|
+
readonly requestId: string | undefined;
|
|
23
|
+
/** The structured reply of a status such as 503 whose body is an outcome, not an error body (code HTTP_<status>). */
|
|
24
|
+
readonly body: unknown;
|
|
25
|
+
constructor(init: ErrorInit);
|
|
26
|
+
}
|
|
27
|
+
export declare const isCommsIdError: (value: unknown) => value is CommsIdError;
|
|
28
|
+
/** Maps an error to the outcome that the reply convention names. A match never reaches this. */
|
|
29
|
+
export declare const outcomeOf: (error: unknown) => Outcome;
|