@structured-id/ui-core 2.0.0 → 3.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/README.md +22 -10
- package/package.json +25 -43
- package/src/components/SidStatusBadge.vue +1 -5
- package/src/composables/useAccountTransport.test.ts +2 -1
- package/src/composables/useGrpc.test.ts +17 -14
- package/src/composables/useGrpc.ts +4 -2
- package/src/index.ts +2 -120
- package/src/profile/components/ConsentManager.vue +5 -1
- package/src/profile/components/ProfileEditor.vue +1 -1
- package/src/profile/components/SecuritySettings.vue +5 -1
- package/src/profile/components/SessionList.vue +2 -1
- package/src/profile/components/SidRegistrationForm.test.ts +173 -1
- package/src/profile/components/SidRegistrationForm.vue +88 -32
- package/src/profile/components/index.ts +1 -4
- package/src/profile/composables/index.ts +1 -0
- package/src/profile/composables/operationPlan.test.ts +155 -0
- package/src/profile/composables/operationPlan.ts +218 -0
- package/src/profile/composables/useAccountApi.ts +4 -4
- package/src/profile/composables/useAuth.test.ts +312 -31
- package/src/profile/composables/useAuth.ts +176 -30
- package/src/profile/composables/useAuthApi.opaque.test.ts +13 -6
- package/src/profile/composables/useAuthApi.ts +40 -18
- package/src/profile/composables/useCurrentPasswordRequirement.test.ts +196 -0
- package/src/profile/composables/useCurrentPasswordRequirement.ts +95 -0
- package/src/profile/composables/useEnrollmentApi.test.ts +7 -3
- package/src/profile/composables/useEnrollmentApi.ts +3 -5
- package/src/profile/composables/useIdentityApi.ts +4 -4
- package/src/profile/composables/useSecurityLevel.test.ts +1 -1
- package/src/profile/composables/useSecurityLevel.ts +1 -1
- package/src/quasar/SidPasswordCeremony.test.ts +253 -0
- package/src/quasar/SidPasswordCeremony.vue +456 -0
- package/src/quasar/index.ts +2 -0
- package/src/utils/rpcRefusal.test.ts +4 -4
- package/src/utils/rpcRefusal.ts +8 -4
- package/dist/browser-vp/index.cjs +0 -349
- package/dist/browser-vp/index.d.cts +0 -276
- package/dist/browser-vp/index.d.ts +0 -276
- package/dist/browser-vp/index.js +0 -349
- package/dist/chunk-C3Q766CY.cjs +0 -125
- package/dist/chunk-J5YXRXB5.js +0 -125
- package/dist/index.cjs +0 -23581
- package/dist/index.d.cts +0 -11539
- package/dist/index.d.ts +0 -11539
- package/dist/index.js +0 -23581
- package/dist/storage-4CB2JTLW.cjs +0 -22
- package/dist/storage-THRWREZP.js +0 -22
- package/src/browser-vp/crypto.ts +0 -253
- package/src/browser-vp/index.test.ts +0 -10
- package/src/browser-vp/index.ts +0 -116
- package/src/browser-vp/prf.ts +0 -179
- package/src/browser-vp/storage.test.ts +0 -9
- package/src/browser-vp/storage.ts +0 -163
- package/src/browser-vp/types.ts +0 -95
- package/src/browser-vp/vp.test.ts +0 -43
- package/src/browser-vp/vp.ts +0 -111
- package/src/generated/google/api/http.ts +0 -687
- package/src/generated/google/api/httpbody.ts +0 -159
- package/src/generated/google/protobuf/any.ts +0 -326
- package/src/generated/google/protobuf/descriptor.ts +0 -4865
- package/src/generated/google/protobuf/duration.ts +0 -230
- package/src/generated/google/protobuf/empty.ts +0 -94
- package/src/generated/google/protobuf/struct.ts +0 -484
- package/src/generated/google/protobuf/timestamp.ts +0 -287
- package/src/generated/google/rpc/error_details.ts +0 -1386
- package/src/generated/google/rpc/status.ts +0 -127
- package/src/generated/sid/v1/account/account.client.ts +0 -527
- package/src/generated/sid/v1/account/account.ts +0 -3261
- package/src/generated/sid/v1/admin/admin.client.ts +0 -139
- package/src/generated/sid/v1/admin/admin.ts +0 -781
- package/src/generated/sid/v1/admin/admin_roles.client.ts +0 -181
- package/src/generated/sid/v1/admin/admin_roles.ts +0 -1606
- package/src/generated/sid/v1/admin/analytics.client.ts +0 -106
- package/src/generated/sid/v1/admin/analytics.ts +0 -1017
- package/src/generated/sid/v1/admin/branding.client.ts +0 -166
- package/src/generated/sid/v1/admin/branding.ts +0 -1906
- package/src/generated/sid/v1/admin/enrollment.client.ts +0 -177
- package/src/generated/sid/v1/admin/enrollment.ts +0 -1766
- package/src/generated/sid/v1/admin/events.client.ts +0 -195
- package/src/generated/sid/v1/admin/events.ts +0 -1900
- package/src/generated/sid/v1/admin/flow.client.ts +0 -183
- package/src/generated/sid/v1/admin/flow.ts +0 -1552
- package/src/generated/sid/v1/admin/keys.client.ts +0 -107
- package/src/generated/sid/v1/admin/keys.ts +0 -931
- package/src/generated/sid/v1/admin/login_experience.client.ts +0 -160
- package/src/generated/sid/v1/admin/login_experience.ts +0 -1061
- package/src/generated/sid/v1/admin/migration.client.ts +0 -127
- package/src/generated/sid/v1/admin/migration.ts +0 -1948
- package/src/generated/sid/v1/admin/notifications.client.ts +0 -134
- package/src/generated/sid/v1/admin/notifications.ts +0 -1273
- package/src/generated/sid/v1/admin/operations.client.ts +0 -241
- package/src/generated/sid/v1/admin/operations.ts +0 -2633
- package/src/generated/sid/v1/admin/organizations.client.ts +0 -57
- package/src/generated/sid/v1/admin/organizations.ts +0 -332
- package/src/generated/sid/v1/admin/provisioning.client.ts +0 -232
- package/src/generated/sid/v1/admin/provisioning.ts +0 -1383
- package/src/generated/sid/v1/admin/scopes.client.ts +0 -171
- package/src/generated/sid/v1/admin/scopes.ts +0 -1324
- package/src/generated/sid/v1/admin/security.client.ts +0 -410
- package/src/generated/sid/v1/admin/security.ts +0 -4077
- package/src/generated/sid/v1/admin/sessions.client.ts +0 -114
- package/src/generated/sid/v1/admin/sessions.ts +0 -923
- package/src/generated/sid/v1/admin/settings.client.ts +0 -351
- package/src/generated/sid/v1/admin/settings.ts +0 -2458
- package/src/generated/sid/v1/admin/user_profile.client.ts +0 -57
- package/src/generated/sid/v1/admin/user_profile.ts +0 -730
- package/src/generated/sid/v1/admin/webhooks.client.ts +0 -269
- package/src/generated/sid/v1/admin/webhooks.ts +0 -2804
- package/src/generated/sid/v1/attestation/attestation.client.ts +0 -115
- package/src/generated/sid/v1/attestation/attestation.ts +0 -813
- package/src/generated/sid/v1/authn/auth.client.ts +0 -943
- package/src/generated/sid/v1/authn/auth.ts +0 -9719
- package/src/generated/sid/v1/authn/flows.client.ts +0 -413
- package/src/generated/sid/v1/authn/flows.ts +0 -3205
- package/src/generated/sid/v1/authn/issuer.client.ts +0 -489
- package/src/generated/sid/v1/authn/issuer.ts +0 -1600
- package/src/generated/sid/v1/authn/password_history.client.ts +0 -57
- package/src/generated/sid/v1/authn/password_history.ts +0 -578
- package/src/generated/sid/v1/authn/system_integration.client.ts +0 -73
- package/src/generated/sid/v1/authn/system_integration.ts +0 -218
- package/src/generated/sid/v1/authz/authz.client.ts +0 -459
- package/src/generated/sid/v1/authz/authz.ts +0 -6524
- package/src/generated/sid/v1/authz/forward_auth.client.ts +0 -97
- package/src/generated/sid/v1/authz/forward_auth.ts +0 -79
- package/src/generated/sid/v1/authz/governance.client.ts +0 -102
- package/src/generated/sid/v1/authz/governance.ts +0 -875
- package/src/generated/sid/v1/common/errors.ts +0 -710
- package/src/generated/sid/v1/common/pagination.ts +0 -152
- package/src/generated/sid/v1/common/transport.ts +0 -227
- package/src/generated/sid/v1/common/types.ts +0 -151
- package/src/generated/sid/v1/events/event_stream.client.ts +0 -67
- package/src/generated/sid/v1/events/event_stream.ts +0 -375
- package/src/generated/sid/v1/federation/upstream.client.ts +0 -142
- package/src/generated/sid/v1/federation/upstream.ts +0 -1736
- package/src/generated/sid/v1/identity/identity.client.ts +0 -467
- package/src/generated/sid/v1/identity/identity.ts +0 -5676
- package/src/generated/sid/v1/ids/ids.ts +0 -395
- package/src/generated/sid/v1/machine/machine_user.client.ts +0 -219
- package/src/generated/sid/v1/machine/machine_user.ts +0 -2364
- package/src/generated/sid/v1/machine/pat.client.ts +0 -130
- package/src/generated/sid/v1/machine/pat.ts +0 -1083
- package/src/generated/sid/v1/projects/projects.client.ts +0 -404
- package/src/generated/sid/v1/projects/projects.ts +0 -4446
- package/src/generated/sid/v1/scim/scim.client.ts +0 -520
- package/src/generated/sid/v1/scim/scim.ts +0 -3182
- package/src/generated/sid/v1/test/test.client.ts +0 -232
- package/src/generated/sid/v1/test/test.ts +0 -1136
- package/src/transport/adaptive.test.ts +0 -728
- package/src/transport/adaptive.ts +0 -308
- package/src/transport/framing.test.ts +0 -227
- package/src/transport/framing.ts +0 -98
- package/src/transport/webtransport.test.ts +0 -728
- package/src/transport/webtransport.ts +0 -323
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebTransport RPC transport for StructuredID.
|
|
3
|
-
*
|
|
4
|
-
* Implements the @protobuf-ts/runtime-rpc RpcTransport interface using
|
|
5
|
-
* the browser WebTransport API over HTTP/3 (QUIC).
|
|
6
|
-
*
|
|
7
|
-
* Each unary RPC opens one bidirectional stream:
|
|
8
|
-
* Client → Server: [4B len][RequestHeader] [4B len][request body]
|
|
9
|
-
* Server → Client: [4B len][ResponseHeader] [4B len][response body]
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
Deferred,
|
|
14
|
-
RpcError,
|
|
15
|
-
mergeRpcOptions,
|
|
16
|
-
UnaryCall,
|
|
17
|
-
} from "@protobuf-ts/runtime-rpc";
|
|
18
|
-
import type {
|
|
19
|
-
RpcTransport,
|
|
20
|
-
MethodInfo,
|
|
21
|
-
RpcOptions,
|
|
22
|
-
RpcMetadata,
|
|
23
|
-
RpcStatus,
|
|
24
|
-
ServerStreamingCall,
|
|
25
|
-
ClientStreamingCall,
|
|
26
|
-
DuplexStreamingCall,
|
|
27
|
-
} from "@protobuf-ts/runtime-rpc";
|
|
28
|
-
import {
|
|
29
|
-
RequestHeader,
|
|
30
|
-
ResponseHeader,
|
|
31
|
-
} from "../generated/sid/v1/common/transport";
|
|
32
|
-
import { FrameReader, writeFrame } from "./framing";
|
|
33
|
-
|
|
34
|
-
export interface WebTransportConnectOptions {
|
|
35
|
-
/** WebTransport server URL, e.g. "https://localhost:4433" */
|
|
36
|
-
url: string;
|
|
37
|
-
/**
|
|
38
|
-
* SHA-256 certificate hash (hex string) for dev self-signed certs.
|
|
39
|
-
* Required for connecting to servers with self-signed certificates.
|
|
40
|
-
*/
|
|
41
|
-
certHash?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Managed WebTransport connection with lazy connect and auto-reconnect detection.
|
|
46
|
-
*/
|
|
47
|
-
export class WebTransportConnection {
|
|
48
|
-
private transport: WebTransport | null = null;
|
|
49
|
-
private connecting: Promise<WebTransport> | null = null;
|
|
50
|
-
private readonly opts: WebTransportConnectOptions;
|
|
51
|
-
|
|
52
|
-
constructor(opts: WebTransportConnectOptions) {
|
|
53
|
-
this.opts = opts;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get connected(): boolean {
|
|
57
|
-
return this.transport !== null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async connect(): Promise<WebTransport> {
|
|
61
|
-
if (this.transport) return this.transport;
|
|
62
|
-
if (this.connecting) return this.connecting;
|
|
63
|
-
|
|
64
|
-
this.connecting = this.doConnect();
|
|
65
|
-
return this.connecting;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
close(): void {
|
|
69
|
-
if (this.transport) {
|
|
70
|
-
this.transport.close();
|
|
71
|
-
this.transport = null;
|
|
72
|
-
}
|
|
73
|
-
this.connecting = null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private async doConnect(): Promise<WebTransport> {
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
-
const initOpts: Record<string, any> = {};
|
|
79
|
-
|
|
80
|
-
if (this.opts.certHash) {
|
|
81
|
-
const hashBytes = hexToBytes(this.opts.certHash);
|
|
82
|
-
initOpts.serverCertificateHashes = [
|
|
83
|
-
{ algorithm: "sha-256", value: hashBytes.buffer },
|
|
84
|
-
];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
const wt = new WebTransport(this.opts.url, initOpts);
|
|
89
|
-
await wt.ready;
|
|
90
|
-
|
|
91
|
-
this.transport = wt;
|
|
92
|
-
this.connecting = null;
|
|
93
|
-
|
|
94
|
-
wt.closed.then(() => {
|
|
95
|
-
if (this.transport === wt) {
|
|
96
|
-
this.transport = null;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return wt;
|
|
101
|
-
} catch (err) {
|
|
102
|
-
// Reset so that subsequent connect() calls retry rather than returning
|
|
103
|
-
// the stale rejected promise.
|
|
104
|
-
this.connecting = null;
|
|
105
|
-
throw err;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* RpcTransport implementation using WebTransport bidirectional streams.
|
|
112
|
-
*
|
|
113
|
-
* Requires an established WebTransportConnection — does NOT manage
|
|
114
|
-
* the connection lifecycle. Use AdaptiveRpcTransport for automatic
|
|
115
|
-
* failover and reconnect.
|
|
116
|
-
*/
|
|
117
|
-
export class WebTransportRpcTransport implements RpcTransport {
|
|
118
|
-
private readonly defaultOptions: RpcOptions;
|
|
119
|
-
private readonly connection: WebTransportConnection;
|
|
120
|
-
|
|
121
|
-
constructor(connection: WebTransportConnection, defaultOptions?: RpcOptions) {
|
|
122
|
-
this.connection = connection;
|
|
123
|
-
this.defaultOptions = defaultOptions ?? {};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
mergeOptions(options?: Partial<RpcOptions>): RpcOptions {
|
|
127
|
-
return mergeRpcOptions(this.defaultOptions, options);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
unary<I extends object, O extends object>(
|
|
131
|
-
method: MethodInfo<I, O>,
|
|
132
|
-
input: I,
|
|
133
|
-
options: RpcOptions,
|
|
134
|
-
): UnaryCall<I, O> {
|
|
135
|
-
const defHeader = new Deferred<RpcMetadata>();
|
|
136
|
-
const defMessage = new Deferred<O>();
|
|
137
|
-
const defStatus = new Deferred<RpcStatus>();
|
|
138
|
-
const defTrailer = new Deferred<RpcMetadata>();
|
|
139
|
-
|
|
140
|
-
this.executeUnary(
|
|
141
|
-
method,
|
|
142
|
-
input,
|
|
143
|
-
options,
|
|
144
|
-
defHeader,
|
|
145
|
-
defMessage,
|
|
146
|
-
defStatus,
|
|
147
|
-
defTrailer,
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
return new UnaryCall(
|
|
151
|
-
method,
|
|
152
|
-
options.meta ?? {},
|
|
153
|
-
input,
|
|
154
|
-
defHeader.promise,
|
|
155
|
-
defMessage.promise,
|
|
156
|
-
defStatus.promise,
|
|
157
|
-
defTrailer.promise,
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
serverStreaming<I extends object, O extends object>(
|
|
162
|
-
_method: MethodInfo<I, O>,
|
|
163
|
-
_input: I,
|
|
164
|
-
_options: RpcOptions,
|
|
165
|
-
): ServerStreamingCall<I, O> {
|
|
166
|
-
throw new RpcError(
|
|
167
|
-
"Server streaming not supported over WebTransport transport",
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
clientStreaming<I extends object, O extends object>(
|
|
172
|
-
_method: MethodInfo<I, O>,
|
|
173
|
-
_options: RpcOptions,
|
|
174
|
-
): ClientStreamingCall<I, O> {
|
|
175
|
-
throw new RpcError(
|
|
176
|
-
"Client streaming not supported over WebTransport transport",
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
duplex<I extends object, O extends object>(
|
|
181
|
-
_method: MethodInfo<I, O>,
|
|
182
|
-
_options: RpcOptions,
|
|
183
|
-
): DuplexStreamingCall<I, O> {
|
|
184
|
-
throw new RpcError(
|
|
185
|
-
"Duplex streaming not supported over WebTransport transport",
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
private async executeUnary<I extends object, O extends object>(
|
|
190
|
-
method: MethodInfo<I, O>,
|
|
191
|
-
input: I,
|
|
192
|
-
options: RpcOptions,
|
|
193
|
-
defHeader: Deferred<RpcMetadata>,
|
|
194
|
-
defMessage: Deferred<O>,
|
|
195
|
-
defStatus: Deferred<RpcStatus>,
|
|
196
|
-
defTrailer: Deferred<RpcMetadata>,
|
|
197
|
-
): Promise<void> {
|
|
198
|
-
try {
|
|
199
|
-
if (!this.connection.connected) {
|
|
200
|
-
throw new RpcError(
|
|
201
|
-
"WebTransport connection not established",
|
|
202
|
-
"UNAVAILABLE",
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const wt = await this.connection.connect();
|
|
207
|
-
const stream = await wt.createBidirectionalStream();
|
|
208
|
-
const writer = stream.writable.getWriter();
|
|
209
|
-
const reader = stream.readable.getReader();
|
|
210
|
-
|
|
211
|
-
try {
|
|
212
|
-
// Build RequestHeader
|
|
213
|
-
const methodPath = `${method.service.typeName}/${method.name}`;
|
|
214
|
-
const metadata: Record<string, string> = {};
|
|
215
|
-
if (options.meta) {
|
|
216
|
-
for (const [key, value] of Object.entries(options.meta)) {
|
|
217
|
-
if (typeof value === "string") {
|
|
218
|
-
metadata[key] = value;
|
|
219
|
-
} else if (Array.isArray(value)) {
|
|
220
|
-
metadata[key] = value.join(",");
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
let timeoutMs = 0;
|
|
226
|
-
if (options.timeout) {
|
|
227
|
-
timeoutMs =
|
|
228
|
-
options.timeout instanceof Date
|
|
229
|
-
? Math.max(0, options.timeout.getTime() - Date.now())
|
|
230
|
-
: options.timeout;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const reqHeader: RequestHeader = {
|
|
234
|
-
method: methodPath,
|
|
235
|
-
metadata,
|
|
236
|
-
timeoutMs,
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
// Send RequestHeader + request body
|
|
240
|
-
const headerBytes = RequestHeader.toBinary(reqHeader);
|
|
241
|
-
await writeFrame(writer, headerBytes);
|
|
242
|
-
|
|
243
|
-
const bodyBytes = method.I.toBinary(input, options.binaryOptions);
|
|
244
|
-
await writeFrame(writer, bodyBytes);
|
|
245
|
-
|
|
246
|
-
// Read ResponseHeader + response body via FrameReader so that excess
|
|
247
|
-
// bytes from one read() are not lost when reading the next frame.
|
|
248
|
-
const frameReader = new FrameReader(reader);
|
|
249
|
-
const respHeaderBytes = await frameReader.readFrame();
|
|
250
|
-
const respHeader = ResponseHeader.fromBinary(respHeaderBytes);
|
|
251
|
-
|
|
252
|
-
const responseHeaders: RpcMetadata = { ...respHeader.metadata };
|
|
253
|
-
defHeader.resolve(responseHeaders);
|
|
254
|
-
|
|
255
|
-
if (respHeader.statusCode !== 0) {
|
|
256
|
-
throw new RpcError(
|
|
257
|
-
respHeader.statusMessage || "RPC error",
|
|
258
|
-
grpcCodeName(respHeader.statusCode),
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Read response body
|
|
263
|
-
const respBodyBytes = await frameReader.readFrame();
|
|
264
|
-
const message = method.O.fromBinary(
|
|
265
|
-
respBodyBytes,
|
|
266
|
-
options.binaryOptions,
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
defMessage.resolve(message);
|
|
270
|
-
defStatus.resolve({ code: "OK", detail: "" });
|
|
271
|
-
defTrailer.resolve({});
|
|
272
|
-
} finally {
|
|
273
|
-
writer.releaseLock();
|
|
274
|
-
reader.releaseLock();
|
|
275
|
-
}
|
|
276
|
-
} catch (err) {
|
|
277
|
-
const rpcErr =
|
|
278
|
-
err instanceof RpcError
|
|
279
|
-
? err
|
|
280
|
-
: new RpcError(
|
|
281
|
-
err instanceof Error ? err.message : String(err),
|
|
282
|
-
"INTERNAL",
|
|
283
|
-
);
|
|
284
|
-
defHeader.rejectPending(rpcErr);
|
|
285
|
-
defMessage.rejectPending(rpcErr);
|
|
286
|
-
defStatus.rejectPending(rpcErr);
|
|
287
|
-
defTrailer.rejectPending(rpcErr);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/** Convert hex string to Uint8Array. */
|
|
293
|
-
function hexToBytes(hex: string): Uint8Array {
|
|
294
|
-
const bytes = new Uint8Array(hex.length / 2);
|
|
295
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
296
|
-
bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
297
|
-
}
|
|
298
|
-
return bytes;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/** Map gRPC numeric status code to string name. */
|
|
302
|
-
function grpcCodeName(code: number): string {
|
|
303
|
-
const names: Record<number, string> = {
|
|
304
|
-
0: "OK",
|
|
305
|
-
1: "CANCELLED",
|
|
306
|
-
2: "UNKNOWN",
|
|
307
|
-
3: "INVALID_ARGUMENT",
|
|
308
|
-
4: "DEADLINE_EXCEEDED",
|
|
309
|
-
5: "NOT_FOUND",
|
|
310
|
-
6: "ALREADY_EXISTS",
|
|
311
|
-
7: "PERMISSION_DENIED",
|
|
312
|
-
8: "RESOURCE_EXHAUSTED",
|
|
313
|
-
9: "FAILED_PRECONDITION",
|
|
314
|
-
10: "ABORTED",
|
|
315
|
-
11: "OUT_OF_RANGE",
|
|
316
|
-
12: "UNIMPLEMENTED",
|
|
317
|
-
13: "INTERNAL",
|
|
318
|
-
14: "UNAVAILABLE",
|
|
319
|
-
15: "DATA_LOSS",
|
|
320
|
-
16: "UNAUTHENTICATED",
|
|
321
|
-
};
|
|
322
|
-
return names[code] ?? "UNKNOWN";
|
|
323
|
-
}
|