@opendatalabs/personal-server-ts-server 0.0.1-canary.ff73228 → 0.0.1-canary.ff9b698

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.
@@ -1,26 +1,8 @@
1
- import type { SchemaRegistrarPort } from "@opendatalabs/personal-server-ts-core/ports";
2
- import type { ServerSigner } from "@opendatalabs/personal-server-ts-core/signing";
3
- import type { Logger } from "pino";
4
1
  /**
5
- * Definition used for scopes that carry unstructured/binary data. Nothing in
6
- * this stack fetches the definitionUrl it only needs to be a stable string —
7
- * but consuming builders may dereference it, so it points at a permissive doc.
2
+ * The no-schema registrar now lives in core so the in-browser PS-Lite runtime
3
+ * can register schemas for binary uploads too (see
4
+ * `packages/core/src/api/schema-registrar.ts`). Re-exported here for backwards
5
+ * compatibility with existing server imports.
8
6
  */
9
- export declare const NO_SCHEMA_NAME = "No Schema";
10
- export declare const NO_SCHEMA_DEFINITION_URL = "https://schemas.vana.org/no-schema/v1.json";
11
- export declare const NO_SCHEMA_DIALECT = "none";
12
- export interface SchemaRegistrarDeps {
13
- gatewayUrl: string;
14
- signer: ServerSigner;
15
- logger?: Logger;
16
- }
17
- /**
18
- * Registers (idempotently, by scope) a permissive "no-schema" schema with the
19
- * gateway via POST /v1/schemas, signing an EIP-712 SchemaRegistration message.
20
- *
21
- * The gateway requires the EIP-712 signer to equal the registered ownerAddress
22
- * (no server-delegation branch for schemas), so the schema is owned by the
23
- * server signing account.
24
- */
25
- export declare function createSchemaRegistrar(deps: SchemaRegistrarDeps): SchemaRegistrarPort;
7
+ export { createSchemaRegistrar, NO_SCHEMA_DEFINITION_URL, NO_SCHEMA_DIALECT, NO_SCHEMA_NAME, type SchemaRegistrarDeps, } from "@opendatalabs/personal-server-ts-core/api";
26
8
  //# sourceMappingURL=schema-registrar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-registrar.d.ts","sourceRoot":"","sources":["../src/schema-registrar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,cAAc,cAAc,CAAC;AAC1C,eAAO,MAAM,wBAAwB,+CACS,CAAC;AAC/C,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAExC,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAoBD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,mBAAmB,GACxB,mBAAmB,CA8CrB"}
1
+ {"version":3,"file":"schema-registrar.d.ts","sourceRoot":"","sources":["../src/schema-registrar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,KAAK,mBAAmB,GACzB,MAAM,2CAA2C,CAAC"}
@@ -1,61 +1,8 @@
1
1
  /**
2
- * Definition used for scopes that carry unstructured/binary data. Nothing in
3
- * this stack fetches the definitionUrl it only needs to be a stable string —
4
- * but consuming builders may dereference it, so it points at a permissive doc.
2
+ * The no-schema registrar now lives in core so the in-browser PS-Lite runtime
3
+ * can register schemas for binary uploads too (see
4
+ * `packages/core/src/api/schema-registrar.ts`). Re-exported here for backwards
5
+ * compatibility with existing server imports.
5
6
  */
6
- export const NO_SCHEMA_NAME = "No Schema";
7
- export const NO_SCHEMA_DEFINITION_URL = "https://schemas.vana.org/no-schema/v1.json";
8
- export const NO_SCHEMA_DIALECT = "none";
9
- function extractSchemaId(body) {
10
- return (body.schemaId ??
11
- body.id ??
12
- body.data?.schemaId ??
13
- body.data?.id ??
14
- undefined);
15
- }
16
- /**
17
- * Registers (idempotently, by scope) a permissive "no-schema" schema with the
18
- * gateway via POST /v1/schemas, signing an EIP-712 SchemaRegistration message.
19
- *
20
- * The gateway requires the EIP-712 signer to equal the registered ownerAddress
21
- * (no server-delegation branch for schemas), so the schema is owned by the
22
- * server signing account.
23
- */
24
- export function createSchemaRegistrar(deps) {
25
- const base = deps.gatewayUrl.replace(/\/+$/, "");
26
- return {
27
- async registerNoSchema(scope) {
28
- const ownerAddress = deps.signer.address;
29
- const message = {
30
- ownerAddress,
31
- name: NO_SCHEMA_NAME,
32
- definitionUrl: NO_SCHEMA_DEFINITION_URL,
33
- scope,
34
- dialect: NO_SCHEMA_DIALECT,
35
- };
36
- const signature = await deps.signer.signSchemaRegistration(message);
37
- const res = await fetch(`${base}/v1/schemas`, {
38
- method: "POST",
39
- headers: {
40
- "Content-Type": "application/json",
41
- Authorization: `Web3Signed ${signature}`,
42
- },
43
- body: JSON.stringify(message),
44
- });
45
- if (!res.ok) {
46
- const detail = await res.text().catch(() => res.statusText);
47
- throw new Error(`Schema registration failed: ${res.status} ${detail}`);
48
- }
49
- const body = (await res
50
- .json()
51
- .catch(() => ({})));
52
- const schemaId = extractSchemaId(body);
53
- if (!schemaId) {
54
- throw new Error(`Schema registration for "${scope}" did not return a schemaId`);
55
- }
56
- deps.logger?.info({ scope, schemaId }, "Registered no-schema schema with gateway");
57
- return { schemaId, definitionUrl: NO_SCHEMA_DEFINITION_URL };
58
- },
59
- };
60
- }
7
+ export { createSchemaRegistrar, NO_SCHEMA_DEFINITION_URL, NO_SCHEMA_DIALECT, NO_SCHEMA_NAME, } from "@opendatalabs/personal-server-ts-core/api";
61
8
  //# sourceMappingURL=schema-registrar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-registrar.js","sourceRoot":"","sources":["../src/schema-registrar.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAC1C,MAAM,CAAC,MAAM,wBAAwB,GACnC,4CAA4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