tangled
alpha
login
or
join now
olaren.dev
/
pdsls
forked from
pds.ls/pdsls
0
fork
atom
atmosphere explorer
0
fork
atom
overview
issues
pulls
pipelines
add ed25519 key detection
handle.invalid
3 months ago
a5a8a76e
d813d590
verified
This commit was signed with the committer's
known signature
.
handle.invalid
SSH Key Fingerprint:
SHA256:mBrT4x0JdzLpbVR95g1hjI1aaErfC02kmLRkPXwsYCk=
+37
-5
4 changed files
expand all
collapse all
unified
split
package.json
pnpm-lock.yaml
src
utils
key.ts
views
repo.tsx
+1
package.json
···
32
32
"@atcute/lexicon-doc": "^2.0.4",
33
33
"@atcute/lexicon-resolver": "^0.1.5",
34
34
"@atcute/lexicons": "^1.2.5",
35
35
+
"@atcute/multibase": "^1.1.6",
35
36
"@atcute/oauth-browser-client": "^2.0.1",
36
37
"@atcute/repo": "^0.1.0",
37
38
"@atcute/tangled": "^1.0.12",
+3
pnpm-lock.yaml
···
41
41
'@atcute/lexicons':
42
42
specifier: ^1.2.5
43
43
version: 1.2.5
44
44
+
'@atcute/multibase':
45
45
+
specifier: ^1.1.6
46
46
+
version: 1.1.6
44
47
'@atcute/oauth-browser-client':
45
48
specifier: ^2.0.1
46
49
version: 2.0.1
+30
src/utils/key.ts
···
1
1
+
import { parseDidKey, parsePublicMultikey } from "@atcute/crypto";
2
2
+
import { fromBase58Btc } from "@atcute/multibase";
3
3
+
4
4
+
export const detectKeyType = (key: string): string => {
5
5
+
try {
6
6
+
return parsePublicMultikey(key).type;
7
7
+
} catch (e) {
8
8
+
try {
9
9
+
const bytes = fromBase58Btc(key.startsWith("z") ? key.slice(1) : key);
10
10
+
if (bytes.length >= 2) {
11
11
+
const type = (bytes[0] << 8) | bytes[1];
12
12
+
if (type === 0xed01) {
13
13
+
return "ed25519";
14
14
+
}
15
15
+
}
16
16
+
} catch {}
17
17
+
return "unknown";
18
18
+
}
19
19
+
};
20
20
+
21
21
+
export const detectDidKeyType = (key: string): string => {
22
22
+
try {
23
23
+
return parseDidKey(key).type;
24
24
+
} catch (e) {
25
25
+
if (key.startsWith("did:key:")) {
26
26
+
return detectKeyType(key.slice(8));
27
27
+
}
28
28
+
return "unknown";
29
29
+
}
30
30
+
};
+3
-5
src/views/repo.tsx
···
1
1
import { Client, CredentialManager } from "@atcute/client";
2
2
-
import { parseDidKey, parsePublicMultikey } from "@atcute/crypto";
3
2
import { DidDocument } from "@atcute/identity";
4
3
import { ActorIdentifier, Did, Handle, Nsid } from "@atcute/lexicons";
5
4
import { A, useLocation, useNavigate, useParams } from "@solidjs/router";
···
39
38
resolvePDS,
40
39
validateHandle,
41
40
} from "../utils/api.js";
41
41
+
import { detectDidKeyType, detectKeyType } from "../utils/key.js";
42
42
import { BlobView } from "./blob.jsx";
43
43
import { PlcLogView } from "./logs.jsx";
44
44
···
566
566
#{verif.id.split("#")[1]}
567
567
</span>
568
568
<span class="rounded bg-neutral-200 px-1 py-0.5 text-xs text-neutral-800 dark:bg-neutral-700 dark:text-neutral-300">
569
569
-
<ErrorBoundary fallback={<>unknown</>}>
570
570
-
{parsePublicMultikey(key()).type}
571
571
-
</ErrorBoundary>
569
569
+
{detectKeyType(key())}
572
570
</span>
573
571
</div>
574
572
<div class="font-mono break-all">{key()}</div>
···
592
590
{(key) => (
593
591
<div class="text-sm">
594
592
<span class="rounded bg-neutral-200 px-1 py-0.5 text-xs text-neutral-800 dark:bg-neutral-700 dark:text-neutral-300">
595
595
-
{parseDidKey(key).type}
593
593
+
{detectDidKeyType(key)}
596
594
</span>
597
595
<div class="font-mono break-all">{key.replace("did:key:", "")}</div>
598
596
</div>