easctl 0.1.3 → 0.2.1

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,119 @@
1
+ export interface PopularSchema {
2
+ name: string;
3
+ schema: string;
4
+ uid: string;
5
+ description: string;
6
+ revocable: boolean;
7
+ category: string;
8
+ }
9
+
10
+ // UIDs are deterministic: keccak256(abi.encodePacked(schema, address(0), revocable))
11
+ // Same UID on every chain (no resolver).
12
+ export const POPULAR_SCHEMAS: PopularSchema[] = [
13
+ // General
14
+ {
15
+ name: 'make-a-statement',
16
+ schema: 'string statement',
17
+ uid: '0xf58b8b212ef75ee8cd7e8d803c37c03e0519890502d5e99ee2412aae1456cafe',
18
+ description: 'General-purpose text statement or note',
19
+ revocable: true,
20
+ category: 'general',
21
+ },
22
+ {
23
+ name: 'is-true',
24
+ schema: 'bool isTrue',
25
+ uid: '0x4eb603f49d68888d7f8b1fadd351b35a252f287ba465408ceb2b1e1e1efd90d5',
26
+ description: 'Simple boolean assertion',
27
+ revocable: true,
28
+ category: 'general',
29
+ },
30
+ {
31
+ name: 'score',
32
+ schema: 'uint256 score',
33
+ uid: '0xef2dbf5e8da46ea760bb4c6eb2635bf04adfc1ade6158e594263363db2a55bcf',
34
+ description: 'Numeric score or rating',
35
+ revocable: true,
36
+ category: 'general',
37
+ },
38
+ {
39
+ name: 'tag',
40
+ schema: 'bytes32 tag',
41
+ uid: '0x7d105b048bfc4c781474627045d2fb9008016018b3f2af686eef31ee6d1d5857',
42
+ description: 'Arbitrary tag or label',
43
+ revocable: true,
44
+ category: 'general',
45
+ },
46
+ // Identity
47
+ {
48
+ name: 'is-a-human',
49
+ schema: 'bool isHuman',
50
+ uid: '0x8af15e65888f2e3b487e536a4922e277dcfe85b4b18187b0cf9afdb802ba6bb6',
51
+ description: 'Humanity verification attestation',
52
+ revocable: true,
53
+ category: 'identity',
54
+ },
55
+ {
56
+ name: 'verified-account',
57
+ schema: 'string platform, string username',
58
+ uid: '0xa0ce1ea8fd393b308ec22d86a9a4451bb16e61f455f964374f2105a371077d02',
59
+ description: 'Social account verification (platform + username)',
60
+ revocable: true,
61
+ category: 'identity',
62
+ },
63
+ // Social
64
+ {
65
+ name: 'is-a-friend',
66
+ schema: 'bool isFriend',
67
+ uid: '0x27d06e3659317e9a4f8154d1e849eb53d43d91fb4f219884d1684f86d797804a',
68
+ description: 'Friendship attestation',
69
+ revocable: true,
70
+ category: 'social',
71
+ },
72
+ {
73
+ name: 'met-irl',
74
+ schema: 'bool metIRL',
75
+ uid: '0xc59265615401143689cbfe73046a922c975c99d97e4c248070435b1104b2dea7',
76
+ description: 'Attest that you met someone in real life',
77
+ revocable: true,
78
+ category: 'social',
79
+ },
80
+ {
81
+ name: 'vouch',
82
+ schema: 'address vouched, string context',
83
+ uid: '0xec3decee9f94f4ef4d1a95b23743ac4904b1b8687164e266564945efd435cf48',
84
+ description: 'Vouch for an address with context',
85
+ revocable: true,
86
+ category: 'social',
87
+ },
88
+ {
89
+ name: 'endorsement',
90
+ schema: 'string endorsement',
91
+ uid: '0xb7fb3a3cae206db4784b42600aaaa640d20babf3b2d4b45161c4856f2b6c6aec',
92
+ description: 'Open-ended endorsement',
93
+ revocable: true,
94
+ category: 'social',
95
+ },
96
+ ];
97
+
98
+ const byName = new Map(POPULAR_SCHEMAS.map((s) => [s.name, s]));
99
+
100
+ export function getPopularSchemaByName(name: string): PopularSchema | undefined {
101
+ return byName.get(name);
102
+ }
103
+
104
+ export function resolveSchemaUID(value: string): string {
105
+ const schema = byName.get(value);
106
+ return schema ? schema.uid : value;
107
+ }
108
+
109
+ export function listPopularSchemas(): PopularSchema[] {
110
+ return POPULAR_SCHEMAS;
111
+ }
112
+
113
+ export function listPopularSchemasByCategory(): Record<string, PopularSchema[]> {
114
+ const grouped: Record<string, PopularSchema[]> = {};
115
+ for (const s of POPULAR_SCHEMAS) {
116
+ (grouped[s.category] ??= []).push(s);
117
+ }
118
+ return grouped;
119
+ }
package/src/validation.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { resolveSchemaUID } from './popular-schemas.js';
2
+
1
3
  const ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
2
4
 
3
5
  export function validateAddress(value: string, label: string): void {
@@ -13,3 +15,9 @@ export function validateBytes32(value: string, label: string): void {
13
15
  throw new Error(`Invalid ${label}: expected 0x + 64 hex characters, got "${value}"`);
14
16
  }
15
17
  }
18
+
19
+ export function resolveAndValidateSchemaUID(value: string, label: string): string {
20
+ const resolved = resolveSchemaUID(value);
21
+ validateBytes32(resolved, label);
22
+ return resolved;
23
+ }