@zlooks.cn/browser-api 1.0.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/index.d.ts +216 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +198 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const BROWSER_API_PROVIDER_DISPATCH_OPERATION = "/browser/dispatch";
|
|
3
|
+
export declare const BROWSER_API_PROVIDER_TOPIC_PREFIX = "registry:zlooks.cn/browser-api/providers/";
|
|
4
|
+
export declare const BROWSER_API_COOKIES_CONTEXT_KEY = "zlooks.browser.cookies";
|
|
5
|
+
export declare const BROWSER_API_CLIENT_CONTEXT_KEY = "zlooks.browser.client";
|
|
6
|
+
export declare const browserApiResponseSchema: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
7
|
+
code: z.ZodLiteral<0>;
|
|
8
|
+
data: z.ZodUnknown & z.ZodType<{} | null, unknown, z.core.$ZodTypeInternals<{} | null, unknown>>;
|
|
9
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
10
|
+
code: z.ZodNumber;
|
|
11
|
+
error: z.ZodString;
|
|
12
|
+
}, z.core.$strict>>]>;
|
|
13
|
+
export declare const browserApiPublicRouteSchema: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
14
|
+
exact: z.ZodString;
|
|
15
|
+
methods: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
16
|
+
DELETE: "DELETE";
|
|
17
|
+
GET: "GET";
|
|
18
|
+
PATCH: "PATCH";
|
|
19
|
+
POST: "POST";
|
|
20
|
+
PUT: "PUT";
|
|
21
|
+
}>>>;
|
|
22
|
+
forwardCookieNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
23
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
24
|
+
prefix: z.ZodString;
|
|
25
|
+
methods: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
26
|
+
DELETE: "DELETE";
|
|
27
|
+
GET: "GET";
|
|
28
|
+
PATCH: "PATCH";
|
|
29
|
+
POST: "POST";
|
|
30
|
+
PUT: "PUT";
|
|
31
|
+
}>>>;
|
|
32
|
+
forwardCookieNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
33
|
+
}, z.core.$strict>>]>;
|
|
34
|
+
export declare const browserApiProviderLeaseSchema: z.ZodReadonly<z.ZodObject<{
|
|
35
|
+
issuedAt: z.ZodISODateTime;
|
|
36
|
+
expiresAt: z.ZodISODateTime;
|
|
37
|
+
sequence: z.ZodNumber;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
export declare const browserApiProviderAnnouncementSchema: z.ZodReadonly<z.ZodObject<{
|
|
40
|
+
protocol: z.ZodLiteral<"zlooks.browser-api.provider">;
|
|
41
|
+
providerId: z.ZodString;
|
|
42
|
+
instanceId: z.ZodString;
|
|
43
|
+
namespace: z.ZodString;
|
|
44
|
+
operation: z.ZodLiteral<"/browser/dispatch">;
|
|
45
|
+
routes: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
46
|
+
exact: z.ZodString;
|
|
47
|
+
methods: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
48
|
+
DELETE: "DELETE";
|
|
49
|
+
GET: "GET";
|
|
50
|
+
PATCH: "PATCH";
|
|
51
|
+
POST: "POST";
|
|
52
|
+
PUT: "PUT";
|
|
53
|
+
}>>>;
|
|
54
|
+
forwardCookieNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
55
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
56
|
+
prefix: z.ZodString;
|
|
57
|
+
methods: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
58
|
+
DELETE: "DELETE";
|
|
59
|
+
GET: "GET";
|
|
60
|
+
PATCH: "PATCH";
|
|
61
|
+
POST: "POST";
|
|
62
|
+
PUT: "PUT";
|
|
63
|
+
}>>>;
|
|
64
|
+
forwardCookieNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
65
|
+
}, z.core.$strict>>]>>>;
|
|
66
|
+
writableCookieNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
67
|
+
errors: z.ZodReadonly<z.ZodObject<{
|
|
68
|
+
invalidRequest: z.ZodReadonly<z.ZodObject<{
|
|
69
|
+
code: z.ZodNumber;
|
|
70
|
+
message: z.ZodString;
|
|
71
|
+
}, z.core.$strict>>;
|
|
72
|
+
unavailable: z.ZodReadonly<z.ZodObject<{
|
|
73
|
+
code: z.ZodNumber;
|
|
74
|
+
message: z.ZodString;
|
|
75
|
+
}, z.core.$strict>>;
|
|
76
|
+
}, z.core.$strict>>;
|
|
77
|
+
lease: z.ZodReadonly<z.ZodObject<{
|
|
78
|
+
issuedAt: z.ZodISODateTime;
|
|
79
|
+
expiresAt: z.ZodISODateTime;
|
|
80
|
+
sequence: z.ZodNumber;
|
|
81
|
+
}, z.core.$strict>>;
|
|
82
|
+
}, z.core.$strict>>;
|
|
83
|
+
export declare const browserApiProviderSnapshotSchema: z.ZodReadonly<z.ZodObject<{
|
|
84
|
+
topic: z.ZodString;
|
|
85
|
+
payload: z.ZodReadonly<z.ZodObject<{
|
|
86
|
+
protocol: z.ZodLiteral<"zlooks.browser-api.provider">;
|
|
87
|
+
providerId: z.ZodString;
|
|
88
|
+
instanceId: z.ZodString;
|
|
89
|
+
namespace: z.ZodString;
|
|
90
|
+
operation: z.ZodLiteral<"/browser/dispatch">;
|
|
91
|
+
routes: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
92
|
+
exact: z.ZodString;
|
|
93
|
+
methods: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
94
|
+
DELETE: "DELETE";
|
|
95
|
+
GET: "GET";
|
|
96
|
+
PATCH: "PATCH";
|
|
97
|
+
POST: "POST";
|
|
98
|
+
PUT: "PUT";
|
|
99
|
+
}>>>;
|
|
100
|
+
forwardCookieNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
101
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
102
|
+
prefix: z.ZodString;
|
|
103
|
+
methods: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
104
|
+
DELETE: "DELETE";
|
|
105
|
+
GET: "GET";
|
|
106
|
+
PATCH: "PATCH";
|
|
107
|
+
POST: "POST";
|
|
108
|
+
PUT: "PUT";
|
|
109
|
+
}>>>;
|
|
110
|
+
forwardCookieNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
111
|
+
}, z.core.$strict>>]>>>;
|
|
112
|
+
writableCookieNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
113
|
+
errors: z.ZodReadonly<z.ZodObject<{
|
|
114
|
+
invalidRequest: z.ZodReadonly<z.ZodObject<{
|
|
115
|
+
code: z.ZodNumber;
|
|
116
|
+
message: z.ZodString;
|
|
117
|
+
}, z.core.$strict>>;
|
|
118
|
+
unavailable: z.ZodReadonly<z.ZodObject<{
|
|
119
|
+
code: z.ZodNumber;
|
|
120
|
+
message: z.ZodString;
|
|
121
|
+
}, z.core.$strict>>;
|
|
122
|
+
}, z.core.$strict>>;
|
|
123
|
+
lease: z.ZodReadonly<z.ZodObject<{
|
|
124
|
+
issuedAt: z.ZodISODateTime;
|
|
125
|
+
expiresAt: z.ZodISODateTime;
|
|
126
|
+
sequence: z.ZodNumber;
|
|
127
|
+
}, z.core.$strict>>;
|
|
128
|
+
}, z.core.$strict>>;
|
|
129
|
+
publishers: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
130
|
+
host: z.ZodString;
|
|
131
|
+
port: z.ZodNumber;
|
|
132
|
+
}, z.core.$strict>>>>;
|
|
133
|
+
}, z.core.$strict>>;
|
|
134
|
+
export declare const browserApiDispatchQuerySchema: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodReadonly<z.ZodArray<z.ZodString>>]>>>;
|
|
135
|
+
export declare const browserApiCookiesSchema: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
136
|
+
export declare const browserApiClientSchema: z.ZodReadonly<z.ZodObject<{
|
|
137
|
+
ipAddress: z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>;
|
|
138
|
+
userAgent: z.ZodNullable<z.ZodString>;
|
|
139
|
+
}, z.core.$strict>>;
|
|
140
|
+
export declare const browserApiDispatchRequestSchema: z.ZodReadonly<z.ZodObject<{
|
|
141
|
+
method: z.ZodEnum<{
|
|
142
|
+
DELETE: "DELETE";
|
|
143
|
+
GET: "GET";
|
|
144
|
+
PATCH: "PATCH";
|
|
145
|
+
POST: "POST";
|
|
146
|
+
PUT: "PUT";
|
|
147
|
+
}>;
|
|
148
|
+
path: z.ZodString;
|
|
149
|
+
origin: z.ZodOptional<z.ZodString>;
|
|
150
|
+
clientKey: z.ZodString;
|
|
151
|
+
query: z.ZodOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodReadonly<z.ZodArray<z.ZodString>>]>>>>;
|
|
152
|
+
body: z.ZodOptional<z.ZodUnknown>;
|
|
153
|
+
}, z.core.$strict>>;
|
|
154
|
+
export declare const browserApiCookieEffectSchema: z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
155
|
+
action: z.ZodLiteral<"set">;
|
|
156
|
+
name: z.ZodString;
|
|
157
|
+
value: z.ZodString;
|
|
158
|
+
expiresAt: z.ZodISODateTime;
|
|
159
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
160
|
+
action: z.ZodLiteral<"clear">;
|
|
161
|
+
name: z.ZodString;
|
|
162
|
+
}, z.core.$strict>], "action">>;
|
|
163
|
+
export declare const browserApiDispatchResponseSchema: z.ZodReadonly<z.ZodObject<{
|
|
164
|
+
status: z.ZodNumber;
|
|
165
|
+
body: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
166
|
+
code: z.ZodLiteral<0>;
|
|
167
|
+
data: z.ZodUnknown & z.ZodType<{} | null, unknown, z.core.$ZodTypeInternals<{} | null, unknown>>;
|
|
168
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
169
|
+
code: z.ZodNumber;
|
|
170
|
+
error: z.ZodString;
|
|
171
|
+
}, z.core.$strict>>]>;
|
|
172
|
+
cookieEffects: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
173
|
+
action: z.ZodLiteral<"set">;
|
|
174
|
+
name: z.ZodString;
|
|
175
|
+
value: z.ZodString;
|
|
176
|
+
expiresAt: z.ZodISODateTime;
|
|
177
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
178
|
+
action: z.ZodLiteral<"clear">;
|
|
179
|
+
name: z.ZodString;
|
|
180
|
+
}, z.core.$strict>], "action">>>>>;
|
|
181
|
+
}, z.core.$strict>>;
|
|
182
|
+
export interface BrowserApiSuccess<T> {
|
|
183
|
+
readonly code: 0;
|
|
184
|
+
readonly data: T;
|
|
185
|
+
}
|
|
186
|
+
export interface BrowserApiFailure {
|
|
187
|
+
readonly code: number;
|
|
188
|
+
readonly error: string;
|
|
189
|
+
}
|
|
190
|
+
export type BrowserApiResponse<T = unknown> = BrowserApiSuccess<T> | BrowserApiFailure;
|
|
191
|
+
export type BrowserApiPublicRoute = z.infer<typeof browserApiPublicRouteSchema>;
|
|
192
|
+
export type BrowserApiProviderLease = z.infer<typeof browserApiProviderLeaseSchema>;
|
|
193
|
+
export type BrowserApiProviderAnnouncement = z.infer<typeof browserApiProviderAnnouncementSchema>;
|
|
194
|
+
export type BrowserApiProviderSnapshot = z.infer<typeof browserApiProviderSnapshotSchema>;
|
|
195
|
+
export type BrowserApiDispatchRequest = z.infer<typeof browserApiDispatchRequestSchema>;
|
|
196
|
+
export type BrowserApiCookies = z.infer<typeof browserApiCookiesSchema>;
|
|
197
|
+
export type BrowserApiClient = z.infer<typeof browserApiClientSchema>;
|
|
198
|
+
export interface BrowserApiContext {
|
|
199
|
+
readonly [BROWSER_API_COOKIES_CONTEXT_KEY]?: BrowserApiCookies;
|
|
200
|
+
readonly [BROWSER_API_CLIENT_CONTEXT_KEY]?: BrowserApiClient;
|
|
201
|
+
}
|
|
202
|
+
export type BrowserApiCookieEffect = z.infer<typeof browserApiCookieEffectSchema>;
|
|
203
|
+
export type BrowserApiDispatchResponse = z.infer<typeof browserApiDispatchResponseSchema>;
|
|
204
|
+
export declare function browserApiSuccess<T>(data: T): BrowserApiSuccess<T>;
|
|
205
|
+
export declare function browserApiFailure(code: number, error: string): BrowserApiFailure;
|
|
206
|
+
export declare function parseBrowserApiResponse(input: unknown): BrowserApiResponse;
|
|
207
|
+
export declare function isBrowserApiFailure(response: BrowserApiResponse): response is BrowserApiFailure;
|
|
208
|
+
export declare function browserApiProviderTopic(providerId: string, instanceId: string): string;
|
|
209
|
+
export declare function parseTrustedBrowserApiProviderAnnouncement(input: unknown, now?: Date, maxLeaseMs?: number, maxClockSkewMs?: number): BrowserApiProviderAnnouncement;
|
|
210
|
+
export declare function parseTrustedBrowserApiProviderSnapshot(input: unknown, now?: Date, maxLeaseMs?: number, maxClockSkewMs?: number): BrowserApiProviderSnapshot;
|
|
211
|
+
export declare function parseBrowserApiDispatchRequest(input: unknown): BrowserApiDispatchRequest;
|
|
212
|
+
export declare function parseBrowserApiCookies(input: unknown): BrowserApiCookies;
|
|
213
|
+
export declare function readBrowserApiCookiesFromContext(input: unknown): BrowserApiCookies;
|
|
214
|
+
export declare function readBrowserApiClientFromContext(input: unknown): BrowserApiClient | undefined;
|
|
215
|
+
export declare function parseBrowserApiDispatchResponse(input: unknown): BrowserApiDispatchResponse;
|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AAuB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAE1E;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,kBAAkB,GAC3B,QAAQ,IAAI,iBAAiB,CAE/B;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEtF;AAED,wBAAgB,0CAA0C,CACxD,KAAK,EAAE,OAAO,EACd,GAAG,OAAa,EAChB,UAAU,SAAS,EACnB,cAAc,SAAI,GACjB,8BAA8B,CAchC;AAED,wBAAgB,sCAAsC,CACpD,KAAK,EAAE,OAAO,EACd,GAAG,OAAa,EAChB,UAAU,SAAS,EACnB,cAAc,SAAI,GACjB,0BAA0B,CAW5B;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,yBAAyB,CAExF;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAExE;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAGlF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAI5F;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,0BAA0B,CAE1F"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const BROWSER_API_PROVIDER_DISPATCH_OPERATION = '/browser/dispatch';
|
|
3
|
+
export const BROWSER_API_PROVIDER_TOPIC_PREFIX = 'registry:zlooks.cn/browser-api/providers/';
|
|
4
|
+
export const BROWSER_API_COOKIES_CONTEXT_KEY = 'zlooks.browser.cookies';
|
|
5
|
+
export const BROWSER_API_CLIENT_CONTEXT_KEY = 'zlooks.browser.client';
|
|
6
|
+
const identifier = z.string().regex(/^[a-z][a-z0-9._-]{0,127}$/);
|
|
7
|
+
const namespace = z.string().regex(/^[a-z][a-z0-9]*(?:\.[a-z][a-z0-9]*)+$/);
|
|
8
|
+
const absolutePath = z.string().min(1).max(2_048).regex(/^\/(?!\/)[^?#\s]*$/);
|
|
9
|
+
const publicApiPath = z.string().min(5).max(2_048).regex(/^\/api\/(?!\/)[^?#\s]*$/);
|
|
10
|
+
const instant = z.iso.datetime({ offset: true });
|
|
11
|
+
const cookieName = z.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,127}$/);
|
|
12
|
+
const httpMethod = z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
13
|
+
const cookieNames = z.array(cookieName).max(8).refine((names) => new Set(names).size === names.length, 'Cookie names must be unique').readonly();
|
|
14
|
+
const publicErrorSchema = z.strictObject({
|
|
15
|
+
code: z.number().int().safe().refine((code) => code !== 0),
|
|
16
|
+
message: z.string().trim().min(1).max(500),
|
|
17
|
+
}).readonly();
|
|
18
|
+
const successSchema = z.strictObject({
|
|
19
|
+
code: z.literal(0),
|
|
20
|
+
data: z.unknown().refine((data) => data !== undefined),
|
|
21
|
+
}).readonly();
|
|
22
|
+
const failureSchema = z.strictObject({
|
|
23
|
+
code: z.number().int().safe().refine((code) => code !== 0),
|
|
24
|
+
error: z.string().trim().min(1).max(500),
|
|
25
|
+
}).readonly();
|
|
26
|
+
export const browserApiResponseSchema = z.union([successSchema, failureSchema]);
|
|
27
|
+
const exactRouteSchema = z.strictObject({
|
|
28
|
+
exact: publicApiPath,
|
|
29
|
+
methods: z.array(httpMethod).min(1).max(5)
|
|
30
|
+
.refine((methods) => new Set(methods).size === methods.length, 'Methods must be unique')
|
|
31
|
+
.readonly(),
|
|
32
|
+
forwardCookieNames: cookieNames,
|
|
33
|
+
}).readonly();
|
|
34
|
+
const prefixRouteSchema = z.strictObject({
|
|
35
|
+
prefix: publicApiPath.refine((path) => path.endsWith('/'), 'Route prefix must end with /'),
|
|
36
|
+
methods: z.array(httpMethod).min(1).max(5)
|
|
37
|
+
.refine((methods) => new Set(methods).size === methods.length, 'Methods must be unique')
|
|
38
|
+
.readonly(),
|
|
39
|
+
forwardCookieNames: cookieNames,
|
|
40
|
+
}).readonly();
|
|
41
|
+
export const browserApiPublicRouteSchema = z.union([exactRouteSchema, prefixRouteSchema]);
|
|
42
|
+
export const browserApiProviderLeaseSchema = z.strictObject({
|
|
43
|
+
issuedAt: instant,
|
|
44
|
+
expiresAt: instant,
|
|
45
|
+
sequence: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
46
|
+
}).refine((lease) => Date.parse(lease.expiresAt) > Date.parse(lease.issuedAt), {
|
|
47
|
+
message: 'Browser API Provider lease must expire after it is issued',
|
|
48
|
+
}).readonly();
|
|
49
|
+
export const browserApiProviderAnnouncementSchema = z.strictObject({
|
|
50
|
+
protocol: z.literal('zlooks.browser-api.provider'),
|
|
51
|
+
providerId: identifier,
|
|
52
|
+
instanceId: identifier,
|
|
53
|
+
namespace,
|
|
54
|
+
operation: z.literal(BROWSER_API_PROVIDER_DISPATCH_OPERATION),
|
|
55
|
+
routes: z.array(browserApiPublicRouteSchema).min(1).max(64).refine((routes) => !routes.some((route, index) => routes.slice(index + 1)
|
|
56
|
+
.some((candidate) => routesOverlap(route, candidate))), 'Provider routes must not overlap for the same HTTP method').readonly(),
|
|
57
|
+
writableCookieNames: cookieNames,
|
|
58
|
+
errors: z.strictObject({
|
|
59
|
+
invalidRequest: publicErrorSchema,
|
|
60
|
+
unavailable: publicErrorSchema,
|
|
61
|
+
}).readonly(),
|
|
62
|
+
lease: browserApiProviderLeaseSchema,
|
|
63
|
+
}).readonly();
|
|
64
|
+
export const browserApiProviderSnapshotSchema = z.strictObject({
|
|
65
|
+
topic: z.string().min(1).max(512),
|
|
66
|
+
payload: browserApiProviderAnnouncementSchema,
|
|
67
|
+
publishers: z.array(z.strictObject({
|
|
68
|
+
host: z.string().trim().min(1).max(253),
|
|
69
|
+
port: z.number().int().min(1).max(65_535),
|
|
70
|
+
}).readonly()).length(1).readonly(),
|
|
71
|
+
}).readonly();
|
|
72
|
+
const queryValue = z.union([
|
|
73
|
+
z.string().max(512),
|
|
74
|
+
z.array(z.string().max(512)).max(20).readonly(),
|
|
75
|
+
]);
|
|
76
|
+
export const browserApiDispatchQuerySchema = z.record(z.string().regex(/^[a-z][a-zA-Z0-9_-]{0,63}$/), queryValue).refine((query) => Object.keys(query).length <= 20, {
|
|
77
|
+
message: 'Browser API query has too many fields',
|
|
78
|
+
}).readonly();
|
|
79
|
+
export const browserApiCookiesSchema = z.record(cookieName, z.string().min(1).max(4_096)).refine((cookies) => Object.keys(cookies).length <= 8, {
|
|
80
|
+
message: 'Browser API context has too many cookies',
|
|
81
|
+
}).readonly();
|
|
82
|
+
export const browserApiClientSchema = z.strictObject({
|
|
83
|
+
ipAddress: z.union([z.ipv4(), z.ipv6()]),
|
|
84
|
+
userAgent: z.string().trim().min(1).max(1_024).nullable(),
|
|
85
|
+
}).readonly();
|
|
86
|
+
export const browserApiDispatchRequestSchema = z.strictObject({
|
|
87
|
+
method: httpMethod,
|
|
88
|
+
path: absolutePath,
|
|
89
|
+
origin: z.string().max(2_048).optional(),
|
|
90
|
+
clientKey: z.string().regex(/^[a-f0-9]{64}$/),
|
|
91
|
+
query: browserApiDispatchQuerySchema.optional(),
|
|
92
|
+
body: z.unknown().optional(),
|
|
93
|
+
}).readonly();
|
|
94
|
+
export const browserApiCookieEffectSchema = z.discriminatedUnion('action', [
|
|
95
|
+
z.strictObject({
|
|
96
|
+
action: z.literal('set'),
|
|
97
|
+
name: cookieName,
|
|
98
|
+
value: z.string().min(1).max(4_096),
|
|
99
|
+
expiresAt: instant,
|
|
100
|
+
}),
|
|
101
|
+
z.strictObject({
|
|
102
|
+
action: z.literal('clear'),
|
|
103
|
+
name: cookieName,
|
|
104
|
+
}),
|
|
105
|
+
]).readonly();
|
|
106
|
+
export const browserApiDispatchResponseSchema = z.strictObject({
|
|
107
|
+
status: z.number().int().min(200).max(599)
|
|
108
|
+
.refine((status) => status < 300 || status >= 400),
|
|
109
|
+
body: browserApiResponseSchema,
|
|
110
|
+
cookieEffects: z.array(browserApiCookieEffectSchema).max(8).refine((effects) => new Set(effects.map((effect) => effect.name)).size === effects.length, 'Cookie effects must target unique names').readonly().optional(),
|
|
111
|
+
}).superRefine((response, context) => {
|
|
112
|
+
const httpSucceeded = response.status >= 200 && response.status < 300;
|
|
113
|
+
if (httpSucceeded === !isBrowserApiFailure(response.body))
|
|
114
|
+
return;
|
|
115
|
+
context.addIssue({
|
|
116
|
+
code: 'custom',
|
|
117
|
+
message: 'HTTP status and browser API response code disagree',
|
|
118
|
+
path: ['body', 'code'],
|
|
119
|
+
});
|
|
120
|
+
}).readonly();
|
|
121
|
+
export function browserApiSuccess(data) {
|
|
122
|
+
successSchema.parse({ code: 0, data });
|
|
123
|
+
return Object.freeze({ code: 0, data });
|
|
124
|
+
}
|
|
125
|
+
export function browserApiFailure(code, error) {
|
|
126
|
+
return failureSchema.parse({ code, error });
|
|
127
|
+
}
|
|
128
|
+
export function parseBrowserApiResponse(input) {
|
|
129
|
+
return browserApiResponseSchema.parse(input);
|
|
130
|
+
}
|
|
131
|
+
export function isBrowserApiFailure(response) {
|
|
132
|
+
return response.code !== 0;
|
|
133
|
+
}
|
|
134
|
+
export function browserApiProviderTopic(providerId, instanceId) {
|
|
135
|
+
return `${BROWSER_API_PROVIDER_TOPIC_PREFIX}${identifier.parse(providerId)}/${identifier.parse(instanceId)}`;
|
|
136
|
+
}
|
|
137
|
+
export function parseTrustedBrowserApiProviderAnnouncement(input, now = new Date(), maxLeaseMs = 30_000, maxClockSkewMs = 0) {
|
|
138
|
+
assertNonNegativeSafeInteger(maxLeaseMs, 'Browser API Provider maximum lease');
|
|
139
|
+
assertNonNegativeSafeInteger(maxClockSkewMs, 'Browser API Provider clock skew');
|
|
140
|
+
const announcement = browserApiProviderAnnouncementSchema.parse(input);
|
|
141
|
+
const issuedAt = Date.parse(announcement.lease.issuedAt);
|
|
142
|
+
const expiresAt = Date.parse(announcement.lease.expiresAt);
|
|
143
|
+
if (expiresAt - issuedAt > maxLeaseMs)
|
|
144
|
+
throw new Error('Browser API Provider lease is too long');
|
|
145
|
+
if (now.getTime() + maxClockSkewMs < issuedAt) {
|
|
146
|
+
throw new Error('Browser API Provider lease is not active yet');
|
|
147
|
+
}
|
|
148
|
+
if (now.getTime() - maxClockSkewMs >= expiresAt) {
|
|
149
|
+
throw new Error('Browser API Provider lease has expired');
|
|
150
|
+
}
|
|
151
|
+
return announcement;
|
|
152
|
+
}
|
|
153
|
+
export function parseTrustedBrowserApiProviderSnapshot(input, now = new Date(), maxLeaseMs = 30_000, maxClockSkewMs = 0) {
|
|
154
|
+
const snapshot = browserApiProviderSnapshotSchema.parse(input);
|
|
155
|
+
const payload = parseTrustedBrowserApiProviderAnnouncement(snapshot.payload, now, maxLeaseMs, maxClockSkewMs);
|
|
156
|
+
const expectedTopic = browserApiProviderTopic(payload.providerId, payload.instanceId);
|
|
157
|
+
if (snapshot.topic !== expectedTopic)
|
|
158
|
+
throw new Error('Browser API Provider topic does not match identity');
|
|
159
|
+
return { topic: snapshot.topic, payload, publishers: snapshot.publishers };
|
|
160
|
+
}
|
|
161
|
+
export function parseBrowserApiDispatchRequest(input) {
|
|
162
|
+
return browserApiDispatchRequestSchema.parse(input);
|
|
163
|
+
}
|
|
164
|
+
export function parseBrowserApiCookies(input) {
|
|
165
|
+
return browserApiCookiesSchema.parse(input);
|
|
166
|
+
}
|
|
167
|
+
export function readBrowserApiCookiesFromContext(input) {
|
|
168
|
+
const context = z.record(z.string(), z.unknown()).parse(input);
|
|
169
|
+
return parseBrowserApiCookies(context[BROWSER_API_COOKIES_CONTEXT_KEY] ?? {});
|
|
170
|
+
}
|
|
171
|
+
export function readBrowserApiClientFromContext(input) {
|
|
172
|
+
const context = z.record(z.string(), z.unknown()).parse(input);
|
|
173
|
+
const client = context[BROWSER_API_CLIENT_CONTEXT_KEY];
|
|
174
|
+
return client === undefined ? undefined : browserApiClientSchema.parse(client);
|
|
175
|
+
}
|
|
176
|
+
export function parseBrowserApiDispatchResponse(input) {
|
|
177
|
+
return browserApiDispatchResponseSchema.parse(input);
|
|
178
|
+
}
|
|
179
|
+
function assertNonNegativeSafeInteger(value, label) {
|
|
180
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
181
|
+
throw new TypeError(`${label} must be a non-negative safe integer`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function routesOverlap(left, right) {
|
|
185
|
+
if (!left.methods.some((method) => right.methods.includes(method)))
|
|
186
|
+
return false;
|
|
187
|
+
if ('exact' in left && 'exact' in right)
|
|
188
|
+
return left.exact === right.exact;
|
|
189
|
+
if ('prefix' in left && 'prefix' in right) {
|
|
190
|
+
return left.prefix.startsWith(right.prefix) || right.prefix.startsWith(left.prefix);
|
|
191
|
+
}
|
|
192
|
+
if ('exact' in left && 'prefix' in right)
|
|
193
|
+
return left.exact.startsWith(right.prefix);
|
|
194
|
+
if ('prefix' in left && 'exact' in right)
|
|
195
|
+
return right.exact.startsWith(left.prefix);
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,uCAAuC,GAAG,mBAAmB,CAAC;AAC3E,MAAM,CAAC,MAAM,iCAAiC,GAAG,2CAA2C,CAAC;AAC7F,MAAM,CAAC,MAAM,+BAA+B,GAAG,wBAAwB,CAAC;AACxE,MAAM,CAAC,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;AAEtE,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;AACjE,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;AAC5E,M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IACrF,IAAI,QAAQ,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zlooks.cn/browser-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "pnpm run clean && tsc -p tsconfig.json && fix-esm-import-path --preserve-import-type ./dist",
|
|
17
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"zod": "4.4.3"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "26.2.0",
|
|
26
|
+
"fix-esm-import-path": "1.10.3",
|
|
27
|
+
"typescript": "7.0.2",
|
|
28
|
+
"vitest": "4.1.11"
|
|
29
|
+
},
|
|
30
|
+
"gitHead": "a3e825c2a62561f73f49a54720e286f08da63429"
|
|
31
|
+
}
|