@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.
- package/dist/schema-registrar.d.ts +5 -23
- package/dist/schema-registrar.d.ts.map +1 -1
- package/dist/schema-registrar.js +5 -58
- package/dist/schema-registrar.js.map +1 -1
- package/dist/ui/ps-lite-debug.js +2598 -1805
- package/package.json +3 -3
|
@@ -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
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
|
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
|
|
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"}
|
package/dist/schema-registrar.js
CHANGED
|
@@ -1,61 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
|
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":"
|
|
1
|
+
{"version":3,"file":"schema-registrar.js","sourceRoot":"","sources":["../src/schema-registrar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,GAEf,MAAM,2CAA2C,CAAC"}
|