corba.js 0.0.12 → 0.1.3

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 (142) hide show
  1. package/LICENSE +70 -83
  2. package/README.IDL.txt +285 -0
  3. package/README.md +88 -48
  4. package/bin/corba-idl +15 -2
  5. package/lib/idl/idl.cjs +2732 -0
  6. package/lib/idl/idl.cjs.map +1 -0
  7. package/lib/idl/src/idl/idl-lexer.d.ts +19 -0
  8. package/lib/idl/src/idl/idl-node.d.ts +101 -0
  9. package/lib/idl/src/idl/idl-parser.d.ts +3 -0
  10. package/lib/idl/src/idl/idl.d.ts +1 -0
  11. package/lib/idl/src/idl/util.d.ts +25 -0
  12. package/lib/idl/src/idl/write-interface.d.ts +2 -0
  13. package/lib/idl/src/idl/write-skeleton.d.ts +2 -0
  14. package/lib/idl/src/idl/write-stub.d.ts +2 -0
  15. package/lib/idl/src/idl/write-value.d.ts +2 -0
  16. package/lib/idl/src/idl/write-valueimpl.d.ts +2 -0
  17. package/lib/idl/src/idl/write-valuetype.d.ts +2 -0
  18. package/lib/idl/src/index.d.ts +5 -0
  19. package/lib/idl/src/net/browser.d.ts +7 -0
  20. package/lib/idl/src/net/index.d.ts +3 -0
  21. package/lib/idl/src/net/tcp.d.ts +11 -0
  22. package/lib/idl/src/net/tls.d.ts +24 -0
  23. package/lib/idl/src/net/ws.d.ts +42 -0
  24. package/lib/idl/src/orb/asn1.d.ts +48 -0
  25. package/lib/idl/src/orb/connection.d.ts +24 -0
  26. package/lib/idl/src/orb/giop.d.ts +276 -0
  27. package/lib/idl/src/orb/index.d.ts +3 -0
  28. package/lib/idl/src/orb/ior.d.ts +89 -0
  29. package/lib/idl/src/orb/orb.d.ts +143 -0
  30. package/lib/idl/src/orb/protocol.d.ts +6 -0
  31. package/lib/idl/src/orb/uint8map.d.ts +14 -0
  32. package/lib/idl/src/orb/url.d.ts +55 -0
  33. package/lib/idl/test/access.spec.d.ts +1 -0
  34. package/lib/idl/test/attribute.spec.d.ts +1 -0
  35. package/lib/idl/test/basics.spec.d.ts +1 -0
  36. package/lib/idl/test/disconnect.spec.d.ts +1 -0
  37. package/lib/idl/test/eventtarget.spec.d.ts +1 -0
  38. package/lib/idl/test/fake.d.ts +31 -0
  39. package/lib/idl/test/giop.spec.d.ts +1 -0
  40. package/lib/idl/test/idl/idl.spec.d.ts +1 -0
  41. package/lib/idl/test/idl_module.spec.d.ts +1 -0
  42. package/lib/idl/test/initialreferences.spec.d.ts +1 -0
  43. package/lib/idl/test/net/tls.spec.d.ts +1 -0
  44. package/lib/idl/test/net/ws.spec.d.ts +1 -0
  45. package/lib/idl/test/net/wss.spec.d.ts +1 -0
  46. package/lib/idl/test/object_by_reference.spec.d.ts +1 -0
  47. package/lib/idl/test/orb/asn1.spec.d.ts +1 -0
  48. package/lib/idl/test/orb/url.spec.d.ts +1 -0
  49. package/lib/idl/test/stub.spec.d.ts +1 -0
  50. package/lib/idl/test/util.d.ts +5 -0
  51. package/lib/idl/test/valuetype.spec.d.ts +1 -0
  52. package/lib/{idl → src/idl}/idl-lexer.d.ts +0 -0
  53. package/lib/src/idl/idl-lexer.js +234 -0
  54. package/lib/src/idl/idl-lexer.js.map +1 -0
  55. package/lib/{idl → src/idl}/idl-node.d.ts +13 -10
  56. package/lib/{idl → src/idl}/idl-node.js +30 -49
  57. package/lib/src/idl/idl-node.js.map +1 -0
  58. package/lib/{idl → src/idl}/idl-parser.d.ts +0 -0
  59. package/lib/{idl → src/idl}/idl-parser.js +367 -291
  60. package/lib/src/idl/idl-parser.js.map +1 -0
  61. package/lib/{idl → src/idl}/idl.d.ts +0 -0
  62. package/lib/src/idl/idl.js +180 -0
  63. package/lib/src/idl/idl.js.map +1 -0
  64. package/lib/src/idl/util.d.ts +25 -0
  65. package/lib/src/idl/util.js +239 -0
  66. package/lib/src/idl/util.js.map +1 -0
  67. package/lib/src/idl/write-interface.d.ts +2 -0
  68. package/lib/src/idl/write-interface.js +111 -0
  69. package/lib/src/idl/write-interface.js.map +1 -0
  70. package/lib/src/idl/write-skeleton.d.ts +2 -0
  71. package/lib/src/idl/write-skeleton.js +116 -0
  72. package/lib/src/idl/write-skeleton.js.map +1 -0
  73. package/lib/src/idl/write-stub.d.ts +2 -0
  74. package/lib/src/idl/write-stub.js +116 -0
  75. package/lib/src/idl/write-stub.js.map +1 -0
  76. package/lib/src/idl/write-value.d.ts +2 -0
  77. package/lib/src/idl/write-value.js +205 -0
  78. package/lib/src/idl/write-value.js.map +1 -0
  79. package/lib/src/idl/write-valueimpl.d.ts +2 -0
  80. package/lib/src/idl/write-valueimpl.js +158 -0
  81. package/lib/src/idl/write-valueimpl.js.map +1 -0
  82. package/lib/src/idl/write-valuetype.d.ts +2 -0
  83. package/lib/src/idl/write-valuetype.js +98 -0
  84. package/lib/src/idl/write-valuetype.js.map +1 -0
  85. package/lib/src/index.d.ts +5 -0
  86. package/lib/src/index.js +6 -0
  87. package/lib/src/index.js.map +1 -0
  88. package/lib/src/net/browser.d.ts +7 -0
  89. package/lib/src/net/browser.js +54 -0
  90. package/lib/src/net/browser.js.map +1 -0
  91. package/lib/src/net/index.d.ts +3 -0
  92. package/lib/src/net/index.js +4 -0
  93. package/lib/src/net/index.js.map +1 -0
  94. package/lib/src/net/tcp.d.ts +11 -0
  95. package/lib/src/net/tcp.js +66 -0
  96. package/lib/src/net/tcp.js.map +1 -0
  97. package/lib/src/net/tls.d.ts +24 -0
  98. package/lib/src/net/tls.js +69 -0
  99. package/lib/src/net/tls.js.map +1 -0
  100. package/lib/src/net/ws.d.ts +42 -0
  101. package/lib/src/net/ws.js +158 -0
  102. package/lib/src/net/ws.js.map +1 -0
  103. package/lib/src/orb/asn1.d.ts +48 -0
  104. package/lib/src/orb/asn1.js +60 -0
  105. package/lib/src/orb/asn1.js.map +1 -0
  106. package/lib/src/orb/connection.d.ts +24 -0
  107. package/lib/src/orb/connection.js +19 -0
  108. package/lib/src/orb/connection.js.map +1 -0
  109. package/lib/src/orb/giop.d.ts +276 -0
  110. package/lib/src/orb/giop.js +1205 -0
  111. package/lib/src/orb/giop.js.map +1 -0
  112. package/lib/src/orb/index.d.ts +3 -0
  113. package/lib/src/orb/index.js +4 -0
  114. package/lib/src/orb/index.js.map +1 -0
  115. package/lib/src/orb/ior.d.ts +89 -0
  116. package/lib/src/orb/ior.js +110 -0
  117. package/lib/src/orb/ior.js.map +1 -0
  118. package/lib/src/orb/orb.d.ts +143 -0
  119. package/lib/src/orb/orb.js +693 -0
  120. package/lib/src/orb/orb.js.map +1 -0
  121. package/lib/src/orb/protocol.d.ts +6 -0
  122. package/lib/src/orb/protocol.js +2 -0
  123. package/lib/src/orb/protocol.js.map +1 -0
  124. package/lib/src/orb/uint8map.d.ts +14 -0
  125. package/lib/src/orb/uint8map.js +48 -0
  126. package/lib/src/orb/uint8map.js.map +1 -0
  127. package/lib/src/orb/url.d.ts +55 -0
  128. package/lib/src/orb/url.js +252 -0
  129. package/lib/src/orb/url.js.map +1 -0
  130. package/package.json +50 -26
  131. package/lib/idl/idl-lexer.js +0 -257
  132. package/lib/idl/idl-lexer.js.map +0 -1
  133. package/lib/idl/idl-node.js.map +0 -1
  134. package/lib/idl/idl-parser.js.map +0 -1
  135. package/lib/idl/idl.js +0 -946
  136. package/lib/idl/idl.js.map +0 -1
  137. package/lib/orb/orb-nodejs.d.ts +0 -7
  138. package/lib/orb/orb-nodejs.js +0 -111
  139. package/lib/orb/orb-nodejs.js.map +0 -1
  140. package/lib/orb/orb.d.ts +0 -62
  141. package/lib/orb/orb.js +0 -514
  142. package/lib/orb/orb.js.map +0 -1
