![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@therms/rpc-client
Advanced tools
A Remote Procedure Call framework for Javascript environments (Node.js & Browser).
npm i @therms/rpc-client
import { RPCClient } from '@therms/rpc-client'
/* Create a client instance */
const rpc = new RPCClient({
hosts: {
http: 'http://localhost:3995/rpc',
websocket: 'ws://localhost:3996', // optional
},
})
/* Make a remote procedure call */
const {
code, // http status code, ie: 200
data, // any data returned from the remote/server
message, // a human readable message from the remote/server
success, // boolean, true|false if the procedure was succesful
} = await rpc.call({
// optional
args: {
email: 'me@gmail.com',
password: '1234567',
},
procedure: 'login',
// optional
scope: 'auth',
// optional
version: '1',
})
Note:
await rpc.call({ ... })
willthrow
when theCallResponse.success
is not true.
This client lib provides the option to use a request string for shorthand calls:
const { data } = await rpc.call('procedure::scope::version')
// 2nd arg is optionally "args" passed with request
const { data } = await rpc.call('get-users::users::1', { active: true })
try {
// RPCClient.call method will throw if `success` is not `true`
const { code, data } = await rpc.call({ ... })
} catch (callResponse) {
console.log(callResponse.code) // number
console.log(callResponse.message) // message
console.log(callResponse.success) // false
}
The RPC server implementation accepts a property with all RPC calls identity
that contains information about the client's authentication info.
The identity
property schema:
{
authorization: string
deviceName?: string
metadata?: { [string]: any }
}
The client library implementation is responsible for sending the identity
property with RPC's to the back-end. The identity
information can be set with the client like this:
rpcClient.setIdentity({ authorization: 'jwt-token-string' })
Once the RPC client instance identity is set, it will be maintained in-memory until explicitly changed.
When the client lib sends a RPC request over HTTP, the RPC will always include the identity
property when the back-end requires authentication/authorization for the specific procedure.
When the client lib makes a connection with the remote, the RPC client lib will immediately send the identity
information to the remote and can expect the remote to maintain it's identity
information as long as the WebSocket connection remains alive. The identity
information will be sent everytime a new WebSocket connection is opened with the remote.
const rpc = new RPCClient({
cacheMaxAgeMs: 5 * 60 * 1000, // optional
deadlineMs: 5000, // optional
hosts: {
http: 'localhost:3995/rpc',
},
})
const rpc = new RPCClient({
hosts: {
http: 'localhost:3995/rpc',
},
requestInterceptor: (request) => {
request.args.count = request.args.count + 1
return request
},
})
const { data } = await rpc.call({
args: { count: 1 },
procedure: 'intercept-request',
})
console.log(data.count) // => 2
const rpc = new RPCClient({
hosts: {
http: 'localhost:3995/rpc',
},
responseInterceptor: (response) => {
response.data.count = 100
return response
},
})
const { data } = await rpc.call({
args: { count: 1 },
procedure: 'intercept-request',
})
console.log(data.count) // => 100
First, setup a custom Transport
:
see the required interface in
src/client/Transports/Transport.ts
class CustomHTTPTransport {
isConnected() {
return true
}
name: 'CustomHTTPTransport'
async sendRequest(call) {
const response = await fetch('localhost:3901/rpc', {
data: call,
}).then((res) => res.json())
return response
}
setIdentity(identity) {
this.identity = identity
}
}
Then, use the CustomHTTPTransport
when you create a client instance:
const rpc = new RPCClient({
cacheMaxAgeMs: 5 * 60 * 1000, // optional
deadlineMs: 5000, // optional
transports: {
http: new CustomHTTPTransport(),
},
})
FAQs
RPC framework, browser client lib
The npm package @therms/rpc-client receives a total of 35 weekly downloads. As such, @therms/rpc-client popularity was classified as not popular.
We found that @therms/rpc-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.