@structured-id/ui-core 1.3.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.
Files changed (152) hide show
  1. package/README.md +22 -10
  2. package/package.json +25 -43
  3. package/src/components/SidStatusBadge.vue +1 -5
  4. package/src/composables/useAccountTransport.test.ts +2 -1
  5. package/src/composables/useGrpc.test.ts +17 -14
  6. package/src/composables/useGrpc.ts +4 -2
  7. package/src/index.ts +2 -120
  8. package/src/profile/components/ConsentManager.vue +5 -1
  9. package/src/profile/components/ProfileEditor.vue +1 -1
  10. package/src/profile/components/SecuritySettings.vue +5 -1
  11. package/src/profile/components/SessionList.vue +2 -1
  12. package/src/profile/components/SidRegistrationForm.test.ts +173 -1
  13. package/src/profile/components/SidRegistrationForm.vue +88 -32
  14. package/src/profile/components/index.ts +1 -4
  15. package/src/profile/composables/index.ts +1 -0
  16. package/src/profile/composables/operationPlan.test.ts +155 -0
  17. package/src/profile/composables/operationPlan.ts +218 -0
  18. package/src/profile/composables/useAccountApi.ts +4 -4
  19. package/src/profile/composables/useAuth.test.ts +312 -31
  20. package/src/profile/composables/useAuth.ts +176 -30
  21. package/src/profile/composables/useAuthApi.opaque.test.ts +13 -6
  22. package/src/profile/composables/useAuthApi.ts +40 -18
  23. package/src/profile/composables/useCurrentPasswordRequirement.test.ts +196 -0
  24. package/src/profile/composables/useCurrentPasswordRequirement.ts +95 -0
  25. package/src/profile/composables/useEnrollmentApi.test.ts +7 -3
  26. package/src/profile/composables/useEnrollmentApi.ts +3 -5
  27. package/src/profile/composables/useIdentityApi.ts +4 -4
  28. package/src/profile/composables/useSecurityLevel.test.ts +1 -1
  29. package/src/profile/composables/useSecurityLevel.ts +1 -1
  30. package/src/quasar/SidPasswordCeremony.test.ts +253 -0
  31. package/src/quasar/SidPasswordCeremony.vue +456 -0
  32. package/src/quasar/index.ts +2 -0
  33. package/src/utils/rpcRefusal.test.ts +4 -4
  34. package/src/utils/rpcRefusal.ts +8 -4
  35. package/dist/browser-vp/index.cjs +0 -349
  36. package/dist/browser-vp/index.d.cts +0 -276
  37. package/dist/browser-vp/index.d.ts +0 -276
  38. package/dist/browser-vp/index.js +0 -349
  39. package/dist/chunk-C3Q766CY.cjs +0 -125
  40. package/dist/chunk-J5YXRXB5.js +0 -125
  41. package/dist/index.cjs +0 -23581
  42. package/dist/index.d.cts +0 -11539
  43. package/dist/index.d.ts +0 -11539
  44. package/dist/index.js +0 -23581
  45. package/dist/storage-4CB2JTLW.cjs +0 -22
  46. package/dist/storage-THRWREZP.js +0 -22
  47. package/src/browser-vp/crypto.ts +0 -253
  48. package/src/browser-vp/index.test.ts +0 -10
  49. package/src/browser-vp/index.ts +0 -116
  50. package/src/browser-vp/prf.ts +0 -179
  51. package/src/browser-vp/storage.test.ts +0 -9
  52. package/src/browser-vp/storage.ts +0 -163
  53. package/src/browser-vp/types.ts +0 -95
  54. package/src/browser-vp/vp.test.ts +0 -43
  55. package/src/browser-vp/vp.ts +0 -111
  56. package/src/generated/google/api/http.ts +0 -687
  57. package/src/generated/google/api/httpbody.ts +0 -159
  58. package/src/generated/google/protobuf/any.ts +0 -326
  59. package/src/generated/google/protobuf/descriptor.ts +0 -4865
  60. package/src/generated/google/protobuf/duration.ts +0 -230
  61. package/src/generated/google/protobuf/empty.ts +0 -94
  62. package/src/generated/google/protobuf/struct.ts +0 -484
  63. package/src/generated/google/protobuf/timestamp.ts +0 -287
  64. package/src/generated/google/rpc/error_details.ts +0 -1386
  65. package/src/generated/google/rpc/status.ts +0 -127
  66. package/src/generated/sid/v1/account/account.client.ts +0 -527
  67. package/src/generated/sid/v1/account/account.ts +0 -3261
  68. package/src/generated/sid/v1/admin/admin.client.ts +0 -139
  69. package/src/generated/sid/v1/admin/admin.ts +0 -781
  70. package/src/generated/sid/v1/admin/admin_roles.client.ts +0 -181
  71. package/src/generated/sid/v1/admin/admin_roles.ts +0 -1606
  72. package/src/generated/sid/v1/admin/analytics.client.ts +0 -106
  73. package/src/generated/sid/v1/admin/analytics.ts +0 -1017
  74. package/src/generated/sid/v1/admin/branding.client.ts +0 -166
  75. package/src/generated/sid/v1/admin/branding.ts +0 -1906
  76. package/src/generated/sid/v1/admin/enrollment.client.ts +0 -177
  77. package/src/generated/sid/v1/admin/enrollment.ts +0 -1766
  78. package/src/generated/sid/v1/admin/events.client.ts +0 -195
  79. package/src/generated/sid/v1/admin/events.ts +0 -1900
  80. package/src/generated/sid/v1/admin/flow.client.ts +0 -183
  81. package/src/generated/sid/v1/admin/flow.ts +0 -1552
  82. package/src/generated/sid/v1/admin/keys.client.ts +0 -107
  83. package/src/generated/sid/v1/admin/keys.ts +0 -931
  84. package/src/generated/sid/v1/admin/login_experience.client.ts +0 -160
  85. package/src/generated/sid/v1/admin/login_experience.ts +0 -1061
  86. package/src/generated/sid/v1/admin/migration.client.ts +0 -127
  87. package/src/generated/sid/v1/admin/migration.ts +0 -1948
  88. package/src/generated/sid/v1/admin/notifications.client.ts +0 -134
  89. package/src/generated/sid/v1/admin/notifications.ts +0 -1273
  90. package/src/generated/sid/v1/admin/operations.client.ts +0 -241
  91. package/src/generated/sid/v1/admin/operations.ts +0 -2633
  92. package/src/generated/sid/v1/admin/organizations.client.ts +0 -57
  93. package/src/generated/sid/v1/admin/organizations.ts +0 -332
  94. package/src/generated/sid/v1/admin/provisioning.client.ts +0 -232
  95. package/src/generated/sid/v1/admin/provisioning.ts +0 -1383
  96. package/src/generated/sid/v1/admin/scopes.client.ts +0 -171
  97. package/src/generated/sid/v1/admin/scopes.ts +0 -1324
  98. package/src/generated/sid/v1/admin/security.client.ts +0 -410
  99. package/src/generated/sid/v1/admin/security.ts +0 -4077
  100. package/src/generated/sid/v1/admin/sessions.client.ts +0 -114
  101. package/src/generated/sid/v1/admin/sessions.ts +0 -923
  102. package/src/generated/sid/v1/admin/settings.client.ts +0 -351
  103. package/src/generated/sid/v1/admin/settings.ts +0 -2458
  104. package/src/generated/sid/v1/admin/user_profile.client.ts +0 -57
  105. package/src/generated/sid/v1/admin/user_profile.ts +0 -730
  106. package/src/generated/sid/v1/admin/webhooks.client.ts +0 -269
  107. package/src/generated/sid/v1/admin/webhooks.ts +0 -2804
  108. package/src/generated/sid/v1/attestation/attestation.client.ts +0 -115
  109. package/src/generated/sid/v1/attestation/attestation.ts +0 -813
  110. package/src/generated/sid/v1/authn/auth.client.ts +0 -943
  111. package/src/generated/sid/v1/authn/auth.ts +0 -9719
  112. package/src/generated/sid/v1/authn/flows.client.ts +0 -413
  113. package/src/generated/sid/v1/authn/flows.ts +0 -3205
  114. package/src/generated/sid/v1/authn/issuer.client.ts +0 -489
  115. package/src/generated/sid/v1/authn/issuer.ts +0 -1600
  116. package/src/generated/sid/v1/authn/password_history.client.ts +0 -57
  117. package/src/generated/sid/v1/authn/password_history.ts +0 -578
  118. package/src/generated/sid/v1/authn/system_integration.client.ts +0 -73
  119. package/src/generated/sid/v1/authn/system_integration.ts +0 -218
  120. package/src/generated/sid/v1/authz/authz.client.ts +0 -459
  121. package/src/generated/sid/v1/authz/authz.ts +0 -6524
  122. package/src/generated/sid/v1/authz/forward_auth.client.ts +0 -97
  123. package/src/generated/sid/v1/authz/forward_auth.ts +0 -79
  124. package/src/generated/sid/v1/authz/governance.client.ts +0 -102
  125. package/src/generated/sid/v1/authz/governance.ts +0 -875
  126. package/src/generated/sid/v1/common/errors.ts +0 -710
  127. package/src/generated/sid/v1/common/pagination.ts +0 -152
  128. package/src/generated/sid/v1/common/transport.ts +0 -227
  129. package/src/generated/sid/v1/common/types.ts +0 -151
  130. package/src/generated/sid/v1/events/event_stream.client.ts +0 -67
  131. package/src/generated/sid/v1/events/event_stream.ts +0 -375
  132. package/src/generated/sid/v1/federation/upstream.client.ts +0 -142
  133. package/src/generated/sid/v1/federation/upstream.ts +0 -1736
  134. package/src/generated/sid/v1/identity/identity.client.ts +0 -467
  135. package/src/generated/sid/v1/identity/identity.ts +0 -5676
  136. package/src/generated/sid/v1/ids/ids.ts +0 -395
  137. package/src/generated/sid/v1/machine/machine_user.client.ts +0 -219
  138. package/src/generated/sid/v1/machine/machine_user.ts +0 -2364
  139. package/src/generated/sid/v1/machine/pat.client.ts +0 -130
  140. package/src/generated/sid/v1/machine/pat.ts +0 -1083
  141. package/src/generated/sid/v1/projects/projects.client.ts +0 -404
  142. package/src/generated/sid/v1/projects/projects.ts +0 -4446
  143. package/src/generated/sid/v1/scim/scim.client.ts +0 -520
  144. package/src/generated/sid/v1/scim/scim.ts +0 -3182
  145. package/src/generated/sid/v1/test/test.client.ts +0 -232
  146. package/src/generated/sid/v1/test/test.ts +0 -1136
  147. package/src/transport/adaptive.test.ts +0 -728
  148. package/src/transport/adaptive.ts +0 -308
  149. package/src/transport/framing.test.ts +0 -227
  150. package/src/transport/framing.ts +0 -98
  151. package/src/transport/webtransport.test.ts +0 -728
  152. package/src/transport/webtransport.ts +0 -323
