diff --git a/apps/cic-meta/.gitignore b/apps/cic-meta/.gitignore index 666bea4..1a6cc5b 100644 --- a/apps/cic-meta/.gitignore +++ b/apps/cic-meta/.gitignore @@ -1,5 +1,6 @@ node_modules dist dist-web +dist-server scratch tests diff --git a/apps/cic-meta/scripts/server/server.ts b/apps/cic-meta/scripts/server/server.ts index 5840f0f..ca9c2df 100755 --- a/apps/cic-meta/scripts/server/server.ts +++ b/apps/cic-meta/scripts/server/server.ts @@ -101,6 +101,18 @@ function parseDigest(url) { async function processRequest(req, res) { let digest = undefined; + const headers = { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "OPTIONS, POST, GET, PUT", + "Access-Control-Max-Age": 2592000, // 30 days + "Access-Control-Allow-Headers": 'Access-Control-Allow-Origin, Content-Type, x-cic-automerge' + }; + + if (req.method === "OPTIONS") { + res.writeHead(200, headers); + res.end(); + return; + } if (!['PUT', 'GET', 'POST'].includes(req.method)) { res.writeHead(405, {"Content-Type": "text/plain"}); @@ -201,6 +213,7 @@ async function processRequest(req, res) { const responseContentLength = (new TextEncoder().encode(content)).length; res.writeHead(200, { + "Access-Control-Allow-Origin": "*", "Content-Type": contentType, "Content-Length": responseContentLength, }); diff --git a/apps/cic-meta/src/index.ts b/apps/cic-meta/src/index.ts index 4ab9250..415a3b5 100644 --- a/apps/cic-meta/src/index.ts +++ b/apps/cic-meta/src/index.ts @@ -1,4 +1,4 @@ -export { PGPSigner, PGPKeyStore } from './auth'; +export { PGPSigner, PGPKeyStore, Signer } from './auth'; export { Envelope, Syncable } from './sync'; export { User } from './assets/user'; export { Phone } from './assets/phone'; diff --git a/apps/cic-meta/src/sync.ts b/apps/cic-meta/src/sync.ts index 7be4208..21dcf87 100644 --- a/apps/cic-meta/src/sync.ts +++ b/apps/cic-meta/src/sync.ts @@ -93,7 +93,7 @@ function orderDict(src) { return dst; } -class Syncable implements JSONSerializable, Authoritative { +class Syncable implements JSONSerializable, Authoritative, Signable { id: string timestamp: number