@totemsdk/identity 0.1.0 → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +306 -0
- package/dist/canonical.js +6 -2
- package/dist/claims.js +15 -9
- package/dist/constants.js +4 -1
- package/dist/document.js +12 -8
- package/dist/guards.js +12 -5
- package/dist/index.js +32 -10
- package/dist/manifest-binding.js +11 -7
- package/dist/resolver.js +6 -3
- package/dist/revocation.js +6 -3
- package/dist/rotation.js +6 -3
- package/dist/signing.js +16 -12
- package/dist/types.js +2 -1
- package/dist/verify.js +13 -10
- package/package.json +29 -6
- package/src/__tests__/identity.test.ts +0 -618
- package/src/canonical.ts +0 -27
- package/src/claims.ts +0 -108
- package/src/constants.ts +0 -1
- package/src/document.ts +0 -35
- package/src/guards.ts +0 -75
- package/src/index.ts +0 -55
- package/src/manifest-binding.ts +0 -163
- package/src/resolver.ts +0 -171
- package/src/revocation.ts +0 -25
- package/src/rotation.ts +0 -23
- package/src/signing.ts +0 -38
- package/src/types.ts +0 -147
- package/src/verify.ts +0 -90
package/dist/signing.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Claim signing using WOTS primitives from @totemsdk/core.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.claimDigest = claimDigest;
|
|
7
|
+
exports.signIdentityClaim = signIdentityClaim;
|
|
8
|
+
const sha3_js_1 = require("@noble/hashes/sha3.js");
|
|
9
|
+
const core_1 = require("@totemsdk/core");
|
|
10
|
+
const canonical_js_1 = require("./canonical.js");
|
|
11
|
+
function claimDigest(claim) {
|
|
12
|
+
const canonical = (0, canonical_js_1.canonicalJson)(claim);
|
|
13
|
+
return (0, sha3_js_1.sha3_256)(new TextEncoder().encode(canonical));
|
|
10
14
|
}
|
|
11
|
-
|
|
15
|
+
async function signIdentityClaim(claim, seed, keyIndex) {
|
|
12
16
|
const digest = claimDigest(claim);
|
|
13
|
-
const sigBytes = wotsSign(seed, keyIndex, digest);
|
|
14
|
-
const kp = wotsKeypairFromSeed(seed, keyIndex);
|
|
15
|
-
const address = wotsAddressFromKeypair(kp);
|
|
17
|
+
const sigBytes = (0, core_1.wotsSign)(seed, keyIndex, digest);
|
|
18
|
+
const kp = (0, core_1.wotsKeypairFromSeed)(seed, keyIndex);
|
|
19
|
+
const address = (0, core_1.wotsAddressFromKeypair)(kp);
|
|
16
20
|
return {
|
|
17
21
|
claim,
|
|
18
22
|
proof: {
|
|
19
23
|
address,
|
|
20
|
-
publicKey: bytesToHex(kp.pk),
|
|
21
|
-
signature: bytesToHex(sigBytes),
|
|
24
|
+
publicKey: (0, core_1.bytesToHex)(kp.pk),
|
|
25
|
+
signature: (0, core_1.bytesToHex)(sigBytes),
|
|
22
26
|
},
|
|
23
27
|
};
|
|
24
28
|
}
|
package/dist/types.js
CHANGED
package/dist/verify.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Claim verification.
|
|
3
4
|
*
|
|
@@ -9,29 +10,31 @@
|
|
|
9
10
|
* expected address from the public key. Any mismatch fails verification,
|
|
10
11
|
* preventing signer-address spoofing.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.verifyIdentityClaim = verifyIdentityClaim;
|
|
15
|
+
const core_1 = require("@totemsdk/core");
|
|
16
|
+
const signing_js_1 = require("./signing.js");
|
|
14
17
|
/**
|
|
15
18
|
* Derive the Minima address from a 32-byte WOTS PKdigest (hex).
|
|
16
19
|
* Returns null if the public key cannot be decoded.
|
|
17
20
|
*/
|
|
18
21
|
function addressFromPkDigest(publicKeyHex) {
|
|
19
22
|
try {
|
|
20
|
-
const pkDigest = hexToBytes(publicKeyHex);
|
|
21
|
-
const script = scriptFromWotsPk(pkDigest);
|
|
22
|
-
return scriptToAddress(script);
|
|
23
|
+
const pkDigest = (0, core_1.hexToBytes)(publicKeyHex);
|
|
24
|
+
const script = (0, core_1.scriptFromWotsPk)(pkDigest);
|
|
25
|
+
return (0, core_1.scriptToAddress)(script);
|
|
23
26
|
}
|
|
24
27
|
catch {
|
|
25
28
|
return null;
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
function verifyIdentityClaim(signed) {
|
|
29
32
|
const { claim, proof } = signed;
|
|
30
33
|
let sigBytes;
|
|
31
34
|
let pkDigest;
|
|
32
35
|
try {
|
|
33
|
-
sigBytes = hexToBytes(proof.signature);
|
|
34
|
-
pkDigest = hexToBytes(proof.publicKey);
|
|
36
|
+
sigBytes = (0, core_1.hexToBytes)(proof.signature);
|
|
37
|
+
pkDigest = (0, core_1.hexToBytes)(proof.publicKey);
|
|
35
38
|
}
|
|
36
39
|
catch (e) {
|
|
37
40
|
return {
|
|
@@ -57,10 +60,10 @@ export function verifyIdentityClaim(signed) {
|
|
|
57
60
|
signerAddress: proof.address,
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
|
-
const digest = claimDigest(claim);
|
|
63
|
+
const digest = (0, signing_js_1.claimDigest)(claim);
|
|
61
64
|
let sigValid;
|
|
62
65
|
try {
|
|
63
|
-
sigValid = wotsVerifyDigest(sigBytes, digest, pkDigest);
|
|
66
|
+
sigValid = (0, core_1.wotsVerifyDigest)(sigBytes, digest, pkDigest);
|
|
64
67
|
}
|
|
65
68
|
catch (e) {
|
|
66
69
|
return {
|
package/package.json
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/identity",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Canonical identity and claims layer for Totem Edge — who controls a manifest, device, or agent",
|
|
5
|
-
"type": "module",
|
|
6
5
|
"main": "dist/index.js",
|
|
7
6
|
"types": "dist/index.d.ts",
|
|
8
7
|
"exports": {
|
|
9
8
|
".": {
|
|
10
9
|
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
-
"
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
17
18
|
],
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@totemsdk/core": "1.0.9",
|
|
20
|
-
"@totemsdk/manifest": "0.1.
|
|
21
|
+
"@totemsdk/manifest": "0.1.1"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
|
-
"@noble/hashes": ">=1.3.0
|
|
24
|
+
"@noble/hashes": ">=1.3.0"
|
|
24
25
|
},
|
|
25
26
|
"peerDependenciesMeta": {
|
|
26
27
|
"@noble/hashes": {
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@noble/hashes": "^
|
|
32
|
+
"@noble/hashes": "^2.2.0",
|
|
32
33
|
"@types/jest": "^29.0.0",
|
|
33
34
|
"@types/node": "^20.0.0",
|
|
34
35
|
"jest": "^29.0.0",
|
|
@@ -43,6 +44,28 @@
|
|
|
43
44
|
"access": "public"
|
|
44
45
|
},
|
|
45
46
|
"license": "MIT",
|
|
47
|
+
"author": "Totem SDK",
|
|
48
|
+
"homepage": "https://totemsdk.com",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/MrGheek/axia-totem/issues"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/MrGheek/axia-totem.git",
|
|
55
|
+
"directory": "packages/totem-sdk/packages/identity"
|
|
56
|
+
},
|
|
57
|
+
"keywords": [
|
|
58
|
+
"totem",
|
|
59
|
+
"totemsdk",
|
|
60
|
+
"minima",
|
|
61
|
+
"blockchain",
|
|
62
|
+
"quantum-resistant",
|
|
63
|
+
"wots",
|
|
64
|
+
"kissvm",
|
|
65
|
+
"utxo",
|
|
66
|
+
"identity",
|
|
67
|
+
"did"
|
|
68
|
+
],
|
|
46
69
|
"scripts": {
|
|
47
70
|
"build": "tsc",
|
|
48
71
|
"clean": "rm -rf dist",
|