Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Files
.claude/
.vscode
.idea
.DS_Store
Expand All @@ -23,6 +24,7 @@ logs
*.tgz
.npmrc

dist/**
smoke/package.json
smoke/pnpm-lock.yaml
smoke/react/package.json
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ scripts/
**/.esm-cache/**
**/dist/**
**/coverage/**
dist/
4 changes: 3 additions & 1 deletion cli/build-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,13 @@ export function buildCmd(sthis: SuperThis) {
// await $`env | grep -e npm_config -e NPM_CONFIG -e PNPM_CONFIG`;
}
const tags = args.pubTags;
console.log("version ---- ", args.version);
try {
const semVer = new SemVer(args.version);
if (semVer.prerelease.find((i) => typeof i === "string" && i.includes("dev"))) {
if (semVer.prerelease.find((i) => typeof i === "string")) {
tags.push("dev");
}
console.log("version ---- ", args.version, semVer, tags);
} catch (e) {
console.warn(`Warn parsing version ${args.version}:`, e);
}
Expand Down
12 changes: 7 additions & 5 deletions cli/tsc-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ export async function handleTsc(args: string[], sthis: SuperThis) {
$.quote = quotePowerShell;
}

$.verbose = false;
const p = $({ stdio: ["inherit", "inherit", "inherit"] })`${cmd}`;
await p;
// $.verbose = true;
// await $`${cmd}`
try {
$.verbose = false;
const p = $({ stdio: ["inherit", "inherit", "inherit"] })`${cmd}`;
await p;
} catch (e) {
process.exit((e as { exitCode?: number }).exitCode ?? 42);
}
}

export function tscCmd(sthis: SuperThis) {
Expand Down
2 changes: 2 additions & 0 deletions cloud/3rd-party/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
},
"dependencies": {
"@adviser/cement": "^0.4.63",
"preact": "^10.27.2",
"preact-render-to-string": "^6.6.2",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"use-fireproof": "workspace:0.0.0"
Expand Down
15 changes: 5 additions & 10 deletions cloud/3rd-party/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { DocWithId, useFireproof, toCloud, RedirectStrategy } from "use-fireproof";
import { DocWithId, useFireproof, toCloud, FPCloudConnectStrategy } from "use-fireproof";
import React, { useState, useEffect } from "react";
import "./App.css";
// import { overlayHtml } from "./overlayHtml.js";
// import { URI } from "@adviser/cement";

function App() {
const { database, attach } = useFireproof("fireproof-5-party", {
attach: toCloud({
strategy: new RedirectStrategy({
strategy: FPCloudConnectStrategy({
// overlayCss: defaultOverlayCss,
overlayHtml: (url: string) => `<div class="fpOverlayContent">
<div class="fpCloseButton">&times;</div>
Fireproof Dashboard<br />
Sign in to Fireproof Dashboard
<a href="${url}" target="_blank">Redirect to Fireproof</a>
</div>`,
// overlayHtml,
// dashboardURI: "http://localhost:7370/fp/cloud/api/token",
}),
// dashboardURI: "http://localhost:7370/fp/cloud/api/token",
// tokenApiURI: "http://localhost:7370/api",
// urls: { base: "fpcloud://localhost:8787?protocol=ws" },
// tenant: "3rd-party",
// ledger: "vibes",
Expand Down
1 change: 1 addition & 0 deletions cloud/3rd-party/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createRoot } from "react-dom/client";
import "./index.css";
import App from "./App.jsx";

console.log("i'm in main.tsx");
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
createRoot(document.getElementById("root")!).render(
<StrictMode>
Expand Down
22 changes: 22 additions & 0 deletions cloud/3rd-party/src/overlayHtml.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { jsx } from "use-fireproof";

const { renderToString, React } = jsx;

// function jsxDEV(...args: unknown[]) {
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// return (React as any).call(React, ...args)
// }
export function overlayHtml(url: string) {
// return renderToString(h("div", {}))
return renderToString(
<div className="fpOverlayContent">
<div className="fpCloseButton">&times;</div>
Fireproof Dashboard
<br />
Sign in to Fireproof Dashboard
<a href={url} target="_blank">
Redirect to Fireproof
</a>
</div>,
);
}
5 changes: 1 addition & 4 deletions cloud/3rd-party/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"jsx": "react",
"esModuleInterop": true,
"types": ["react"]
"outDir": "./dist"
}
}
10 changes: 9 additions & 1 deletion cloud/3rd-party/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
plugins: [react()],
plugins: [
react({
jsxRuntime: "classic", // Use classic instead of automatic
}),
],
build: {
sourcemap: true,
target: "esnext",
Expand All @@ -13,6 +17,10 @@ export default defineConfig({
external: [".dev.vars"],
},
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
// This makes Vite try .ts if .js doesn't exist
},
server: {
port: 3001,
hmr: true,
Expand Down
3 changes: 1 addition & 2 deletions cloud/backend/base/ws-sockets.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { sleep } from "@fireproof/core-runtime";
import * as ps from "@fireproof/core-types-protocols-cloud";
import { Msger } from "@fireproof/core-protocols-cloud";
import { testSuperThis } from "@fireproof/cloud-base";
import { Future, URI } from "@adviser/cement";
import { Future, URI, sleep } from "@adviser/cement";
import { describe, beforeAll, afterAll, it, expect, assert } from "vitest";
import { mockJWK, MockJWK } from "./test-helper.js";

Expand Down
40 changes: 40 additions & 0 deletions cloud/connector/base/convert-to-token-and-claims.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Logger, exception2Result, Result } from "@adviser/cement";
import { FPCloudClaim, FPCloudClaimSchema } from "@fireproof/core-types-protocols-cloud";
import { jwtVerify } from "jose";
import { JWKPublic } from "@fireproof/core-types-base";

export interface TokenAndClaims {
readonly token: string;
readonly claims: FPCloudClaim;
}
export async function convertToTokenAndClaims(
dashApi: {
getClerkPublishableKey(): Promise<{ cloudPublicKeys: JWKPublic[] }>;
},
logger: Logger,
token: string,
): Promise<Result<TokenAndClaims>> {
for (const jwkPublic of await dashApi.getClerkPublishableKey().then((r) => r.cloudPublicKeys)) {
const rUnknownClaims = await exception2Result(() => jwtVerify(token, jwkPublic));
if (rUnknownClaims.isErr() || !rUnknownClaims.Ok()?.payload) {
logger
.Warn()
.Err(rUnknownClaims)
.Any({
kid: jwkPublic.kid,
})
.Msg("Token failed");
continue;
}
const rFPCloudClaim = FPCloudClaimSchema.safeParse(rUnknownClaims.Ok().payload);
if (!rFPCloudClaim.success) {
logger.Warn().Err(rFPCloudClaim.error).Any({ inObj: rUnknownClaims.Ok().payload }).Msg("Token claims validation failed");
continue;
}
return Result.Ok({
token,
claims: rFPCloudClaim.data,
});
}
return Result.Err("No valid JWK found to verify token");
}
Loading