@@ -1,159 +0,0 @@
1
- // @generated by protobuf-ts 2.11.1 with parameter client_generic,generate_dependencies
2
- // @generated from protobuf file "google/api/httpbody.proto" (package "google.api", syntax proto3)
3
- // tslint:disable
4
- //
5
- // Copyright 2026 Google LLC
6
- //
7
- // Licensed under the Apache License, Version 2.0 (the "License");
8
- // you may not use this file except in compliance with the License.
9
- // You may obtain a copy of the License at
10
- //
11
- // http://www.apache.org/licenses/LICENSE-2.0
12
- //
13
- // Unless required by applicable law or agreed to in writing, software
14
- // distributed under the License is distributed on an "AS IS" BASIS,
15
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- // See the License for the specific language governing permissions and
17
- // limitations under the License.
18
- //
19
- import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
20
- import type { IBinaryWriter } from "@protobuf-ts/runtime";
21
- import { WireType } from "@protobuf-ts/runtime";
22
- import type { BinaryReadOptions } from "@protobuf-ts/runtime";
23
- import type { IBinaryReader } from "@protobuf-ts/runtime";
24
- import { UnknownFieldHandler } from "@protobuf-ts/runtime";
25
- import type { PartialMessage } from "@protobuf-ts/runtime";
26
- import { reflectionMergePartial } from "@protobuf-ts/runtime";
27
- import { MessageType } from "@protobuf-ts/runtime";
28
- import { Any } from "../protobuf/any";
29
- /**
30
- * Message that represents an arbitrary HTTP body. It should only be used for
31
- * payload formats that can't be represented as JSON, such as raw binary or
32
- * an HTML page.
33
- *
34
- *
35
- * This message can be used both in streaming and non-streaming API methods in
36
- * the request as well as the response.
37
- *
38
- * It can be used as a top-level request field, which is convenient if one
39
- * wants to extract parameters from either the URL or HTTP template into the
40
- * request fields and also want access to the raw HTTP body.
41
- *
42
- * Example:
43
- *
44
- * message GetResourceRequest {
45
- * // A unique request id.
46
- * string request_id = 1;
47
- *
48
- * // The raw HTTP body is bound to this field.
49
- * google.api.HttpBody http_body = 2;
50
- *
51
- * }
52
- *
53
- * service ResourceService {
54
- * rpc GetResource(GetResourceRequest)
55
- * returns (google.api.HttpBody);
56
- * rpc UpdateResource(google.api.HttpBody)
57
- * returns (google.protobuf.Empty);
58
- *
59
- * }
60
- *
61
- * Example with streaming methods:
62
- *
63
- * service CaldavService {
64
- * rpc GetCalendar(stream google.api.HttpBody)
65
- * returns (stream google.api.HttpBody);
66
- * rpc UpdateCalendar(stream google.api.HttpBody)
67
- * returns (stream google.api.HttpBody);
68
- *
69
- * }
70
- *
71
- * Use of this type only changes how the request and response bodies are
72
- * handled, all other features will continue to work unchanged.
73
- *
74
- * @generated from protobuf message google.api.HttpBody
75
- */
76
- export interface HttpBody {
77
- /**
78
- * The HTTP Content-Type header value specifying the content type of the body.
79
- *
80
- * @generated from protobuf field: string content_type = 1
81
- */
82
- contentType: string;
83
- /**
84
- * The HTTP request/response body as raw binary.
85
- *
86
- * @generated from protobuf field: bytes data = 2
87
- */
88
- data: Uint8Array;
89
- /**
90
- * Application specific response metadata. Must be set in the first response
91
- * for streaming APIs.
92
- *
93
- * @generated from protobuf field: repeated google.protobuf.Any extensions = 3
94
- */
95
- extensions: Any[];
96
- }
97
- // @generated message type with reflection information, may provide speed optimized methods
98
- class HttpBody$Type extends MessageType<HttpBody> {
99
- constructor() {
100
- super("google.api.HttpBody", [
101
- { no: 1, name: "content_type", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
102
- { no: 2, name: "data", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
103
- { no: 3, name: "extensions", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Any }
104
- ]);
105
- }
106
- create(value?: PartialMessage<HttpBody>): HttpBody {
107
- const message = globalThis.Object.create((this.messagePrototype!));
108
- message.contentType = "";
109
- message.data = new Uint8Array(0);
110
- message.extensions = [];
111
- if (value !== undefined)
112
- reflectionMergePartial<HttpBody>(this, message, value);
113
- return message;
114
- }
115
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: HttpBody): HttpBody {
116
- let message = target ?? this.create(), end = reader.pos + length;
117
- while (reader.pos < end) {
118
- let [fieldNo, wireType] = reader.tag();
119
- switch (fieldNo) {
120
- case /* string content_type */ 1:
121
- message.contentType = reader.string();
122
- break;
123
- case /* bytes data */ 2:
124
- message.data = reader.bytes();
125
- break;
126
- case /* repeated google.protobuf.Any extensions */ 3:
127
- message.extensions.push(Any.internalBinaryRead(reader, reader.uint32(), options));
128
- break;
129
- default:
130
- let u = options.readUnknownField;
131
- if (u === "throw")
132
- throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
133
- let d = reader.skip(wireType);
134
- if (u !== false)
135
- (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
136
- }
137
- }
138
- return message;
139
- }
140
- internalBinaryWrite(message: HttpBody, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
141
- /* string content_type = 1; */
142
- if (message.contentType !== "")
143
- writer.tag(1, WireType.LengthDelimited).string(message.contentType);
144
- /* bytes data = 2; */
145
- if (message.data.length)
146
- writer.tag(2, WireType.LengthDelimited).bytes(message.data);
147
- /* repeated google.protobuf.Any extensions = 3; */
148
- for (let i = 0; i < message.extensions.length; i++)
149
- Any.internalBinaryWrite(message.extensions[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();
150
- let u = options.writeUnknownFields;
151
- if (u !== false)
152
- (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
153
- return writer;
154
- }
155
- }
156
- /**
157
- * @generated MessageType for protobuf message google.api.HttpBody
158
- */
159
- export const HttpBody = new HttpBody$Type();
@@ -1,326 +0,0 @@
1
- // @generated by protobuf-ts 2.11.1 with parameter client_generic,generate_dependencies
2
- // @generated from protobuf file "google/protobuf/any.proto" (package "google.protobuf", syntax proto3)
3
- // tslint:disable
4
- //
5
- // Protocol Buffers - Google's data interchange format
6
- // Copyright 2008 Google Inc. All rights reserved.
7
- // https://developers.google.com/protocol-buffers/
8
- //
9
- // Redistribution and use in source and binary forms, with or without
10
- // modification, are permitted provided that the following conditions are
11
- // met:
12
- //
13
- // * Redistributions of source code must retain the above copyright
14
- // notice, this list of conditions and the following disclaimer.
15
- // * Redistributions in binary form must reproduce the above
16
- // copyright notice, this list of conditions and the following disclaimer
17
- // in the documentation and/or other materials provided with the
18
- // distribution.
19
- // * Neither the name of Google Inc. nor the names of its
20
- // contributors may be used to endorse or promote products derived from
21
- // this software without specific prior written permission.
22
- //
23
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
- //
35
- import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
36
- import type { IBinaryWriter } from "@protobuf-ts/runtime";
37
- import { WireType } from "@protobuf-ts/runtime";
38
- import type { IBinaryReader } from "@protobuf-ts/runtime";
39
- import { UnknownFieldHandler } from "@protobuf-ts/runtime";
40
- import type { PartialMessage } from "@protobuf-ts/runtime";
41
- import { reflectionMergePartial } from "@protobuf-ts/runtime";
42
- import { isJsonObject } from "@protobuf-ts/runtime";
43
- import { typeofJsonValue } from "@protobuf-ts/runtime";
44
- import type { JsonValue } from "@protobuf-ts/runtime";
45
- import { jsonWriteOptions } from "@protobuf-ts/runtime";
46
- import type { JsonReadOptions } from "@protobuf-ts/runtime";
47
- import type { JsonWriteOptions } from "@protobuf-ts/runtime";
48
- import type { BinaryReadOptions } from "@protobuf-ts/runtime";
49
- import type { IMessageType } from "@protobuf-ts/runtime";
50
- import { MessageType } from "@protobuf-ts/runtime";
51
- /**
52
- * `Any` contains an arbitrary serialized protocol buffer message along with a
53
- * URL that describes the type of the serialized message.
54
- *
55
- * Protobuf library provides support to pack/unpack Any values in the form
56
- * of utility functions or additional generated methods of the Any type.
57
- *
58
- * Example 1: Pack and unpack a message in C++.
59
- *
60
- * Foo foo = ...;
61
- * Any any;
62
- * any.PackFrom(foo);
63
- * ...
64
- * if (any.UnpackTo(&foo)) {
65
- * ...
66
- * }
67
- *
68
- * Example 2: Pack and unpack a message in Java.
69
- *
70
- * Foo foo = ...;
71
- * Any any = Any.pack(foo);
72
- * ...
73
- * if (any.is(Foo.class)) {
74
- * foo = any.unpack(Foo.class);
75
- * }
76
- * // or ...
77
- * if (any.isSameTypeAs(Foo.getDefaultInstance())) {
78
- * foo = any.unpack(Foo.getDefaultInstance());
79
- * }
80
- *
81
- * Example 3: Pack and unpack a message in Python.
82
- *
83
- * foo = Foo(...)
84
- * any = Any()
85
- * any.Pack(foo)
86
- * ...
87
- * if any.Is(Foo.DESCRIPTOR):
88
- * any.Unpack(foo)
89
- * ...
90
- *
91
- * Example 4: Pack and unpack a message in Go
92
- *
93
- * foo := &pb.Foo{...}
94
- * any, err := anypb.New(foo)
95
- * if err != nil {
96
- * ...
97
- * }
98
- * ...
99
- * foo := &pb.Foo{}
100
- * if err := any.UnmarshalTo(foo); err != nil {
101
- * ...
102
- * }
103
- *
104
- * The pack methods provided by protobuf library will by default use
105
- * 'type.googleapis.com/full.type.name' as the type URL and the unpack
106
- * methods only use the fully qualified type name after the last '/'
107
- * in the type URL, for example "foo.bar.com/x/y.z" will yield type
108
- * name "y.z".
109
- *
110
- * JSON
111
- * ====
112
- * The JSON representation of an `Any` value uses the regular
113
- * representation of the deserialized, embedded message, with an
114
- * additional field `@type` which contains the type URL. Example:
115
- *
116
- * package google.profile;
117
- * message Person {
118
- * string first_name = 1;
119
- * string last_name = 2;
120
- * }
121
- *
122
- * {
123
- * "@type": "type.googleapis.com/google.profile.Person",
124
- * "firstName": <string>,
125
- * "lastName": <string>
126
- * }
127
- *
128
- * If the embedded message type is well-known and has a custom JSON
129
- * representation, that representation will be embedded adding a field
130
- * `value` which holds the custom JSON in addition to the `@type`
131
- * field. Example (for message [google.protobuf.Duration][]):
132
- *
133
- * {
134
- * "@type": "type.googleapis.com/google.protobuf.Duration",
135
- * "value": "1.212s"
136
- * }
137
- *
138
- *
139
- * @generated from protobuf message google.protobuf.Any
140
- */
141
- export interface Any {
142
- /**
143
- * A URL/resource name that uniquely identifies the type of the serialized
144
- * protocol buffer message. This string must contain at least
145
- * one "/" character. The last segment of the URL's path must represent
146
- * the fully qualified name of the type (as in
147
- * `path/google.protobuf.Duration`). The name should be in a canonical form
148
- * (e.g., leading "." is not accepted).
149
- *
150
- * In practice, teams usually precompile into the binary all types that they
151
- * expect it to use in the context of Any. However, for URLs which use the
152
- * scheme `http`, `https`, or no scheme, one can optionally set up a type
153
- * server that maps type URLs to message definitions as follows:
154
- *
155
- * * If no scheme is provided, `https` is assumed.
156
- * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
157
- * value in binary format, or produce an error.
158
- * * Applications are allowed to cache lookup results based on the
159
- * URL, or have them precompiled into a binary to avoid any
160
- * lookup. Therefore, binary compatibility needs to be preserved
161
- * on changes to types. (Use versioned type names to manage
162
- * breaking changes.)
163
- *
164
- * Note: this functionality is not currently available in the official
165
- * protobuf release, and it is not used for type URLs beginning with
166
- * type.googleapis.com. As of May 2023, there are no widely used type server
167
- * implementations and no plans to implement one.
168
- *
169
- * Schemes other than `http`, `https` (or the empty scheme) might be
170
- * used with implementation specific semantics.
171
- *
172
- *
173
- * @generated from protobuf field: string type_url = 1
174
- */
175
- typeUrl: string;
176
- /**
177
- * Must be a valid serialized protocol buffer of the above specified type.
178
- *
179
- * @generated from protobuf field: bytes value = 2
180
- */
181
- value: Uint8Array;
182
- }
183
- // @generated message type with reflection information, may provide speed optimized methods
184
- class Any$Type extends MessageType<Any> {
185
- constructor() {
186
- super("google.protobuf.Any", [
187
- { no: 1, name: "type_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
188
- { no: 2, name: "value", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
189
- ]);
190
- }
191
- /**
192
- * Pack the message into a new `Any`.
193
- *
194
- * Uses 'type.googleapis.com/full.type.name' as the type URL.
195
- */
196
- pack<T extends object>(message: T, type: IMessageType<T>): Any {
197
- return {
198
- typeUrl: this.typeNameToUrl(type.typeName), value: type.toBinary(message),
199
- };
200
- }
201
- /**
202
- * Unpack the message from the `Any`.
203
- */
204
- unpack<T extends object>(any: Any, type: IMessageType<T>, options?: Partial<BinaryReadOptions>): T {
205
- if (!this.contains(any, type))
206
- throw new Error("Cannot unpack google.protobuf.Any with typeUrl '" + any.typeUrl + "' as " + type.typeName + ".");
207
- return type.fromBinary(any.value, options);
208
- }
209
- /**
210
- * Does the given `Any` contain a packed message of the given type?
211
- */
212
- contains(any: Any, type: IMessageType<any> | string): boolean {
213
- if (!any.typeUrl.length)
214
- return false;
215
- let wants = typeof type == "string" ? type : type.typeName;
216
- let has = this.typeUrlToName(any.typeUrl);
217
- return wants === has;
218
- }
219
- /**
220
- * Convert the message to canonical JSON value.
221
- *
222
- * You have to provide the `typeRegistry` option so that the
223
- * packed message can be converted to JSON.
224
- *
225
- * The `typeRegistry` option is also required to read
226
- * `google.protobuf.Any` from JSON format.
227
- */
228
- internalJsonWrite(any: Any, options: JsonWriteOptions): JsonValue {
229
- if (any.typeUrl === "")
230
- return {};
231
- let typeName = this.typeUrlToName(any.typeUrl);
232
- let opt = jsonWriteOptions(options);
233
- let type = opt.typeRegistry?.find(t => t.typeName === typeName);
234
- if (!type)
235
- throw new globalThis.Error("Unable to convert google.protobuf.Any with typeUrl '" + any.typeUrl + "' to JSON. The specified type " + typeName + " is not available in the type registry.");
236
- let value = type.fromBinary(any.value, { readUnknownField: false });
237
- let json = type.internalJsonWrite(value, opt);
238
- if (typeName.startsWith("google.protobuf.") || !isJsonObject(json))
239
- json = { value: json };
240
- json["@type"] = any.typeUrl;
241
- return json;
242
- }
243
- internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Any): Any {
244
- if (!isJsonObject(json))
245
- throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON " + typeofJsonValue(json) + ".");
246
- if (typeof json["@type"] != "string" || json["@type"] == "")
247
- return this.create();
248
- let typeName = this.typeUrlToName(json["@type"]);
249
- let type = options?.typeRegistry?.find(t => t.typeName == typeName);
250
- if (!type)
251
- throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON. The specified type " + typeName + " is not available in the type registry.");
252
- let value;
253
- if (typeName.startsWith("google.protobuf.") && json.hasOwnProperty("value"))
254
- value = type.fromJson(json["value"], options);
255
- else {
256
- let copy = Object.assign({}, json);
257
- delete copy["@type"];
258
- value = type.fromJson(copy, options);
259
- }
260
- if (target === undefined)
261
- target = this.create();
262
- target.typeUrl = json["@type"];
263
- target.value = type.toBinary(value);
264
- return target;
265
- }
266
- typeNameToUrl(name: string): string {
267
- if (!name.length)
268
- throw new Error("invalid type name: " + name);
269
- return "type.googleapis.com/" + name;
270
- }
271
- typeUrlToName(url: string): string {
272
- if (!url.length)
273
- throw new Error("invalid type url: " + url);
274
- let slash = url.lastIndexOf("/");
275
- let name = slash > 0 ? url.substring(slash + 1) : url;
276
- if (!name.length)
277
- throw new Error("invalid type url: " + url);
278
- return name;
279
- }
280
- create(value?: PartialMessage<Any>): Any {
281
- const message = globalThis.Object.create((this.messagePrototype!));
282
- message.typeUrl = "";
283
- message.value = new Uint8Array(0);
284
- if (value !== undefined)
285
- reflectionMergePartial<Any>(this, message, value);
286
- return message;
287
- }
288
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Any): Any {
289
- let message = target ?? this.create(), end = reader.pos + length;
290
- while (reader.pos < end) {
291
- let [fieldNo, wireType] = reader.tag();
292
- switch (fieldNo) {
293
- case /* string type_url */ 1:
294
- message.typeUrl = reader.string();
295
- break;
296
- case /* bytes value */ 2:
297
- message.value = reader.bytes();
298
- break;
299
- default:
300
- let u = options.readUnknownField;
301
- if (u === "throw")
302
- throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
303
- let d = reader.skip(wireType);
304
- if (u !== false)
305
- (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
306
- }
307
- }
308
- return message;
309
- }
310
- internalBinaryWrite(message: Any, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
311
- /* string type_url = 1; */
312
- if (message.typeUrl !== "")
313
- writer.tag(1, WireType.LengthDelimited).string(message.typeUrl);
314
- /* bytes value = 2; */
315
- if (message.value.length)
316
- writer.tag(2, WireType.LengthDelimited).bytes(message.value);
317
- let u = options.writeUnknownFields;
318
- if (u !== false)
319
- (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
320
- return writer;
321
- }
322
- }
323
- /**
324
- * @generated MessageType for protobuf message google.protobuf.Any
325
- */
326
- export const Any = new Any$Type();