@insureco/bio 0.5.0 → 0.8.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/dist/{chunk-PLN6QPED.mjs → chunk-CKHMGUDP.mjs} +41 -0
- package/dist/chunk-UBURAGWI.mjs +154 -0
- package/dist/graph.d.mts +73 -1
- package/dist/graph.d.ts +73 -1
- package/dist/graph.js +41 -0
- package/dist/graph.mjs +1 -1
- package/dist/index.d.mts +99 -4
- package/dist/index.d.ts +99 -4
- package/dist/index.js +466 -2
- package/dist/index.mjs +274 -1
- package/dist/passport-react.d.mts +27 -0
- package/dist/passport-react.d.ts +27 -0
- package/dist/passport-react.js +115 -0
- package/dist/passport-react.mjs +90 -0
- package/dist/passport-types-bPgjNxv-.d.mts +79 -0
- package/dist/passport-types-bPgjNxv-.d.ts +79 -0
- package/dist/passport.d.mts +70 -0
- package/dist/passport.d.ts +70 -0
- package/dist/passport.js +180 -0
- package/dist/passport.mjs +6 -0
- package/dist/{types-Dkb-drHZ.d.mts → types-DOpXwdF2.d.mts} +117 -1
- package/dist/{types-Dkb-drHZ.d.ts → types-DOpXwdF2.d.ts} +117 -1
- package/dist/users.d.mts +1 -1
- package/dist/users.d.ts +1 -1
- package/dist/users.js +1 -0
- package/dist/users.mjs +1 -0
- package/package.json +24 -2
|
@@ -64,7 +64,48 @@ var GraphClient = class _GraphClient {
|
|
|
64
64
|
async matchAppetite(input) {
|
|
65
65
|
return this.post("/api/graph/appetite/match", input, { requiresAuth: true });
|
|
66
66
|
}
|
|
67
|
+
// ─── Verification Routes (auth required, gas-metered) ─────────────────────
|
|
68
|
+
/**
|
|
69
|
+
* Verify an agent's license for a given state and line of business.
|
|
70
|
+
* Returns validity, license number, expiry, and a Septor proof hash.
|
|
71
|
+
*/
|
|
72
|
+
async verifyLicense(input) {
|
|
73
|
+
return this.post("/api/graph/verify/license", input, { requiresAuth: true });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Verify an agent's appointment with a carrier.
|
|
77
|
+
* Returns validity, appointed date, states, and a Septor proof hash.
|
|
78
|
+
*/
|
|
79
|
+
async verifyAppointment(input) {
|
|
80
|
+
return this.post("/api/graph/verify/appointment", input, { requiresAuth: true });
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get the distribution chain for an entity (agent → agency → MGA → carrier).
|
|
84
|
+
* Requires an accessToken (auth: required).
|
|
85
|
+
*/
|
|
86
|
+
async getChain(entityId) {
|
|
87
|
+
return this.getAuth(`/api/graph/chain/${encodeURIComponent(entityId)}`);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Search across Agent, Agency, MGA, and Carrier nodes.
|
|
91
|
+
* Public route — no auth required.
|
|
92
|
+
*/
|
|
93
|
+
async search(query, options) {
|
|
94
|
+
const params = new URLSearchParams({ q: query });
|
|
95
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
96
|
+
if (options?.types?.length) params.set("types", options.types.join(","));
|
|
97
|
+
return this.get(`/api/graph/search?${params.toString()}`);
|
|
98
|
+
}
|
|
67
99
|
// ─── Internal ─────────────────────────────────────────────────────────────
|
|
100
|
+
async getAuth(path) {
|
|
101
|
+
if (!this.accessToken) {
|
|
102
|
+
throw new BioError(
|
|
103
|
+
`bio-graph ${path} requires an accessToken \u2014 pass it in the GraphClient constructor`,
|
|
104
|
+
"config_error"
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return this.get(path);
|
|
108
|
+
}
|
|
68
109
|
async get(path, attempt = 0) {
|
|
69
110
|
const url = `${this.graphUrl}${path}`;
|
|
70
111
|
const controller = new AbortController();
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// src/passport-client.ts
|
|
2
|
+
var PassportClient = class {
|
|
3
|
+
config;
|
|
4
|
+
ws = null;
|
|
5
|
+
_passport = null;
|
|
6
|
+
_status = "disconnected";
|
|
7
|
+
reconnectAttempt = 0;
|
|
8
|
+
reconnectTimer = null;
|
|
9
|
+
listeners = /* @__PURE__ */ new Map();
|
|
10
|
+
closed = false;
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.config = {
|
|
13
|
+
autoReconnect: true,
|
|
14
|
+
maxReconnectDelay: 3e4,
|
|
15
|
+
...config
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Current passport object (null until first identity message) */
|
|
19
|
+
get passport() {
|
|
20
|
+
return this._passport;
|
|
21
|
+
}
|
|
22
|
+
/** Current connection status */
|
|
23
|
+
get status() {
|
|
24
|
+
return this._status;
|
|
25
|
+
}
|
|
26
|
+
/** Connect to the passport WebSocket */
|
|
27
|
+
connect() {
|
|
28
|
+
if (this.closed) return;
|
|
29
|
+
this.setStatus("connecting");
|
|
30
|
+
const url = new URL("/passport", this.config.bioIdUrl.replace(/^http/, "ws"));
|
|
31
|
+
url.searchParams.set("token", this.config.accessToken);
|
|
32
|
+
url.searchParams.set("version", "1");
|
|
33
|
+
if (this.config.service) {
|
|
34
|
+
url.searchParams.set("service", this.config.service);
|
|
35
|
+
}
|
|
36
|
+
this.ws = new WebSocket(url.toString());
|
|
37
|
+
this.ws.onopen = () => {
|
|
38
|
+
this.reconnectAttempt = 0;
|
|
39
|
+
this.setStatus("connected");
|
|
40
|
+
this.emit("connected", this._status);
|
|
41
|
+
};
|
|
42
|
+
this.ws.onmessage = (event) => {
|
|
43
|
+
try {
|
|
44
|
+
const data = JSON.parse(
|
|
45
|
+
typeof event.data === "string" ? event.data : ""
|
|
46
|
+
);
|
|
47
|
+
if (data.type === "identity" || data.type === "passport_updated") {
|
|
48
|
+
this._passport = data.passport ?? null;
|
|
49
|
+
this.emit(data.type, this._passport);
|
|
50
|
+
} else if (data.type === "revoked") {
|
|
51
|
+
this._passport = null;
|
|
52
|
+
this.emit("revoked");
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
this.ws.onclose = (event) => {
|
|
58
|
+
this.setStatus("disconnected");
|
|
59
|
+
this.emit("disconnected", this._status);
|
|
60
|
+
if (event?.code === 4003 && this.config.refreshToken && this.config.bioAuth) {
|
|
61
|
+
this.handleTokenRefresh();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.scheduleReconnect();
|
|
65
|
+
};
|
|
66
|
+
this.ws.onerror = () => {
|
|
67
|
+
const error = new Error("Passport WebSocket error");
|
|
68
|
+
this.emit("error", error);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Subscribe to an event */
|
|
72
|
+
on(event, handler) {
|
|
73
|
+
if (!this.listeners.has(event)) {
|
|
74
|
+
this.listeners.set(event, /* @__PURE__ */ new Set());
|
|
75
|
+
}
|
|
76
|
+
this.listeners.get(event).add(handler);
|
|
77
|
+
}
|
|
78
|
+
/** Unsubscribe from an event */
|
|
79
|
+
off(event, handler) {
|
|
80
|
+
this.listeners.get(event)?.delete(handler);
|
|
81
|
+
}
|
|
82
|
+
/** Disconnect and stop reconnecting */
|
|
83
|
+
close() {
|
|
84
|
+
this.closed = true;
|
|
85
|
+
if (this.reconnectTimer) {
|
|
86
|
+
clearTimeout(this.reconnectTimer);
|
|
87
|
+
this.reconnectTimer = null;
|
|
88
|
+
}
|
|
89
|
+
if (this.ws) {
|
|
90
|
+
this.ws.onclose = null;
|
|
91
|
+
this.ws.close();
|
|
92
|
+
this.ws = null;
|
|
93
|
+
}
|
|
94
|
+
this.setStatus("disconnected");
|
|
95
|
+
}
|
|
96
|
+
/** Update access token (e.g. after refresh) and reconnect */
|
|
97
|
+
updateToken(accessToken) {
|
|
98
|
+
this.config.accessToken = accessToken;
|
|
99
|
+
if (this.ws) {
|
|
100
|
+
this.ws.onclose = null;
|
|
101
|
+
this.ws.close();
|
|
102
|
+
this.ws = null;
|
|
103
|
+
}
|
|
104
|
+
this.reconnectAttempt = 0;
|
|
105
|
+
this.connect();
|
|
106
|
+
}
|
|
107
|
+
async handleTokenRefresh() {
|
|
108
|
+
if (!this.config.refreshToken || !this.config.bioAuth) return;
|
|
109
|
+
try {
|
|
110
|
+
const tokens = await this.config.bioAuth.refreshToken(this.config.refreshToken);
|
|
111
|
+
this.config.accessToken = tokens.access_token;
|
|
112
|
+
if (tokens.refresh_token) {
|
|
113
|
+
this.config.refreshToken = tokens.refresh_token;
|
|
114
|
+
}
|
|
115
|
+
if (this.config.onTokenRefresh) {
|
|
116
|
+
this.config.onTokenRefresh(tokens);
|
|
117
|
+
}
|
|
118
|
+
this.reconnectAttempt = 0;
|
|
119
|
+
this.connect();
|
|
120
|
+
} catch {
|
|
121
|
+
this.emit("error", new Error("Token refresh failed"));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
setStatus(status) {
|
|
125
|
+
this._status = status;
|
|
126
|
+
}
|
|
127
|
+
emit(event, ...args) {
|
|
128
|
+
const handlers = this.listeners.get(event);
|
|
129
|
+
if (handlers) {
|
|
130
|
+
for (const handler of handlers) {
|
|
131
|
+
try {
|
|
132
|
+
handler(...args);
|
|
133
|
+
} catch {
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
scheduleReconnect() {
|
|
139
|
+
if (this.closed || !this.config.autoReconnect) return;
|
|
140
|
+
const delay = Math.min(
|
|
141
|
+
1e3 * Math.pow(2, this.reconnectAttempt),
|
|
142
|
+
this.config.maxReconnectDelay ?? 3e4
|
|
143
|
+
);
|
|
144
|
+
this.reconnectAttempt++;
|
|
145
|
+
this.reconnectTimer = setTimeout(() => {
|
|
146
|
+
this.reconnectTimer = null;
|
|
147
|
+
this.connect();
|
|
148
|
+
}, delay);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export {
|
|
153
|
+
PassportClient
|
|
154
|
+
};
|
package/dist/graph.d.mts
CHANGED
|
@@ -136,6 +136,57 @@ interface AppetiteMatchResult {
|
|
|
136
136
|
programs: AppetiteMatchProgram[];
|
|
137
137
|
total: number;
|
|
138
138
|
}
|
|
139
|
+
interface VerifyLicenseInput {
|
|
140
|
+
npn: string;
|
|
141
|
+
state: string;
|
|
142
|
+
lob: string;
|
|
143
|
+
}
|
|
144
|
+
interface LicenseVerifyResult {
|
|
145
|
+
valid: boolean;
|
|
146
|
+
licenseNumber: string | null;
|
|
147
|
+
expiry: string | null;
|
|
148
|
+
septorProof: string;
|
|
149
|
+
}
|
|
150
|
+
interface VerifyAppointmentInput {
|
|
151
|
+
npn: string;
|
|
152
|
+
carrierNaic: string;
|
|
153
|
+
}
|
|
154
|
+
interface AppointmentVerifyResult {
|
|
155
|
+
valid: boolean;
|
|
156
|
+
appointedDate: string | null;
|
|
157
|
+
states: string[];
|
|
158
|
+
septorProof: string;
|
|
159
|
+
}
|
|
160
|
+
interface GraphChainNode {
|
|
161
|
+
id: string;
|
|
162
|
+
type: string;
|
|
163
|
+
label: string;
|
|
164
|
+
}
|
|
165
|
+
interface GraphChainEdge {
|
|
166
|
+
source: string;
|
|
167
|
+
target: string;
|
|
168
|
+
type: string;
|
|
169
|
+
}
|
|
170
|
+
interface GraphChainResult {
|
|
171
|
+
nodes: GraphChainNode[];
|
|
172
|
+
edges: GraphChainEdge[];
|
|
173
|
+
}
|
|
174
|
+
interface GraphSearchOptions {
|
|
175
|
+
limit?: number;
|
|
176
|
+
types?: string[];
|
|
177
|
+
}
|
|
178
|
+
interface GraphSearchResultItem {
|
|
179
|
+
type: string;
|
|
180
|
+
iecHash: string;
|
|
181
|
+
name: string;
|
|
182
|
+
npn?: string;
|
|
183
|
+
naic?: string;
|
|
184
|
+
orgSlug?: string;
|
|
185
|
+
}
|
|
186
|
+
interface GraphSearchResult {
|
|
187
|
+
results: GraphSearchResultItem[];
|
|
188
|
+
total: number;
|
|
189
|
+
}
|
|
139
190
|
/**
|
|
140
191
|
* Client for bio-graph InsureBio distribution graph endpoints.
|
|
141
192
|
*
|
|
@@ -195,10 +246,31 @@ declare class GraphClient {
|
|
|
195
246
|
* @param input - Risk criteria: NAICS code, state, line of business, optional limits
|
|
196
247
|
*/
|
|
197
248
|
matchAppetite(input: AppetiteMatchInput): Promise<AppetiteMatchResult>;
|
|
249
|
+
/**
|
|
250
|
+
* Verify an agent's license for a given state and line of business.
|
|
251
|
+
* Returns validity, license number, expiry, and a Septor proof hash.
|
|
252
|
+
*/
|
|
253
|
+
verifyLicense(input: VerifyLicenseInput): Promise<LicenseVerifyResult>;
|
|
254
|
+
/**
|
|
255
|
+
* Verify an agent's appointment with a carrier.
|
|
256
|
+
* Returns validity, appointed date, states, and a Septor proof hash.
|
|
257
|
+
*/
|
|
258
|
+
verifyAppointment(input: VerifyAppointmentInput): Promise<AppointmentVerifyResult>;
|
|
259
|
+
/**
|
|
260
|
+
* Get the distribution chain for an entity (agent → agency → MGA → carrier).
|
|
261
|
+
* Requires an accessToken (auth: required).
|
|
262
|
+
*/
|
|
263
|
+
getChain(entityId: string): Promise<GraphChainResult>;
|
|
264
|
+
/**
|
|
265
|
+
* Search across Agent, Agency, MGA, and Carrier nodes.
|
|
266
|
+
* Public route — no auth required.
|
|
267
|
+
*/
|
|
268
|
+
search(query: string, options?: GraphSearchOptions): Promise<GraphSearchResult>;
|
|
269
|
+
private getAuth;
|
|
198
270
|
private get;
|
|
199
271
|
private post;
|
|
200
272
|
private buildHeaders;
|
|
201
273
|
private handleResponse;
|
|
202
274
|
}
|
|
203
275
|
|
|
204
|
-
export { type AgencyProfile, type AgencyProgram, type AgencyStaffMember, type AgentEmployer, type AgentProfile, type AppetiteMatchInput, type AppetiteMatchProgram, type AppetiteMatchResult, type CarrierProfile, type CarrierProgram, GraphClient, type GraphClientConfig, type ProgramProfile };
|
|
276
|
+
export { type AgencyProfile, type AgencyProgram, type AgencyStaffMember, type AgentEmployer, type AgentProfile, type AppetiteMatchInput, type AppetiteMatchProgram, type AppetiteMatchResult, type AppointmentVerifyResult, type CarrierProfile, type CarrierProgram, type GraphChainEdge, type GraphChainNode, type GraphChainResult, GraphClient, type GraphClientConfig, type GraphSearchOptions, type GraphSearchResult, type GraphSearchResultItem, type LicenseVerifyResult, type ProgramProfile, type VerifyAppointmentInput, type VerifyLicenseInput };
|
package/dist/graph.d.ts
CHANGED
|
@@ -136,6 +136,57 @@ interface AppetiteMatchResult {
|
|
|
136
136
|
programs: AppetiteMatchProgram[];
|
|
137
137
|
total: number;
|
|
138
138
|
}
|
|
139
|
+
interface VerifyLicenseInput {
|
|
140
|
+
npn: string;
|
|
141
|
+
state: string;
|
|
142
|
+
lob: string;
|
|
143
|
+
}
|
|
144
|
+
interface LicenseVerifyResult {
|
|
145
|
+
valid: boolean;
|
|
146
|
+
licenseNumber: string | null;
|
|
147
|
+
expiry: string | null;
|
|
148
|
+
septorProof: string;
|
|
149
|
+
}
|
|
150
|
+
interface VerifyAppointmentInput {
|
|
151
|
+
npn: string;
|
|
152
|
+
carrierNaic: string;
|
|
153
|
+
}
|
|
154
|
+
interface AppointmentVerifyResult {
|
|
155
|
+
valid: boolean;
|
|
156
|
+
appointedDate: string | null;
|
|
157
|
+
states: string[];
|
|
158
|
+
septorProof: string;
|
|
159
|
+
}
|
|
160
|
+
interface GraphChainNode {
|
|
161
|
+
id: string;
|
|
162
|
+
type: string;
|
|
163
|
+
label: string;
|
|
164
|
+
}
|
|
165
|
+
interface GraphChainEdge {
|
|
166
|
+
source: string;
|
|
167
|
+
target: string;
|
|
168
|
+
type: string;
|
|
169
|
+
}
|
|
170
|
+
interface GraphChainResult {
|
|
171
|
+
nodes: GraphChainNode[];
|
|
172
|
+
edges: GraphChainEdge[];
|
|
173
|
+
}
|
|
174
|
+
interface GraphSearchOptions {
|
|
175
|
+
limit?: number;
|
|
176
|
+
types?: string[];
|
|
177
|
+
}
|
|
178
|
+
interface GraphSearchResultItem {
|
|
179
|
+
type: string;
|
|
180
|
+
iecHash: string;
|
|
181
|
+
name: string;
|
|
182
|
+
npn?: string;
|
|
183
|
+
naic?: string;
|
|
184
|
+
orgSlug?: string;
|
|
185
|
+
}
|
|
186
|
+
interface GraphSearchResult {
|
|
187
|
+
results: GraphSearchResultItem[];
|
|
188
|
+
total: number;
|
|
189
|
+
}
|
|
139
190
|
/**
|
|
140
191
|
* Client for bio-graph InsureBio distribution graph endpoints.
|
|
141
192
|
*
|
|
@@ -195,10 +246,31 @@ declare class GraphClient {
|
|
|
195
246
|
* @param input - Risk criteria: NAICS code, state, line of business, optional limits
|
|
196
247
|
*/
|
|
197
248
|
matchAppetite(input: AppetiteMatchInput): Promise<AppetiteMatchResult>;
|
|
249
|
+
/**
|
|
250
|
+
* Verify an agent's license for a given state and line of business.
|
|
251
|
+
* Returns validity, license number, expiry, and a Septor proof hash.
|
|
252
|
+
*/
|
|
253
|
+
verifyLicense(input: VerifyLicenseInput): Promise<LicenseVerifyResult>;
|
|
254
|
+
/**
|
|
255
|
+
* Verify an agent's appointment with a carrier.
|
|
256
|
+
* Returns validity, appointed date, states, and a Septor proof hash.
|
|
257
|
+
*/
|
|
258
|
+
verifyAppointment(input: VerifyAppointmentInput): Promise<AppointmentVerifyResult>;
|
|
259
|
+
/**
|
|
260
|
+
* Get the distribution chain for an entity (agent → agency → MGA → carrier).
|
|
261
|
+
* Requires an accessToken (auth: required).
|
|
262
|
+
*/
|
|
263
|
+
getChain(entityId: string): Promise<GraphChainResult>;
|
|
264
|
+
/**
|
|
265
|
+
* Search across Agent, Agency, MGA, and Carrier nodes.
|
|
266
|
+
* Public route — no auth required.
|
|
267
|
+
*/
|
|
268
|
+
search(query: string, options?: GraphSearchOptions): Promise<GraphSearchResult>;
|
|
269
|
+
private getAuth;
|
|
198
270
|
private get;
|
|
199
271
|
private post;
|
|
200
272
|
private buildHeaders;
|
|
201
273
|
private handleResponse;
|
|
202
274
|
}
|
|
203
275
|
|
|
204
|
-
export { type AgencyProfile, type AgencyProgram, type AgencyStaffMember, type AgentEmployer, type AgentProfile, type AppetiteMatchInput, type AppetiteMatchProgram, type AppetiteMatchResult, type CarrierProfile, type CarrierProgram, GraphClient, type GraphClientConfig, type ProgramProfile };
|
|
276
|
+
export { type AgencyProfile, type AgencyProgram, type AgencyStaffMember, type AgentEmployer, type AgentProfile, type AppetiteMatchInput, type AppetiteMatchProgram, type AppetiteMatchResult, type AppointmentVerifyResult, type CarrierProfile, type CarrierProgram, type GraphChainEdge, type GraphChainNode, type GraphChainResult, GraphClient, type GraphClientConfig, type GraphSearchOptions, type GraphSearchResult, type GraphSearchResultItem, type LicenseVerifyResult, type ProgramProfile, type VerifyAppointmentInput, type VerifyLicenseInput };
|
package/dist/graph.js
CHANGED
|
@@ -120,7 +120,48 @@ var GraphClient = class _GraphClient {
|
|
|
120
120
|
async matchAppetite(input) {
|
|
121
121
|
return this.post("/api/graph/appetite/match", input, { requiresAuth: true });
|
|
122
122
|
}
|
|
123
|
+
// ─── Verification Routes (auth required, gas-metered) ─────────────────────
|
|
124
|
+
/**
|
|
125
|
+
* Verify an agent's license for a given state and line of business.
|
|
126
|
+
* Returns validity, license number, expiry, and a Septor proof hash.
|
|
127
|
+
*/
|
|
128
|
+
async verifyLicense(input) {
|
|
129
|
+
return this.post("/api/graph/verify/license", input, { requiresAuth: true });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Verify an agent's appointment with a carrier.
|
|
133
|
+
* Returns validity, appointed date, states, and a Septor proof hash.
|
|
134
|
+
*/
|
|
135
|
+
async verifyAppointment(input) {
|
|
136
|
+
return this.post("/api/graph/verify/appointment", input, { requiresAuth: true });
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get the distribution chain for an entity (agent → agency → MGA → carrier).
|
|
140
|
+
* Requires an accessToken (auth: required).
|
|
141
|
+
*/
|
|
142
|
+
async getChain(entityId) {
|
|
143
|
+
return this.getAuth(`/api/graph/chain/${encodeURIComponent(entityId)}`);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Search across Agent, Agency, MGA, and Carrier nodes.
|
|
147
|
+
* Public route — no auth required.
|
|
148
|
+
*/
|
|
149
|
+
async search(query, options) {
|
|
150
|
+
const params = new URLSearchParams({ q: query });
|
|
151
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
152
|
+
if (options?.types?.length) params.set("types", options.types.join(","));
|
|
153
|
+
return this.get(`/api/graph/search?${params.toString()}`);
|
|
154
|
+
}
|
|
123
155
|
// ─── Internal ─────────────────────────────────────────────────────────────
|
|
156
|
+
async getAuth(path) {
|
|
157
|
+
if (!this.accessToken) {
|
|
158
|
+
throw new BioError(
|
|
159
|
+
`bio-graph ${path} requires an accessToken \u2014 pass it in the GraphClient constructor`,
|
|
160
|
+
"config_error"
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
return this.get(path);
|
|
164
|
+
}
|
|
124
165
|
async get(path, attempt = 0) {
|
|
125
166
|
const url = `${this.graphUrl}${path}`;
|
|
126
167
|
const controller = new AbortController();
|
package/dist/graph.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export { AgencyProfile, AgencyProgram, AgencyStaffMember, AgentEmployer, AgentProfile, AppetiteMatchInput, AppetiteMatchProgram, AppetiteMatchResult, CarrierProfile, CarrierProgram, GraphClient, GraphClientConfig, ProgramProfile } from './graph.mjs';
|
|
1
|
+
import { b as BioAuthConfig, A as AuthorizeOptions, c as AuthorizeResult, S as SilentAuthOptions, T as TokenResponse, d as BioUser, I as IntrospectResult, e as BioAdminConfig, U as UserFilters, f as UpdateUserData, g as BioDepartment, C as CreateDepartmentData, h as BioRole, i as CreateRoleData, j as BioOAuthClient, k as CreateClientData, E as EmbedClientConfig, l as EmbedLoginParams, m as EmbedAuthResult, n as EmbedSignupParams, o as EmbedMagicLinkParams, p as EmbedVerifyParams, q as EmbedRefreshParams, r as EmbedLogoutParams, s as BioTokenPayload, V as VerifyOptions, J as JWKSVerifyOptions } from './types-DOpXwdF2.mjs';
|
|
2
|
+
export { t as AdminResponse, u as BioAddress, v as BioClientTokenPayload, w as BioMessaging, B as BioUsersConfig, x as EmbedBranding, y as EmbedUser, z as OrgMember, O as OrgMemberFilters, a as OrgMembersResult, D as ServiceRole } from './types-DOpXwdF2.mjs';
|
|
3
|
+
export { AgencyProfile, AgencyProgram, AgencyStaffMember, AgentEmployer, AgentProfile, AppetiteMatchInput, AppetiteMatchProgram, AppetiteMatchResult, AppointmentVerifyResult, CarrierProfile, CarrierProgram, GraphChainEdge, GraphChainNode, GraphChainResult, GraphClient, GraphClientConfig, GraphSearchOptions, GraphSearchResult, GraphSearchResultItem, LicenseVerifyResult, ProgramProfile, VerifyAppointmentInput, VerifyLicenseInput } from './graph.mjs';
|
|
4
|
+
export { PassportClient } from './passport.mjs';
|
|
5
|
+
export { P as Passport, b as PassportBranding, c as PassportClientConfig, d as PassportCrossOrgPermission, e as PassportEventType, f as PassportMessage, g as PassportServiceGrant, h as PassportSession, a as PassportStatus, i as PassportTokenRefresher, j as PassportVillage } from './passport-types-bPgjNxv-.mjs';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* OAuth flow client for Bio-ID SSO.
|
|
@@ -28,6 +30,14 @@ declare class BioAuth {
|
|
|
28
30
|
* Store the state and codeVerifier securely (e.g. in a cookie) for the callback.
|
|
29
31
|
*/
|
|
30
32
|
getAuthorizationUrl(opts: AuthorizeOptions): AuthorizeResult;
|
|
33
|
+
/**
|
|
34
|
+
* Build an authorization URL with prompt=none for silent authentication.
|
|
35
|
+
*
|
|
36
|
+
* Useful for checking if the user has an existing session without showing
|
|
37
|
+
* a login screen. If the user is not authenticated, Bio-ID redirects back
|
|
38
|
+
* with an `error=login_required` query parameter instead of showing UI.
|
|
39
|
+
*/
|
|
40
|
+
silentAuth(opts: SilentAuthOptions): AuthorizeResult;
|
|
31
41
|
/**
|
|
32
42
|
* Exchange an authorization code for tokens.
|
|
33
43
|
*
|
|
@@ -105,6 +115,91 @@ declare class BioAdmin {
|
|
|
105
115
|
private request;
|
|
106
116
|
}
|
|
107
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Client for Bio-ID headless embed endpoints.
|
|
120
|
+
*
|
|
121
|
+
* Use this when building custom login/signup UIs that authenticate
|
|
122
|
+
* directly against Bio-ID without redirects (no OAuth flow).
|
|
123
|
+
*
|
|
124
|
+
* All endpoints use X-Client-Id / X-Client-Secret header auth.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* import { EmbedClient } from '@insureco/bio'
|
|
129
|
+
*
|
|
130
|
+
* const embed = EmbedClient.fromEnv()
|
|
131
|
+
*
|
|
132
|
+
* // Login
|
|
133
|
+
* const result = await embed.login({ email: 'user@example.com', password: 'secret' })
|
|
134
|
+
* console.log(result.accessToken, result.user.bioId)
|
|
135
|
+
*
|
|
136
|
+
* // Refresh
|
|
137
|
+
* const refreshed = await embed.refresh({ refreshToken: result.refreshToken })
|
|
138
|
+
*
|
|
139
|
+
* // Logout
|
|
140
|
+
* await embed.logout({ refreshToken: result.refreshToken })
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
declare class EmbedClient {
|
|
144
|
+
private readonly bioIdUrl;
|
|
145
|
+
private readonly clientId;
|
|
146
|
+
private readonly clientSecret;
|
|
147
|
+
private readonly retries;
|
|
148
|
+
private readonly timeoutMs;
|
|
149
|
+
constructor(config: EmbedClientConfig);
|
|
150
|
+
/**
|
|
151
|
+
* Create an EmbedClient from environment variables.
|
|
152
|
+
*
|
|
153
|
+
* Reads: BIO_CLIENT_ID, BIO_CLIENT_SECRET, BIO_ID_URL
|
|
154
|
+
*/
|
|
155
|
+
static fromEnv(overrides?: Partial<EmbedClientConfig>): EmbedClient;
|
|
156
|
+
/**
|
|
157
|
+
* Authenticate a user with email and password.
|
|
158
|
+
*
|
|
159
|
+
* @param params - Email and password
|
|
160
|
+
* @returns Access token, refresh token, user profile, and optional branding
|
|
161
|
+
*/
|
|
162
|
+
login(params: EmbedLoginParams): Promise<EmbedAuthResult>;
|
|
163
|
+
/**
|
|
164
|
+
* Create a new user account.
|
|
165
|
+
*
|
|
166
|
+
* @param params - Email, password, name, and optional invite token
|
|
167
|
+
* @returns Access token, refresh token, user profile, and optional branding
|
|
168
|
+
*/
|
|
169
|
+
signup(params: EmbedSignupParams): Promise<EmbedAuthResult>;
|
|
170
|
+
/**
|
|
171
|
+
* Send a magic link email to the user.
|
|
172
|
+
*
|
|
173
|
+
* The user clicks the link to authenticate without a password.
|
|
174
|
+
* After sending, use `verify()` with the token from the link.
|
|
175
|
+
*
|
|
176
|
+
* @param params - Email address to send the magic link to
|
|
177
|
+
*/
|
|
178
|
+
sendMagicLink(params: EmbedMagicLinkParams): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Verify a magic link token and exchange it for auth tokens.
|
|
181
|
+
*
|
|
182
|
+
* @param params - The token from the magic link
|
|
183
|
+
* @returns Access token, refresh token, user profile, and optional branding
|
|
184
|
+
*/
|
|
185
|
+
verify(params: EmbedVerifyParams): Promise<EmbedAuthResult>;
|
|
186
|
+
/**
|
|
187
|
+
* Refresh an expired access token using a refresh token.
|
|
188
|
+
*
|
|
189
|
+
* @param params - The refresh token to exchange
|
|
190
|
+
* @returns New access token, rotated refresh token, user profile, and optional branding
|
|
191
|
+
*/
|
|
192
|
+
refresh(params: EmbedRefreshParams): Promise<EmbedAuthResult>;
|
|
193
|
+
/**
|
|
194
|
+
* Revoke a refresh token (logout).
|
|
195
|
+
*
|
|
196
|
+
* @param params - The refresh token to revoke
|
|
197
|
+
*/
|
|
198
|
+
logout(params: EmbedLogoutParams): Promise<void>;
|
|
199
|
+
private embedRequest;
|
|
200
|
+
private fetchWithRetry;
|
|
201
|
+
}
|
|
202
|
+
|
|
108
203
|
/** Error thrown by Bio SDK operations */
|
|
109
204
|
declare class BioError extends Error {
|
|
110
205
|
/** HTTP status code (if from an API response) */
|
|
@@ -155,4 +250,4 @@ declare function isTokenExpired(token: string, bufferSeconds?: number): boolean;
|
|
|
155
250
|
*/
|
|
156
251
|
declare function verifyTokenJWKS(token: string, options?: JWKSVerifyOptions): Promise<BioTokenPayload>;
|
|
157
252
|
|
|
158
|
-
export { AuthorizeOptions, AuthorizeResult, BioAdmin, BioAdminConfig, BioAuth, BioAuthConfig, BioDepartment, BioError, BioOAuthClient, BioRole, BioTokenPayload, BioUser, CreateClientData, CreateDepartmentData, CreateRoleData, IntrospectResult, JWKSVerifyOptions, TokenResponse, UpdateUserData, UserFilters, VerifyOptions, decodeToken, generatePKCE, isTokenExpired, verifyToken, verifyTokenJWKS };
|
|
253
|
+
export { AuthorizeOptions, AuthorizeResult, BioAdmin, BioAdminConfig, BioAuth, BioAuthConfig, BioDepartment, BioError, BioOAuthClient, BioRole, BioTokenPayload, BioUser, CreateClientData, CreateDepartmentData, CreateRoleData, EmbedAuthResult, EmbedClient, EmbedClientConfig, EmbedLoginParams, EmbedLogoutParams, EmbedMagicLinkParams, EmbedRefreshParams, EmbedSignupParams, EmbedVerifyParams, IntrospectResult, JWKSVerifyOptions, SilentAuthOptions, TokenResponse, UpdateUserData, UserFilters, VerifyOptions, decodeToken, generatePKCE, isTokenExpired, verifyToken, verifyTokenJWKS };
|