@libid/contracts 0.16.0 → 0.18.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.
- package/README.md +108 -47
- package/dist/abis/bindErrors.d.ts +714 -0
- package/dist/abis/bindErrors.d.ts.map +1 -0
- package/dist/abis/bindErrors.js +955 -0
- package/dist/abis/bindErrors.js.map +1 -0
- package/dist/abis/ceremonyPayloads.d.ts +118 -0
- package/dist/abis/ceremonyPayloads.d.ts.map +1 -0
- package/dist/abis/ceremonyPayloads.js +154 -0
- package/dist/abis/ceremonyPayloads.js.map +1 -0
- package/dist/abis/ceremonyProofVerifier.d.ts +6 -6
- package/dist/abis/ceremonyProofVerifier.js +6 -6
- package/dist/abis/ceremonyProofVerifier.js.map +1 -1
- package/dist/abis/handleEscrow.d.ts +56 -16
- package/dist/abis/handleEscrow.d.ts.map +1 -1
- package/dist/abis/handleEscrow.js +71 -19
- package/dist/abis/handleEscrow.js.map +1 -1
- package/dist/abis/honkVerifierErrors.d.ts +54 -0
- package/dist/abis/honkVerifierErrors.d.ts.map +1 -0
- package/dist/abis/honkVerifierErrors.js +71 -0
- package/dist/abis/honkVerifierErrors.js.map +1 -0
- package/dist/abis/identityRegistry.d.ts +123 -157
- package/dist/abis/identityRegistry.d.ts.map +1 -1
- package/dist/abis/identityRegistry.js +150 -194
- package/dist/abis/identityRegistry.js.map +1 -1
- package/dist/abis/index.d.ts +3 -0
- package/dist/abis/index.d.ts.map +1 -1
- package/dist/abis/index.js +3 -0
- package/dist/abis/index.js.map +1 -1
- package/dist/calls/handleEscrow.d.ts +1 -0
- package/dist/calls/handleEscrow.d.ts.map +1 -1
- package/dist/calls/handleEscrow.js +7 -0
- package/dist/calls/handleEscrow.js.map +1 -1
- package/dist/calls/identityRegistry.d.ts +2 -1
- package/dist/calls/identityRegistry.d.ts.map +1 -1
- package/dist/calls/identityRegistry.js +9 -2
- package/dist/calls/identityRegistry.js.map +1 -1
- package/dist/ceremony/profiles.d.ts +38 -48
- package/dist/ceremony/profiles.d.ts.map +1 -1
- package/dist/ceremony/profiles.js +31 -36
- package/dist/ceremony/profiles.js.map +1 -1
- package/dist/identity/index.d.ts +1 -2
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +5 -10
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/node.d.ts +3 -3
- package/dist/identity/node.d.ts.map +1 -1
- package/dist/identity/node.js +25 -16
- package/dist/identity/node.js.map +1 -1
- package/dist/identity/resolve.d.ts +6 -8
- package/dist/identity/resolve.d.ts.map +1 -1
- package/dist/identity/resolve.js +54 -86
- package/dist/identity/resolve.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/payloads.d.ts +124 -0
- package/dist/payloads.d.ts.map +1 -0
- package/dist/payloads.js +59 -0
- package/dist/payloads.js.map +1 -0
- package/dist/platforms/handle.d.ts +11 -0
- package/dist/platforms/handle.d.ts.map +1 -0
- package/dist/platforms/handle.js +29 -0
- package/dist/platforms/handle.js.map +1 -0
- package/dist/platforms/id.d.ts +8 -0
- package/dist/platforms/id.d.ts.map +1 -0
- package/dist/platforms/id.js +21 -0
- package/dist/platforms/id.js.map +1 -0
- package/dist/platforms/index.d.ts +4 -0
- package/dist/platforms/index.d.ts.map +1 -0
- package/dist/platforms/index.js +7 -0
- package/dist/platforms/index.js.map +1 -0
- package/dist/platforms/platforms.d.ts +39 -0
- package/dist/platforms/platforms.d.ts.map +1 -0
- package/dist/platforms/platforms.js +90 -0
- package/dist/platforms/platforms.js.map +1 -0
- package/package.json +8 -3
- package/src/abis/bindErrors.ts +957 -0
- package/src/abis/ceremonyPayloads.ts +156 -0
- package/src/abis/ceremonyProofVerifier.ts +6 -6
- package/src/abis/handleEscrow.ts +71 -19
- package/src/abis/honkVerifierErrors.ts +73 -0
- package/src/abis/identityRegistry.ts +150 -194
- package/src/abis/index.ts +3 -0
- package/src/calls/handleEscrow.ts +12 -0
- package/src/calls/identityRegistry.ts +14 -2
- package/src/ceremony/profiles.ts +53 -65
- package/src/identity/index.ts +5 -10
- package/src/identity/node.ts +25 -21
- package/src/identity/resolve.ts +72 -118
- package/src/index.ts +3 -4
- package/src/payloads.ts +90 -0
- package/src/platforms/handle.ts +36 -0
- package/src/platforms/id.ts +26 -0
- package/src/platforms/index.ts +7 -0
- package/src/platforms/platforms.ts +114 -0
- package/dist/identity/handle.d.ts +0 -22
- package/dist/identity/handle.d.ts.map +0 -1
- package/dist/identity/handle.js +0 -140
- package/dist/identity/handle.js.map +0 -1
- package/dist/identity/handleVectors.d.ts +0 -50
- package/dist/identity/handleVectors.d.ts.map +0 -1
- package/dist/identity/handleVectors.js +0 -89
- package/dist/identity/handleVectors.js.map +0 -1
- package/src/identity/handle.ts +0 -176
- package/src/identity/handleVectors.ts +0 -104
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// Turns a typed handle into the form the identity circuits hash into a node.
|
|
2
|
+
/// Mirrors the circuits and Rust; all run the `handles.json` vectors.
|
|
3
|
+
|
|
4
|
+
import { HandleError, PLATFORM_GITHUB, PLATFORM_GOOGLE, PLATFORM_X, platform } from './platforms.js'
|
|
5
|
+
|
|
6
|
+
/// What one platform's circuit takes, generated from the circuits' `platforms.json`.
|
|
7
|
+
export interface Rules {
|
|
8
|
+
/** Bytes the circuit's buffer holds. */
|
|
9
|
+
maxLength: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const RULES_X: Rules = PLATFORM_X.rules
|
|
13
|
+
export const RULES_GITHUB: Rules = PLATFORM_GITHUB.rules
|
|
14
|
+
export const RULES_GOOGLE: Rules = PLATFORM_GOOGLE.rules
|
|
15
|
+
|
|
16
|
+
/// The rules for a platform key from the generated table.
|
|
17
|
+
export function rulesFor(platformKey: string): Rules | null {
|
|
18
|
+
return platform(platformKey)?.rules ?? null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/// A byte of a JSON string as sent: printable ASCII, not `"` or `\`.
|
|
22
|
+
export function isStringByte(b: number): boolean {
|
|
23
|
+
return b >= 0x20 && b <= 0x7e && b !== 0x22 && b !== 0x5c
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// The handle with A-Z folded. Throws a `HandleError` unless it is one JSON
|
|
27
|
+
/// string as a platform sends it, no longer than the circuit's buffer.
|
|
28
|
+
export function normalize(raw: string, rules: Rules): string {
|
|
29
|
+
// Bytes, not code units: the circuits measure and refuse bytes.
|
|
30
|
+
const input = new TextEncoder().encode(raw)
|
|
31
|
+
if (input.length === 0) throw new HandleError('Empty')
|
|
32
|
+
if (input.length > rules.maxLength) throw new HandleError('TooLong')
|
|
33
|
+
if (!input.every(isStringByte)) throw new HandleError('BadCharacter')
|
|
34
|
+
// ASCII alone, so this folds A-Z and nothing else.
|
|
35
|
+
return raw.toLowerCase()
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// The id check the identity circuits apply: an id is hashed exactly as the
|
|
2
|
+
/// platform sent it, so it is checked and never normalized.
|
|
3
|
+
|
|
4
|
+
import { isStringByte } from './handle.js'
|
|
5
|
+
import { IdError, platform } from './platforms.js'
|
|
6
|
+
|
|
7
|
+
/// What a platform allows in an id, as the generated table states it.
|
|
8
|
+
export interface IdRules {
|
|
9
|
+
/** Bytes the circuit's buffer holds. */
|
|
10
|
+
maxLength: number
|
|
11
|
+
/** True: ASCII digits. False: printable ASCII without a quote or backslash. */
|
|
12
|
+
decimal: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/// Accept an id exactly as given, or throw an `IdError` saying why no circuit would hash it.
|
|
16
|
+
export function checkId(platformKey: string, id: string): void {
|
|
17
|
+
const rules = platform(platformKey)?.idRules
|
|
18
|
+
if (rules === undefined) throw new Error(`unknown platform ${JSON.stringify(platformKey)}`)
|
|
19
|
+
const bytes = new TextEncoder().encode(id)
|
|
20
|
+
if (bytes.length === 0) throw new IdError('Empty')
|
|
21
|
+
if (bytes.length > rules.maxLength) throw new IdError('TooLong')
|
|
22
|
+
for (const b of bytes) {
|
|
23
|
+
const ok = rules.decimal ? b >= 0x30 && b <= 0x39 : isStringByte(b)
|
|
24
|
+
if (!ok) throw new IdError('BadCharacter')
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// The platform table and the checks the identity circuits apply to handles
|
|
2
|
+
/// and ids: normalization, the id check and the refusals they throw. Loads
|
|
3
|
+
/// without viem; node hashing and the registry reads are in `../identity`.
|
|
4
|
+
|
|
5
|
+
export * from './handle.js'
|
|
6
|
+
export * from './id.js'
|
|
7
|
+
export * from './platforms.js'
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Generated by scripts/regen-identity-handles.py. Do not edit.
|
|
2
|
+
// The sources are the pinned libID-circuits release's platforms.json and handles.json,
|
|
3
|
+
// vendored into solidity/contracts/circuits/ by scripts/vendor-circuit-verifiers.sh.
|
|
4
|
+
|
|
5
|
+
/// The platform table: each platform's key, node tags and buffers, and the
|
|
6
|
+
/// refusals the handle and id checks share.
|
|
7
|
+
|
|
8
|
+
import type { Rules } from './handle.js'
|
|
9
|
+
import type { IdRules } from './id.js'
|
|
10
|
+
|
|
11
|
+
/** A platform: its key, node tags and buffers. */
|
|
12
|
+
export interface Platform {
|
|
13
|
+
/** keccak256 of this string is the platform id. */
|
|
14
|
+
key: string
|
|
15
|
+
/** An id node is SHA256 of this tag, then the id. */
|
|
16
|
+
userIdTag: string
|
|
17
|
+
/** A handle node is SHA256 of this tag, then the normalized handle. */
|
|
18
|
+
handleTag: string
|
|
19
|
+
rules: Rules
|
|
20
|
+
idRules: IdRules
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** keccak256 of this string is the platform id. */
|
|
24
|
+
export const PLATFORM_GOOGLE_KEY = 'google'
|
|
25
|
+
/** keccak256 of this string is the platform id. */
|
|
26
|
+
export const PLATFORM_X_KEY = 'x'
|
|
27
|
+
/** keccak256 of this string is the platform id. */
|
|
28
|
+
export const PLATFORM_GITHUB_KEY = 'github'
|
|
29
|
+
|
|
30
|
+
export const PLATFORM_GOOGLE: Platform = {
|
|
31
|
+
key: PLATFORM_GOOGLE_KEY,
|
|
32
|
+
userIdTag: 'libid.google.user-id',
|
|
33
|
+
handleTag: 'libid.google.handle',
|
|
34
|
+
rules: {
|
|
35
|
+
maxLength: 62,
|
|
36
|
+
},
|
|
37
|
+
idRules: {
|
|
38
|
+
maxLength: 31,
|
|
39
|
+
decimal: false,
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
export const PLATFORM_X: Platform = {
|
|
43
|
+
key: PLATFORM_X_KEY,
|
|
44
|
+
userIdTag: 'libid.x.user-id',
|
|
45
|
+
handleTag: 'libid.x.handle',
|
|
46
|
+
rules: {
|
|
47
|
+
maxLength: 39,
|
|
48
|
+
},
|
|
49
|
+
idRules: {
|
|
50
|
+
maxLength: 20,
|
|
51
|
+
decimal: true,
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
export const PLATFORM_GITHUB: Platform = {
|
|
55
|
+
key: PLATFORM_GITHUB_KEY,
|
|
56
|
+
userIdTag: 'libid.github.user-id',
|
|
57
|
+
handleTag: 'libid.github.handle',
|
|
58
|
+
rules: {
|
|
59
|
+
maxLength: 39,
|
|
60
|
+
},
|
|
61
|
+
idRules: {
|
|
62
|
+
maxLength: 20,
|
|
63
|
+
decimal: true,
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Every platform, in table order. */
|
|
68
|
+
export const PLATFORMS: readonly Platform[] = [PLATFORM_GOOGLE, PLATFORM_X, PLATFORM_GITHUB]
|
|
69
|
+
|
|
70
|
+
/** The platform with this key, if the table names it. */
|
|
71
|
+
export function platform(key: string): Platform | undefined {
|
|
72
|
+
return PLATFORMS.find((p) => p.key === key)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Which refusal a handle or an id met, as the shared table names it. */
|
|
76
|
+
export type RefusalKind = 'Empty' | 'TooLong' | 'BadCharacter'
|
|
77
|
+
|
|
78
|
+
/** Why a handle was refused. */
|
|
79
|
+
export class HandleError extends Error {
|
|
80
|
+
constructor(readonly kind: RefusalKind) {
|
|
81
|
+
super(handleRefusal(kind))
|
|
82
|
+
this.name = 'HandleError'
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function handleRefusal(kind: RefusalKind): string {
|
|
87
|
+
switch (kind) {
|
|
88
|
+
case 'Empty':
|
|
89
|
+
return 'the handle is empty'
|
|
90
|
+
case 'TooLong':
|
|
91
|
+
return 'the handle is too long for this platform'
|
|
92
|
+
case 'BadCharacter':
|
|
93
|
+
return 'the handle has a byte outside printable ASCII, or a quote or backslash'
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Why no circuit would hash an id. */
|
|
98
|
+
export class IdError extends Error {
|
|
99
|
+
constructor(readonly kind: RefusalKind) {
|
|
100
|
+
super(idRefusal(kind))
|
|
101
|
+
this.name = 'IdError'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function idRefusal(kind: RefusalKind): string {
|
|
106
|
+
switch (kind) {
|
|
107
|
+
case 'Empty':
|
|
108
|
+
return 'the id is empty'
|
|
109
|
+
case 'TooLong':
|
|
110
|
+
return 'the id is too long for this platform'
|
|
111
|
+
case 'BadCharacter':
|
|
112
|
+
return 'the id has a byte this platform does not allow'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare class HandleError extends Error {
|
|
2
|
-
readonly kind: number;
|
|
3
|
-
constructor(kind: number, message: string);
|
|
4
|
-
}
|
|
5
|
-
export interface Rules {
|
|
6
|
-
/** Bytes allowed after trimming and the `@` strip. */
|
|
7
|
-
maxLength: number;
|
|
8
|
-
/** Remove one leading `@`. X and GitHub do. An email keeps its own `@`. */
|
|
9
|
-
stripLeadingAt: boolean;
|
|
10
|
-
/** Validate as an address instead of a bare handle. */
|
|
11
|
-
isEmail: boolean;
|
|
12
|
-
/** Allowed by X, not by GitHub. */
|
|
13
|
-
allowUnderscore: boolean;
|
|
14
|
-
/** A hyphen may not start or end the handle, and two may not touch. */
|
|
15
|
-
allowHyphen: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare const RULES_X: Rules;
|
|
18
|
-
export declare const RULES_GITHUB: Rules;
|
|
19
|
-
export declare const RULES_GOOGLE: Rules;
|
|
20
|
-
export declare function rulesFor(platformKey: string): Rules | null;
|
|
21
|
-
export declare function normalize(raw: string, rules: Rules): string;
|
|
22
|
-
//# sourceMappingURL=handle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../src/identity/handle.ts"],"names":[],"mappings":"AAqCA,qBAAa,WAAY,SAAQ,KAAK;IAElC,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAWD,MAAM,WAAW,KAAK;IACpB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAA;IACjB,2EAA2E;IAC3E,cAAc,EAAE,OAAO,CAAA;IACvB,uDAAuD;IACvD,OAAO,EAAE,OAAO,CAAA;IAChB,mCAAmC;IACnC,eAAe,EAAE,OAAO,CAAA;IACxB,uEAAuE;IACvE,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,eAAO,MAAM,OAAO,EAAE,KAMrB,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,KAM1B,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,KAM1B,CAAA;AAKD,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAK1D;AAGD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAkC3D"}
|
package/dist/identity/handle.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/// Turns a platform handle into the one form the identity system hashes into a
|
|
2
|
-
/// node.
|
|
3
|
-
///
|
|
4
|
-
/// This mirrors `solidity/contracts/identity/HandleNormalizer.sol` and
|
|
5
|
-
/// `rust/identity/src/handle.rs` byte for byte. The three transforms
|
|
6
|
-
/// are hand written; the rules they run and the vectors they are checked
|
|
7
|
-
/// against are generated from `solidity/contracts/identity/handles.json`, so a
|
|
8
|
-
/// difference between them fails a test instead of looking up a node the chain
|
|
9
|
-
/// never wrote.
|
|
10
|
-
import { ALLOW_HYPHEN_GITHUB, ALLOW_HYPHEN_GOOGLE, ALLOW_HYPHEN_X, ALLOW_UNDERSCORE_GITHUB, ALLOW_UNDERSCORE_GOOGLE, ALLOW_UNDERSCORE_X, ERROR_BADCHARACTER, ERROR_BADSHAPE, ERROR_EMPTY, ERROR_TOOLONG, IS_EMAIL_GITHUB, IS_EMAIL_GOOGLE, IS_EMAIL_X, MAX_LENGTH_GITHUB, MAX_LENGTH_GOOGLE, MAX_LENGTH_X, PLATFORM_GITHUB_KEY, PLATFORM_GOOGLE_KEY, PLATFORM_X_KEY, STRIP_LEADING_AT_GITHUB, STRIP_LEADING_AT_GOOGLE, STRIP_LEADING_AT_X, } from './handleVectors.js';
|
|
11
|
-
/// Why a handle was refused. The kinds match the Solidity errors and the Rust
|
|
12
|
-
/// ones, because the vector table names which refusal it expects.
|
|
13
|
-
export class HandleError extends Error {
|
|
14
|
-
kind;
|
|
15
|
-
constructor(kind, message) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.kind = kind;
|
|
18
|
-
this.name = 'HandleError';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
const EMPTY = () => new HandleError(ERROR_EMPTY, 'the handle is empty');
|
|
22
|
-
const TOO_LONG = () => new HandleError(ERROR_TOOLONG, 'the handle is too long for this platform');
|
|
23
|
-
const BAD_CHARACTER = () => new HandleError(ERROR_BADCHARACTER, 'the handle has a character this platform does not allow');
|
|
24
|
-
const BAD_SHAPE = () => new HandleError(ERROR_BADSHAPE, 'the handle has an arrangement this platform does not allow');
|
|
25
|
-
export const RULES_X = {
|
|
26
|
-
maxLength: MAX_LENGTH_X,
|
|
27
|
-
stripLeadingAt: STRIP_LEADING_AT_X,
|
|
28
|
-
isEmail: IS_EMAIL_X,
|
|
29
|
-
allowUnderscore: ALLOW_UNDERSCORE_X,
|
|
30
|
-
allowHyphen: ALLOW_HYPHEN_X,
|
|
31
|
-
};
|
|
32
|
-
export const RULES_GITHUB = {
|
|
33
|
-
maxLength: MAX_LENGTH_GITHUB,
|
|
34
|
-
stripLeadingAt: STRIP_LEADING_AT_GITHUB,
|
|
35
|
-
isEmail: IS_EMAIL_GITHUB,
|
|
36
|
-
allowUnderscore: ALLOW_UNDERSCORE_GITHUB,
|
|
37
|
-
allowHyphen: ALLOW_HYPHEN_GITHUB,
|
|
38
|
-
};
|
|
39
|
-
export const RULES_GOOGLE = {
|
|
40
|
-
maxLength: MAX_LENGTH_GOOGLE,
|
|
41
|
-
stripLeadingAt: STRIP_LEADING_AT_GOOGLE,
|
|
42
|
-
isEmail: IS_EMAIL_GOOGLE,
|
|
43
|
-
allowUnderscore: ALLOW_UNDERSCORE_GOOGLE,
|
|
44
|
-
allowHyphen: ALLOW_HYPHEN_GOOGLE,
|
|
45
|
-
};
|
|
46
|
-
/// The rules for a platform key from the generated table: what the contracts
|
|
47
|
-
/// were released with. The chain's owner can change a platform's rules, so a
|
|
48
|
-
/// hash for a deposit should use `rulesOf`.
|
|
49
|
-
export function rulesFor(platformKey) {
|
|
50
|
-
if (platformKey === PLATFORM_X_KEY)
|
|
51
|
-
return RULES_X;
|
|
52
|
-
if (platformKey === PLATFORM_GITHUB_KEY)
|
|
53
|
-
return RULES_GITHUB;
|
|
54
|
-
if (platformKey === PLATFORM_GOOGLE_KEY)
|
|
55
|
-
return RULES_GOOGLE;
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
/// The normalized handle, or a `HandleError` naming what was wrong.
|
|
59
|
-
export function normalize(raw, rules) {
|
|
60
|
-
// Work on bytes, not code units. A character above 0x7f is several bytes and
|
|
61
|
-
// must be refused as bytes, the way Solidity sees it.
|
|
62
|
-
const input = new TextEncoder().encode(raw);
|
|
63
|
-
// Trim ASCII spaces only. A tab or a newline is not whitespace to remove
|
|
64
|
-
// here; it is a byte the platform does not allow, and the character check
|
|
65
|
-
// below refuses it. Trimming it would accept "ali\tce" as "alice" here and
|
|
66
|
-
// refuse it on chain.
|
|
67
|
-
let start = 0;
|
|
68
|
-
let end = input.length;
|
|
69
|
-
while (start < end && input[start] === 0x20)
|
|
70
|
-
start++;
|
|
71
|
-
while (end > start && input[end - 1] === 0x20)
|
|
72
|
-
end--;
|
|
73
|
-
if (rules.stripLeadingAt && end > start && input[start] === 0x40)
|
|
74
|
-
start++;
|
|
75
|
-
const length = end - start;
|
|
76
|
-
if (length === 0)
|
|
77
|
-
throw EMPTY();
|
|
78
|
-
if (length > rules.maxLength)
|
|
79
|
-
throw TOO_LONG();
|
|
80
|
-
const out = new Uint8Array(length);
|
|
81
|
-
for (let i = 0; i < length; i++) {
|
|
82
|
-
let c = input[start + i];
|
|
83
|
-
// Fold A-Z down. Nothing else changes, so two addresses that differ in more
|
|
84
|
-
// than case stay two identities.
|
|
85
|
-
if (c >= 0x41 && c <= 0x5a)
|
|
86
|
-
c += 0x20;
|
|
87
|
-
if (!allowed(c, rules))
|
|
88
|
-
throw BAD_CHARACTER();
|
|
89
|
-
out[i] = c;
|
|
90
|
-
}
|
|
91
|
-
if (rules.isEmail)
|
|
92
|
-
requireEmailShape(out);
|
|
93
|
-
else if (rules.allowHyphen)
|
|
94
|
-
requireHyphenShape(out);
|
|
95
|
-
return new TextDecoder().decode(out);
|
|
96
|
-
}
|
|
97
|
-
/// One byte, after folding. Anything outside the platform's set is refused,
|
|
98
|
-
/// including every byte above 0x7f, so a multi-byte character never reaches a
|
|
99
|
-
/// node.
|
|
100
|
-
function allowed(c, rules) {
|
|
101
|
-
if (c >= 0x61 && c <= 0x7a)
|
|
102
|
-
return true; // a-z
|
|
103
|
-
if (c >= 0x30 && c <= 0x39)
|
|
104
|
-
return true; // 0-9
|
|
105
|
-
if (rules.isEmail) {
|
|
106
|
-
// The set a Google address uses. The dot, the plus and the tag stay exactly
|
|
107
|
-
// as proved: this transform must never map two addresses onto one identity.
|
|
108
|
-
return c === 0x2e || c === 0x2b || c === 0x2d || c === 0x5f || c === 0x40;
|
|
109
|
-
}
|
|
110
|
-
if (rules.allowUnderscore && c === 0x5f)
|
|
111
|
-
return true;
|
|
112
|
-
if (rules.allowHyphen && c === 0x2d)
|
|
113
|
-
return true;
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
/// Exactly one `@`, and not at either edge.
|
|
117
|
-
function requireEmailShape(value) {
|
|
118
|
-
let at = -1;
|
|
119
|
-
for (let i = 0; i < value.length; i++) {
|
|
120
|
-
if (value[i] === 0x40) {
|
|
121
|
-
if (at !== -1)
|
|
122
|
-
throw BAD_SHAPE(); // a second one
|
|
123
|
-
at = i;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (at === -1)
|
|
127
|
-
throw BAD_SHAPE(); // none
|
|
128
|
-
if (at === 0 || at === value.length - 1)
|
|
129
|
-
throw BAD_SHAPE(); // an empty side
|
|
130
|
-
}
|
|
131
|
-
/// A hyphen may not start or end the handle, and two may not touch.
|
|
132
|
-
function requireHyphenShape(value) {
|
|
133
|
-
if (value[0] === 0x2d || value[value.length - 1] === 0x2d)
|
|
134
|
-
throw BAD_SHAPE();
|
|
135
|
-
for (let i = 1; i < value.length; i++) {
|
|
136
|
-
if (value[i] === 0x2d && value[i - 1] === 0x2d)
|
|
137
|
-
throw BAD_SHAPE();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
//# sourceMappingURL=handle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../../src/identity/handle.ts"],"names":[],"m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K,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI;YAAE,MAAM,SAAS,EAAE,CAAA;IACnE,CAAC;AACH,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export interface HandleVector {
|
|
2
|
-
platform: string;
|
|
3
|
-
input: string;
|
|
4
|
-
/** The normalized handle, or an empty string when the case is refused. */
|
|
5
|
-
output: string;
|
|
6
|
-
accepted: boolean;
|
|
7
|
-
errorKind: number;
|
|
8
|
-
}
|
|
9
|
-
/** keccak256 of this string is the platform id. */
|
|
10
|
-
export declare const PLATFORM_X_KEY = "x";
|
|
11
|
-
/** keccak256 of this string is the platform id. */
|
|
12
|
-
export declare const PLATFORM_GITHUB_KEY = "github";
|
|
13
|
-
/** keccak256 of this string is the platform id. */
|
|
14
|
-
export declare const PLATFORM_GOOGLE_KEY = "google";
|
|
15
|
-
/** Bytes a x handle may have after normalization. */
|
|
16
|
-
export declare const MAX_LENGTH_X = 15;
|
|
17
|
-
/** Bytes a github handle may have after normalization. */
|
|
18
|
-
export declare const MAX_LENGTH_GITHUB = 39;
|
|
19
|
-
/** Bytes a google handle may have after normalization. */
|
|
20
|
-
export declare const MAX_LENGTH_GOOGLE = 62;
|
|
21
|
-
/** Remove one leading `@`. */
|
|
22
|
-
export declare const STRIP_LEADING_AT_X = true;
|
|
23
|
-
/** Validate as an address instead of a bare handle. */
|
|
24
|
-
export declare const IS_EMAIL_X = false;
|
|
25
|
-
/** Allow `_`. */
|
|
26
|
-
export declare const ALLOW_UNDERSCORE_X = true;
|
|
27
|
-
/** Allow `-`, but not leading, trailing or doubled. */
|
|
28
|
-
export declare const ALLOW_HYPHEN_X = false;
|
|
29
|
-
/** Remove one leading `@`. */
|
|
30
|
-
export declare const STRIP_LEADING_AT_GITHUB = true;
|
|
31
|
-
/** Validate as an address instead of a bare handle. */
|
|
32
|
-
export declare const IS_EMAIL_GITHUB = false;
|
|
33
|
-
/** Allow `_`. */
|
|
34
|
-
export declare const ALLOW_UNDERSCORE_GITHUB = false;
|
|
35
|
-
/** Allow `-`, but not leading, trailing or doubled. */
|
|
36
|
-
export declare const ALLOW_HYPHEN_GITHUB = true;
|
|
37
|
-
/** Remove one leading `@`. */
|
|
38
|
-
export declare const STRIP_LEADING_AT_GOOGLE = false;
|
|
39
|
-
/** Validate as an address instead of a bare handle. */
|
|
40
|
-
export declare const IS_EMAIL_GOOGLE = true;
|
|
41
|
-
/** Allow `_`. */
|
|
42
|
-
export declare const ALLOW_UNDERSCORE_GOOGLE = false;
|
|
43
|
-
/** Allow `-`, but not leading, trailing or doubled. */
|
|
44
|
-
export declare const ALLOW_HYPHEN_GOOGLE = false;
|
|
45
|
-
export declare const ERROR_EMPTY = 0;
|
|
46
|
-
export declare const ERROR_TOOLONG = 1;
|
|
47
|
-
export declare const ERROR_BADCHARACTER = 2;
|
|
48
|
-
export declare const ERROR_BADSHAPE = 3;
|
|
49
|
-
export declare const HANDLE_VECTORS: HandleVector[];
|
|
50
|
-
//# sourceMappingURL=handleVectors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleVectors.d.ts","sourceRoot":"","sources":["../../src/identity/handleVectors.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,mDAAmD;AACnD,eAAO,MAAM,cAAc,MAAM,CAAA;AACjC,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,WAAW,CAAA;AAC3C,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,WAAW,CAAA;AAE3C,qDAAqD;AACrD,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAEnC,8BAA8B;AAC9B,eAAO,MAAM,kBAAkB,OAAO,CAAA;AACtC,uDAAuD;AACvD,eAAO,MAAM,UAAU,QAAQ,CAAA;AAC/B,iBAAiB;AACjB,eAAO,MAAM,kBAAkB,OAAO,CAAA;AACtC,uDAAuD;AACvD,eAAO,MAAM,cAAc,QAAQ,CAAA;AACnC,8BAA8B;AAC9B,eAAO,MAAM,uBAAuB,OAAO,CAAA;AAC3C,uDAAuD;AACvD,eAAO,MAAM,eAAe,QAAQ,CAAA;AACpC,iBAAiB;AACjB,eAAO,MAAM,uBAAuB,QAAQ,CAAA;AAC5C,uDAAuD;AACvD,eAAO,MAAM,mBAAmB,OAAO,CAAA;AACvC,8BAA8B;AAC9B,eAAO,MAAM,uBAAuB,QAAQ,CAAA;AAC5C,uDAAuD;AACvD,eAAO,MAAM,eAAe,OAAO,CAAA;AACnC,iBAAiB;AACjB,eAAO,MAAM,uBAAuB,QAAQ,CAAA;AAC5C,uDAAuD;AACvD,eAAO,MAAM,mBAAmB,QAAQ,CAAA;AAExC,eAAO,MAAM,WAAW,IAAI,CAAA;AAC5B,eAAO,MAAM,aAAa,IAAI,CAAA;AAC9B,eAAO,MAAM,kBAAkB,IAAI,CAAA;AACnC,eAAO,MAAM,cAAc,IAAI,CAAA;AAE/B,eAAO,MAAM,cAAc,EAAE,YAAY,EA6CxC,CAAA"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// Generated by scripts/regen-identity-handles.py. Do not edit.
|
|
2
|
-
// The source of truth is solidity/contracts/identity/handles.json.
|
|
3
|
-
/** keccak256 of this string is the platform id. */
|
|
4
|
-
export const PLATFORM_X_KEY = 'x';
|
|
5
|
-
/** keccak256 of this string is the platform id. */
|
|
6
|
-
export const PLATFORM_GITHUB_KEY = 'github';
|
|
7
|
-
/** keccak256 of this string is the platform id. */
|
|
8
|
-
export const PLATFORM_GOOGLE_KEY = 'google';
|
|
9
|
-
/** Bytes a x handle may have after normalization. */
|
|
10
|
-
export const MAX_LENGTH_X = 15;
|
|
11
|
-
/** Bytes a github handle may have after normalization. */
|
|
12
|
-
export const MAX_LENGTH_GITHUB = 39;
|
|
13
|
-
/** Bytes a google handle may have after normalization. */
|
|
14
|
-
export const MAX_LENGTH_GOOGLE = 62;
|
|
15
|
-
/** Remove one leading `@`. */
|
|
16
|
-
export const STRIP_LEADING_AT_X = true;
|
|
17
|
-
/** Validate as an address instead of a bare handle. */
|
|
18
|
-
export const IS_EMAIL_X = false;
|
|
19
|
-
/** Allow `_`. */
|
|
20
|
-
export const ALLOW_UNDERSCORE_X = true;
|
|
21
|
-
/** Allow `-`, but not leading, trailing or doubled. */
|
|
22
|
-
export const ALLOW_HYPHEN_X = false;
|
|
23
|
-
/** Remove one leading `@`. */
|
|
24
|
-
export const STRIP_LEADING_AT_GITHUB = true;
|
|
25
|
-
/** Validate as an address instead of a bare handle. */
|
|
26
|
-
export const IS_EMAIL_GITHUB = false;
|
|
27
|
-
/** Allow `_`. */
|
|
28
|
-
export const ALLOW_UNDERSCORE_GITHUB = false;
|
|
29
|
-
/** Allow `-`, but not leading, trailing or doubled. */
|
|
30
|
-
export const ALLOW_HYPHEN_GITHUB = true;
|
|
31
|
-
/** Remove one leading `@`. */
|
|
32
|
-
export const STRIP_LEADING_AT_GOOGLE = false;
|
|
33
|
-
/** Validate as an address instead of a bare handle. */
|
|
34
|
-
export const IS_EMAIL_GOOGLE = true;
|
|
35
|
-
/** Allow `_`. */
|
|
36
|
-
export const ALLOW_UNDERSCORE_GOOGLE = false;
|
|
37
|
-
/** Allow `-`, but not leading, trailing or doubled. */
|
|
38
|
-
export const ALLOW_HYPHEN_GOOGLE = false;
|
|
39
|
-
export const ERROR_EMPTY = 0;
|
|
40
|
-
export const ERROR_TOOLONG = 1;
|
|
41
|
-
export const ERROR_BADCHARACTER = 2;
|
|
42
|
-
export const ERROR_BADSHAPE = 3;
|
|
43
|
-
export const HANDLE_VECTORS = [
|
|
44
|
-
{ platform: "x", input: " @Alice_1 ", output: "alice_1", accepted: true, errorKind: 0 },
|
|
45
|
-
{ platform: "x", input: "alice", output: "alice", accepted: true, errorKind: 0 },
|
|
46
|
-
{ platform: "x", input: "@a", output: "a", accepted: true, errorKind: 0 },
|
|
47
|
-
{ platform: "x", input: "A1_b2", output: "a1_b2", accepted: true, errorKind: 0 },
|
|
48
|
-
{ platform: "x", input: "a12345678901234", output: "a12345678901234", accepted: true, errorKind: 0 },
|
|
49
|
-
{ platform: "x", input: "a123456789012345", output: "", accepted: false, errorKind: 1 },
|
|
50
|
-
{ platform: "x", input: "", output: "", accepted: false, errorKind: 0 },
|
|
51
|
-
{ platform: "x", input: " ", output: "", accepted: false, errorKind: 0 },
|
|
52
|
-
{ platform: "x", input: "@", output: "", accepted: false, errorKind: 0 },
|
|
53
|
-
{ platform: "x", input: "@@alice", output: "", accepted: false, errorKind: 2 },
|
|
54
|
-
{ platform: "x", input: "alice-1", output: "", accepted: false, errorKind: 2 },
|
|
55
|
-
{ platform: "x", input: "ali ce", output: "", accepted: false, errorKind: 2 },
|
|
56
|
-
{ platform: "x", input: "ali\tce", output: "", accepted: false, errorKind: 2 },
|
|
57
|
-
{ platform: "x", input: "ali\nce", output: "", accepted: false, errorKind: 2 },
|
|
58
|
-
{ platform: "x", input: "alic\u00e9", output: "", accepted: false, errorKind: 2 },
|
|
59
|
-
{ platform: "x", input: "\talice", output: "", accepted: false, errorKind: 2 },
|
|
60
|
-
{ platform: "x", input: "alice\t", output: "", accepted: false, errorKind: 2 },
|
|
61
|
-
{ platform: "x", input: "\nalice", output: "", accepted: false, errorKind: 2 },
|
|
62
|
-
{ platform: "x", input: " @ alice ", output: "", accepted: false, errorKind: 2 },
|
|
63
|
-
{ platform: "github", input: "@Octo-Cat", output: "octo-cat", accepted: true, errorKind: 0 },
|
|
64
|
-
{ platform: "github", input: "octocat", output: "octocat", accepted: true, errorKind: 0 },
|
|
65
|
-
{ platform: "github", input: " OctoCat ", output: "octocat", accepted: true, errorKind: 0 },
|
|
66
|
-
{ platform: "github", input: "a", output: "a", accepted: true, errorKind: 0 },
|
|
67
|
-
{ platform: "github", input: "o-c", output: "o-c", accepted: true, errorKind: 0 },
|
|
68
|
-
{ platform: "github", input: "-octocat", output: "", accepted: false, errorKind: 3 },
|
|
69
|
-
{ platform: "github", input: "octocat-", output: "", accepted: false, errorKind: 3 },
|
|
70
|
-
{ platform: "github", input: "octo--cat", output: "", accepted: false, errorKind: 3 },
|
|
71
|
-
{ platform: "github", input: "octo_cat", output: "", accepted: false, errorKind: 2 },
|
|
72
|
-
{ platform: "github", input: "-", output: "", accepted: false, errorKind: 3 },
|
|
73
|
-
{ platform: "github", input: "", output: "", accepted: false, errorKind: 0 },
|
|
74
|
-
{ platform: "github", input: "abcdefghijabcdefghijabcdefghijabcdefghi", output: "abcdefghijabcdefghijabcdefghijabcdefghi", accepted: true, errorKind: 0 },
|
|
75
|
-
{ platform: "github", input: "abcdefghijabcdefghijabcdefghijabcdefghij", output: "", accepted: false, errorKind: 1 },
|
|
76
|
-
{ platform: "github", input: "\n", output: "", accepted: false, errorKind: 2 },
|
|
77
|
-
{ platform: "google", input: "A.B+tag@Example.COM", output: "a.b+tag@example.com", accepted: true, errorKind: 0 },
|
|
78
|
-
{ platform: "google", input: "alice@example.com", output: "alice@example.com", accepted: true, errorKind: 0 },
|
|
79
|
-
{ platform: "google", input: " Alice@Example.com ", output: "alice@example.com", accepted: true, errorKind: 0 },
|
|
80
|
-
{ platform: "google", input: "@Alice@example.com", output: "", accepted: false, errorKind: 3 },
|
|
81
|
-
{ platform: "google", input: "alice", output: "", accepted: false, errorKind: 3 },
|
|
82
|
-
{ platform: "google", input: "@example.com", output: "", accepted: false, errorKind: 3 },
|
|
83
|
-
{ platform: "google", input: "alice@", output: "", accepted: false, errorKind: 3 },
|
|
84
|
-
{ platform: "google", input: "", output: "", accepted: false, errorKind: 0 },
|
|
85
|
-
{ platform: "google", input: "ali ce@example.com", output: "", accepted: false, errorKind: 2 },
|
|
86
|
-
{ platform: "google", input: "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij@example.com", output: "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij@example.com", accepted: true, errorKind: 0 },
|
|
87
|
-
{ platform: "google", input: "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijk@example.com", output: "", accepted: false, errorKind: 1 },
|
|
88
|
-
];
|
|
89
|
-
//# sourceMappingURL=handleVectors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleVectors.js","sourceRoot":"","sources":["../../src/identity/handleVectors.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,mEAAmE;AAanE,mDAAmD;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AACjC,mDAAmD;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAA;AAC3C,mDAAmD;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAA;AAE3C,qDAAqD;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAC9B,0DAA0D;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AACnC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAEnC,8BAA8B;AAC9B,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAA;AACtC,uDAAuD;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAA;AAC/B,iBAAiB;AACjB,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAA;AACtC,uDAAuD;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAA;AACnC,8BAA8B;AAC9B,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAA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