Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Cloudflare, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Security Policy

https://www.cloudflare.com/disclosure

## Reporting a Vulnerability

* https://hackerone.com/cloudflare
* All Cloudflare products are in scope for reporting. If you submit a valid report on bounty-eligible assets through our disclosure program, we will transfer your report to our private bug bounty program and invite you as a participant.
* `mailto:[email protected]`
* If you'd like to encrypt your message, please do so within the the body of the message. Our email system doesn't handle PGP-MIME well.
* https://www.cloudflare.com/gpg/security-at-cloudflare-pubkey-06A67236.txt

All abuse reports should be submitted to our Trust & Safety team through our dedicated page: https://www.cloudflare.com/abuse/

4 changes: 4 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import { expect, it, describe, inject } from "vitest"
import { deserialize, serialize, RpcSession, type RpcSessionOptions, RpcTransport, RpcTarget,
RpcStub, newWebSocketRpcSession, newMessagePortRpcSession,
Expand Down
4 changes: 4 additions & 0 deletions __tests__/test-server-workerd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

// Test server implemented in workerd instead of Node.
//
// This is only used by the workerd tests, across a service binding.
Expand Down
4 changes: 4 additions & 0 deletions __tests__/test-server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

// Implements a test RPC backend server for tests to try connecting to.
//
// This is intended to be used as a vitest `globalSetup`. That means this strictly runs under Node.
Expand Down
4 changes: 4 additions & 0 deletions __tests__/test-util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

// Common RPC interfaces / implementations used in several tests.

import { RpcStub, RpcTarget } from '../src/index.js';
Expand Down
4 changes: 4 additions & 0 deletions __tests__/workerd.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

/// <reference types="@cloudflare/workers-types" />
import { expect, it, describe } from "vitest";
import { RpcStub as NativeRpcStub, RpcTarget as NativeRpcTarget, env, DurableObject } from "cloudflare:workers";
Expand Down
4 changes: 4 additions & 0 deletions src/batch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import { RpcStub } from "./core.js";
import { RpcTransport, RpcSession, RpcSessionOptions } from "./rpc.js";
import type { IncomingMessage, ServerResponse, OutgoingHttpHeader, OutgoingHttpHeaders } from "node:http";
Expand Down
4 changes: 4 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import type { RpcTargetBranded, __RPC_TARGET_BRAND } from "./types.js";

// Polyfill Symbol.dispose for browsers that don't support it yet
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import { RpcTarget as RpcTargetImpl, RpcStub as RpcStubImpl, RpcPromise as RpcPromiseImpl } from "./core.js";
import { serialize, deserialize } from "./serialize.js";
import { RpcTransport, RpcSession as RpcSessionImpl, RpcSessionOptions } from "./rpc.js";
Expand Down
4 changes: 4 additions & 0 deletions src/map.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import { StubHook, PropertyPath, RpcPayload, RpcStub, RpcPromise, withCallInterceptor, ErrorStubHook, mapImpl, PayloadStubHook, unwrapStubAndPath, unwrapStubNoProperties } from "./core.js";
import { Devaluator, Exporter, Importer, ExportId, ImportId, Evaluator } from "./serialize.js";

Expand Down
4 changes: 4 additions & 0 deletions src/messageport.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import { RpcStub } from "./core.js";
import { RpcTransport, RpcSession, RpcSessionOptions } from "./rpc.js";

Expand Down
4 changes: 4 additions & 0 deletions src/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import { StubHook, RpcPayload, RpcStub, PropertyPath, PayloadStubHook, ErrorStubHook, RpcTarget, unwrapStubAndPath } from "./core.js";
import { Devaluator, Evaluator, ExportId, ImportId, Exporter, Importer, serialize } from "./serialize.js";

Expand Down
4 changes: 4 additions & 0 deletions src/serialize.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import { StubHook, RpcPayload, typeForRpc, RpcStub, RpcPromise, LocatedPromise, RpcTarget, PropertyPath, unwrapStubAndPath } from "./core.js";

export type ImportId = number;
Expand Down
4 changes: 4 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

// This file borrows heavily from `types/defines/rpc.d.ts` in workerd.

// Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
Expand Down
4 changes: 4 additions & 0 deletions src/websocket.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

/// <reference types="@cloudflare/workers-types" />

import { RpcStub } from "./core.js";
Expand Down
4 changes: 4 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import { defineConfig } from 'tsup'

export default defineConfig({
Expand Down
4 changes: 4 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down
4 changes: 4 additions & 0 deletions vitest.shims.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2025 Cloudflare, Inc.
// Licensed under the MIT license found in the LICENSE.txt file or at:
// https://opensource.org/license/mit

declare module 'vitest' {
export interface ProvidedContext {
testServerHost: string
Expand Down