@registrystack/client 0.0.0 → 0.26.1
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/README.md +25 -3
- package/breg/client.d.ts +231 -0
- package/breg/client.js +185 -0
- package/breg/index.d.ts +79 -0
- package/breg/index.js +3 -0
- package/discovery/client.d.ts +238 -0
- package/discovery/client.js +329 -0
- package/discovery/index.d.ts +35 -0
- package/discovery/index.js +3 -0
- package/evidence/client.d.ts +181 -0
- package/evidence/client.js +239 -0
- package/evidence/index.d.ts +302 -0
- package/evidence/index.js +3 -0
- package/index.d.ts +6 -0
- package/index.js +8 -0
- package/native.js +34 -0
- package/package.json +40 -12
- package/relay/client.d.ts +408 -0
- package/relay/client.js +172 -0
- package/relay/index.d.ts +58 -0
- package/relay/index.js +3 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
export type ServiceKind = 'evidence' | 'relay';
|
|
2
|
+
|
|
3
|
+
export interface DiscoveryClientOptions {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
requestTimeoutMilliseconds?: number;
|
|
6
|
+
connectTimeoutMilliseconds?: number;
|
|
7
|
+
maximumResponseBytes?: number;
|
|
8
|
+
trustedRootCertificates?: Buffer;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface EvidenceTypeResolveRequest {
|
|
12
|
+
requirementId: string;
|
|
13
|
+
jurisdiction?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ResolvedAlternative {
|
|
17
|
+
evidenceTypeListId: string;
|
|
18
|
+
evidenceTypeIds: string[];
|
|
19
|
+
mappingId: string;
|
|
20
|
+
mappingAuthorityId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface EvidenceTypeResolveResponse extends EvidenceTypeResolveRequest {
|
|
24
|
+
mappingRevision: string;
|
|
25
|
+
alternatives: ResolvedAlternative[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ServiceFilters {
|
|
29
|
+
recordId?: string[];
|
|
30
|
+
serviceId?: string[];
|
|
31
|
+
serviceKind?: ServiceKind[];
|
|
32
|
+
jurisdiction?: string[];
|
|
33
|
+
conformsTo?: string[];
|
|
34
|
+
evidenceType?: string[];
|
|
35
|
+
semanticClass?: string[];
|
|
36
|
+
operationFamily?: string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface EvidenceServiceQuery {
|
|
40
|
+
evidenceTypeId: string;
|
|
41
|
+
jurisdiction?: string;
|
|
42
|
+
serviceIds?: string[];
|
|
43
|
+
conformsTo?: string[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface RelayServiceQueryOptions {
|
|
47
|
+
jurisdiction?: string;
|
|
48
|
+
serviceIds?: string[];
|
|
49
|
+
conformsTo?: string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type RelayServiceQuery = RelayServiceQueryOptions & (
|
|
53
|
+
| { semanticClassId: string; operationFamilyId?: string }
|
|
54
|
+
| { semanticClassId?: string; operationFamilyId: string }
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export interface ServiceRecord {
|
|
58
|
+
recordId: string;
|
|
59
|
+
bindingId: string;
|
|
60
|
+
serviceId: string;
|
|
61
|
+
serviceKind: ServiceKind;
|
|
62
|
+
title: string;
|
|
63
|
+
description: string;
|
|
64
|
+
endpointUrl: string;
|
|
65
|
+
publisherId?: string;
|
|
66
|
+
operatorId?: string;
|
|
67
|
+
registryAuthorityId?: string;
|
|
68
|
+
legalIssuerId?: string;
|
|
69
|
+
technicalProviderId?: string;
|
|
70
|
+
jurisdictions: string[];
|
|
71
|
+
conformsTo: string[];
|
|
72
|
+
evidenceTypeIds: string[];
|
|
73
|
+
semanticClassIds: string[];
|
|
74
|
+
operationFamilyIds: string[];
|
|
75
|
+
originId: string;
|
|
76
|
+
originUrl: string;
|
|
77
|
+
originContentDigest: string;
|
|
78
|
+
originFetchedAt: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ServiceSearchResponse {
|
|
82
|
+
catalogRevision: string;
|
|
83
|
+
items: ServiceRecord[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type MatchedCapability =
|
|
87
|
+
| { kind: 'evidence-type'; id: string }
|
|
88
|
+
| { kind: 'semantic-class'; id: string }
|
|
89
|
+
| { kind: 'operation-family'; id: string };
|
|
90
|
+
|
|
91
|
+
export interface SelectionRequest {
|
|
92
|
+
recordId: string;
|
|
93
|
+
matchedCapability: MatchedCapability;
|
|
94
|
+
mappingRevision?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface EvidenceResolutionContext {
|
|
98
|
+
requirementId: string;
|
|
99
|
+
jurisdiction?: string;
|
|
100
|
+
mappingRevision: string;
|
|
101
|
+
evidenceTypeListId: string;
|
|
102
|
+
evidenceTypeIds: string[];
|
|
103
|
+
mappingId: string;
|
|
104
|
+
mappingAuthorityId: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface EvidenceSelectionRequest {
|
|
108
|
+
recordId: string;
|
|
109
|
+
evidenceTypeId: string;
|
|
110
|
+
resolution?: EvidenceResolutionContext;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type RelayCapabilityMatch =
|
|
114
|
+
| { semanticClassId: string; operationFamilyId?: string }
|
|
115
|
+
| { semanticClassId?: string; operationFamilyId: string };
|
|
116
|
+
|
|
117
|
+
export interface RelaySelectionRequest {
|
|
118
|
+
recordId: string;
|
|
119
|
+
capabilityMatch: RelayCapabilityMatch;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface CommonServiceSelection extends Omit<ServiceRecord, 'title' | 'description'> {
|
|
123
|
+
matchedCapability: MatchedCapability;
|
|
124
|
+
catalogRevision: string;
|
|
125
|
+
mappingRevision?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface EvidenceServiceSelection extends CommonServiceSelection {
|
|
129
|
+
serviceKind: 'evidence';
|
|
130
|
+
matchedCapability: { kind: 'evidence-type'; id: string };
|
|
131
|
+
evidenceResolution?: EvidenceResolutionContext;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface RelayServiceSelection extends CommonServiceSelection {
|
|
135
|
+
serviceKind: 'relay';
|
|
136
|
+
matchedCapability:
|
|
137
|
+
| { kind: 'semantic-class'; id: string }
|
|
138
|
+
| { kind: 'operation-family'; id: string };
|
|
139
|
+
relayCapabilityMatch: RelayCapabilityMatch;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export type ServiceSelection = CommonServiceSelection;
|
|
143
|
+
|
|
144
|
+
export type DiscoveryClientErrorKind =
|
|
145
|
+
| 'configuration'
|
|
146
|
+
| 'query'
|
|
147
|
+
| 'no_matching_service'
|
|
148
|
+
| 'ambiguous_selection'
|
|
149
|
+
| 'no_matching_alternative'
|
|
150
|
+
| 'ambiguous_alternative'
|
|
151
|
+
| 'capability_mismatch'
|
|
152
|
+
| 'local_acceptance_refused'
|
|
153
|
+
| 'selection_changed'
|
|
154
|
+
| 'transport'
|
|
155
|
+
| 'problem'
|
|
156
|
+
| 'protocol'
|
|
157
|
+
| 'client';
|
|
158
|
+
|
|
159
|
+
export class DiscoveryClientError extends Error {
|
|
160
|
+
readonly kind: DiscoveryClientErrorKind;
|
|
161
|
+
readonly status?: number;
|
|
162
|
+
readonly problem?: string;
|
|
163
|
+
readonly transportKind?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export class DiscoveryClient {
|
|
167
|
+
constructor(options: string | DiscoveryClientOptions);
|
|
168
|
+
resolveEvidenceTypes(request: EvidenceTypeResolveRequest): Promise<EvidenceTypeResolveResponse>;
|
|
169
|
+
searchServices(filters?: ServiceFilters): Promise<ServiceSearchResponse>;
|
|
170
|
+
searchEvidenceServices(query: EvidenceServiceQuery): Promise<ServiceSearchResponse>;
|
|
171
|
+
searchRelayServices(query: RelayServiceQuery): Promise<ServiceSearchResponse>;
|
|
172
|
+
selectExact(response: ServiceSearchResponse, request: SelectionRequest): CommonServiceSelection;
|
|
173
|
+
selectEvidenceAlternative(
|
|
174
|
+
response: EvidenceTypeResolveResponse,
|
|
175
|
+
evidenceTypeListId?: string,
|
|
176
|
+
): EvidenceResolutionContext;
|
|
177
|
+
selectEvidenceService(
|
|
178
|
+
response: ServiceSearchResponse,
|
|
179
|
+
request: EvidenceSelectionRequest,
|
|
180
|
+
): EvidenceServiceSelection;
|
|
181
|
+
selectRelayService(
|
|
182
|
+
response: ServiceSearchResponse,
|
|
183
|
+
request: RelaySelectionRequest,
|
|
184
|
+
): RelayServiceSelection;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function selectExact(
|
|
188
|
+
response: ServiceSearchResponse,
|
|
189
|
+
request: SelectionRequest,
|
|
190
|
+
): CommonServiceSelection;
|
|
191
|
+
|
|
192
|
+
export function selectEvidenceAlternative(
|
|
193
|
+
response: EvidenceTypeResolveResponse,
|
|
194
|
+
evidenceTypeListId?: string,
|
|
195
|
+
): EvidenceResolutionContext;
|
|
196
|
+
|
|
197
|
+
export function selectEvidenceService(
|
|
198
|
+
response: ServiceSearchResponse,
|
|
199
|
+
request: EvidenceSelectionRequest,
|
|
200
|
+
): EvidenceServiceSelection;
|
|
201
|
+
|
|
202
|
+
export function selectRelayService(
|
|
203
|
+
response: ServiceSearchResponse,
|
|
204
|
+
request: RelaySelectionRequest,
|
|
205
|
+
): RelayServiceSelection;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Validate closed shape and capability binding only.
|
|
209
|
+
*
|
|
210
|
+
* This does not prove origin authenticity, catalog currentness, mapping
|
|
211
|
+
* currency, authorization, or adopter trust.
|
|
212
|
+
*/
|
|
213
|
+
export function validateSelectionStructure<T extends CommonServiceSelection>(selection: T): T;
|
|
214
|
+
|
|
215
|
+
/** @deprecated Use validateSelectionStructure. This operation is structural, not trust. */
|
|
216
|
+
export function validateSelection<T extends CommonServiceSelection>(selection: T): T;
|
|
217
|
+
|
|
218
|
+
export class AcceptedServiceSelection<T extends CommonServiceSelection> {
|
|
219
|
+
private constructor();
|
|
220
|
+
private readonly __acceptedServiceSelectionBrand: void;
|
|
221
|
+
readonly endpointUrl: string;
|
|
222
|
+
readonly selection: T;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Apply a synchronous adopter-owned local policy after structural validation. */
|
|
226
|
+
export function acceptSelection<T extends CommonServiceSelection>(
|
|
227
|
+
selection: T,
|
|
228
|
+
accepts: (selection: T) => boolean,
|
|
229
|
+
): AcceptedServiceSelection<T>;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Return a freshly reselected service only when its trust-relevant semantics
|
|
233
|
+
* are unchanged. The current selection must come from a new online lookup.
|
|
234
|
+
*/
|
|
235
|
+
export function renewUnchangedSelection<T extends CommonServiceSelection>(
|
|
236
|
+
previous: T,
|
|
237
|
+
current: T,
|
|
238
|
+
): T;
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { types: { isProxy } } = require('node:util');
|
|
4
|
+
const native = require('./index');
|
|
5
|
+
|
|
6
|
+
const MAX_JSON_DEPTH = 128;
|
|
7
|
+
const MAX_REQUEST_JSON_NODES = 100_000;
|
|
8
|
+
// A valid 16 MiB result can contain far more collection nodes than a request.
|
|
9
|
+
const MAX_RESPONSE_JSON_NODES = 3_000_000;
|
|
10
|
+
const MAX_JSON_STRING_BYTES = 16 * 1024 * 1024;
|
|
11
|
+
const ACCEPTED_CONSTRUCTION = Symbol('accepted-service-selection');
|
|
12
|
+
|
|
13
|
+
class DiscoveryClientError extends Error {
|
|
14
|
+
constructor(envelope) {
|
|
15
|
+
super(envelope.message);
|
|
16
|
+
this.name = 'DiscoveryClientError';
|
|
17
|
+
this.kind = envelope.kind;
|
|
18
|
+
for (const field of ['status', 'problem', 'transportKind']) {
|
|
19
|
+
if (envelope[field] !== undefined && envelope[field] !== null) this[field] = envelope[field];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function normalize(error, fallbackKind = undefined) {
|
|
25
|
+
if (error instanceof DiscoveryClientError) return error;
|
|
26
|
+
if (error instanceof Error && typeof error.message === 'string') {
|
|
27
|
+
try {
|
|
28
|
+
const envelope = JSON.parse(error.message);
|
|
29
|
+
if (envelope && typeof envelope === 'object' && typeof envelope.kind === 'string') {
|
|
30
|
+
return new DiscoveryClientError(envelope);
|
|
31
|
+
}
|
|
32
|
+
} catch {
|
|
33
|
+
// napi argument conversion failures are mapped below.
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (fallbackKind) {
|
|
37
|
+
return new DiscoveryClientError({
|
|
38
|
+
kind: fallbackKind,
|
|
39
|
+
message: fallbackKind === 'configuration'
|
|
40
|
+
? 'the Discovery client configuration is invalid'
|
|
41
|
+
: 'the Discovery query is invalid',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return error;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function inputError(kind) {
|
|
48
|
+
return new DiscoveryClientError({
|
|
49
|
+
kind,
|
|
50
|
+
message: kind === 'configuration'
|
|
51
|
+
? 'the Discovery client configuration is invalid'
|
|
52
|
+
: 'the Discovery query is invalid',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function localAcceptanceError() {
|
|
57
|
+
return new DiscoveryClientError({
|
|
58
|
+
kind: 'local_acceptance_refused',
|
|
59
|
+
message: 'the relying application refused the advertised service',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
class AcceptedServiceSelection {
|
|
64
|
+
#selection;
|
|
65
|
+
|
|
66
|
+
constructor(construction, selection) {
|
|
67
|
+
if (construction !== ACCEPTED_CONSTRUCTION) throw inputError('query');
|
|
68
|
+
this.#selection = selection;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get endpointUrl() {
|
|
72
|
+
return this.#selection.endpointUrl;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get selection() {
|
|
76
|
+
return responseValue(this.#selection);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function cloneJson(value, budget, depth) {
|
|
81
|
+
if (depth > MAX_JSON_DEPTH) throw inputError('query');
|
|
82
|
+
budget.nodes += 1;
|
|
83
|
+
if (budget.nodes > budget.maximumNodes) throw inputError('query');
|
|
84
|
+
|
|
85
|
+
if (value === null || typeof value === 'boolean') return value;
|
|
86
|
+
if (typeof value === 'string') {
|
|
87
|
+
budget.stringBytes += Buffer.byteLength(value, 'utf8');
|
|
88
|
+
if (budget.stringBytes > MAX_JSON_STRING_BYTES) throw inputError('query');
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
if (typeof value === 'number') {
|
|
92
|
+
if (!Number.isFinite(value)) throw inputError('query');
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
if (typeof value !== 'object' || isProxy(value)) throw inputError('query');
|
|
96
|
+
|
|
97
|
+
const array = Array.isArray(value);
|
|
98
|
+
const prototype = Object.getPrototypeOf(value);
|
|
99
|
+
if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) {
|
|
100
|
+
throw inputError('query');
|
|
101
|
+
}
|
|
102
|
+
if (budget.active.has(value)) throw inputError('query');
|
|
103
|
+
budget.active.add(value);
|
|
104
|
+
try {
|
|
105
|
+
const clone = array ? [] : Object.create(null);
|
|
106
|
+
const keys = Reflect.ownKeys(value);
|
|
107
|
+
if (keys.some((key) => typeof key !== 'string')) throw inputError('query');
|
|
108
|
+
let elementCount = 0;
|
|
109
|
+
for (const key of keys) {
|
|
110
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
111
|
+
if (!descriptor || !Object.hasOwn(descriptor, 'value')) {
|
|
112
|
+
throw inputError('query');
|
|
113
|
+
}
|
|
114
|
+
if (array && key === 'length') continue;
|
|
115
|
+
if (!descriptor.enumerable) throw inputError('query');
|
|
116
|
+
if (array) {
|
|
117
|
+
const index = Number(key);
|
|
118
|
+
if (!Number.isInteger(index) || index < 0 || index >= value.length || String(index) !== key) {
|
|
119
|
+
throw inputError('query');
|
|
120
|
+
}
|
|
121
|
+
elementCount += 1;
|
|
122
|
+
} else {
|
|
123
|
+
budget.stringBytes += Buffer.byteLength(key, 'utf8');
|
|
124
|
+
if (budget.stringBytes > MAX_JSON_STRING_BYTES) throw inputError('query');
|
|
125
|
+
}
|
|
126
|
+
clone[key] = cloneJson(descriptor.value, budget, depth + 1);
|
|
127
|
+
}
|
|
128
|
+
if (array && elementCount !== value.length) throw inputError('query');
|
|
129
|
+
return clone;
|
|
130
|
+
} finally {
|
|
131
|
+
budget.active.delete(value);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function requestValue(value) {
|
|
136
|
+
return cloneJson(value, {
|
|
137
|
+
nodes: 0,
|
|
138
|
+
maximumNodes: MAX_REQUEST_JSON_NODES,
|
|
139
|
+
stringBytes: 0,
|
|
140
|
+
active: new Set(),
|
|
141
|
+
}, 1);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function responseValue(value) {
|
|
145
|
+
return cloneJson(value, {
|
|
146
|
+
nodes: 0,
|
|
147
|
+
maximumNodes: MAX_RESPONSE_JSON_NODES,
|
|
148
|
+
stringBytes: 0,
|
|
149
|
+
active: new Set(),
|
|
150
|
+
}, 1);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function configurationValue(options) {
|
|
154
|
+
if (typeof options === 'string') return options;
|
|
155
|
+
if (!options || typeof options !== 'object' || isProxy(options)
|
|
156
|
+
|| Object.getPrototypeOf(options) !== Object.prototype) {
|
|
157
|
+
throw inputError('configuration');
|
|
158
|
+
}
|
|
159
|
+
const allowed = new Set([
|
|
160
|
+
'baseUrl',
|
|
161
|
+
'requestTimeoutMilliseconds',
|
|
162
|
+
'connectTimeoutMilliseconds',
|
|
163
|
+
'maximumResponseBytes',
|
|
164
|
+
'trustedRootCertificates',
|
|
165
|
+
]);
|
|
166
|
+
const copy = Object.create(null);
|
|
167
|
+
for (const key of Reflect.ownKeys(options)) {
|
|
168
|
+
if (typeof key !== 'string' || !allowed.has(key)) throw inputError('configuration');
|
|
169
|
+
const descriptor = Object.getOwnPropertyDescriptor(options, key);
|
|
170
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, 'value')) {
|
|
171
|
+
throw inputError('configuration');
|
|
172
|
+
}
|
|
173
|
+
const value = descriptor.value;
|
|
174
|
+
if (key === 'trustedRootCertificates') {
|
|
175
|
+
if (!Buffer.isBuffer(value) || value.length > 4 * 1024 * 1024) {
|
|
176
|
+
throw inputError('configuration');
|
|
177
|
+
}
|
|
178
|
+
copy[key] = Buffer.from(value);
|
|
179
|
+
} else if (key === 'baseUrl') {
|
|
180
|
+
if (typeof value !== 'string') throw inputError('configuration');
|
|
181
|
+
copy[key] = value;
|
|
182
|
+
} else {
|
|
183
|
+
if (!Number.isSafeInteger(value) || value < 0) throw inputError('configuration');
|
|
184
|
+
copy[key] = value;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return copy;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
class DiscoveryClient {
|
|
191
|
+
#inner;
|
|
192
|
+
|
|
193
|
+
constructor(options) {
|
|
194
|
+
try {
|
|
195
|
+
this.#inner = new native.DiscoveryClient(configurationValue(options));
|
|
196
|
+
} catch (error) {
|
|
197
|
+
throw normalize(error, 'configuration');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async resolveEvidenceTypes(request) {
|
|
202
|
+
try {
|
|
203
|
+
return await this.#inner.resolveEvidenceTypes(requestValue(request));
|
|
204
|
+
} catch (error) {
|
|
205
|
+
throw normalize(error, 'query');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async searchServices(filters = {}) {
|
|
210
|
+
try {
|
|
211
|
+
return await this.#inner.searchServices(requestValue(filters));
|
|
212
|
+
} catch (error) {
|
|
213
|
+
throw normalize(error, 'query');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async searchEvidenceServices(query) {
|
|
218
|
+
try {
|
|
219
|
+
return await this.#inner.searchEvidenceServices(requestValue(query));
|
|
220
|
+
} catch (error) {
|
|
221
|
+
throw normalize(error, 'query');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async searchRelayServices(query) {
|
|
226
|
+
try {
|
|
227
|
+
return await this.#inner.searchRelayServices(requestValue(query));
|
|
228
|
+
} catch (error) {
|
|
229
|
+
throw normalize(error, 'query');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
selectExact(response, request) {
|
|
234
|
+
try {
|
|
235
|
+
return this.#inner.selectExact(responseValue(response), requestValue(request));
|
|
236
|
+
} catch (error) {
|
|
237
|
+
throw normalize(error, 'query');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
selectEvidenceAlternative(response, evidenceTypeListId = undefined) {
|
|
242
|
+
return selectEvidenceAlternative(response, evidenceTypeListId);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
selectEvidenceService(response, request) {
|
|
246
|
+
return selectEvidenceService(response, request);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
selectRelayService(response, request) {
|
|
250
|
+
return selectRelayService(response, request);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function selectExact(response, request) {
|
|
255
|
+
try {
|
|
256
|
+
return native.selectExact(responseValue(response), requestValue(request));
|
|
257
|
+
} catch (error) {
|
|
258
|
+
throw normalize(error, 'query');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function selectEvidenceAlternative(response, evidenceTypeListId = undefined) {
|
|
263
|
+
try {
|
|
264
|
+
if (evidenceTypeListId !== undefined && typeof evidenceTypeListId !== 'string') {
|
|
265
|
+
throw inputError('query');
|
|
266
|
+
}
|
|
267
|
+
return native.selectEvidenceAlternative(responseValue(response), evidenceTypeListId);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
throw normalize(error, 'query');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function selectEvidenceService(response, request) {
|
|
274
|
+
try {
|
|
275
|
+
return native.selectEvidenceService(responseValue(response), requestValue(request));
|
|
276
|
+
} catch (error) {
|
|
277
|
+
throw normalize(error, 'query');
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function selectRelayService(response, request) {
|
|
282
|
+
try {
|
|
283
|
+
return native.selectRelayService(responseValue(response), requestValue(request));
|
|
284
|
+
} catch (error) {
|
|
285
|
+
throw normalize(error, 'query');
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function validateSelectionStructure(selection) {
|
|
290
|
+
try {
|
|
291
|
+
return native.validateSelectionStructure(requestValue(selection));
|
|
292
|
+
} catch (error) {
|
|
293
|
+
throw normalize(error, 'query');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function validateSelection(selection) {
|
|
298
|
+
return validateSelectionStructure(selection);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function acceptSelection(selection, accepts) {
|
|
302
|
+
const checked = validateSelectionStructure(selection);
|
|
303
|
+
if (typeof accepts !== 'function') throw inputError('query');
|
|
304
|
+
const accepted = accepts(responseValue(checked));
|
|
305
|
+
if (accepted !== true) throw localAcceptanceError();
|
|
306
|
+
return new AcceptedServiceSelection(ACCEPTED_CONSTRUCTION, checked);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function renewUnchangedSelection(previous, current) {
|
|
310
|
+
try {
|
|
311
|
+
return native.renewUnchangedSelection(requestValue(previous), requestValue(current));
|
|
312
|
+
} catch (error) {
|
|
313
|
+
throw normalize(error, 'query');
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
module.exports = {
|
|
318
|
+
AcceptedServiceSelection,
|
|
319
|
+
DiscoveryClient,
|
|
320
|
+
DiscoveryClientError,
|
|
321
|
+
acceptSelection,
|
|
322
|
+
renewUnchangedSelection,
|
|
323
|
+
selectEvidenceAlternative,
|
|
324
|
+
selectEvidenceService,
|
|
325
|
+
selectExact,
|
|
326
|
+
selectRelayService,
|
|
327
|
+
validateSelection,
|
|
328
|
+
validateSelectionStructure,
|
|
329
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export declare class DiscoveryClient {
|
|
4
|
+
constructor(options: string | DiscoveryClientOptions)
|
|
5
|
+
resolveEvidenceTypes(request: any): Promise<any>
|
|
6
|
+
searchServices(filters: any): Promise<any>
|
|
7
|
+
searchEvidenceServices(query: any): Promise<any>
|
|
8
|
+
searchRelayServices(query: any): Promise<any>
|
|
9
|
+
selectExact(response: any, request: any): any
|
|
10
|
+
selectEvidenceAlternative(response: any, evidenceTypeListId?: string | undefined | null): any
|
|
11
|
+
selectEvidenceService(response: any, request: any): any
|
|
12
|
+
selectRelayService(response: any, request: any): any
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DiscoveryClientOptions {
|
|
16
|
+
baseUrl: string
|
|
17
|
+
requestTimeoutMilliseconds?: number
|
|
18
|
+
connectTimeoutMilliseconds?: number
|
|
19
|
+
maximumResponseBytes?: number
|
|
20
|
+
trustedRootCertificates?: Buffer
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare function renewUnchangedSelection(previous: any, current: any): any
|
|
24
|
+
|
|
25
|
+
export declare function selectEvidenceAlternative(response: any, evidenceTypeListId?: string | undefined | null): any
|
|
26
|
+
|
|
27
|
+
export declare function selectEvidenceService(response: any, request: any): any
|
|
28
|
+
|
|
29
|
+
export declare function selectExact(response: any, request: any): any
|
|
30
|
+
|
|
31
|
+
export declare function selectRelayService(response: any, request: any): any
|
|
32
|
+
|
|
33
|
+
export declare function validateSelection(selection: any): any
|
|
34
|
+
|
|
35
|
+
export declare function validateSelectionStructure(selection: any): any
|