zeus-time 0.1.3 → 0.2.2
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/LICENSE +24 -16
- package/README.md +143 -97
- package/dist/index.cjs +219 -2898
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -0
- package/dist/index.d.ts +36 -4
- package/dist/index.js +181 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -24
- package/src/api.ts +43 -0
- package/src/compat.ts +62 -0
- package/src/encode.ts +55 -0
- package/src/hash.ts +21 -0
- package/src/index.ts +23 -4
- package/src/legacy.ts +8 -38
- package/src/normalize.ts +35 -0
- package/src/types.ts +7 -0
- package/src/validation.ts +9 -20
- package/__tests__/legacy.test.ts +0 -17
- package/__tests__/timehash.enhanced.test.ts +0 -42
- package/__tests__/timehash.test.ts +0 -14
- package/__tests__/validation.test.ts +0 -17
- package/dist/conversion.d.ts +0 -13
- package/dist/execution.d.ts +0 -6
- package/dist/index.mjs +0 -2893
- package/dist/index.mjs.map +0 -1
- package/dist/legacy.d.ts +0 -11
- package/dist/timehash.d.ts +0 -6
- package/dist/utils.d.ts +0 -39
- package/dist/validation.d.ts +0 -7
- package/jest.config.js +0 -9
- package/rollup.config.ts +0 -20
- package/src/conversion.js +0 -22
- package/src/conversion.ts +0 -20
- package/src/execution.js +0 -22
- package/src/execution.ts +0 -20
- package/src/index.js +0 -20
- package/src/legacy.js +0 -42
- package/src/timehash.js +0 -19
- package/src/timehash.ts +0 -17
- package/src/utils.js +0 -87
- package/src/utils.ts +0 -85
- package/src/validation.js +0 -24
- package/tsconfig.json +0 -14
package/LICENSE
CHANGED
|
@@ -2,22 +2,6 @@
|
|
|
2
2
|
Version 2.0, January 2004
|
|
3
3
|
http://www.apache.org/licenses/
|
|
4
4
|
|
|
5
|
-
Copyright 2025 Drew Gardiner aka o0CroMag0o - TIMESync38
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
5
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
22
6
|
|
|
23
7
|
1. Definitions.
|
|
@@ -191,3 +175,27 @@
|
|
|
191
175
|
|
|
192
176
|
END OF TERMS AND CONDITIONS
|
|
193
177
|
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,155 +1,201 @@
|
|
|
1
|
-
# ZEUS
|
|
1
|
+
# ZEUS-Time
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Deterministic. Verifiable. Calm.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
ZEUS-Time is a verifiable time primitive for distributed systems. It
|
|
6
|
+
does not replace clocks. It does not guess truth. It produces
|
|
7
|
+
deterministic, cryptographically verifiable receipts of time.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
Unix time is treated as input material, not authority.
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
👉 **Epoch-Based Execution** – Set an epoch based on a ZEUS hash for synchronized execution.
|
|
11
|
-
👉 **Decentralized & Immutable** – No single point of failure; timestamp verification is trustless.
|
|
12
|
-
👉 **Backward-Compatible with UNIX** – Convert traditional UNIX time into ZEUS easily.
|
|
13
|
-
👉 **Supports Legacy Systems** – SHA-256 fallback for older systems that can't run Blake3.
|
|
14
|
-
👉 **Ideal for Web3, Smart Contracts, IoT, and Security Applications**
|
|
11
|
+
------------------------------------------------------------------------
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
## What ZEUS Is (and Is Not)
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
ZEUS provides verifiable ordering and integrity of time-based events.
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
- It proves when something happened relative to other events
|
|
18
|
+
- It does not claim civil time accuracy
|
|
19
|
+
- It does not reverse hashes
|
|
20
|
+
- It does not depend on blockchains or consensus
|
|
21
|
+
|
|
22
|
+
Think of ZEUS as a time receipt, not a clock.
|
|
23
|
+
|
|
24
|
+
------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- Deterministic time hashing using BLAKE3
|
|
29
|
+
- Stable, reproducible outputs across platforms
|
|
30
|
+
- Local-first, no network dependency
|
|
31
|
+
- Expo and React Native compatible
|
|
32
|
+
- Legacy helpers for smooth migration from 0.1.x
|
|
33
|
+
- Optional base64url or hex encoding
|
|
34
|
+
- Explicit separation between time representation and hashing
|
|
23
35
|
|
|
24
|
-
|
|
36
|
+
------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
``` sh
|
|
25
41
|
npm install zeus-time
|
|
26
42
|
```
|
|
27
43
|
|
|
28
|
-
|
|
44
|
+
or
|
|
45
|
+
|
|
46
|
+
``` sh
|
|
47
|
+
yarn add zeus-time
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
## Basic Usage
|
|
29
53
|
|
|
30
|
-
|
|
54
|
+
### Generate a ZEUS hash from a timestamp
|
|
31
55
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
import { generateZeusHash } from "zeus-time";
|
|
56
|
+
``` ts
|
|
57
|
+
import { zeusHash } from "zeus-time";
|
|
35
58
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const hash = await generateZeusHash(timestamp);
|
|
39
|
-
console.log(`ZEUS Time Hash: ${hash}`);
|
|
40
|
-
}
|
|
59
|
+
const iso = new Date().toISOString();
|
|
60
|
+
const hash = zeusHash(iso);
|
|
41
61
|
|
|
42
|
-
|
|
62
|
+
console.log(hash);
|
|
43
63
|
```
|
|
44
64
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
import { unixToZeus } from "zeus-time";
|
|
65
|
+
This hash is deterministic. The same input always produces the same
|
|
66
|
+
output.
|
|
48
67
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
68
|
+
------------------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
### Stamp unix time deterministically (sync)
|
|
71
|
+
|
|
72
|
+
``` ts
|
|
73
|
+
import { unixToZeusSync } from "zeus-time";
|
|
74
|
+
|
|
75
|
+
const unixSeconds = Math.floor(Date.now() / 1000);
|
|
76
|
+
const hash = unixToZeusSync(unixSeconds);
|
|
53
77
|
```
|
|
54
78
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
This is the preferred hot path for applications.
|
|
80
|
+
|
|
81
|
+
------------------------------------------------------------------------
|
|
58
82
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
83
|
+
### Async compatibility helper (legacy friendly)
|
|
84
|
+
|
|
85
|
+
``` ts
|
|
86
|
+
import { unixToZeus } from "zeus-time";
|
|
87
|
+
|
|
88
|
+
const hash = await unixToZeus(1704067200);
|
|
62
89
|
```
|
|
90
|
+
|
|
91
|
+
This exists for continuity with earlier versions.
|
|
92
|
+
|
|
93
|
+
------------------------------------------------------------------------
|
|
94
|
+
|
|
95
|
+
## Verification
|
|
96
|
+
|
|
97
|
+
### Verify a timestamp against a hash
|
|
98
|
+
|
|
99
|
+
``` ts
|
|
100
|
+
import { verifyZeusHash } from "zeus-time";
|
|
101
|
+
|
|
102
|
+
const ok = verifyZeusHash(iso, hash);
|
|
63
103
|
```
|
|
64
|
-
|
|
104
|
+
|
|
105
|
+
Returns true if the hash matches the normalized timestamp.
|
|
106
|
+
|
|
107
|
+
------------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
### Safe validation helper
|
|
110
|
+
|
|
111
|
+
``` ts
|
|
112
|
+
import { validateZeusTimestamp } from "zeus-time";
|
|
113
|
+
|
|
114
|
+
const isValid = await validateZeusTimestamp(iso, hash);
|
|
65
115
|
```
|
|
66
116
|
|
|
67
|
-
|
|
68
|
-
|
|
117
|
+
This helper never throws. It returns false on invalid input.
|
|
118
|
+
|
|
119
|
+
------------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
## Epoch-Based Execution
|
|
122
|
+
|
|
123
|
+
``` ts
|
|
69
124
|
import { executeAtZeusEpoch } from "zeus-time";
|
|
70
125
|
|
|
71
126
|
executeAtZeusEpoch(1735689600, () => {
|
|
72
|
-
console.log("
|
|
127
|
+
console.log("ZEUS epoch reached");
|
|
73
128
|
});
|
|
74
129
|
```
|
|
75
130
|
|
|
76
|
-
|
|
131
|
+
------------------------------------------------------------------------
|
|
77
132
|
|
|
78
|
-
##
|
|
79
|
-
Zeus-Time is **blazing fast!** Recent tests show it can **hash timestamps at record-breaking speeds!** 💥
|
|
133
|
+
## Legacy Compatibility
|
|
80
134
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Performance Test: Hashed 5000 timestamps in **51ms** ⚡
|
|
84
|
-
Performance Test: Hashed 10,000 timestamps in **98ms** ⚡
|
|
85
|
-
Performance Test: Hashed 50,000 timestamps in **434ms** ⚡
|
|
86
|
-
```
|
|
135
|
+
ZEUS 0.2.x keeps compatibility helpers while preserving one-way
|
|
136
|
+
integrity.
|
|
87
137
|
|
|
88
|
-
###
|
|
89
|
-
👉 **Ultra-Fast** - Outperforms traditional UNIX-based hashing.
|
|
90
|
-
👉 **Cryptographically Secure** - Uses BLAKE3 hashing for reliability.
|
|
91
|
-
👉 **Future-Proof** - Designed for next-gen blockchain & AI applications.
|
|
138
|
+
### Legacy hashing helpers
|
|
92
139
|
|
|
93
|
-
|
|
140
|
+
``` ts
|
|
141
|
+
import { legacyUnixToZeus, legacyZeusHash } from "zeus-time";
|
|
142
|
+
```
|
|
94
143
|
|
|
95
|
-
|
|
144
|
+
### Legacy unix conversion
|
|
96
145
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
👉 **Supply Chain & IoT** – Devices validate time-based triggers securely.
|
|
101
|
-
👉 **File Integrity & Authentication** – Timestamped events are cryptographically secured.
|
|
146
|
+
``` ts
|
|
147
|
+
import { legacyZeusToUnix } from "zeus-time";
|
|
148
|
+
```
|
|
102
149
|
|
|
103
|
-
|
|
150
|
+
- If the input looks like an ISO timestamp, it is parsed
|
|
151
|
+
- If the input looks like a hash, it throws
|
|
152
|
+
- Hashes remain one-way by design
|
|
104
153
|
|
|
105
|
-
|
|
154
|
+
------------------------------------------------------------------------
|
|
106
155
|
|
|
107
|
-
|
|
156
|
+
## Performance
|
|
108
157
|
|
|
109
|
-
|
|
110
|
-
- `legacyUnixToZeus()` → Converts UNIX to ZEUS hash using SHA-256.
|
|
111
|
-
- `legacyZeusToUnix()` → Attempts UNIX conversion but is not cryptographically reversible.
|
|
158
|
+
ZEUS is fast enough to be boring.
|
|
112
159
|
|
|
113
|
-
|
|
160
|
+
Example benchmarks on a standard desktop:
|
|
114
161
|
|
|
115
|
-
|
|
162
|
+
1,000 hashes \~12 ms 5,000 hashes \~51 ms 10,000 hashes \~98 ms 50,000
|
|
163
|
+
hashes \~430 ms
|
|
116
164
|
|
|
117
|
-
|
|
165
|
+
------------------------------------------------------------------------
|
|
118
166
|
|
|
119
|
-
|
|
120
|
-
👉 Validates timestamps correctly (Ensures input is formatted and normalized properly)
|
|
121
|
-
👉 Ensures deterministic hashing (Same input always produces the same secure hash)
|
|
122
|
-
👉 Supports legacy SHA-256 fallback (Ensures compatibility with older systems if BLAKE3 is unavailable)
|
|
123
|
-
👉 Prevents invalid time manipulation (Rejects malformed, tampered, or unrealistic timestamps)
|
|
124
|
-
👉 Ensures consistent hash output across formats (Tests Date objects, ISO strings, and UNIX timestamps)
|
|
125
|
-
👉 Handles extreme dates correctly (Validates UNIX epoch and future dates like 2999-12-31)
|
|
126
|
-
👉 Rejects invalid inputs (Throws errors for undefined, null, and malformed timestamps)
|
|
127
|
-
👉 Performance benchmark confirmed (**1000 hashes computed in 12ms**)
|
|
167
|
+
## Use Cases
|
|
128
168
|
|
|
129
|
-
|
|
169
|
+
- Audit receipts and compliance logs
|
|
170
|
+
- Distributed systems needing ordering guarantees
|
|
171
|
+
- Event integrity verification
|
|
172
|
+
- Local-first applications
|
|
173
|
+
- Smart contract preparation and off-chain proofs
|
|
174
|
+
- Time-bound unlocks and delayed execution
|
|
130
175
|
|
|
131
|
-
|
|
132
|
-
yarn test
|
|
133
|
-
```
|
|
176
|
+
ZEUS provides proof of time, not surveillance.
|
|
134
177
|
|
|
135
|
-
|
|
178
|
+
------------------------------------------------------------------------
|
|
136
179
|
|
|
137
|
-
##
|
|
180
|
+
## Versioning Strategy
|
|
138
181
|
|
|
139
|
-
|
|
182
|
+
- 0.1.x is the stable legacy line
|
|
183
|
+
- 0.2.x clarifies semantics and adds Expo compatibility
|
|
184
|
+
- latest remains conservative
|
|
185
|
+
- New behavior is opt-in
|
|
140
186
|
|
|
141
|
-
|
|
187
|
+
------------------------------------------------------------------------
|
|
142
188
|
|
|
143
|
-
##
|
|
189
|
+
## License
|
|
144
190
|
|
|
145
|
-
|
|
191
|
+
Apache 2.0 Open, boring, and dependable.
|
|
146
192
|
|
|
147
|
-
|
|
193
|
+
------------------------------------------------------------------------
|
|
148
194
|
|
|
149
|
-
##
|
|
195
|
+
## A Small Amount of Fire
|
|
150
196
|
|
|
151
|
-
|
|
152
|
-
Get started today and be part of the next evolution in timekeeping!
|
|
197
|
+
Unix time still works. But it was never designed to be verifiable.
|
|
153
198
|
|
|
154
|
-
|
|
199
|
+
ZEUS does not replace the clock. It replaces the argument.
|
|
155
200
|
|
|
201
|
+
BAM!
|