@structured-id/ids 0.0.0-stage → 0.1.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.
@@ -0,0 +1,353 @@
1
+ import { MessageType } from '@protobuf-ts/runtime';
2
+
3
+ /** The identifier kinds this package delivers: one per `sid.v1.ids` message. */
4
+ type IdKind = "BindingId" | "MachineUserId" | "PasswordOperationId" | "ProvisioningConnectorId" | "ProvisioningCredentialId" | "ResourceId";
5
+ /** Why a value is not a valid identifier. */
6
+ type IdErrorReason =
7
+ /** The text is not a UUID in any accepted textual form. */
8
+ {
9
+ readonly type: "malformed";
10
+ }
11
+ /** Binary form of a length other than 16 bytes. */
12
+ | {
13
+ readonly type: "length";
14
+ readonly length: number;
15
+ }
16
+ /** The nil UUID (all zero bits). */
17
+ | {
18
+ readonly type: "nil";
19
+ }
20
+ /** The max UUID (all one bits). */
21
+ | {
22
+ readonly type: "max";
23
+ }
24
+ /** The variant bits are not those of RFC 9562. */
25
+ | {
26
+ readonly type: "variant";
27
+ }
28
+ /** An RFC 9562 UUID of a version other than 7. */
29
+ | {
30
+ readonly type: "version";
31
+ readonly version: number;
32
+ };
33
+ /**
34
+ * A value that is not a valid identifier of the requested kind. Carries the
35
+ * kind and the reason, never the value, so it can be logged freely.
36
+ */
37
+ declare class IdError extends Error {
38
+ readonly kind: IdKind;
39
+ readonly reason: IdErrorReason;
40
+ readonly name = "IdError";
41
+ constructor(kind: IdKind, reason: IdErrorReason);
42
+ }
43
+ /** A required identifier message was absent. Absence is never a default. */
44
+ declare class MissingIdError extends Error {
45
+ readonly kind: IdKind;
46
+ readonly name = "MissingIdError";
47
+ constructor(kind: IdKind);
48
+ }
49
+
50
+ declare class BindingId$Type extends MessageType<BindingId$1> {
51
+ constructor();
52
+ }
53
+ /**
54
+ * A Profile's identity at one organization: the pairwise subject that
55
+ * organization's services see. Opaque and unlinkable across organizations;
56
+ * it never carries or reveals a ProfileId.
57
+ *
58
+ * @generated from protobuf message sid.v1.ids.BindingId
59
+ */
60
+ interface BindingId$1 {
61
+ /**
62
+ * Exactly 16 bytes: an RFC 9562 UUID of version 7 and the RFC 9562 variant,
63
+ * in network byte order. Nil, max, other lengths, versions and variants are
64
+ * invalid. Issued by SID; compared by exact byte equality.
65
+ *
66
+ * @generated from protobuf field: bytes value = 1
67
+ */
68
+ value: Uint8Array;
69
+ }
70
+ /**
71
+ * @generated MessageType for protobuf message sid.v1.ids.BindingId
72
+ */
73
+ declare const BindingId$1: BindingId$Type;
74
+ declare class PasswordOperationId$Type extends MessageType<PasswordOperationId$1> {
75
+ constructor();
76
+ }
77
+ /**
78
+ * One password-installing operation (a registration, change or authorized
79
+ * reset) from its preparation to its commit. Every step and retry of the
80
+ * operation carries it, so a lost response resolves to the operation's one
81
+ * outcome instead of starting another.
82
+ *
83
+ * @generated from protobuf message sid.v1.ids.PasswordOperationId
84
+ */
85
+ interface PasswordOperationId$1 {
86
+ /**
87
+ * Exactly 16 bytes: an RFC 9562 UUID of version 7 and the RFC 9562 variant,
88
+ * in network byte order. Nil, max, other lengths, versions and variants are
89
+ * invalid. Issued by SID; compared by exact byte equality.
90
+ *
91
+ * @generated from protobuf field: bytes value = 1
92
+ */
93
+ value: Uint8Array;
94
+ }
95
+ /**
96
+ * @generated MessageType for protobuf message sid.v1.ids.PasswordOperationId
97
+ */
98
+ declare const PasswordOperationId$1: PasswordOperationId$Type;
99
+ declare class MachineUserId$Type extends MessageType<MachineUserId$1> {
100
+ constructor();
101
+ }
102
+ /**
103
+ * A non-human actor (a service, bot or agent) with its own SID credentials.
104
+ * Not a Binding, a Profile or a device, whatever its bytes.
105
+ *
106
+ * @generated from protobuf message sid.v1.ids.MachineUserId
107
+ */
108
+ interface MachineUserId$1 {
109
+ /**
110
+ * Exactly 16 bytes: an RFC 9562 UUID of version 7 and the RFC 9562 variant,
111
+ * in network byte order. Nil, max, other lengths, versions and variants are
112
+ * invalid. Issued by SID; compared by exact byte equality.
113
+ *
114
+ * @generated from protobuf field: bytes value = 1
115
+ */
116
+ value: Uint8Array;
117
+ }
118
+ /**
119
+ * @generated MessageType for protobuf message sid.v1.ids.MachineUserId
120
+ */
121
+ declare const MachineUserId$1: MachineUserId$Type;
122
+ declare class ProvisioningConnectorId$Type extends MessageType<ProvisioningConnectorId$1> {
123
+ constructor();
124
+ }
125
+ /**
126
+ * A provisioning connector: one directory source sending SCIM to an
127
+ * organization, or one target the organization provisions, acting as its own
128
+ * actor with its own credentials and grants. Not a machine user or a Profile.
129
+ *
130
+ * @generated from protobuf message sid.v1.ids.ProvisioningConnectorId
131
+ */
132
+ interface ProvisioningConnectorId$1 {
133
+ /**
134
+ * Exactly 16 bytes: an RFC 9562 UUID of version 7 and the RFC 9562 variant,
135
+ * in network byte order. Nil, max, other lengths, versions and variants are
136
+ * invalid. Issued by SID; compared by exact byte equality.
137
+ *
138
+ * @generated from protobuf field: bytes value = 1
139
+ */
140
+ value: Uint8Array;
141
+ }
142
+ /**
143
+ * @generated MessageType for protobuf message sid.v1.ids.ProvisioningConnectorId
144
+ */
145
+ declare const ProvisioningConnectorId$1: ProvisioningConnectorId$Type;
146
+ declare class ResourceId$Type extends MessageType<ResourceId$1> {
147
+ constructor();
148
+ }
149
+ /**
150
+ * A registered protected resource: the application or API at which access is
151
+ * enforced, in its issuer's context. Not an OAuth client and not an audience
152
+ * string; its indicator and issuer come from its registration.
153
+ *
154
+ * @generated from protobuf message sid.v1.ids.ResourceId
155
+ */
156
+ interface ResourceId$1 {
157
+ /**
158
+ * Exactly 16 bytes: an RFC 9562 UUID of version 7 and the RFC 9562 variant,
159
+ * in network byte order. Nil, max, other lengths, versions and variants are
160
+ * invalid. Issued by SID; compared by exact byte equality.
161
+ *
162
+ * @generated from protobuf field: bytes value = 1
163
+ */
164
+ value: Uint8Array;
165
+ }
166
+ /**
167
+ * @generated MessageType for protobuf message sid.v1.ids.ResourceId
168
+ */
169
+ declare const ResourceId$1: ResourceId$Type;
170
+ declare class ProvisioningCredentialId$Type extends MessageType<ProvisioningCredentialId$1> {
171
+ constructor();
172
+ }
173
+ /**
174
+ * One credential of a provisioning connector: the reference listings,
175
+ * rotations, revocations and audit records name. Never the secret itself.
176
+ *
177
+ * @generated from protobuf message sid.v1.ids.ProvisioningCredentialId
178
+ */
179
+ interface ProvisioningCredentialId$1 {
180
+ /**
181
+ * Exactly 16 bytes: an RFC 9562 UUID of version 7 and the RFC 9562 variant,
182
+ * in network byte order. Nil, max, other lengths, versions and variants are
183
+ * invalid. Issued by SID; compared by exact byte equality.
184
+ *
185
+ * @generated from protobuf field: bytes value = 1
186
+ */
187
+ value: Uint8Array;
188
+ }
189
+ /**
190
+ * @generated MessageType for protobuf message sid.v1.ids.ProvisioningCredentialId
191
+ */
192
+ declare const ProvisioningCredentialId$1: ProvisioningCredentialId$Type;
193
+
194
+ declare namespace ids {
195
+ export { BindingId$1 as BindingId, MachineUserId$1 as MachineUserId, PasswordOperationId$1 as PasswordOperationId, ProvisioningConnectorId$1 as ProvisioningConnectorId, ProvisioningCredentialId$1 as ProvisioningCredentialId, ResourceId$1 as ResourceId };
196
+ }
197
+
198
+ /**
199
+ * The common behaviour of every identifier. A value is always a valid UUIDv7:
200
+ * it is built only through validation and its bytes are private. Each kind is
201
+ * its own class with a literal `kind`, so values of different kinds are
202
+ * different types even when their bytes are equal.
203
+ *
204
+ * A valid identifier proves only its shape. It does not prove that the entity
205
+ * exists, whom it belongs to, or that the caller may act on it.
206
+ */
207
+ declare abstract class Identifier {
208
+ #private;
209
+ abstract readonly kind: IdKind;
210
+ protected constructor(bytes: Uint8Array);
211
+ /** A copy of the 16 bytes in network order: the wire value. */
212
+ toBytes(): Uint8Array;
213
+ /** Lowercase hyphenated text, for display only; the wire carries bytes. */
214
+ toString(): string;
215
+ /** The same text as `toString`, so JSON logs show a readable value. */
216
+ toJSON(): string;
217
+ /** True for an identifier of the same kind with the same bytes. */
218
+ equals(other: unknown): boolean;
219
+ }
220
+ /**
221
+ * A Profile's identity at one organization: the pairwise subject that
222
+ * organization's services see. Opaque and unlinkable across organizations.
223
+ */
224
+ declare class BindingId extends Identifier {
225
+ static readonly kind = "BindingId";
226
+ readonly kind = "BindingId";
227
+ private constructor();
228
+ /** Accept 16 bytes as this identifier, or throw `IdError` saying why not. */
229
+ static fromBytes(bytes: Uint8Array): BindingId;
230
+ /** Accept a textual UUID as this identifier, or throw `IdError`. */
231
+ static parse(text: string): BindingId;
232
+ /** Validate a decoded wire message; throws `IdError`. */
233
+ static fromWire(message: BindingId$1): BindingId;
234
+ /** The wire message carrying this identifier's bytes. */
235
+ toWire(): BindingId$1;
236
+ }
237
+ /**
238
+ * A non-human actor (a service, bot or agent) with its own credentials. Not a
239
+ * Binding, a Profile or a device, whatever its bytes.
240
+ */
241
+ declare class MachineUserId extends Identifier {
242
+ static readonly kind = "MachineUserId";
243
+ readonly kind = "MachineUserId";
244
+ private constructor();
245
+ /** Accept 16 bytes as this identifier, or throw `IdError` saying why not. */
246
+ static fromBytes(bytes: Uint8Array): MachineUserId;
247
+ /** Accept a textual UUID as this identifier, or throw `IdError`. */
248
+ static parse(text: string): MachineUserId;
249
+ /** Validate a decoded wire message; throws `IdError`. */
250
+ static fromWire(message: MachineUserId$1): MachineUserId;
251
+ /** The wire message carrying this identifier's bytes. */
252
+ toWire(): MachineUserId$1;
253
+ }
254
+ /**
255
+ * One password-installing operation (a registration, change or authorized
256
+ * reset) from its preparation to its commit. Every retry carries it, so a lost
257
+ * response resolves to the operation's one outcome.
258
+ */
259
+ declare class PasswordOperationId extends Identifier {
260
+ static readonly kind = "PasswordOperationId";
261
+ readonly kind = "PasswordOperationId";
262
+ private constructor();
263
+ /** Accept 16 bytes as this identifier, or throw `IdError` saying why not. */
264
+ static fromBytes(bytes: Uint8Array): PasswordOperationId;
265
+ /** Accept a textual UUID as this identifier, or throw `IdError`. */
266
+ static parse(text: string): PasswordOperationId;
267
+ /** Validate a decoded wire message; throws `IdError`. */
268
+ static fromWire(message: PasswordOperationId$1): PasswordOperationId;
269
+ /** The wire message carrying this identifier's bytes. */
270
+ toWire(): PasswordOperationId$1;
271
+ }
272
+ /**
273
+ * A provisioning connector: one directory source or target acting as its own
274
+ * actor with its own credentials and grants. Not a machine user or a Profile.
275
+ */
276
+ declare class ProvisioningConnectorId extends Identifier {
277
+ static readonly kind = "ProvisioningConnectorId";
278
+ readonly kind = "ProvisioningConnectorId";
279
+ private constructor();
280
+ /** Accept 16 bytes as this identifier, or throw `IdError` saying why not. */
281
+ static fromBytes(bytes: Uint8Array): ProvisioningConnectorId;
282
+ /** Accept a textual UUID as this identifier, or throw `IdError`. */
283
+ static parse(text: string): ProvisioningConnectorId;
284
+ /** Validate a decoded wire message; throws `IdError`. */
285
+ static fromWire(message: ProvisioningConnectorId$1): ProvisioningConnectorId;
286
+ /** The wire message carrying this identifier's bytes. */
287
+ toWire(): ProvisioningConnectorId$1;
288
+ }
289
+ /**
290
+ * One credential of a provisioning connector: the reference listings,
291
+ * rotations, revocations and audit records name. Never the secret itself.
292
+ */
293
+ declare class ProvisioningCredentialId extends Identifier {
294
+ static readonly kind = "ProvisioningCredentialId";
295
+ readonly kind = "ProvisioningCredentialId";
296
+ private constructor();
297
+ /** Accept 16 bytes as this identifier, or throw `IdError` saying why not. */
298
+ static fromBytes(bytes: Uint8Array): ProvisioningCredentialId;
299
+ /** Accept a textual UUID as this identifier, or throw `IdError`. */
300
+ static parse(text: string): ProvisioningCredentialId;
301
+ /** Validate a decoded wire message; throws `IdError`. */
302
+ static fromWire(message: ProvisioningCredentialId$1): ProvisioningCredentialId;
303
+ /** The wire message carrying this identifier's bytes. */
304
+ toWire(): ProvisioningCredentialId$1;
305
+ }
306
+ /**
307
+ * A registered protected resource: the application or API at which access is
308
+ * enforced, in its issuer's context. Not an OAuth client or an audience string.
309
+ */
310
+ declare class ResourceId extends Identifier {
311
+ static readonly kind = "ResourceId";
312
+ readonly kind = "ResourceId";
313
+ private constructor();
314
+ /** Accept 16 bytes as this identifier, or throw `IdError` saying why not. */
315
+ static fromBytes(bytes: Uint8Array): ResourceId;
316
+ /** Accept a textual UUID as this identifier, or throw `IdError`. */
317
+ static parse(text: string): ResourceId;
318
+ /** Validate a decoded wire message; throws `IdError`. */
319
+ static fromWire(message: ResourceId$1): ResourceId;
320
+ /** The wire message carrying this identifier's bytes. */
321
+ toWire(): ResourceId$1;
322
+ }
323
+ /** An identifier class: its kind and its checked wire conversion. */
324
+ interface IdType<T, W> {
325
+ readonly kind: IdKind;
326
+ fromWire(message: W): T;
327
+ }
328
+ /**
329
+ * The identifier in a required message field: absence throws
330
+ * `MissingIdError`, an invalid value throws `IdError`.
331
+ */
332
+ declare function required<T, W>(type: IdType<T, W>, message: W | undefined): T;
333
+ /**
334
+ * The identifier in an optional message field: absence stays `undefined`, a
335
+ * present but invalid value throws `IdError` (an empty message is invalid,
336
+ * not absent).
337
+ */
338
+ declare function optional<T, W>(type: IdType<T, W>, message: W | undefined): T | undefined;
339
+
340
+ /**
341
+ * StructuredID identifiers for TypeScript.
342
+ *
343
+ * Each identifier kind is its own class (`BindingId`, `MachineUserId`, ...),
344
+ * built only through validation: exactly 16 bytes of an RFC 9562 UUIDv7, not
345
+ * nil or max. `wire` holds the generated `sid.v1.ids` messages with their
346
+ * binary and standard ProtoJSON codecs; decoding one proves nothing, and the
347
+ * checked conversion (`fromWire`, `required`, `optional`) validates it.
348
+ */
349
+
350
+ /** The include-relative path of the identifier schema this package carries. */
351
+ declare const PROTO_PATH = "sid/v1/ids/ids.proto";
352
+
353
+ export { BindingId, IdError, type IdErrorReason, type IdKind, type IdType, MachineUserId, MissingIdError, PROTO_PATH, PasswordOperationId, ProvisioningConnectorId, ProvisioningCredentialId, ResourceId, optional, required, ids as wire };