corba.js 0.1.7 → 0.1.8

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 (128) hide show
  1. package/README.md +3 -1
  2. package/lib/idl/idl.cjs +3771 -2909
  3. package/lib/idl/idl.cjs.map +1 -1
  4. package/m13-es-transformer.cjs +190 -0
  5. package/package.json +33 -31
  6. package/lib/idl/src/idl/idl-lexer.d.ts +0 -19
  7. package/lib/idl/src/idl/idl-node.d.ts +0 -102
  8. package/lib/idl/src/idl/idl-parser.d.ts +0 -3
  9. package/lib/idl/src/idl/idl.d.ts +0 -1
  10. package/lib/idl/src/idl/util.d.ts +0 -25
  11. package/lib/idl/src/idl/write-interface.d.ts +0 -2
  12. package/lib/idl/src/idl/write-skeleton.d.ts +0 -2
  13. package/lib/idl/src/idl/write-stub.d.ts +0 -2
  14. package/lib/idl/src/idl/write-value.d.ts +0 -2
  15. package/lib/idl/src/idl/write-valueimpl.d.ts +0 -2
  16. package/lib/idl/src/idl/write-valuetype.d.ts +0 -2
  17. package/lib/idl/src/index.d.ts +0 -5
  18. package/lib/idl/src/net/browser.d.ts +0 -7
  19. package/lib/idl/src/net/index.d.ts +0 -3
  20. package/lib/idl/src/net/tcp.d.ts +0 -11
  21. package/lib/idl/src/net/tls.d.ts +0 -24
  22. package/lib/idl/src/net/ws.d.ts +0 -42
  23. package/lib/idl/src/orb/asn1.d.ts +0 -48
  24. package/lib/idl/src/orb/connection.d.ts +0 -24
  25. package/lib/idl/src/orb/giop.d.ts +0 -276
  26. package/lib/idl/src/orb/index.d.ts +0 -3
  27. package/lib/idl/src/orb/ior.d.ts +0 -89
  28. package/lib/idl/src/orb/orb.d.ts +0 -143
  29. package/lib/idl/src/orb/protocol.d.ts +0 -6
  30. package/lib/idl/src/orb/uint8map.d.ts +0 -14
  31. package/lib/idl/src/orb/url.d.ts +0 -55
  32. package/lib/idl/test/access.spec.d.ts +0 -1
  33. package/lib/idl/test/attribute.spec.d.ts +0 -1
  34. package/lib/idl/test/basics.spec.d.ts +0 -1
  35. package/lib/idl/test/disconnect.spec.d.ts +0 -1
  36. package/lib/idl/test/eventtarget.spec.d.ts +0 -1
  37. package/lib/idl/test/fake.d.ts +0 -31
  38. package/lib/idl/test/giop.spec.d.ts +0 -1
  39. package/lib/idl/test/idl/idl.spec.d.ts +0 -1
  40. package/lib/idl/test/idl_module.spec.d.ts +0 -1
  41. package/lib/idl/test/initialreferences.spec.d.ts +0 -1
  42. package/lib/idl/test/net/tls.spec.d.ts +0 -1
  43. package/lib/idl/test/net/ws.spec.d.ts +0 -1
  44. package/lib/idl/test/net/wss.spec.d.ts +0 -1
  45. package/lib/idl/test/object_by_reference.spec.d.ts +0 -1
  46. package/lib/idl/test/orb/asn1.spec.d.ts +0 -1
  47. package/lib/idl/test/orb/url.spec.d.ts +0 -1
  48. package/lib/idl/test/stub.spec.d.ts +0 -1
  49. package/lib/idl/test/util.d.ts +0 -5
  50. package/lib/idl/test/valuetype.spec.d.ts +0 -1
  51. package/lib/src/idl/idl-lexer.d.ts +0 -19
  52. package/lib/src/idl/idl-lexer.js +0 -234
  53. package/lib/src/idl/idl-lexer.js.map +0 -1
  54. package/lib/src/idl/idl-node.d.ts +0 -102
  55. package/lib/src/idl/idl-node.js +0 -214
  56. package/lib/src/idl/idl-node.js.map +0 -1
  57. package/lib/src/idl/idl-parser.d.ts +0 -3
  58. package/lib/src/idl/idl-parser.js +0 -1199
  59. package/lib/src/idl/idl-parser.js.map +0 -1
  60. package/lib/src/idl/idl.d.ts +0 -1
  61. package/lib/src/idl/idl.js +0 -180
  62. package/lib/src/idl/idl.js.map +0 -1
  63. package/lib/src/idl/util.d.ts +0 -25
  64. package/lib/src/idl/util.js +0 -248
  65. package/lib/src/idl/util.js.map +0 -1
  66. package/lib/src/idl/write-interface.d.ts +0 -2
  67. package/lib/src/idl/write-interface.js +0 -212
  68. package/lib/src/idl/write-interface.js.map +0 -1
  69. package/lib/src/idl/write-skeleton.d.ts +0 -2
  70. package/lib/src/idl/write-skeleton.js +0 -116
  71. package/lib/src/idl/write-skeleton.js.map +0 -1
  72. package/lib/src/idl/write-stub.d.ts +0 -2
  73. package/lib/src/idl/write-stub.js +0 -116
  74. package/lib/src/idl/write-stub.js.map +0 -1
  75. package/lib/src/idl/write-value.d.ts +0 -2
  76. package/lib/src/idl/write-value.js +0 -206
  77. package/lib/src/idl/write-value.js.map +0 -1
  78. package/lib/src/idl/write-valueimpl.d.ts +0 -2
  79. package/lib/src/idl/write-valueimpl.js +0 -158
  80. package/lib/src/idl/write-valueimpl.js.map +0 -1
  81. package/lib/src/idl/write-valuetype.d.ts +0 -2
  82. package/lib/src/idl/write-valuetype.js +0 -98
  83. package/lib/src/idl/write-valuetype.js.map +0 -1
  84. package/lib/src/index.d.ts +0 -5
  85. package/lib/src/index.js +0 -6
  86. package/lib/src/index.js.map +0 -1
  87. package/lib/src/net/browser.d.ts +0 -7
  88. package/lib/src/net/browser.js +0 -55
  89. package/lib/src/net/browser.js.map +0 -1
  90. package/lib/src/net/index.d.ts +0 -3
  91. package/lib/src/net/index.js +0 -4
  92. package/lib/src/net/index.js.map +0 -1
  93. package/lib/src/net/tcp.d.ts +0 -11
  94. package/lib/src/net/tcp.js +0 -66
  95. package/lib/src/net/tcp.js.map +0 -1
  96. package/lib/src/net/tls.d.ts +0 -24
  97. package/lib/src/net/tls.js +0 -69
  98. package/lib/src/net/tls.js.map +0 -1
  99. package/lib/src/net/ws.d.ts +0 -42
  100. package/lib/src/net/ws.js +0 -158
  101. package/lib/src/net/ws.js.map +0 -1
  102. package/lib/src/orb/asn1.d.ts +0 -48
  103. package/lib/src/orb/asn1.js +0 -60
  104. package/lib/src/orb/asn1.js.map +0 -1
  105. package/lib/src/orb/connection.d.ts +0 -24
  106. package/lib/src/orb/connection.js +0 -19
  107. package/lib/src/orb/connection.js.map +0 -1
  108. package/lib/src/orb/giop.d.ts +0 -276
  109. package/lib/src/orb/giop.js +0 -1204
  110. package/lib/src/orb/giop.js.map +0 -1
  111. package/lib/src/orb/index.d.ts +0 -3
  112. package/lib/src/orb/index.js +0 -4
  113. package/lib/src/orb/index.js.map +0 -1
  114. package/lib/src/orb/ior.d.ts +0 -89
  115. package/lib/src/orb/ior.js +0 -110
  116. package/lib/src/orb/ior.js.map +0 -1
  117. package/lib/src/orb/orb.d.ts +0 -143
  118. package/lib/src/orb/orb.js +0 -693
  119. package/lib/src/orb/orb.js.map +0 -1
  120. package/lib/src/orb/protocol.d.ts +0 -6
  121. package/lib/src/orb/protocol.js +0 -2
  122. package/lib/src/orb/protocol.js.map +0 -1
  123. package/lib/src/orb/uint8map.d.ts +0 -14
  124. package/lib/src/orb/uint8map.js +0 -48
  125. package/lib/src/orb/uint8map.js.map +0 -1
  126. package/lib/src/orb/url.d.ts +0 -55
  127. package/lib/src/orb/url.js +0 -252
  128. package/lib/src/orb/url.js.map +0 -1