package/README.md CHANGED
@@ -1,46 +1,69 @@
1
1
  # corba.js
2
2
 
3
3
  Welcome to corba.js, an Object Request Broker (ORB) and Interface Definition
4
- Language (IDL) compiler in TypeScript/JavaScript based on the CORBA v3.0
5
- specification.
4
+ Language (IDL) compiler for TypeScript lousily based on the CORBA specification. (ISO/IEC 19500)
6
5
 
7
- CORBA is a registered trademark by the Object Management Group.
8
- http://www.corba.org/
6
+ _CORBA is a registered trademark by the Object Management Group. http://www.corba.org/_
9
7
 
10
- ## Why? What?
8
+ ## What does it do?
11
9
 
12
- * CORBA is an object oriented RPC library, which allows remote
13
- objects being treated as local objects and independent of the
14
- programming languages being used.
15
- * After CORBA became more and more complicated through design by committee, CORBA was replaced by SOAP.
16
- * After SOAP became more and more complicated, SOAP was replaced by REST.
17
- * With the advent of WebApps and WebSockets, CORBA became feasible again.
10
+ CORBA helps to hide the split of modern WebApps into frontend and backend by making
11
+ remote objects appear like local objects.
18
12
 
19
- corba.js is currently being written to develop <a
20
- href="https://github.com/markandre13/workflow">workflow - A collaborative
21
- real-time white- and kanban board</a>, which has so much communication
22
- happening between the server and it's clients, that I wanted as much of the
23
- network code being created automatically.
13
+ For this objects, exceptions and data structures (aka DTOs), which need to bridge the
14
+ network, are described in the Interface Definition Language (IDL), which is then
15
+ compiled into code to be used in the application.
16
+
17
+ Data structures can even be pointer based ones like trees or cyclic graphs.
18
+
19
+ Frontend and backend can connect via WebSockets to carry CORBA's binary
20
+ GIOP protocol. In the future there will be also support for WebRTC and/or HTTP/3's
21
+ WebTransport, where the IDL's `oneway` keyword can make use of the unreliable
22
+ transport provided by these UDP based protocols.
23
+
24
+ ## What does it not do?
25
+
26
+ CORBA's goal is to make frontend and backend look like one application, which implies tight coupling. Microservices on the other hand are intended to be loosely coupled.
27
+ Here a protocol like REST+JSON, 0MQ+MessagePack, etc. can be a better solution.
28
+
29
+ See also: [REST, SOAP, and CORBA, i.e. How We Got Here](https://greglturnquist.com/2016/05/03/rest-soap-corba-e-got/).
30
+
31
+ ## Why?
32
+
33
+ corba.js is written to be used in [workflow](https://github.com/markandre13/workflow#readme) where it handles
34
+
35
+ * the communication between frontend and backend
36
+ * persisting objects to the database
37
+ * persisting objects to files (using CORBA's binary encoding GIOP)
38
+
39
+ In the 90ties CORBA was quite the hype but design-by-committee made it bloated, slow
40
+ and no fun to use. (See [The Rise and Fall of CORBA](https://queue.acm.org/detail.cfm?id=1142044) and [What's Wrong With CORBA](https://wiki.c2.com/?WhatsWrongWithCorba).)
41
+
42
+ Still, stripped to it's core, one finds a fast and lightweight system, which made it ideal for modern WebApps. This might be in part attributed to CORBA's roots in the experimental object oriented [Spring](https://en.wikipedia.org/wiki/Spring_(operating_system)) operating system and some sole individuals undermining the design-by-committee with their expertise. 😁
43
+
44
+ Around 2004 a group developers previously involed with CORBA and the OMG presented a much improved successor of CORBA, the [Internet Communications Engine](https://zeroc.com/products/ice) (ICE), which is also available for JavaScript/TypeScript under the GNU GPLv2.
45
+
46
+ Around 2012, CERN switched from CORBA to [0MQ](https://en.wikipedia.org/wiki/ZeroMQ) and a custom serializer.
24
47
 
25
48
  ## Interfaces
26
49
 
27
50
  In the following example, a server will provide an object of type _Server_ and
28
51
  the clients an object of type _Client_, which are to be defined in an IDL file:
29
- ```
52
+ ```java
30
53
  interface Client {
31
- oneway printMessage(in string message);
54
+ oneway void printMessage(in string message);
32
55
  }
33
56
 
34
57
  interface Server {
35
- oneway registerClient(in Client client);
58
+ oneway void registerClient(in Client client);
36
59
  double add(in double a, in double b);
37
60
  }
38
61
  ```
39
62
 
40
- * 'oneway' is CORBA's version of 'void', meaning the method call will not
41
- return a result.
42
- * 'in' specifies that the argument will not be written into to return data.
43
- ('out' and 'inout' are not implemented by corba.js)
63
+ * `oneway` means that the client expects no confirmation that the call has
64
+ reached it's destination.
65
+ * `in` specifies that the argument will not be written into to return data.
66
+ (`out` and `inout` are not implemented by corba.js)
44
67
 
45
68
  For each interface, the IDL compiler will generate stub and skeleton
46
69
  classes:
@@ -86,6 +109,8 @@ Here are example implementations for the client and server defined earlier:
86
109
  The server side initialization:
87
110
 
88
111
  ```javascript
112
+ import { WsProtocol } from "corba.js/net/ws"
113
+
89
114
  let orb = new ORB()
90
115
 
91
116
  // create the server implementation
@@ -99,23 +124,25 @@ The server side initialization:
99
124
  orb.registerStubClass(stub.Client)
100
125
 
101
126
  // listen for incoming WebSocket connections
102
- orb.listen("0.0.0.0", 8000)
127
+ const protocol = new WsProtocol()
128
+ orb.addProtocol(protocol)
129
+ protocol.listen(orb, 8809)
103
130
  ```
104
131
 
105
132
  The client side initialization:
106
133
 
107
134
  ```javascript
135
+ import { WsProtocol } from "corba.js/net/browser"
136
+
108
137
  let orb = new ORB()
138
+ orb.addProtocol(new WsProtocol())
109
139
 
110
140
  // for the client, the server is a remote object,
111
141
  // so we need to register the server's stub
112
142
  orb.registerStubClass(stub.Server)
113
143
 
114
- // connect to the WebSocket server
115
- orb.connect("ws://somehostname:8000/")
116
-
117
144
  // find the object registered as "MyServer"
118
- let object = await orb.resolve("MyServer")
145
+ const object = orb.stringToObject("corbaname::localhost:8809#MyServer")
119
146
 
120
147
  // try to cast it to type stub.Server
121
148
  let server = stub.Server.narrow(object)
@@ -133,16 +160,16 @@ The client side initialization:
133
160
  console.log(server.add(3, 2))
134
161
  ```
135
162
 
136
- Note to self: The narrow() is a classic CORBA function, but I guess we could reduce it to
137
-
138
- let server = await orb.resolve<Server>("MyServer")
139
-
140
163
  ## Security Model
141
164
 
142
- corba.js does not implement CORBA's security model and instead relies on
143
- SSL/TLS and by restricting access to objects to those exchanged via
165
+ corba.js 0.0.x did not implement CORBA's security model and instead relies on
166
+ SSL/TLS and by restricting access to objects made public to the peer.
167
+
168
+ corba.js 0.1.x uses CORBA's IIOP protocol currently provides only
169
+ SSL/TLS and password login but no means to restrict access to individual
170
+ objects.
144
171
 
145
- ### Bind/Resolve
172
+ ## Bind/Resolve
146
173
 
147
174
  Ie. in the example above the side which provided the implementation
148
175
  made the object publicly accessible via
@@ -152,7 +179,9 @@ made the object publicly accessible via
152
179
  ```
153
180
  and the side using the remote object gained access to it via
154
181
  ```javascript
155
- let server = orb.resolve("MyServer")
182
+ const server = stub.Server.narrow(
183
+ await orb.stringToObject("corbaname::localhost:2809#MyServer")
184
+ )
156
185
  ```
157
186
  ### Objects passed by reference
158
187
 
@@ -168,20 +197,20 @@ Any further access control must be dealt with by the application.
168
197
 
169
198
  The IDL compiler represents IDL types as follows in TypeScript
170
199
 
171
- IDL Type | TypeScript Type
172
- ------------------------------- | ---------------
173
- boolean | boolean
174
- float, double, short, long, ... | number
175
- string | string
176
- sequence&lt;T&gt; | Array&lt;T&gt;
177
- interface T | skel.T, stub.T
200
+ IDL Type | TypeScript Type
201
+ -------------------------------- | ---------------
202
+ boolean | boolean
203
+ octet, short, long float, double | number
204
+ char, string | string
205
+ sequence&lt;T&gt; | Array&lt;T&gt;
206
+ interface T | skel.T, stub.T
178
207
 
179
208
  While IDL interfaces are used to provide communication between objects
180
209
  registered at different ORBs, valuetypes can be used to exchange data
181
210
  between them. When used as arguments in methods, CORBA will serialize
182
211
  and deserialize them based on their IDL description:
183
212
 
184
- ```
213
+ ```java
185
214
  valuetype Point {
186
215
  public double x, y;
187
216
  };
@@ -240,7 +269,7 @@ instantiate the registered implementation of the class.
240
269
  Methods in valuetypes may also use types which are not to be meant to
241
270
  be exchanged between ORBs. These can be declared as 'native':
242
271
 
243
- ```
272
+ ```java
244
273
  native Path;
245
274
 
246
275
  valuetype Figure {
@@ -249,10 +278,9 @@ be exchanged between ORBs. These can be declared as 'native':
249
278
  }
250
279
  ```
251
280
 
252
- NOTE: corba.js does not implement CORBA's capability to handle pointers, ie. when
281
+ _NOTE: corba.js does not implement CORBA's capability to handle pointers, ie. when
253
282
  two objects are referencing the same object, two instances of the object will be
254
- created on the other side instead of one. As this feature might simplify the implementation
255
- of the Workflow App, it might be implemented for corba.js in the future.
283
+ created on the other side instead of one. This is going to change with the implementation of CORBA's binary encoding GIOP._
256
284
 
257
285
  ## IDL
258
286
 
@@ -272,3 +300,15 @@ corba.js does not implement the CORBA network protocol (GIOP/IIOP).
272
300
 
273
301
  As corba.js is intended to ease the implementation of WebApps, it uses
274
302
  JSON to be lightweight and efficient with some inspiration from JSON-RPC and EJSON.
303
+
304
+ ## Development
305
+
306
+ All build stages are setup to run in watch mode for performance reasons.
307
+
308
+ * I ususally run `npm dev:build` in Visual Studio Code's terminal window to
309
+ be able to jump from compiler errors directly into the source code.
310
+
311
+ * `npm dev:test` runs all tests in watch mode.
312
+
313
+ * `npm dev:test --file=lib/test/valuetype.spec.js` runs a single test file
314
+ in watch mode.
package/bin/corba-idl CHANGED
@@ -1,2 +1,15 @@
1
- #!/usr/bin/env node
2
- require('../lib/idl/idl.js')
1
+ #!/bin/sh
2
+
3
+ tryrun() {
4
+ if test -f "$1" ; then
5
+ exec /usr/bin/env node --enable-source-maps -- $*
6
+ fi
7
+ }
8
+
9
+ tryrun "${0%/*}/../lib/idl/idl.cjs" $*
10
+ tryrun "${0%/*}/../corba.js/lib/idl/idl.cjs" $*
11
+
12
+ echo "${0%/*}"
13
+
14
+ echo "$0: internal error; couldn't find idl.cjs" 1>&2
15
+ exit 1