@aikdna/kdna-core 0.20.0 → 0.22.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/CHANGELOG.md +71 -0
- package/README.md +12 -2
- package/package.json +2 -2
- package/schema/load-contract.schema.json +3 -2
- package/schema/load-plan.schema.json +7 -0
- package/schema/manifest.schema.json +24 -14
- package/schema/payload-profile.schema.json +156 -6
- package/schema/runtime-capsule.schema.json +67 -10
- package/src/asset-reader.js +30 -105
- package/src/container/index.js +550 -44
- package/src/crypto-profile.js +18 -3
- package/src/external-key-grant.js +4 -8
- package/src/index.js +2 -0
- package/src/index.mjs +22 -2
- package/src/public-api.js +55 -13
- package/src/runtime-capsule.js +84 -1
- package/src/signature.js +320 -0
- package/src/types.d.ts +109 -19
package/src/types.d.ts
CHANGED
|
@@ -240,7 +240,6 @@ export interface KDNAManifest {
|
|
|
240
240
|
[key: string]: any;
|
|
241
241
|
};
|
|
242
242
|
content_digest?: string;
|
|
243
|
-
signature?: string;
|
|
244
243
|
[key: string]: any;
|
|
245
244
|
}
|
|
246
245
|
|
|
@@ -292,7 +291,6 @@ export interface KdnaAssetVerifyResult {
|
|
|
292
291
|
manifest: KDNAManifest | null;
|
|
293
292
|
asset_digest: string;
|
|
294
293
|
content_digest: string;
|
|
295
|
-
signature_valid: boolean | null;
|
|
296
294
|
}
|
|
297
295
|
|
|
298
296
|
export interface KdnaAssetIndexProfile {
|
|
@@ -338,7 +336,6 @@ export interface KdnaAssetReader {
|
|
|
338
336
|
options?: {
|
|
339
337
|
asset_digest?: string;
|
|
340
338
|
content_digest?: string;
|
|
341
|
-
requireSignature?: boolean;
|
|
342
339
|
requireDecryption?: boolean;
|
|
343
340
|
} & KdnaDecryptOptions,
|
|
344
341
|
): KdnaAssetVerifyResult;
|
|
@@ -347,7 +344,6 @@ export interface KdnaAssetReader {
|
|
|
347
344
|
options?: {
|
|
348
345
|
asset_digest?: string;
|
|
349
346
|
content_digest?: string;
|
|
350
|
-
requireSignature?: boolean;
|
|
351
347
|
requireDecryption?: boolean;
|
|
352
348
|
} & KdnaDecryptOptions,
|
|
353
349
|
): Promise<KdnaAssetVerifyResult>;
|
|
@@ -736,7 +732,6 @@ export interface KDNAInspectResult {
|
|
|
736
732
|
entries: string[];
|
|
737
733
|
asset_digest: string;
|
|
738
734
|
content_digest: string;
|
|
739
|
-
signature_valid: boolean | null;
|
|
740
735
|
ok: boolean | null;
|
|
741
736
|
errors: string[];
|
|
742
737
|
warnings: string[];
|
|
@@ -748,6 +743,12 @@ export interface KDNAValidationReport {
|
|
|
748
743
|
schema_valid: boolean;
|
|
749
744
|
payload_valid: boolean;
|
|
750
745
|
checksums_valid: boolean;
|
|
746
|
+
signature_valid: boolean;
|
|
747
|
+
signature_state: 'absent' | 'verified' | 'invalid';
|
|
748
|
+
signature_evidence: (KDNASignatureEvidenceVerified & {
|
|
749
|
+
algorithm: 'ed25519';
|
|
750
|
+
public_key: string;
|
|
751
|
+
}) | null;
|
|
751
752
|
load_contract_valid: boolean;
|
|
752
753
|
loader_version: string;
|
|
753
754
|
min_loader_version: string | null;
|
|
@@ -788,6 +789,22 @@ export interface KDNADigestEvidence {
|
|
|
788
789
|
runtime_entry_set: KDNADigestValue;
|
|
789
790
|
}
|
|
790
791
|
|
|
792
|
+
export interface KDNASignatureEvidenceAbsent {
|
|
793
|
+
state: 'absent';
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
export interface KDNASignatureEvidenceVerified {
|
|
797
|
+
state: 'verified';
|
|
798
|
+
profile: 'kdsig.ed25519';
|
|
799
|
+
profile_version: '0.1.0';
|
|
800
|
+
key_fingerprint: string;
|
|
801
|
+
content_digest: string;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
export type KDNASignatureEvidence =
|
|
805
|
+
| KDNASignatureEvidenceAbsent
|
|
806
|
+
| KDNASignatureEvidenceVerified;
|
|
807
|
+
|
|
791
808
|
export interface KDNARuntimeCapsule {
|
|
792
809
|
type: 'kdna.runtime-capsule';
|
|
793
810
|
contract_version: '0.1.0';
|
|
@@ -798,7 +815,7 @@ export interface KDNARuntimeCapsule {
|
|
|
798
815
|
judgment_version: string;
|
|
799
816
|
};
|
|
800
817
|
digests: KDNADigestEvidence;
|
|
801
|
-
signature:
|
|
818
|
+
signature: KDNASignatureEvidence;
|
|
802
819
|
access: 'public' | 'licensed' | 'remote';
|
|
803
820
|
profile: 'index' | 'compact' | 'scenario' | 'full';
|
|
804
821
|
context: Record<string, any>;
|
|
@@ -809,8 +826,13 @@ export interface KDNARuntimeCapsule {
|
|
|
809
826
|
input_kind: 'packaged_file' | 'packaged_bytes';
|
|
810
827
|
runtime_eligible: true;
|
|
811
828
|
schema_valid: true;
|
|
812
|
-
signature_state: '
|
|
829
|
+
signature_state: 'absent' | 'verified';
|
|
813
830
|
profile: 'index' | 'compact' | 'scenario' | 'full';
|
|
831
|
+
projection_report?: {
|
|
832
|
+
status: 'complete' | 'partial';
|
|
833
|
+
omitted: Array<{ path: string; count: number }>;
|
|
834
|
+
omitted_total: number;
|
|
835
|
+
};
|
|
814
836
|
};
|
|
815
837
|
}
|
|
816
838
|
|
|
@@ -852,11 +874,72 @@ export function buildRuntimeCapsule(input: {
|
|
|
852
874
|
projection: Record<string, any>;
|
|
853
875
|
manifest: KDNAManifest;
|
|
854
876
|
digests: KDNADigestEvidence;
|
|
855
|
-
signature
|
|
877
|
+
signature?: KDNASignatureEvidence;
|
|
856
878
|
inputKind: 'packaged_file' | 'packaged_bytes';
|
|
857
879
|
loadedAt?: string;
|
|
858
880
|
schemaValid?: boolean;
|
|
859
881
|
}): KDNARuntimeCapsule;
|
|
882
|
+
|
|
883
|
+
export const KDSIG_PROFILE: 'kdsig.ed25519';
|
|
884
|
+
export const KDSIG_PROFILE_VERSION: '0.1.0';
|
|
885
|
+
export const KDSIG_ALGORITHM: 'ed25519';
|
|
886
|
+
export const SIGNATURE_ENTRY_NAME: 'signature.kdsig';
|
|
887
|
+
|
|
888
|
+
export interface KDNASignatureBundle {
|
|
889
|
+
algorithm: 'ed25519';
|
|
890
|
+
content_digest: string;
|
|
891
|
+
profile: 'kdsig.ed25519';
|
|
892
|
+
profile_version: '0.1.0';
|
|
893
|
+
public_key: string;
|
|
894
|
+
signature: string;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
export function buildSigningPayload(contentDigest: string): Uint8Array;
|
|
898
|
+
export function generateSigningKeyPair(): {
|
|
899
|
+
algorithm: 'ed25519';
|
|
900
|
+
private_key: string;
|
|
901
|
+
public_key: string;
|
|
902
|
+
};
|
|
903
|
+
export function keyFingerprint(publicKeyHex: string): string;
|
|
904
|
+
export function parseSignatureBundle(bytes: Uint8Array | string): KDNASignatureBundle;
|
|
905
|
+
export function serializeSignatureBundle(bundle: KDNASignatureBundle): Uint8Array;
|
|
906
|
+
export function signContentDigest(
|
|
907
|
+
contentDigest: string,
|
|
908
|
+
privateKeySeedHex: string,
|
|
909
|
+
): KDNASignatureBundle;
|
|
910
|
+
export function verifySignatureBundle(
|
|
911
|
+
bundle: Uint8Array | string,
|
|
912
|
+
contentDigest: string,
|
|
913
|
+
options?: { expectedPublicKey?: string },
|
|
914
|
+
): KDNASignatureEvidenceVerified & { algorithm: 'ed25519'; public_key: string };
|
|
915
|
+
export function signKDNA(
|
|
916
|
+
input: string | Uint8Array,
|
|
917
|
+
privateKey: string,
|
|
918
|
+
options?: { outputPath?: string },
|
|
919
|
+
): Promise<{
|
|
920
|
+
containerBytes: Uint8Array;
|
|
921
|
+
bundle: KDNASignatureBundle;
|
|
922
|
+
bundleBytes: Uint8Array;
|
|
923
|
+
content_digest: string;
|
|
924
|
+
}>;
|
|
925
|
+
export function signKDNASync(
|
|
926
|
+
input: string | Uint8Array,
|
|
927
|
+
privateKey: string,
|
|
928
|
+
options?: { outputPath?: string },
|
|
929
|
+
): {
|
|
930
|
+
containerBytes: Uint8Array;
|
|
931
|
+
bundle: KDNASignatureBundle;
|
|
932
|
+
bundleBytes: Uint8Array;
|
|
933
|
+
content_digest: string;
|
|
934
|
+
};
|
|
935
|
+
export function verifyKDNASignature(
|
|
936
|
+
input: string | Uint8Array,
|
|
937
|
+
options?: { required?: boolean; expectedPublicKey?: string },
|
|
938
|
+
): Promise<KDNASignatureEvidence>;
|
|
939
|
+
export function verifyKDNASignatureSync(
|
|
940
|
+
input: string | Uint8Array,
|
|
941
|
+
options?: { required?: boolean; expectedPublicKey?: string },
|
|
942
|
+
): KDNASignatureEvidence;
|
|
860
943
|
export function loadRuntimeCapsule(
|
|
861
944
|
input: string | Uint8Array,
|
|
862
945
|
options?: {
|
|
@@ -1296,7 +1379,6 @@ export function verifyAsset(
|
|
|
1296
1379
|
options?: {
|
|
1297
1380
|
asset_digest?: string;
|
|
1298
1381
|
content_digest?: string;
|
|
1299
|
-
requireSignature?: boolean;
|
|
1300
1382
|
requireDecryption?: boolean;
|
|
1301
1383
|
} & KdnaDecryptOptions,
|
|
1302
1384
|
): Promise<KdnaAssetVerifyResult>;
|
|
@@ -1305,7 +1387,6 @@ export function verifyAssetSync(
|
|
|
1305
1387
|
options?: {
|
|
1306
1388
|
asset_digest?: string;
|
|
1307
1389
|
content_digest?: string;
|
|
1308
|
-
requireSignature?: boolean;
|
|
1309
1390
|
requireDecryption?: boolean;
|
|
1310
1391
|
} & KdnaDecryptOptions,
|
|
1311
1392
|
): KdnaAssetVerifyResult;
|
|
@@ -1319,14 +1400,6 @@ export function verifyDigestSync(
|
|
|
1319
1400
|
expectedDigest: string,
|
|
1320
1401
|
options?: KdnaDecryptOptions,
|
|
1321
1402
|
): KdnaAssetVerifyResult;
|
|
1322
|
-
export function verifySignature(
|
|
1323
|
-
input: KDNAAssetInput,
|
|
1324
|
-
options?: KdnaDecryptOptions,
|
|
1325
|
-
): Promise<KdnaAssetVerifyResult>;
|
|
1326
|
-
export function verifySignatureSync(
|
|
1327
|
-
input: KDNAAssetInput,
|
|
1328
|
-
options?: KdnaDecryptOptions,
|
|
1329
|
-
): KdnaAssetVerifyResult;
|
|
1330
1403
|
export function matchDomain(
|
|
1331
1404
|
input: string,
|
|
1332
1405
|
candidates: Array<KDNAAssetInput | KDNAInspectResult>,
|
|
@@ -1370,6 +1443,11 @@ export interface KDNALayout {
|
|
|
1370
1443
|
}
|
|
1371
1444
|
|
|
1372
1445
|
export function readLayout(inputPath: string): KDNALayout;
|
|
1446
|
+
export function readLayoutBytes(input: Uint8Array): KDNALayout;
|
|
1447
|
+
export function fullEntryBufferMap(layout: KDNALayout): Record<string, Uint8Array>;
|
|
1448
|
+
export function contentDigestFromEntryBuffers(
|
|
1449
|
+
buffers: Map<string, Uint8Array> | Record<string, Uint8Array>,
|
|
1450
|
+
): string;
|
|
1373
1451
|
|
|
1374
1452
|
export interface KDNAChecksumEntry {
|
|
1375
1453
|
algorithm: 'sha256';
|
|
@@ -1393,7 +1471,7 @@ export function inspect(
|
|
|
1393
1471
|
input: string | Uint8Array,
|
|
1394
1472
|
options?: Record<string, any>,
|
|
1395
1473
|
): Record<string, any>;
|
|
1396
|
-
export const KDNA_LOADER_VERSION: '0.
|
|
1474
|
+
export const KDNA_LOADER_VERSION: '0.22.0';
|
|
1397
1475
|
export const STRICT_LOADER_VERSION: RegExp;
|
|
1398
1476
|
export function parseLoaderVersion(version: unknown): readonly [string, string, string] | null;
|
|
1399
1477
|
export function compareLoaderVersions(left: string, right: string): -1 | 0 | 1;
|
|
@@ -1454,6 +1532,7 @@ export interface KDNALoadPlan {
|
|
|
1454
1532
|
source_fingerprint: string;
|
|
1455
1533
|
} | null;
|
|
1456
1534
|
checks: Record<string, boolean>;
|
|
1535
|
+
signature_state: 'absent' | 'verified' | 'invalid';
|
|
1457
1536
|
issues: KDNALoadPlanIssue[];
|
|
1458
1537
|
source: {
|
|
1459
1538
|
kind: 'dir' | 'file' | 'memory' | string | null;
|
|
@@ -1470,6 +1549,17 @@ export function planLoad(
|
|
|
1470
1549
|
): KDNALoadPlan;
|
|
1471
1550
|
export function buildChecksums(sourceDir: string): KDNAChecksums;
|
|
1472
1551
|
export function pack(sourceDir: string, outputPath: string): void;
|
|
1552
|
+
export function packEntryMap(map: Record<string, Uint8Array>): Uint8Array;
|
|
1553
|
+
export function signContainerBytes(
|
|
1554
|
+
input: Uint8Array,
|
|
1555
|
+
privateKey: string,
|
|
1556
|
+
options?: Record<string, any>,
|
|
1557
|
+
): {
|
|
1558
|
+
containerBytes: Uint8Array;
|
|
1559
|
+
bundle: KDNASignatureBundle;
|
|
1560
|
+
bundleBytes: Uint8Array;
|
|
1561
|
+
content_digest: string;
|
|
1562
|
+
};
|
|
1473
1563
|
export function unpack(inputPath: string, outputDir: string): void;
|
|
1474
1564
|
export function loadAuthorized(
|
|
1475
1565
|
input: string | Uint8Array,
|