@@ -1,1204 +0,0 @@
1
- import { ORB, Stub, Skeleton } from "./orb.js";
2
- import { IOR } from "./ior.js";
3
- import { ASN1Tag, ASN1Encoding, ASN1Class, ASN1UniversalTag } from "./asn1.js";
4
- import { CompletionStatus, OBJECT_ADAPTER } from "./orb.js";
5
- export var MessageType;
6
- (function (MessageType) {
7
- MessageType[MessageType["REQUEST"] = 0] = "REQUEST";
8
- MessageType[MessageType["REPLY"] = 1] = "REPLY";
9
- MessageType[MessageType["CANCEL_REQUEST"] = 2] = "CANCEL_REQUEST";
10
- MessageType[MessageType["LOCATE_REQUEST"] = 3] = "LOCATE_REQUEST";
11
- MessageType[MessageType["LOCATE_REPLY"] = 4] = "LOCATE_REPLY";
12
- MessageType[MessageType["CLOSE_CONNECTION"] = 5] = "CLOSE_CONNECTION";
13
- MessageType[MessageType["MESSAGE_ERROR"] = 6] = "MESSAGE_ERROR";
14
- MessageType[MessageType["FRAGMENT"] = 7] = "FRAGMENT";
15
- })(MessageType || (MessageType = {}));
16
- export var TagType;
17
- (function (TagType) {
18
- TagType[TagType["ORB_TYPE"] = 0] = "ORB_TYPE";
19
- TagType[TagType["CODE_SETS"] = 1] = "CODE_SETS";
20
- TagType[TagType["POLICIES"] = 2] = "POLICIES";
21
- TagType[TagType["ALTERNATE_IIOP_ADDRESS"] = 3] = "ALTERNATE_IIOP_ADDRESS";
22
- TagType[TagType["ASSOCIATION_OPTIONS"] = 13] = "ASSOCIATION_OPTIONS";
23
- TagType[TagType["SEC_NAME"] = 14] = "SEC_NAME";
24
- TagType[TagType["SPKM_1_SEC_MECH"] = 15] = "SPKM_1_SEC_MECH";
25
- TagType[TagType["SPKM_2_SEC_MECH"] = 16] = "SPKM_2_SEC_MECH";
26
- TagType[TagType["KerberosV5_SEC_MECH"] = 17] = "KerberosV5_SEC_MECH";
27
- TagType[TagType["CSI_ECMA_Secret_SEC_MECH"] = 18] = "CSI_ECMA_Secret_SEC_MECH";
28
- TagType[TagType["CSI_ECMA_Hybrid_SEC_MECH"] = 19] = "CSI_ECMA_Hybrid_SEC_MECH";
29
- TagType[TagType["CSI_ECMA_Public_SEC_MECH"] = 21] = "CSI_ECMA_Public_SEC_MECH";
30
- TagType[TagType["GENERIC_SEC_MECH"] = 22] = "GENERIC_SEC_MECH";
31
- TagType[TagType["CSI_SEC_MECH_LIST"] = 33] = "CSI_SEC_MECH_LIST";
32
- TagType[TagType["SSL_SEC_TRANS"] = 10] = "SSL_SEC_TRANS";
33
- TagType[TagType["TLS_SEC_TRANS"] = 36] = "TLS_SEC_TRANS";
34
- TagType[TagType["IIOP_SEC_TRANS"] = 43] = "IIOP_SEC_TRANS";
35
- TagType[TagType["INET_SEC_TRANS"] = 123] = "INET_SEC_TRANS";
36
- TagType[TagType["SECIOP_SEC_TRANS"] = 35] = "SECIOP_SEC_TRANS";
37
- TagType[TagType["FIREWALL_TRANS"] = 13] = "FIREWALL_TRANS";
38
- TagType[TagType["PASSTHRU_TRANS"] = 41] = "PASSTHRU_TRANS";
39
- TagType[TagType["FIREWALL_PATH"] = 42] = "FIREWALL_PATH";
40
- TagType[TagType["SCCP_CONTACT_INFO"] = 14] = "SCCP_CONTACT_INFO";
41
- TagType[TagType["JAVA_CODEBASE"] = 15] = "JAVA_CODEBASE";
42
- TagType[TagType["TRANSACTION_POLICY"] = 16] = "TRANSACTION_POLICY";
43
- TagType[TagType["MESSAGE_ROUTERS"] = 30] = "MESSAGE_ROUTERS";
44
- TagType[TagType["OTS_POLICY"] = 31] = "OTS_POLICY";
45
- TagType[TagType["INV_POLICY"] = 32] = "INV_POLICY";
46
- TagType[TagType["TAG_NULL_TAG"] = 34] = "TAG_NULL_TAG";
47
- TagType[TagType["ACTIVITY_POLICY"] = 37] = "ACTIVITY_POLICY";
48
- TagType[TagType["RMI_CUSTOM_MAX_STREAM_FORMAT"] = 38] = "RMI_CUSTOM_MAX_STREAM_FORMAT";
49
- TagType[TagType["GROUP"] = 39] = "GROUP";
50
- TagType[TagType["GROUP_IIOP"] = 40] = "GROUP_IIOP";
51
- })(TagType || (TagType = {}));
52
- export var ServiceId;
53
- (function (ServiceId) {
54
- ServiceId[ServiceId["TransactionService"] = 0] = "TransactionService";
55
- ServiceId[ServiceId["CodeSets"] = 1] = "CodeSets";
56
- ServiceId[ServiceId["ChainBypassCheck"] = 2] = "ChainBypassCheck";
57
- ServiceId[ServiceId["ChainBypassInfo"] = 3] = "ChainBypassInfo";
58
- ServiceId[ServiceId["LogicalThreadId"] = 4] = "LogicalThreadId";
59
- ServiceId[ServiceId["BI_DIR_IIOP"] = 5] = "BI_DIR_IIOP";
60
- ServiceId[ServiceId["SendingContextRunTime"] = 6] = "SendingContextRunTime";
61
- ServiceId[ServiceId["INVOCATION_POLICIES"] = 7] = "INVOCATION_POLICIES";
62
- ServiceId[ServiceId["FORWARDED_IDENTITY"] = 8] = "FORWARDED_IDENTITY";
63
- ServiceId[ServiceId["UnknownExceptionInfo"] = 9] = "UnknownExceptionInfo";
64
- ServiceId[ServiceId["RTCorbaPriority"] = 10] = "RTCorbaPriority";
65
- ServiceId[ServiceId["RTCorbaPriorityRange"] = 11] = "RTCorbaPriorityRange";
66
- ServiceId[ServiceId["FT_GROUP_VERSION"] = 12] = "FT_GROUP_VERSION";
67
- ServiceId[ServiceId["FT_REQUEST"] = 13] = "FT_REQUEST";
68
- ServiceId[ServiceId["ExceptionDetailMessage"] = 14] = "ExceptionDetailMessage";
69
- ServiceId[ServiceId["SecurityAttributeService"] = 15] = "SecurityAttributeService";
70
- ServiceId[ServiceId["ActivityService"] = 16] = "ActivityService";
71
- ServiceId[ServiceId["RMICustomMaxStreamFormat"] = 17] = "RMICustomMaxStreamFormat";
72
- ServiceId[ServiceId["ACCESS_SESSION_ID"] = 18] = "ACCESS_SESSION_ID";
73
- ServiceId[ServiceId["SERVICE_SESSION_ID"] = 19] = "SERVICE_SESSION_ID";
74
- ServiceId[ServiceId["FIREWALL_PATH"] = 20] = "FIREWALL_PATH";
75
- ServiceId[ServiceId["FIREWALL_PATH_RESP"] = 21] = "FIREWALL_PATH_RESP";
76
- ServiceId[ServiceId["SERVICE_PADDING_CONTEXT"] = 1245790977] = "SERVICE_PADDING_CONTEXT";
77
- })(ServiceId || (ServiceId = {}));
78
- var SASType;
79
- (function (SASType) {
80
- SASType[SASType["EstablishContext"] = 0] = "EstablishContext";
81
- SASType[SASType["CompleteEstablishContext"] = 1] = "CompleteEstablishContext";
82
- SASType[SASType["ContextError"] = 2] = "ContextError";
83
- SASType[SASType["MessageInContext"] = 3] = "MessageInContext";
84
- })(SASType || (SASType = {}));
85
- export class AuthorizationToken {
86
- constructor(type, content) {
87
- this.type = type;
88
- this.content = content;
89
- }
90
- }
91
- export class GSSUPInitialContextToken {
92
- constructor(user, password, target_name) {
93
- this.user = user;
94
- this.password = password;
95
- this.target_name = target_name;
96
- }
97
- }
98
- export class SecurityContext {
99
- }
100
- export class EstablishContext extends SecurityContext {
101
- constructor() {
102
- super(...arguments);
103
- this.clientContextId = 0n;
104
- this.authorizationToken = [];
105
- }
106
- decode(decoder) {
107
- this.clientContextId = decoder.ulonglong();
108
- if (decoder.encapStack[decoder.encapStack.length - 1].nextOffset - decoder.offset < 4) {
109
- return;
110
- }
111
- const authorizationTokenCount = decoder.ulong();
112
- for (let i = 0; i < authorizationTokenCount; ++i) {
113
- const type = decoder.ulong();
114
- const content = decoder.blob();
115
- this.authorizationToken.push(new AuthorizationToken(type, content));
116
- }
117
- const tokenType = decoder.ulong();
118
- switch (tokenType) {
119
- case IdentityTokenType.Absent:
120
- {
121
- const absent = decoder.bool();
122
- }
123
- break;
124
- default: {
125
- }
126
- }
127
- const blobLength = decoder.ulong();
128
- if (decoder.asn1expect(ASN1Class.APPLICATION, 0, ASN1Encoding.CONSTRUCTED) === undefined)
129
- return;
130
- if (!decoder.asn1expectOID([2, 23, 130, 1, 1, 1]))
131
- return;
132
- const cdr = new GIOPDecoder(decoder.buffer.slice(decoder.offset));
133
- cdr.endian();
134
- const te = new TextDecoder();
135
- this.clientAuthenticationToken = new GSSUPInitialContextToken(te.decode(cdr.blob()), te.decode(cdr.blob()), te.decode(cdr.blob()));
136
- }
137
- }
138
- export class ContextError extends SecurityContext {
139
- constructor() {
140
- super(...arguments);
141
- this.clientContextId = 0n;
142
- this.majorStatus = 1;
143
- this.minorStatus = 1;
144
- }
145
- }
146
- export class CompleteEstablishContext extends SecurityContext {
147
- constructor() {
148
- super(...arguments);
149
- this.clientContextId = 0n;
150
- }
151
- }
152
- export var AuthenticationStatus;
153
- (function (AuthenticationStatus) {
154
- AuthenticationStatus[AuthenticationStatus["SUCCESS"] = 0] = "SUCCESS";
155
- AuthenticationStatus[AuthenticationStatus["ERROR_UNSPECIFIED"] = 1] = "ERROR_UNSPECIFIED";
156
- AuthenticationStatus[AuthenticationStatus["ERROR_BADPASSWORD"] = 2] = "ERROR_BADPASSWORD";
157
- AuthenticationStatus[AuthenticationStatus["ERROR_NOUSER"] = 3] = "ERROR_NOUSER";
158
- AuthenticationStatus[AuthenticationStatus["ERROR_BAD_TARGET"] = 4] = "ERROR_BAD_TARGET";
159
- })(AuthenticationStatus || (AuthenticationStatus = {}));
160
- var IdentityTokenType;
161
- (function (IdentityTokenType) {
162
- IdentityTokenType[IdentityTokenType["Absent"] = 0] = "Absent";
163
- IdentityTokenType[IdentityTokenType["Anonymous"] = 1] = "Anonymous";
164
- IdentityTokenType[IdentityTokenType["PrincipalName"] = 2] = "PrincipalName";
165
- IdentityTokenType[IdentityTokenType["X509CertChain"] = 4] = "X509CertChain";
166
- IdentityTokenType[IdentityTokenType["DistinguishedName"] = 8] = "DistinguishedName";
167
- })(IdentityTokenType || (IdentityTokenType = {}));
168
- export var AddressingDisposition;
169
- (function (AddressingDisposition) {
170
- AddressingDisposition[AddressingDisposition["KeyAddr"] = 0] = "KeyAddr";
171
- AddressingDisposition[AddressingDisposition["ProfileAddr"] = 1] = "ProfileAddr";
172
- AddressingDisposition[AddressingDisposition["ReferenceAddr"] = 2] = "ReferenceAddr";
173
- })(AddressingDisposition || (AddressingDisposition = {}));
174
- export var ReplyStatus;
175
- (function (ReplyStatus) {
176
- ReplyStatus[ReplyStatus["NO_EXCEPTION"] = 0] = "NO_EXCEPTION";
177
- ReplyStatus[ReplyStatus["USER_EXCEPTION"] = 1] = "USER_EXCEPTION";
178
- ReplyStatus[ReplyStatus["SYSTEM_EXCEPTION"] = 2] = "SYSTEM_EXCEPTION";
179
- ReplyStatus[ReplyStatus["LOCATION_FORWARD"] = 3] = "LOCATION_FORWARD";
180
- ReplyStatus[ReplyStatus["LOCATION_FORWARD_PERM"] = 4] = "LOCATION_FORWARD_PERM";
181
- ReplyStatus[ReplyStatus["NEEDS_ADDRESSING_MODE"] = 5] = "NEEDS_ADDRESSING_MODE";
182
- })(ReplyStatus || (ReplyStatus = {}));
183
- export class BidirectionalIIOPServiceContext {
184
- }
185
- export class RequestData {
186
- }
187
- class ReplyData {
188
- }
189
- class LocateRequest {
190
- }
191
- export var LocateStatusType;
192
- (function (LocateStatusType) {
193
- LocateStatusType[LocateStatusType["UNKNOWN_OBJECT"] = 0] = "UNKNOWN_OBJECT";
194
- LocateStatusType[LocateStatusType["OBJECT_HERE"] = 1] = "OBJECT_HERE";
195
- LocateStatusType[LocateStatusType["OBJECT_FORWARD"] = 2] = "OBJECT_FORWARD";
196
- LocateStatusType[LocateStatusType["OBJECT_FORWARD_PERM"] = 3] = "OBJECT_FORWARD_PERM";
197
- LocateStatusType[LocateStatusType["LOC_SYSTEM_EXCEPTION"] = 4] = "LOC_SYSTEM_EXCEPTION";
198
- LocateStatusType[LocateStatusType["LOC_NEEDS_ADDRESSING_MODE"] = 5] = "LOC_NEEDS_ADDRESSING_MODE";
199
- })(LocateStatusType || (LocateStatusType = {}));
200
- class LocateReply {
201
- }
202
- export class ObjectReference {
203
- toString() {
204
- return `ObjectReference(oid=${this.oid}, host=${this.host}, port=${this.port}, objectKey=${this.objectKey}')`;
205
- }
206
- }
207
- export class GIOPBase {
208
- constructor(connection) {
209
- this.offset = 0;
210
- this.majorVersion = 1;
211
- this.minorVersion = 2;
212
- this.connection = connection;
213
- }
214
- }
215
- GIOPBase.ENDIAN_BIG = 0;
216
- GIOPBase.ENDIAN_LITTLE = 1;
217
- GIOPBase.FLOAT64_MAX = 1.7976931348623157e+308;
218
- GIOPBase.FLOAT64_MIN = 2.2250738585072014e-308;
219
- GIOPBase.TWO_TO_20 = 1048576;
220
- GIOPBase.TWO_TO_32 = 4294967296;
221
- GIOPBase.TWO_TO_52 = 4503599627370496;
222
- export class GIOPEncoder extends GIOPBase {
223
- constructor(connection) {
224
- super(connection);
225
- this.buffer = new ArrayBuffer(0xFFFF);
226
- this.data = new DataView(this.buffer);
227
- this.bytes = new Uint8Array(this.buffer);
228
- this.repositoryIds = new Map();
229
- this.objectPosition = new Map();
230
- this.sizeStack = [];
231
- if (GIOPEncoder.littleEndian === undefined) {
232
- const buffer = new ArrayBuffer(2);
233
- new Int16Array(buffer)[0] = 0x1234;
234
- GIOPEncoder.littleEndian = new DataView(buffer).getUint8(0) === 0x34;
235
- }
236
- }
237
- get buf() {
238
- return this.buffer;
239
- }
240
- reserveSize() {
241
- this.alignAndReserve(4);
242
- this.offset += 4;
243
- this.sizeStack.push(this.offset);
244
- }
245
- fillinSize() {
246
- const currrentOffset = this.offset;
247
- const savedOffset = this.sizeStack.pop();
248
- if (savedOffset === undefined)
249
- throw Error(`internal error: fillinSize() misses reserveSize()`);
250
- this.offset = savedOffset - 4;
251
- const size = currrentOffset - savedOffset;
252
- this.ulong(size);
253
- this.offset = currrentOffset;
254
- }
255
- beginEncapsulation(type) {
256
- this.ulong(type);
257
- this.reserveSize();
258
- this.endian();
259
- }
260
- endEncapsulation() {
261
- this.fillinSize();
262
- }
263
- skipGIOPHeader() {
264
- this.offset = 10;
265
- }
266
- setGIOPHeader(type) {
267
- this.data.setUint32(0, 0x47494f50);
268
- this.data.setUint8(4, this.majorVersion);
269
- this.data.setUint8(5, this.minorVersion);
270
- this.data.setUint8(6, GIOPEncoder.littleEndian ? GIOPBase.ENDIAN_LITTLE : GIOPBase.ENDIAN_BIG);
271
- this.data.setUint8(7, type);
272
- this.data.setUint32(8, this.offset - 12, GIOPEncoder.littleEndian);
273
- }
274
- encodeRequest(objectKey, operation, requestId = 1, responseExpected) {
275
- this.skipGIOPHeader();
276
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
277
- this.serviceContext();
278
- }
279
- this.ulong(requestId);
280
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
281
- this.octet(responseExpected ? 1 : 0);
282
- }
283
- else {
284
- this.octet(responseExpected ? 3 : 0);
285
- }
286
- this.offset += 3;
287
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
288
- this.blob(objectKey);
289
- }
290
- else {
291
- this.ushort(AddressingDisposition.KeyAddr);
292
- this.blob(objectKey);
293
- }
294
- this.string(operation);
295
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
296
- this.ulong(0);
297
- }
298
- else {
299
- this.serviceContext();
300
- this.alignAndReserve(8);
301
- }
302
- }
303
- encodeReply(requestId, replyStatus = ReplyStatus.NO_EXCEPTION) {
304
- this.skipGIOPHeader();
305
- if (this.majorVersion == 1 && this.minorVersion < 2) {
306
- this.ulong(0);
307
- }
308
- this.ulong(requestId);
309
- this.ulong(replyStatus);
310
- if (this.majorVersion == 1 && this.minorVersion >= 2) {
311
- this.ulong(0);
312
- }
313
- }
314
- encodeLocateReply(requestId, status) {
315
- this.skipGIOPHeader();
316
- this.ulong(requestId);
317
- this.ulong(status);
318
- }
319
- serviceContext() {
320
- if (!this.connection) {
321
- this.ulong(0);
322
- return;
323
- }
324
- let count = 1;
325
- let initialToken;
326
- if (this.connection.orb.outgoingAuthenticator) {
327
- initialToken = this.connection.orb.outgoingAuthenticator(this.connection);
328
- if (initialToken) {
329
- ++count;
330
- }
331
- }
332
- this.ulong(count);
333
- this.beginEncapsulation(ServiceId.BI_DIR_IIOP);
334
- this.ulong(1);
335
- this.string(this.connection.localAddress);
336
- this.ushort(this.connection.localPort);
337
- this.endEncapsulation();
338
- if (initialToken) {
339
- this.establishSecurityContext(initialToken);
340
- }
341
- }
342
- establishSecurityContext(initialToken) {
343
- this.beginEncapsulation(ServiceId.SecurityAttributeService);
344
- this.ulong(SASType.EstablishContext);
345
- this.ulonglong(1n);
346
- this.ulong(0);
347
- this.ulong(IdentityTokenType.Absent);
348
- this.bool(true);
349
- this.reserveSize();
350
- this.asn1tag(ASN1Class.APPLICATION, 0, ASN1Encoding.CONSTRUCTED, (encoder) => {
351
- encoder.asn1tag(ASN1Class.UNIVERSAL, ASN1UniversalTag.OID, ASN1Encoding.PRIMITIVE, (encoder) => {
352
- encoder.asn1oid([2, 23, 130, 1, 1, 1]);
353
- });
354
- encoder.endian();
355
- const te = new TextEncoder();
356
- encoder.blob(te.encode(initialToken.user));
357
- encoder.blob(te.encode(initialToken.password));
358
- encoder.blob(te.encode(initialToken.target_name));
359
- });
360
- this.fillinSize();
361
- this.endEncapsulation();
362
- }
363
- setReplyHeader(requestId, replyStatus = ReplyStatus.NO_EXCEPTION) {
364
- this.skipGIOPHeader();
365
- this.encodeReply(requestId, replyStatus);
366
- }
367
- skipReplyHeader() {
368
- this.offset = 24;
369
- }
370
- repositoryId(name) {
371
- const id = `IDL:${name}:1.0`;
372
- const position = this.repositoryIds.get(id);
373
- if (position === undefined) {
374
- this.ulong(0x7fffff02);
375
- this.repositoryIds.set(id, this.offset);
376
- this.string(id);
377
- }
378
- else {
379
- this.ulong(0x7fffff02);
380
- this.ulong(0xffffffff);
381
- this.long(position - this.offset);
382
- }
383
- }
384
- reference(object) {
385
- const className = object.constructor._idlClassName();
386
- const reference = new ObjectReference();
387
- reference.host = this.connection.localAddress;
388
- reference.port = this.connection.localPort;
389
- reference.oid = `IDL:${className}:1.0`;
390
- reference.objectKey = object.id;
391
- this.string(reference.oid);
392
- this.ulong(1);
393
- this.ulong(IOR.TAG.IOR.INTERNET_IOP);
394
- this.reserveSize();
395
- this.endian();
396
- this.octet(this.majorVersion);
397
- this.octet(this.minorVersion);
398
- this.string(reference.host);
399
- this.short(reference.port);
400
- this.blob(reference.objectKey);
401
- if (this.majorVersion != 1 || this.minorVersion != 0) {
402
- this.ulong(1);
403
- this.beginEncapsulation(0);
404
- this.ulong(0x4d313300);
405
- this.endEncapsulation();
406
- }
407
- this.fillinSize();
408
- }
409
- value(object) {
410
- this.object(object);
411
- }
412
- object(object) {
413
- if (object === undefined) {
414
- this.ulong(0);
415
- return;
416
- }
417
- if (object instanceof Stub) {
418
- throw Error("ORB: can not serialize Stub yet");
419
- }
420
- if (object instanceof Skeleton) {
421
- if (this.connection === undefined) {
422
- throw Error("GIOPEncoder has no connection defined. Can not add object to ACL.");
423
- }
424
- this.connection.orb.aclAdd(object);
425
- this.reference(object);
426
- return;
427
- }
428
- const position = this.objectPosition.get(object);
429
- if (position !== undefined) {
430
- this.ulong(0xffffffff);
431
- this.long(position - this.offset);
432
- return;
433
- }
434
- let prototype = Object.getPrototypeOf(object);
435
- let valueTypeInformation;
436
- while (prototype !== null) {
437
- valueTypeInformation = ORB.valueTypeByPrototype.get(prototype);
438
- if (valueTypeInformation !== undefined)
439
- break;
440
- prototype = Object.getPrototypeOf(prototype);
441
- }
442
- if (valueTypeInformation === undefined) {
443
- throw Error(`ORB: can not serialize object of unregistered valuetype ${object.constructor.name}`);
444
- }
445
- if (valueTypeInformation?.construct.name !== object.constructor.name) {
446
- throw Error(`ORB: No value type registered for class ${object.constructor.name}. Best match was class ${valueTypeInformation?.construct.name}.`);
447
- }
448
- this.alignAndReserve(4);
449
- this.objectPosition.set(object, this.offset);
450
- this.repositoryId(valueTypeInformation.name);
451
- valueTypeInformation.encode(this, object);
452
- }
453
- endian() {
454
- this.octet(GIOPEncoder.littleEndian ? GIOPBase.ENDIAN_LITTLE : GIOPBase.ENDIAN_BIG);
455
- }
456
- reserveOne() {
457
- if (this.buffer.byteLength <= this.offset + 1) {
458
- const bufferNew = new ArrayBuffer(this.buffer.byteLength * 2);
459
- new Uint8Array(bufferNew).set(new Uint8Array(this.buffer));
460
- this.buffer = bufferNew;
461
- this.data = new DataView(this.buffer);
462
- this.bytes = new Uint8Array(this.buffer);
463
- }
464
- }
465
- alignAndReserve(align) {
466
- const inversePadding = this.offset % align;
467
- if (inversePadding !== 0)
468
- this.offset += align - inversePadding;
469
- if (this.buffer.byteLength <= this.offset + align) {
470
- const bufferNew = new ArrayBuffer(this.buffer.byteLength * 2);
471
- new Uint8Array(bufferNew).set(new Uint8Array(this.buffer));
472
- this.buffer = bufferNew;
473
- this.data = new DataView(this.buffer);
474
- this.bytes = new Uint8Array(this.buffer);
475
- }
476
- }
477
- alignAndReserveVarying(align, room) {
478
- const inversePadding = this.offset % align;
479
- if (inversePadding !== 0)
480
- this.offset += align - inversePadding;
481
- if (this.buffer.byteLength <= this.offset + room) {
482
- let newLength = this.buffer.byteLength * 2;
483
- while (newLength <= this.offset + room) {
484
- newLength *= 2;
485
- }
486
- const bufferNew = new ArrayBuffer(newLength);
487
- new Uint8Array(bufferNew).set(new Uint8Array(this.buffer));
488
- this.buffer = bufferNew;
489
- this.data = new DataView(this.buffer);
490
- this.bytes = new Uint8Array(this.buffer);
491
- }
492
- }
493
- blob(value) {
494
- this.alignAndReserveVarying(4, 4 + value.length);
495
- this.ulong(value.length);
496
- this.bytes.set(value, this.offset);
497
- this.offset += value.length;
498
- }
499
- string(value) {
500
- const octets = GIOPEncoder.textEncoder.encode(value);
501
- this.alignAndReserveVarying(4, 4 + octets.length + 1);
502
- this.ulong(octets.length + 1);
503
- this.bytes.set(octets, this.offset);
504
- this.offset += octets.length;
505
- this.bytes[this.offset] = 0;
506
- this.offset++;
507
- }
508
- sequence(array, encodeItem) {
509
- this.ulong(array.length);
510
- array.forEach((value, index) => {
511
- encodeItem(value);
512
- });
513
- }
514
- bool(value) {
515
- this.reserveOne();
516
- this.data.setUint8(this.offset, value ? 1 : 0);
517
- this.offset += 1;
518
- }
519
- char(value) {
520
- this.reserveOne();
521
- this.data.setUint8(this.offset, value.charCodeAt(0));
522
- this.offset += 1;
523
- }
524
- octet(value) {
525
- this.reserveOne();
526
- this.data.setUint8(this.offset, value);
527
- this.offset += 1;
528
- }
529
- short(value) {
530
- this.alignAndReserve(2);
531
- this.data.setInt16(this.offset, value, GIOPEncoder.littleEndian);
532
- this.offset += 2;
533
- }
534
- ushort(value) {
535
- this.alignAndReserve(2);
536
- this.data.setUint16(this.offset, value, GIOPEncoder.littleEndian);
537
- this.offset += 2;
538
- }
539
- long(value) {
540
- this.alignAndReserve(4);
541
- this.data.setInt32(this.offset, value, GIOPEncoder.littleEndian);
542
- this.offset += 4;
543
- }
544
- ulong(value) {
545
- this.alignAndReserve(4);
546
- this.data.setUint32(this.offset, value, GIOPEncoder.littleEndian);
547
- this.offset += 4;
548
- }
549
- longlong(value) {
550
- this.alignAndReserve(8);
551
- this.data.setBigInt64(this.offset, value, GIOPEncoder.littleEndian);
552
- this.offset += 8;
553
- }
554
- ulonglong(value) {
555
- this.alignAndReserve(8);
556
- this.data.setBigUint64(this.offset, value, GIOPEncoder.littleEndian);
557
- this.offset += 8;
558
- }
559
- float(value) {
560
- this.alignAndReserve(4);
561
- this.data.setFloat32(this.offset, value, GIOPEncoder.littleEndian);
562
- this.offset += 4;
563
- }
564
- double(value) {
565
- this.alignAndReserve(8);
566
- this.data.setFloat64(this.offset, value, GIOPEncoder.littleEndian);
567
- this.offset += 8;
568
- }
569
- asn1number(n) {
570
- let out = [];
571
- while (n > 0x7F) {
572
- out.push(n & 0x7F);
573
- n >>= 7;
574
- }
575
- out.push(n);
576
- for (let i = out.length - 1; i > 0; --i) {
577
- this.octet(out[i] | 0x80);
578
- }
579
- this.octet(out[0]);
580
- }
581
- asn1numberE(n) {
582
- let out = [];
583
- while (n > 0) {
584
- out.push(n & 0xFF);
585
- n >>= 8;
586
- }
587
- this.octet(out.length);
588
- for (let i = out.length - 1; i >= 0; --i) {
589
- this.octet(out[i]);
590
- }
591
- }
592
- asn1tag(tagClass, tag, encoding, sub) {
593
- const c = (tagClass << 6) | (encoding << 5);
594
- if (tag < 0x1F) {
595
- this.octet(c | tag);
596
- }
597
- else {
598
- this.octet(c | 0x1F);
599
- this.asn1number(tag);
600
- }
601
- const subencoder = new GIOPEncoder();
602
- if (sub !== undefined) {
603
- sub(subencoder);
604
- }
605
- this.asn1number(subencoder.offset);
606
- for (let i = 0; i < subencoder.offset; ++i) {
607
- this.octet(subencoder.bytes[i]);
608
- }
609
- }
610
- asn1oid(oid) {
611
- this.octet(oid[0] * 40 + oid[1]);
612
- for (let i = 2; i < oid.length; ++i) {
613
- this.asn1number(oid[i]);
614
- }
615
- }
616
- }
617
- GIOPEncoder.textEncoder = new TextEncoder();
618
- export class GIOPDecoder extends GIOPBase {
619
- constructor(buffer, connection) {
620
- super(connection);
621
- this.littleEndian = true;
622
- this.objects = new Map();
623
- this.encapStack = [];
624
- this.buffer = buffer;
625
- this.data = new DataView(buffer);
626
- this.bytes = new Uint8Array(buffer);
627
- }
628
- beginEncapsulation() {
629
- const type = this.ulong();
630
- const size = this.ulong();
631
- const nextOffset = this.offset + size;
632
- this.encapStack.push({
633
- nextOffset,
634
- endian: this.littleEndian
635
- });
636
- this.endian();
637
- return type;
638
- }
639
- endEncapsulation() {
640
- const e = this.encapStack.pop();
641
- this.littleEndian = e.endian;
642
- this.offset = e.nextOffset;
643
- }
644
- scanGIOPHeader() {
645
- const magic = this.data.getUint32(0);
646
- if (magic !== 0x47494f50) {
647
- throw Error(`Missing GIOP Header Magic Number (got 0x${magic.toString(16)}, expected 0x47494f50`);
648
- }
649
- this.offset += 4;
650
- this.majorVersion = this.octet();
651
- this.minorVersion = this.octet();
652
- this.endian();
653
- this.type = this.octet();
654
- this.length = this.ulong();
655
- return this.type;
656
- }
657
- scanLocateRequest() {
658
- const data = new LocateRequest();
659
- data.requestId = this.ulong();
660
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
661
- data.objectKey = this.blob();
662
- }
663
- else {
664
- const addressingDisposition = this.ushort();
665
- switch (addressingDisposition) {
666
- case AddressingDisposition.KeyAddr:
667
- data.objectKey = this.blob();
668
- break;
669
- case AddressingDisposition.ProfileAddr:
670
- case AddressingDisposition.ReferenceAddr:
671
- throw Error(`Unsupported AddressingDisposition(${AddressingDisposition[addressingDisposition]})`);
672
- default:
673
- throw Error(`Unknown AddressingDisposition(${addressingDisposition})`);
674
- }
675
- }
676
- return data;
677
- }
678
- scanLocateReply() {
679
- const data = new LocateReply();
680
- data.requestId = this.ulong();
681
- data.status = this.ulong();
682
- return data;
683
- }
684
- scanRequestHeader() {
685
- const data = new RequestData();
686
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
687
- data.serviceContext = this.serviceContext();
688
- }
689
- data.requestId = this.ulong();
690
- const responseFlags = this.octet();
691
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
692
- data.responseExpected = responseFlags != 0;
693
- }
694
- else {
695
- switch (responseFlags) {
696
- case 0:
697
- data.responseExpected = false;
698
- break;
699
- case 1:
700
- break;
701
- case 2:
702
- break;
703
- case 3:
704
- data.responseExpected = true;
705
- break;
706
- }
707
- }
708
- this.offset += 3;
709
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
710
- data.objectKey = this.blob();
711
- }
712
- else {
713
- const addressingDisposition = this.ushort();
714
- switch (addressingDisposition) {
715
- case AddressingDisposition.KeyAddr:
716
- data.objectKey = this.blob();
717
- break;
718
- case AddressingDisposition.ProfileAddr:
719
- case AddressingDisposition.ReferenceAddr:
720
- throw Error(`Unsupported AddressingDisposition(${AddressingDisposition[addressingDisposition]})`);
721
- default:
722
- throw Error(`Unknown AddressingDisposition(${addressingDisposition})`);
723
- }
724
- }
725
- data.method = this.string();
726
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
727
- const requestingPrincipalLength = this.ulong();
728
- }
729
- else {
730
- data.serviceContext = this.serviceContext();
731
- this.align(8);
732
- }
733
- return data;
734
- }
735
- scanReplyHeader() {
736
- const data = new ReplyData();
737
- if (this.majorVersion == 1 && this.minorVersion <= 1) {
738
- this.serviceContext();
739
- }
740
- data.requestId = this.ulong();
741
- data.replyStatus = this.ulong();
742
- if (this.majorVersion == 1 && this.minorVersion >= 2) {
743
- this.serviceContext();
744
- }
745
- return data;
746
- }
747
- serviceContext() {
748
- const result = [];
749
- const serviceContextListLength = this.ulong();
750
- for (let i = 0; i < serviceContextListLength; ++i) {
751
- const serviceId = this.beginEncapsulation();
752
- switch (serviceId) {
753
- case ServiceId.BI_DIR_IIOP:
754
- {
755
- const ctx = new BidirectionalIIOPServiceContext();
756
- ctx.host = this.string();
757
- ctx.port = this.ushort();
758
- result.push(ctx);
759
- }
760
- break;
761
- case ServiceId.SecurityAttributeService:
762
- {
763
- const type = this.ulong();
764
- switch (type) {
765
- case SASType.EstablishContext:
766
- {
767
- const context = new EstablishContext();
768
- context.decode(this);
769
- result.push(context);
770
- }
771
- break;
772
- case SASType.CompleteEstablishContext:
773
- {
774
- const context = new CompleteEstablishContext();
775
- context.clientContextId = this.ulonglong();
776
- context.contextStateful = this.bool();
777
- result.push(context);
778
- }
779
- break;
780
- case SASType.ContextError:
781
- {
782
- const context = new ContextError();
783
- context.clientContextId = this.ulonglong();
784
- context.majorStatus = this.long();
785
- context.minorStatus = this.long();
786
- result.push(context);
787
- }
788
- break;
789
- }
790
- }
791
- break;
792
- default:
793
- }
794
- this.endEncapsulation();
795
- }
796
- return result;
797
- }
798
- reference(length = undefined) {
799
- const data = new ObjectReference();
800
- data.oid = this.string(length);
801
- const profileCount = this.ulong();
802
- for (let i = 0; i < profileCount; ++i) {
803
- const profileId = this.beginEncapsulation();
804
- switch (profileId) {
805
- case IOR.TAG.IOR.INTERNET_IOP:
806
- {
807
- const iiopMajorVersion = this.octet();
808
- const iiopMinorVersion = this.octet();
809
- data.host = this.string();
810
- data.port = this.ushort();
811
- data.objectKey = this.blob();
812
- if (iiopMajorVersion === 1 && iiopMinorVersion !== 0) {
813
- const n = this.ulong();
814
- for (i = 0; i < n; ++i) {
815
- const id = this.ulong();
816
- const length = this.ulong();
817
- const nextOffset = this.offset + length;
818
- switch (id) {
819
- case TagType.ORB_TYPE:
820
- const typeCount = this.ulong();
821
- for (let j = 0; j < typeCount; ++j) {
822
- const orbType = this.ulong();
823
- const orbTypeNames = [
824
- [0x48500000, 0x4850000f, "Hewlett Packard"],
825
- [0x49424d00, 0x49424d0f, "IBM"],
826
- [0x494c5500, 0x494c55ff, "Xerox"],
827
- [0x49534900, 0x4953490f, "AdNovum Informatik AG"],
828
- [0x56495300, 0x5649530f, "Borland (VisiBroker)"],
829
- [0x4f495300, 0x4f4953ff, "Objective Interface Systems"],
830
- [0x46420000, 0x4642000f, "FloorBoard Software"],
831
- [0x4E4E4E56, 0x4E4E4E56, "Rogue Wave"],
832
- [0x4E550000, 0x4E55000f, "Nihon Unisys, Ltd"],
833
- [0x4A424B52, 0x4A424B52, "SilverStream Software"],
834
- [0x54414f00, 0x54414f00, "Center for Distributed Object Computing, Washington University"],
835
- [0x4C434200, 0x4C43420F, "2AB"],
836
- [0x41505831, 0x41505831, "Informatik 4, Univ. of Erlangen-Nuernberg"],
837
- [0x4f425400, 0x4f425400, "ORBit"],
838
- [0x47534900, 0x4753490f, "GemStone Systems, Inc."],
839
- [0x464a0000, 0x464a000f, "Fujitsu Limited"],
840
- [0x4E534440, 0x4E53444F, "Compaq Computer"],
841
- [0x4f425f00, 0x4f425f0f, "TIBCO"],
842
- [0x4f414b00, 0x4f414b0f, "Camros Corporation"],
843
- [0x41545400, 0x4154540f, "AT&T Laboratories, Cambridge (OmniORB)"],
844
- [0x4f4f4300, 0x4f4f430f, "IONA Technologies"],
845
- [0x4e454300, 0x4e454303, "NEC Corporation"],
846
- [0x424c5500, 0x424c550f, "Berry Software"],
847
- [0x56495400, 0x564954ff, "Vitra"],
848
- [0x444f4700, 0x444f47ff, "Exoffice Technologies"],
849
- [0xcb0e0000, 0xcb0e00ff, "Chicago Board of Exchange (CBOE)"],
850
- [0x4A414300, 0x4A41430f, "FU Berlin Institut für Informatik (JAC)"],
851
- [0x58545240, 0x5854524F, "Xtradyne Technologies AG"],
852
- [0x54475800, 0x54475803, "Top Graph'X"],
853
- [0x41646100, 0x41646103, "AdaOS project"],
854
- [0x4e4f4b00, 0x4e4f4bff, "Nokia"],
855
- [0x53414E00, 0x53414E0f, "Sankhya Technologies Private Limited, India"],
856
- [0x414E4400, 0x414E440f, "Androsoft GmbH"],
857
- [0x42424300, 0x4242430f, "Bionic Buffalo Corporation"],
858
- [0x4d313300, 0x4d313300, "corba.js"]
859
- ];
860
- let name;
861
- for (let x of orbTypeNames) {
862
- if (x[0] <= orbType && orbType <= x[1]) {
863
- name = x[2];
864
- break;
865
- }
866
- }
867
- if (name === undefined) {
868
- name = `0x${orbType.toString(16)}`;
869
- }
870
- }
871
- break;
872
- case TagType.CODE_SETS:
873
- break;
874
- case TagType.POLICIES:
875
- break;
876
- default:
877
- }
878
- this.offset = nextOffset;
879
- }
880
- }
881
- }
882
- break;
883
- default:
884
- }
885
- this.endEncapsulation();
886
- }
887
- return data;
888
- }
889
- value(typeInfo = undefined) {
890
- return this.object(typeInfo, true);
891
- }
892
- object(typeInfo = undefined, isValue = false) {
893
- const code = this.ulong();
894
- if (code === 0)
895
- return undefined;
896
- const objectOffset = this.offset - 4;
897
- if ((code & 0xffffff00) === 0x7fffff00) {
898
- let valueTypeConstructor;
899
- if (code & 1) {
900
- throw Error(`value_tag contains unsupported codebase URL`);
901
- }
902
- if ((code & 6) === 2) {
903
- let repositoryId;
904
- const len = this.ulong();
905
- if (len !== 0xffffffff) {
906
- repositoryId = this.string(len);
907
- }
908
- else {
909
- const offset = this.offset;
910
- const indirection = this.long();
911
- const nextOffset = this.offset;
912
- this.offset = offset + indirection;
913
- if ((this.offset & 0x03) !== 0) {
914
- console.error(`WRONG INDIRECTION: GOT 0x${this.offset.toString(16)}, EXPECTED 0x${(this.offset - (this.offset & 0x03)).toString(16)}`);
915
- this.offset = this.offset - (this.offset & 0x03);
916
- }
917
- repositoryId = this.string();
918
- this.offset = nextOffset;
919
- }
920
- if (repositoryId.length < 8 || repositoryId.substring(0, 4) !== "IDL:" || repositoryId.substring(repositoryId.length - 4) !== ":1.0")
921
- throw Error(`Unsupported CORBA GIOP Repository ID '${repositoryId}'`);
922
- const shortName = repositoryId.substring(4, repositoryId.length - 4);
923
- valueTypeConstructor = ORB.lookupValueType(shortName);
924
- if (valueTypeConstructor === undefined)
925
- throw Error(`Unregistered Repository ID '${repositoryId}' (${shortName})`);
926
- }
927
- if ((code & 6) === 6) {
928
- throw Error(`value_tag contains unsupported list of repository IDs`);
929
- }
930
- if (valueTypeConstructor === undefined && typeInfo !== undefined) {
931
- valueTypeConstructor = ORB.lookupValueType(typeInfo);
932
- }
933
- if (valueTypeConstructor === undefined) {
934
- throw Error(`insufficient value type information`);
935
- }
936
- const obj = new (valueTypeConstructor)(this);
937
- this.objects.set(objectOffset + 2, obj);
938
- return obj;
939
- }
940
- if (code === 0xffffffff) {
941
- let indirection = this.long();
942
- indirection += 2;
943
- const position = this.offset + indirection;
944
- const obj = this.objects.get(position);
945
- if (obj === undefined) {
946
- throw Error("IDL:omg.org/CORBA/MARSHAL:1.0");
947
- }
948
- return obj;
949
- }
950
- if (code < 0x7fffff00) {
951
- if (this.connection === undefined)
952
- throw Error("GIOPDecoder has no connection defined. Can not resolve resolve reference to stub object.");
953
- const reference = this.reference(code);
954
- if (reference.host == this.connection.localAddress && reference.port == this.connection.localPort) {
955
- return this.connection.orb.servants.get(reference.objectKey);
956
- }
957
- let object = this.connection.stubsById.get(reference.objectKey);
958
- if (object !== undefined)
959
- return object;
960
- const shortName = reference.oid.substring(4, reference.oid.length - 4);
961
- let aStubClass = this.connection.orb.stubsByName.get(shortName);
962
- if (aStubClass === undefined) {
963
- throw new OBJECT_ADAPTER(0x4f4d0003, CompletionStatus.NO);
964
- }
965
- object = new aStubClass(this.connection.orb, reference.objectKey, this.connection);
966
- this.connection.stubsById.set(reference.objectKey, object);
967
- return object;
968
- }
969
- throw Error(`GIOPDecoder: Unsupported value with CORBA tag 0x${code.toString(16)}`);
970
- }
971
- endian() {
972
- const byteOrder = this.octet();
973
- this.littleEndian = byteOrder === GIOPBase.ENDIAN_LITTLE;
974
- }
975
- blob(length) {
976
- if (length === undefined)
977
- length = this.ulong();
978
- const value = this.bytes.subarray(this.offset, this.offset + length);
979
- this.offset += length;
980
- return value;
981
- }
982
- string(length) {
983
- if (length === undefined)
984
- length = this.ulong();
985
- const rawString = this.bytes.subarray(this.offset, this.offset + length - 1);
986
- const value = GIOPDecoder.textDecoder.decode(rawString);
987
- this.offset += length;
988
- return value;
989
- }
990
- sequence(decodeItem) {
991
- const length = this.ulong();
992
- const array = new Array(length);
993
- for (let i = 0; i < length; ++i) {
994
- array[i] = decodeItem();
995
- }
996
- return array;
997
- }
998
- bool() {
999
- const value = this.data.getUint8(this.offset) !== 0;
1000
- ++this.offset;
1001
- return value;
1002
- }
1003
- char() {
1004
- const value = String.fromCharCode(this.data.getUint8(this.offset));
1005
- ++this.offset;
1006
- return value;
1007
- }
1008
- octet() {
1009
- const value = this.data.getUint8(this.offset);
1010
- ++this.offset;
1011
- return value;
1012
- }
1013
- short() {
1014
- this.align(2);
1015
- const value = this.data.getInt16(this.offset, this.littleEndian);
1016
- this.offset += 2;
1017
- return value;
1018
- }
1019
- ushort() {
1020
- this.align(2);
1021
- const value = this.data.getUint16(this.offset, this.littleEndian);
1022
- this.offset += 2;
1023
- return value;
1024
- }
1025
- long() {
1026
- this.align(4);
1027
- const value = this.data.getInt32(this.offset, this.littleEndian);
1028
- this.offset += 4;
1029
- return value;
1030
- }
1031
- ulong() {
1032
- this.align(4);
1033
- const value = this.data.getUint32(this.offset, this.littleEndian);
1034
- this.offset += 4;
1035
- return value;
1036
- }
1037
- longlong() {
1038
- this.align(8);
1039
- const value = this.data.getBigInt64(this.offset, this.littleEndian);
1040
- this.offset += 8;
1041
- return value;
1042
- }
1043
- ulonglong() {
1044
- this.align(8);
1045
- const value = this.data.getBigUint64(this.offset, this.littleEndian);
1046
- this.offset += 8;
1047
- return value;
1048
- }
1049
- float() {
1050
- this.align(4);
1051
- const value = this.data.getFloat32(this.offset, this.littleEndian);
1052
- this.offset += 4;
1053
- return value;
1054
- }
1055
- double() {
1056
- this.align(8);
1057
- const value = this.data.getFloat64(this.offset, this.littleEndian);
1058
- this.offset += 8;
1059
- return value;
1060
- }
1061
- asn1number() {
1062
- let n = 0;
1063
- while (true) {
1064
- const c = this.octet();
1065
- n <<= 7;
1066
- if (c & 0x80) {
1067
- n |= c & 0x7f;
1068
- }
1069
- else {
1070
- n |= c;
1071
- break;
1072
- }
1073
- }
1074
- return n;
1075
- }
1076
- asn1tag() {
1077
- const tag = new ASN1Tag();
1078
- let state = 0;
1079
- let lenghtOfLength;
1080
- while (state >= 0) {
1081
- const c = this.octet();
1082
- switch (state) {
1083
- case 0:
1084
- tag.tagClass = (c & 0xC0) >> 6;
1085
- tag.encoding = (c & 0x20) >> 5;
1086
- tag.tag = c & 0x1F;
1087
- if (tag.tag == 0x1F) {
1088
- state = 1;
1089
- tag.tag = 0;
1090
- }
1091
- else {
1092
- state = 2;
1093
- }
1094
- break;
1095
- case 1:
1096
- tag.tag <<= 7;
1097
- tag.tag |= c & 0x7F;
1098
- if (c & 0x80)
1099
- state = 2;
1100
- break;
1101
- case 2:
1102
- tag.length = c;
1103
- if (c & 0x80) {
1104
- lenghtOfLength = tag.length & 0x7F;
1105
- tag.length = 0;
1106
- state = 3;
1107
- }
1108
- else {
1109
- state = -1;
1110
- }
1111
- break;
1112
- case 3:
1113
- tag.length <<= 8;
1114
- tag.length |= c;
1115
- if (--lenghtOfLength == 0)
1116
- state = -1;
1117
- break;
1118
- }
1119
- }
1120
- return tag;
1121
- }
1122
- asn1oid(len) {
1123
- const oid = [];
1124
- let state = 0;
1125
- let akku = 0;
1126
- for (let i = 0; i < len; ++i) {
1127
- const c = this.octet();
1128
- switch (state) {
1129
- case 0:
1130
- oid.push(Math.floor(c / 40));
1131
- oid.push(c % 40);
1132
- state = 1;
1133
- break;
1134
- case 1:
1135
- if (c & 0x80) {
1136
- akku = c & 0x7F;
1137
- state = 2;
1138
- }
1139
- else {
1140
- oid.push(c);
1141
- }
1142
- break;
1143
- case 2:
1144
- akku <<= 7;
1145
- akku |= (c & 0x7F);
1146
- if (!(c & 0x80)) {
1147
- oid.push(akku);
1148
- state = 1;
1149
- }
1150
- break;
1151
- }
1152
- }
1153
- return oid;
1154
- }
1155
- asn1expect(cls, tag, encoding) {
1156
- const t0 = this.asn1tag();
1157
- if (t0.tagClass !== cls || t0.tag !== tag || t0.encoding !== encoding) {
1158
- console.log(`Can not authenticate client: ASN.1 decoding error`);
1159
- return undefined;
1160
- }
1161
- return t0;
1162
- }
1163
- asn1expectOID(oid) {
1164
- const t1 = this.asn1expect(ASN1Class.UNIVERSAL, ASN1UniversalTag.OID, ASN1Encoding.PRIMITIVE);
1165
- if (t1 === undefined)
1166
- return false;
1167
- const got = this.asn1oid(t1.length);
1168
- if (oid.length !== got.length) {
1169
- console.log(`Can not authenticate client: Wrong OID`);
1170
- return false;
1171
- }
1172
- for (let i = 0; i < oid.length; ++i) {
1173
- if (oid[i] !== got[i]) {
1174
- console.log(`Can not authenticate client: Wrong OID`);
1175
- return false;
1176
- }
1177
- }
1178
- return true;
1179
- }
1180
- align(alignment) {
1181
- const inversePadding = this.offset % alignment;
1182
- if (inversePadding !== 0)
1183
- this.offset += alignment - inversePadding;
1184
- }
1185
- }
1186
- GIOPDecoder.textDecoder = new TextDecoder();
1187
- function hexdump(bytes, addr = 0, length = bytes.byteLength) {
1188
- while (addr < length) {
1189
- let line = addr.toString(16).padStart(4, "0");
1190
- for (let i = 0, j = addr; i < 16 && j < bytes.byteLength; ++i, ++j)
1191
- line += " " + bytes[j].toString(16).padStart(2, "0");
1192
- line = line.padEnd(4 + 16 * 3 + 1, " ");
1193
- for (let i = 0, j = addr; i < 16 && j < bytes.byteLength; ++i, ++j) {
1194
- const b = bytes[j];
1195
- if (b >= 32 && b < 127)
1196
- line += String.fromCharCode(b);
1197
- else
1198
- line += ".";
1199
- }
1200
- addr += 16;
1201
- console.log(line);
1202
- }
1203
- }
1204
- //# sourceMappingURL=giop.js.map