@totemsdk/spatial-proof 0.1.0

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.
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @totemsdk/spatial-proof — Type definitions
3
+ *
4
+ * Pure schema for geospatial relationship proofs.
5
+ *
6
+ * COORDINATE ORDER: GeoJSON order — [longitude, latitude] in decimal degrees
7
+ * (WGS84 / EPSG:4326). This is the opposite of "lat, lon". All geometry
8
+ * functions and hashes in this package assume [lon, lat].
9
+ *
10
+ * No network, no storage, no map rendering, no GIS engine dependency.
11
+ */
12
+ export type Coordinate = [number, number];
13
+ export type GeoGeometry = GeoPointGeometry | GeoLineStringGeometry | GeoPolygonGeometry | GeoMultiPolygonGeometry;
14
+ export interface GeoPointGeometry {
15
+ type: 'Point';
16
+ coordinates: Coordinate;
17
+ }
18
+ export interface GeoLineStringGeometry {
19
+ type: 'LineString';
20
+ coordinates: Coordinate[];
21
+ }
22
+ export interface GeoPolygonGeometry {
23
+ type: 'Polygon';
24
+ coordinates: Coordinate[][];
25
+ }
26
+ export interface GeoMultiPolygonGeometry {
27
+ type: 'MultiPolygon';
28
+ coordinates: Coordinate[][][];
29
+ }
30
+ /** Optional feature-type geometry that can be normalized to bbox or points. */
31
+ export type SpatialSubjectGeometry = GeoGeometry;
32
+ export interface BoundingBox {
33
+ minLon: number;
34
+ minLat: number;
35
+ maxLon: number;
36
+ maxLat: number;
37
+ }
38
+ export type SpatialObjectKind = 'site-boundary' | 'zone' | 'route' | 'scene-footprint' | 'asset-footprint' | 'restricted-area' | 'inspection-area' | 'custom';
39
+ export interface SpatialObject {
40
+ spatialId: string;
41
+ kind: SpatialObjectKind;
42
+ geometry: GeoGeometry;
43
+ crs?: 'EPSG:4326' | string;
44
+ name?: string;
45
+ metadata?: Record<string, unknown>;
46
+ }
47
+ export type SpatialRelationType = 'inside' | 'outside' | 'intersects' | 'overlaps' | 'covers' | 'covered_by' | 'within_distance' | 'near_boundary' | 'on_route' | 'entered_zone' | 'exited_zone' | 'unknown';
48
+ export interface EngineInfo {
49
+ name: string;
50
+ version: string;
51
+ algorithm: string;
52
+ }
53
+ export interface SpatialRelationClaimInputs {
54
+ /** totem:geo:<hex> hash of the subject geometry (when supplied). */
55
+ subjectGeometryHash?: string;
56
+ /** totem:geo:<hex> hash of the spatial object's geometry. */
57
+ spatialGeometryHash: string;
58
+ /** Optional subject proof ID the geometry was derived from. */
59
+ subjectProofId?: string;
60
+ /** Optional location claim ID the geometry was derived from. */
61
+ locationClaimId?: string;
62
+ /** Optional raster/scene manifest ID the geometry was derived from. */
63
+ rasterManifestId?: string;
64
+ }
65
+ export interface SpatialRelationClaimResult {
66
+ matched: boolean;
67
+ distanceM?: number;
68
+ confidenceScore?: number;
69
+ /**
70
+ * Explicit notes on approximation. Present whenever a relation was
71
+ * evaluated with an approximate algorithm (e.g. bbox-only). Honesty is
72
+ * critical — the package never silently claims exactness.
73
+ */
74
+ uncertainty?: string[];
75
+ }
76
+ export interface SpatialRelationClaim {
77
+ relationId: string;
78
+ subjectId: string;
79
+ subjectKind: string;
80
+ spatialObjectId: string;
81
+ relation: SpatialRelationType;
82
+ computedAt: number;
83
+ engine: EngineInfo;
84
+ inputs: SpatialRelationClaimInputs;
85
+ result: SpatialRelationClaimResult;
86
+ metadata?: Record<string, unknown>;
87
+ }
88
+ export interface SpatialValidationResult {
89
+ valid: boolean;
90
+ errors: string[];
91
+ warnings: string[];
92
+ }
93
+ export interface EvaluateSpatialRelationParams {
94
+ subjectId: string;
95
+ subjectKind: string;
96
+ spatialObject: SpatialObject;
97
+ relation: SpatialRelationType;
98
+ subjectGeometry?: SpatialSubjectGeometry;
99
+ /** Required for distance-based relations (within_distance, on_route, near_boundary). */
100
+ maxDistanceM?: number;
101
+ computedAt?: number;
102
+ subjectProofId?: string;
103
+ locationClaimId?: string;
104
+ rasterManifestId?: string;
105
+ metadata?: Record<string, unknown>;
106
+ }
107
+ export interface CreateSpatialProofParams {
108
+ claim: SpatialRelationClaim;
109
+ /** Full spatial object used to compute its evidence hash. */
110
+ spatialObject: SpatialObject;
111
+ /** Optional subject geometry used to add a geometry evidence ref. */
112
+ subjectGeometry?: GeoGeometry;
113
+ issuer?: string;
114
+ issuedAt?: number;
115
+ expiresAt?: number;
116
+ }
117
+ export interface SpatialProofVerifyResult {
118
+ valid: boolean;
119
+ reason?: string;
120
+ signerAddress?: string;
121
+ spatialObjectId?: string;
122
+ relationId?: string;
123
+ payloadValid?: boolean;
124
+ evidenceHashValid?: boolean;
125
+ relationIdValid?: boolean;
126
+ }
package/dist/types.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /**
3
+ * @totemsdk/spatial-proof — Type definitions
4
+ *
5
+ * Pure schema for geospatial relationship proofs.
6
+ *
7
+ * COORDINATE ORDER: GeoJSON order — [longitude, latitude] in decimal degrees
8
+ * (WGS84 / EPSG:4326). This is the opposite of "lat, lon". All geometry
9
+ * functions and hashes in this package assume [lon, lat].
10
+ *
11
+ * No network, no storage, no map rendering, no GIS engine dependency.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@totemsdk/spatial-proof",
3
+ "version": "0.1.0",
4
+ "description": "Generic spatial relationship proof primitives for Totem Edge — geometry hashes, geofence relations, route checks, and proof envelope integration",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "dependencies": {
20
+ "@totemsdk/core": "^1.2.7",
21
+ "@totemsdk/proof": "^0.1.2",
22
+ "@totemsdk/location-proof": "^0.1.0",
23
+ "@totemsdk/proofgraph": "^0.1.1"
24
+ },
25
+ "devDependencies": {
26
+ "@types/jest": "^30.0.0",
27
+ "@types/node": "^20.0.0",
28
+ "jest": "^30.4.2",
29
+ "ts-jest": "^29.0.0",
30
+ "typescript": "^7.0.2"
31
+ },
32
+ "engines": {
33
+ "node": ">=18.0.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "license": "MIT",
39
+ "author": "Totem SDK",
40
+ "homepage": "https://totem.ing",
41
+ "bugs": {
42
+ "url": "https://github.com/totem-sdk/totem-sdk/issues"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/totem-sdk/totem-sdk.git",
47
+ "directory": "packages/spatial-proof"
48
+ },
49
+ "keywords": [
50
+ "totem",
51
+ "totemsdk",
52
+ "spatial",
53
+ "geojson",
54
+ "geofence",
55
+ "proof",
56
+ "location",
57
+ "route",
58
+ "boundary",
59
+ "edge",
60
+ "autonomous-devices"
61
+ ],
62
+ "scripts": {
63
+ "build": "tsc",
64
+ "clean": "rm -rf dist",
65
+ "test": "jest"
66
+ }
67
+ }