@nextera.one/tps-standard 0.5.33 → 0.5.34
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/date.d.ts +54 -0
- package/dist/date.js +174 -0
- package/dist/date.js.map +1 -0
- package/dist/drivers/gregorian.d.ts +3 -5
- package/dist/drivers/gregorian.js +26 -19
- package/dist/drivers/gregorian.js.map +1 -1
- package/dist/drivers/hijri.d.ts +1 -16
- package/dist/drivers/hijri.js +9 -102
- package/dist/drivers/hijri.js.map +1 -1
- package/dist/drivers/holocene.d.ts +6 -3
- package/dist/drivers/holocene.js +7 -20
- package/dist/drivers/holocene.js.map +1 -1
- package/dist/drivers/julian.d.ts +3 -10
- package/dist/drivers/julian.js +11 -71
- package/dist/drivers/julian.js.map +1 -1
- package/dist/drivers/persian.d.ts +1 -6
- package/dist/drivers/persian.js +17 -92
- package/dist/drivers/persian.js.map +1 -1
- package/dist/drivers/tps.d.ts +11 -28
- package/dist/drivers/tps.js +8 -58
- package/dist/drivers/tps.js.map +1 -1
- package/dist/drivers/unix.d.ts +5 -6
- package/dist/drivers/unix.js +10 -32
- package/dist/drivers/unix.js.map +1 -1
- package/dist/index.d.ts +6 -477
- package/dist/index.js +33 -978
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +85 -0
- package/dist/types.js +30 -0
- package/dist/types.js.map +1 -0
- package/dist/uid.d.ts +48 -0
- package/dist/uid.js +225 -0
- package/dist/uid.js.map +1 -0
- package/dist/utils/calendar.d.ts +55 -0
- package/dist/utils/calendar.js +136 -0
- package/dist/utils/calendar.js.map +1 -0
- package/dist/utils/env.d.ts +12 -0
- package/dist/utils/env.js +79 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/tps-string.d.ts +12 -0
- package/dist/utils/tps-string.js +164 -0
- package/dist/utils/tps-string.js.map +1 -0
- package/package.json +1 -1
- package/src/date.ts +243 -0
- package/src/drivers/gregorian.ts +29 -27
- package/src/drivers/hijri.ts +13 -113
- package/src/drivers/holocene.ts +11 -12
- package/src/drivers/julian.ts +18 -72
- package/src/drivers/persian.ts +25 -92
- package/src/drivers/tps.ts +16 -55
- package/src/drivers/unix.ts +12 -33
- package/src/index.ts +18 -1446
- package/src/types.ts +107 -0
- package/src/uid.ts +308 -0
- package/src/utils/calendar.ts +161 -0
- package/src/utils/env.ts +88 -0
- package/src/utils/tps-string.ts +166 -0
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* TPS: Temporal Positioning System
|
|
3
3
|
* The Universal Protocol for Space-Time Coordinates.
|
|
4
4
|
* @packageDocumentation
|
|
5
|
-
* @version 0.5.
|
|
5
|
+
* @version 0.5.34
|
|
6
6
|
* @license Apache-2.0
|
|
7
7
|
* @copyright 2026 TPS Standards Working Group
|
|
8
8
|
*
|
|
@@ -12,225 +12,11 @@
|
|
|
12
12
|
* - Added structural anchors (bldg, floor, room, zone)
|
|
13
13
|
* - Added geospatial cell systems (S2, H3, Plus Code, what3words)
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly JUL: "jul";
|
|
21
|
-
readonly HOLO: "holo";
|
|
22
|
-
readonly UNIX: "unix";
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Specifies the direction of the time-component hierarchy when serializing or
|
|
26
|
-
* deserializing a TPS string. The default is `'descending'` (millennium → … →
|
|
27
|
-
* second), but `'ascending'` produces the reverse order.
|
|
28
|
-
*/
|
|
29
|
-
export declare enum TimeOrder {
|
|
30
|
-
DESC = "desc",
|
|
31
|
-
ASC = "asc"
|
|
32
|
-
}
|
|
33
|
-
export interface TPSComponents {
|
|
34
|
-
calendar: string;
|
|
35
|
-
millennium: number;
|
|
36
|
-
century: number;
|
|
37
|
-
year: number;
|
|
38
|
-
month: number;
|
|
39
|
-
day: number;
|
|
40
|
-
hour: number;
|
|
41
|
-
minute: number;
|
|
42
|
-
second: number;
|
|
43
|
-
/** Sub-second precision (0–999). Encoded as the last `m` token. */
|
|
44
|
-
millisecond: number;
|
|
45
|
-
unixSeconds?: number;
|
|
46
|
-
latitude?: number;
|
|
47
|
-
longitude?: number;
|
|
48
|
-
altitude?: number;
|
|
49
|
-
/** Google S2 cell ID (hierarchical, prefix-searchable) */
|
|
50
|
-
s2Cell?: string;
|
|
51
|
-
/** Uber H3 cell ID (hexagonal grid) */
|
|
52
|
-
h3Cell?: string;
|
|
53
|
-
/** Open Location Code / Plus Code */
|
|
54
|
-
plusCode?: string;
|
|
55
|
-
/** what3words address (e.g. "filled.count.soap") */
|
|
56
|
-
what3words?: string;
|
|
57
|
-
/** Physical building identifier */
|
|
58
|
-
building?: string;
|
|
59
|
-
/** Vertical division (level) */
|
|
60
|
-
floor?: string;
|
|
61
|
-
/** Enclosed space identifier */
|
|
62
|
-
room?: string;
|
|
63
|
-
/** Logical area within building */
|
|
64
|
-
zone?: string;
|
|
65
|
-
/** Raw pre-@ space anchor (e.g. adm:city:SA:riyadh, node:api-1, net:ip4:203.0.113.10) */
|
|
66
|
-
spaceAnchor?: string;
|
|
67
|
-
/** Technical missing data (e.g. server log without GPS) */
|
|
68
|
-
isUnknownLocation?: boolean;
|
|
69
|
-
/** Removed for legal/security reasons (e.g. GDPR) */
|
|
70
|
-
isRedactedLocation?: boolean;
|
|
71
|
-
/** Masked by user preference (e.g. "Don't show my location") */
|
|
72
|
-
isHiddenLocation?: boolean;
|
|
73
|
-
/** Actor anchor - identifies observer/witness (e.g. "did:web:sensor.example.com", "node:gateway-01") */
|
|
74
|
-
actor?: string;
|
|
75
|
-
/** Verification hash appended to time (e.g. "sha256:8f3e2a...") */
|
|
76
|
-
signature?: string;
|
|
77
|
-
extensions?: Record<string, string>;
|
|
78
|
-
order?: TimeOrder;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Interface for Calendar Driver plugins.
|
|
82
|
-
* Implementations provide conversion logic to/from Gregorian and support for
|
|
83
|
-
* external calendar libraries.
|
|
84
|
-
*
|
|
85
|
-
* @example Using a driver to parse a Hijri date string
|
|
86
|
-
* ```ts
|
|
87
|
-
* const driver = TPS.getDriver('hij');
|
|
88
|
-
* if (driver?.parseDate) {
|
|
89
|
-
* const components = driver.parseDate('1447-07-21');
|
|
90
|
-
* const gregDate = driver.toGregorian(components);
|
|
91
|
-
* const tpsString = TPS.fromDate(gregDate, 'hij');
|
|
92
|
-
* }
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* @example Wrapping an external library (moment-hijri)
|
|
96
|
-
* ```ts
|
|
97
|
-
* import moment from 'moment-hijri';
|
|
98
|
-
*
|
|
99
|
-
* class HijriDriver implements CalendarDriver {
|
|
100
|
-
* readonly code = 'hij';
|
|
101
|
-
*
|
|
102
|
-
* parseDate(input: string, format?: string): Partial<TPSComponents> {
|
|
103
|
-
* const m = moment(input, format || 'iYYYY-iMM-iDD');
|
|
104
|
-
* return {
|
|
105
|
-
* calendar: 'hij',
|
|
106
|
-
* year: m.iYear(),
|
|
107
|
-
* month: m.iMonth() + 1,
|
|
108
|
-
* day: m.iDate()
|
|
109
|
-
* };
|
|
110
|
-
* }
|
|
111
|
-
*
|
|
112
|
-
* fromGregorian(date: Date): Partial<TPSComponents> {
|
|
113
|
-
* const m = moment(date);
|
|
114
|
-
* return {
|
|
115
|
-
* calendar: 'hij',
|
|
116
|
-
* year: m.iYear(),
|
|
117
|
-
* month: m.iMonth() + 1,
|
|
118
|
-
* day: m.iDate(),
|
|
119
|
-
* hour: m.hour(),
|
|
120
|
-
* minute: m.minute(),
|
|
121
|
-
* second: m.second()
|
|
122
|
-
* };
|
|
123
|
-
* }
|
|
124
|
-
*
|
|
125
|
-
* // ... other methods
|
|
126
|
-
* }
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
export interface CalendarDriver {
|
|
130
|
-
/** The calendar code this driver handles (e.g., 'hij', 'jul'). */
|
|
131
|
-
readonly code: string;
|
|
132
|
-
/**
|
|
133
|
-
* Human-readable name for this calendar (optional).
|
|
134
|
-
* @example "Hijri (Islamic)"
|
|
135
|
-
*/
|
|
136
|
-
readonly name?: string;
|
|
137
|
-
/**
|
|
138
|
-
* Converts a Date to this calendar's components.
|
|
139
|
-
* @param date - The Gregorian Date object.
|
|
140
|
-
* @returns Partial TPS components for year, month, day, etc.
|
|
141
|
-
*/
|
|
142
|
-
getComponentsFromDate(date: Date): Partial<TPSComponents>;
|
|
143
|
-
/**
|
|
144
|
-
* Converts this calendar's components to a Date.
|
|
145
|
-
* @param components - Partial TPS components (year, month, day, etc.).
|
|
146
|
-
* @returns A JavaScript Date object.
|
|
147
|
-
*/
|
|
148
|
-
getDateFromComponents(components: Partial<TPSComponents>): Date;
|
|
149
|
-
/**
|
|
150
|
-
* Generates a TPS time string for this calendar from a Date.
|
|
151
|
-
* @param date - The Gregorian Date object.
|
|
152
|
-
* @returns A TPS time string (e.g., "T:hij.y1447.m07.d21...").
|
|
153
|
-
*/
|
|
154
|
-
getFromDate(date: Date): string;
|
|
155
|
-
/**
|
|
156
|
-
* Parse a calendar-specific date string into TPS components.
|
|
157
|
-
* This allows drivers to handle native date formats from external libraries.
|
|
158
|
-
*
|
|
159
|
-
* @param input - Date string in calendar-native format (e.g., '1447-07-21' for Hijri)
|
|
160
|
-
* @param format - Optional format string (driver-specific, e.g., 'iYYYY-iMM-iDD')
|
|
161
|
-
* @returns Partial TPS components
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```ts
|
|
165
|
-
* // Hijri driver
|
|
166
|
-
* driver.parseDate('1447-07-21'); // → { year: 1447, month: 7, day: 21, calendar: 'hij' }
|
|
167
|
-
*
|
|
168
|
-
* // With time
|
|
169
|
-
* driver.parseDate('1447-07-21 14:30:00'); // → { year: 1447, month: 7, day: 21, hour: 14, ... }
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
parseDate(input: string, format?: string): Partial<TPSComponents>;
|
|
173
|
-
/**
|
|
174
|
-
* Format TPS components to a calendar-specific date string.
|
|
175
|
-
* Inverse of parseDate().
|
|
176
|
-
*
|
|
177
|
-
* @param components - TPS components to format
|
|
178
|
-
* @param format - Optional format string (driver-specific)
|
|
179
|
-
* @returns Formatted date string in calendar-native format
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```ts
|
|
183
|
-
* driver.format({ year: 1447, month: 7, day: 21 }); // → '1447-07-21'
|
|
184
|
-
* driver.format({ year: 1447, month: 7, day: 21 }, 'short'); // → '21/7/1447'
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
format(components: Partial<TPSComponents>, format?: string): string;
|
|
188
|
-
/**
|
|
189
|
-
* Validate a calendar-specific date string or components.
|
|
190
|
-
*
|
|
191
|
-
* @param input - Date string or components to validate
|
|
192
|
-
* @returns true if valid for this calendar
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* ```ts
|
|
196
|
-
* driver.validate('1447-13-01'); // → false (month 13 invalid)
|
|
197
|
-
* driver.validate({ year: 1447, month: 7, day: 31 }); // → false (Rajab has 30 days)
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
validate(input: string | Partial<TPSComponents>): boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Get calendar metadata (month names, day names, etc.).
|
|
203
|
-
* Useful for UI rendering.
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* ```ts
|
|
207
|
-
* driver.getMetadata().monthNames
|
|
208
|
-
* // → ['Muharram', 'Safar', 'Rabi I', ...]
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
getMetadata(): CalendarMetadata;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Metadata about a calendar system.
|
|
215
|
-
*/
|
|
216
|
-
export interface CalendarMetadata {
|
|
217
|
-
/** Human-readable calendar name */
|
|
218
|
-
name: string;
|
|
219
|
-
/** Month names in order (1-12 or 1-13) */
|
|
220
|
-
monthNames?: string[];
|
|
221
|
-
/** Short month names */
|
|
222
|
-
monthNamesShort?: string[];
|
|
223
|
-
/** Day of week names (Sunday=0 or locale-specific) */
|
|
224
|
-
dayNames?: string[];
|
|
225
|
-
/** Short day names */
|
|
226
|
-
dayNamesShort?: string[];
|
|
227
|
-
/** Whether this calendar is lunar-based */
|
|
228
|
-
isLunar?: boolean;
|
|
229
|
-
/** Number of months per year */
|
|
230
|
-
monthsPerYear?: number;
|
|
231
|
-
/** Epoch year (for reference) */
|
|
232
|
-
epochYear?: number;
|
|
233
|
-
}
|
|
15
|
+
export * from "./types";
|
|
16
|
+
export * from "./uid";
|
|
17
|
+
export * from "./date";
|
|
18
|
+
export { Env } from "./utils/env";
|
|
19
|
+
import { CalendarDriver, TPSComponents, TimeOrder } from "./types";
|
|
234
20
|
export declare class TPS {
|
|
235
21
|
private static readonly drivers;
|
|
236
22
|
/**
|
|
@@ -358,217 +144,8 @@ export declare class TPS {
|
|
|
358
144
|
* ```
|
|
359
145
|
*/
|
|
360
146
|
static formatCalendarDate(calendar: string, components: Partial<TPSComponents>, format?: string): string;
|
|
361
|
-
/**
|
|
362
|
-
* Generate the canonical `T:` time string for a set of components. The
|
|
363
|
-
* `order` field (or `comp.order`) controls whether tokens are emitted in
|
|
364
|
-
* ascending or descending hierarchy; if undefined the default
|
|
365
|
-
* `'descending'` orientation is used.
|
|
366
|
-
*
|
|
367
|
-
* Drivers may ignore this helper and produce their own time strings if they
|
|
368
|
-
* implement custom ordering logic.
|
|
369
|
-
*/
|
|
370
|
-
static buildTimePart(comp: TPSComponents): string;
|
|
371
|
-
/**
|
|
372
|
-
* Parse the *time* portion of a TPS string (optionally beginning with
|
|
373
|
-
* `T:`) into components and determine the component ordering. This helper
|
|
374
|
-
* accepts tokens in **any** sequence and will return an `order` value of
|
|
375
|
-
* `'ascending'` or `'descending'`.
|
|
376
|
-
*
|
|
377
|
-
* The caller is responsible for stripping off a leading signature or other
|
|
378
|
-
* trailer characters; this method will drop anything after `!`, `;`, `?` or
|
|
379
|
-
* `#`.
|
|
380
|
-
*
|
|
381
|
-
* ### `m`-token disambiguation
|
|
382
|
-
* All four of millennium (rank 8), month (rank 5), minute (rank 2) and
|
|
383
|
-
* millisecond (rank 0) share the single-character prefix `m`. They are told
|
|
384
|
-
* apart by their **position relative to the neighbouring tokens**. The
|
|
385
|
-
* algorithm is:
|
|
386
|
-
*
|
|
387
|
-
* 1. Pre-scan the non-`m` tokens (c, y, d, h, s) whose ranks are fixed to
|
|
388
|
-
* determine whether the string is ascending or descending.
|
|
389
|
-
* 2. While iterating, track `lastAssignedRank` – the rank of the most
|
|
390
|
-
* recently processed token (m or non-m).
|
|
391
|
-
* 3. When an `m` token is encountered, derive its rank from `lastAssignedRank`
|
|
392
|
-
* and the detected order:
|
|
393
|
-
* - **DESC** null → 8 (mill) | rank > 5 → 5 (month) | rank > 2 → 2 (min) | else → 0 (ms)
|
|
394
|
-
* - **ASC** null → 0 (ms) | rank < 2 → 2 (min) | rank < 5 → 5 (month) | else → 8 (mill)
|
|
395
|
-
*
|
|
396
|
-
* @param input - Time fragment (e.g. `"T:greg.m3.c1.y26"` or `"greg.m0.s25.m30"`)
|
|
397
|
-
*/
|
|
398
|
-
static parseTimeString(input: string): {
|
|
399
|
-
components: Partial<TPSComponents>;
|
|
400
|
-
order: TimeOrder;
|
|
401
|
-
} | null;
|
|
402
147
|
private static _mapGroupsToComponents;
|
|
403
148
|
}
|
|
404
|
-
/**
|
|
405
|
-
* Decoded result from TPSUID7RB binary format.
|
|
406
|
-
*/
|
|
407
|
-
export type TPSUID7RBDecodeResult = {
|
|
408
|
-
/** Version identifier */
|
|
409
|
-
version: "tpsuid7rb";
|
|
410
|
-
/** Epoch milliseconds (UTC) */
|
|
411
|
-
epochMs: number;
|
|
412
|
-
/** Whether the TPS payload was compressed */
|
|
413
|
-
compressed: boolean;
|
|
414
|
-
/** 32-bit nonce for collision prevention */
|
|
415
|
-
nonce: number;
|
|
416
|
-
/** The original TPS string (exact reconstruction) */
|
|
417
|
-
tps: string;
|
|
418
|
-
};
|
|
419
|
-
/**
|
|
420
|
-
* Encoding options for TPSUID7RB.
|
|
421
|
-
*/
|
|
422
|
-
export type TPSUID7RBEncodeOptions = {
|
|
423
|
-
/** Enable zlib compression of TPS payload */
|
|
424
|
-
compress?: boolean;
|
|
425
|
-
/** Override epoch milliseconds (default: parsed from TPS) */
|
|
426
|
-
epochMs?: number;
|
|
427
|
-
};
|
|
428
|
-
/**
|
|
429
|
-
* TPS-UID v1 — Temporal Positioning System Identifier (Binary Reversible)
|
|
430
|
-
*
|
|
431
|
-
* A time-first, reversible identifier that binds an event to a TPS coordinate.
|
|
432
|
-
* Unlike UUIDs, TPS-UID identifies events in spacetime and allows exact
|
|
433
|
-
* reconstruction of the original TPS string.
|
|
434
|
-
*
|
|
435
|
-
* Binary Schema (all integers big-endian):
|
|
436
|
-
* ```
|
|
437
|
-
* MAGIC 4 bytes "TPU7"
|
|
438
|
-
* VER 1 byte 0x01
|
|
439
|
-
* FLAGS 1 byte bit0 = compression flag
|
|
440
|
-
* TIME 6 bytes epoch_ms (48-bit unsigned)
|
|
441
|
-
* NONCE 4 bytes 32-bit random
|
|
442
|
-
* LEN varint length of TPS payload
|
|
443
|
-
* TPS bytes UTF-8 TPS string (raw or zlib-compressed)
|
|
444
|
-
* ```
|
|
445
|
-
*
|
|
446
|
-
* @example
|
|
447
|
-
* ```ts
|
|
448
|
-
* const tps = 'tps://31.95,35.91@T:greg.m3.c1.y26.m01.d09';
|
|
449
|
-
*
|
|
450
|
-
* // Encode to binary
|
|
451
|
-
* const bytes = TPSUID7RB.encodeBinary(tps);
|
|
452
|
-
*
|
|
453
|
-
* // Encode to base64url string
|
|
454
|
-
* const id = TPSUID7RB.encodeBinaryB64(tps);
|
|
455
|
-
* // → "tpsuid7rb_AFRQV..."
|
|
456
|
-
*
|
|
457
|
-
* // Decode back to original TPS
|
|
458
|
-
* const decoded = TPSUID7RB.decodeBinaryB64(id);
|
|
459
|
-
* console.log(decoded.tps); // exact original TPS
|
|
460
|
-
* ```
|
|
461
|
-
*/
|
|
462
|
-
export declare class TPSUID7RB {
|
|
463
|
-
/** Magic bytes: "TPU7" */
|
|
464
|
-
private static readonly MAGIC;
|
|
465
|
-
/** Version 1 */
|
|
466
|
-
private static readonly VER;
|
|
467
|
-
/** String prefix for base64url encoded form */
|
|
468
|
-
private static readonly PREFIX;
|
|
469
|
-
/** Regex for validating base64url encoded form */
|
|
470
|
-
static readonly REGEX: RegExp;
|
|
471
|
-
/**
|
|
472
|
-
* Encode TPS string to binary bytes (Uint8Array).
|
|
473
|
-
* This is the canonical form for hashing, signing, and storage.
|
|
474
|
-
*
|
|
475
|
-
* @param tps - The TPS string to encode
|
|
476
|
-
* @param opts - Encoding options (compress, epochMs override)
|
|
477
|
-
* @returns Binary TPS-UID as Uint8Array
|
|
478
|
-
*/
|
|
479
|
-
static encodeBinary(tps: string, opts?: TPSUID7RBEncodeOptions): Uint8Array;
|
|
480
|
-
/**
|
|
481
|
-
* Decode binary bytes back to original TPS string.
|
|
482
|
-
*
|
|
483
|
-
* @param bytes - Binary TPS-UID
|
|
484
|
-
* @returns Decoded result with original TPS string
|
|
485
|
-
*/
|
|
486
|
-
static decodeBinary(bytes: Uint8Array): TPSUID7RBDecodeResult;
|
|
487
|
-
/**
|
|
488
|
-
* Encode TPS to base64url string with prefix.
|
|
489
|
-
* This is the transport/storage form.
|
|
490
|
-
*
|
|
491
|
-
* @param tps - The TPS string to encode
|
|
492
|
-
* @param opts - Encoding options
|
|
493
|
-
* @returns Base64url encoded TPS-UID with prefix
|
|
494
|
-
*/
|
|
495
|
-
static encodeBinaryB64(tps: string, opts?: TPSUID7RBEncodeOptions): string;
|
|
496
|
-
/**
|
|
497
|
-
* Decode base64url string back to original TPS string.
|
|
498
|
-
*
|
|
499
|
-
* @param id - Base64url encoded TPS-UID with prefix
|
|
500
|
-
* @returns Decoded result with original TPS string
|
|
501
|
-
*/
|
|
502
|
-
static decodeBinaryB64(id: string): TPSUID7RBDecodeResult;
|
|
503
|
-
/**
|
|
504
|
-
* Validate base64url encoded TPS-UID format.
|
|
505
|
-
* Note: This validates shape only; binary decode is authoritative.
|
|
506
|
-
*
|
|
507
|
-
* @param id - String to validate
|
|
508
|
-
* @returns true if format is valid
|
|
509
|
-
*/
|
|
510
|
-
static validateBinaryB64(id: string): boolean;
|
|
511
|
-
/**
|
|
512
|
-
* Generate a TPS-UID from the current time and optional location.
|
|
513
|
-
*
|
|
514
|
-
* @param opts - Generation options
|
|
515
|
-
* @returns Base64url encoded TPS-UID
|
|
516
|
-
*/
|
|
517
|
-
static generate(opts?: {
|
|
518
|
-
latitude?: number;
|
|
519
|
-
longitude?: number;
|
|
520
|
-
altitude?: number;
|
|
521
|
-
compress?: boolean;
|
|
522
|
-
order?: TimeOrder;
|
|
523
|
-
}): string;
|
|
524
|
-
/**
|
|
525
|
-
* Generate a TPS string from a Date and optional location.
|
|
526
|
-
*/
|
|
527
|
-
/**
|
|
528
|
-
* Parse epoch milliseconds from a TPS string.
|
|
529
|
-
* Supports both URI format (tps://...) and time-only format (T:greg...)
|
|
530
|
-
*/
|
|
531
|
-
static epochMsFromTPSString(tps: string): number;
|
|
532
|
-
/** Write 48-bit unsigned integer (big-endian) */
|
|
533
|
-
private static writeU48;
|
|
534
|
-
/** Read 48-bit unsigned integer (big-endian) */
|
|
535
|
-
private static readU48;
|
|
536
|
-
/** Encode unsigned integer as LEB128 varint */
|
|
537
|
-
private static uvarintEncode;
|
|
538
|
-
/** Decode LEB128 varint */
|
|
539
|
-
private static uvarintDecode;
|
|
540
|
-
/** Encode bytes to base64url (no padding) */
|
|
541
|
-
private static base64UrlEncode;
|
|
542
|
-
/** Decode base64url to bytes */
|
|
543
|
-
private static base64UrlDecode;
|
|
544
|
-
/** Compress using zlib deflate raw */
|
|
545
|
-
private static deflateRaw;
|
|
546
|
-
/** Decompress using zlib inflate raw */
|
|
547
|
-
private static inflateRaw;
|
|
548
|
-
/**
|
|
549
|
-
* Seal (sign) a TPS string to create a cryptographically verifiable TPS-UID.
|
|
550
|
-
* This appends an Ed25519 signature to the binary form.
|
|
551
|
-
*
|
|
552
|
-
* @param tps - The TPS string to seal
|
|
553
|
-
* @param privateKey - Ed25519 private key (hex or buffer)
|
|
554
|
-
* @param opts - Encoding options
|
|
555
|
-
* @returns Sealed binary TPS-UID
|
|
556
|
-
*/
|
|
557
|
-
static seal(tps: string, privateKey: string | Buffer | Uint8Array, opts?: TPSUID7RBEncodeOptions): Uint8Array;
|
|
558
|
-
/**
|
|
559
|
-
* Verify a sealed TPS-UID and decode it.
|
|
560
|
-
* Throws if signature is invalid or not sealed.
|
|
561
|
-
*
|
|
562
|
-
* @param sealedBytes - The binary sealed TPS-UID
|
|
563
|
-
* @param publicKey - Ed25519 public key (hex or buffer) to verify against
|
|
564
|
-
* @returns Decoded result
|
|
565
|
-
*/
|
|
566
|
-
static verifyAndDecode(sealedBytes: Uint8Array, publicKey: string | Buffer | Uint8Array): TPSUID7RBDecodeResult;
|
|
567
|
-
private static signEd25519;
|
|
568
|
-
private static verifyEd25519;
|
|
569
|
-
/** Generate cryptographically secure random bytes */
|
|
570
|
-
private static randomBytes;
|
|
571
|
-
}
|
|
572
149
|
/**
|
|
573
150
|
* `TpsDate` is a Date-like wrapper with native TPS conversion helpers.
|
|
574
151
|
*
|
|
@@ -579,51 +156,3 @@ export declare class TPSUID7RB {
|
|
|
579
156
|
* - `new TpsDate(tpsString)`
|
|
580
157
|
* - `new TpsDate(year, monthIndex, day?, hour?, minute?, second?, ms?)`
|
|
581
158
|
*/
|
|
582
|
-
export declare class TpsDate {
|
|
583
|
-
private readonly internal;
|
|
584
|
-
private getTpsComponents;
|
|
585
|
-
private getTpsFullYear;
|
|
586
|
-
constructor();
|
|
587
|
-
constructor(value: string | number | Date | TpsDate);
|
|
588
|
-
constructor(year: number, monthIndex: number, day?: number, hours?: number, minutes?: number, seconds?: number, ms?: number);
|
|
589
|
-
private static looksLikeTPS;
|
|
590
|
-
static now(): number;
|
|
591
|
-
static parse(input: string): number;
|
|
592
|
-
static UTC(year: number, monthIndex: number, day?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
|
|
593
|
-
static fromTPS(tps: string): TpsDate;
|
|
594
|
-
toGregorianDate(): Date;
|
|
595
|
-
toDate(): Date;
|
|
596
|
-
toTPS(calendar?: string, opts?: {
|
|
597
|
-
order?: TimeOrder;
|
|
598
|
-
}): string;
|
|
599
|
-
toTPSURI(calendar?: string, opts?: {
|
|
600
|
-
order?: TimeOrder;
|
|
601
|
-
latitude?: number;
|
|
602
|
-
longitude?: number;
|
|
603
|
-
altitude?: number;
|
|
604
|
-
isUnknownLocation?: boolean;
|
|
605
|
-
isHiddenLocation?: boolean;
|
|
606
|
-
isRedactedLocation?: boolean;
|
|
607
|
-
}): string;
|
|
608
|
-
getTime(): number;
|
|
609
|
-
valueOf(): number;
|
|
610
|
-
toString(): string;
|
|
611
|
-
toISOString(): string;
|
|
612
|
-
toUTCString(): string;
|
|
613
|
-
toJSON(): string | null;
|
|
614
|
-
getFullYear(): number;
|
|
615
|
-
getUTCFullYear(): number;
|
|
616
|
-
getMonth(): number;
|
|
617
|
-
getUTCMonth(): number;
|
|
618
|
-
getDate(): number;
|
|
619
|
-
getUTCDate(): number;
|
|
620
|
-
getHours(): number;
|
|
621
|
-
getUTCHours(): number;
|
|
622
|
-
getMinutes(): number;
|
|
623
|
-
getUTCMinutes(): number;
|
|
624
|
-
getSeconds(): number;
|
|
625
|
-
getUTCSeconds(): number;
|
|
626
|
-
getMilliseconds(): number;
|
|
627
|
-
getUTCMilliseconds(): number;
|
|
628
|
-
[Symbol.toPrimitive](hint: string): string | number;
|
|
629
|
-
}
|