@nexart/ai-execution 0.11.0 → 0.12.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/dist/index.d.cts CHANGED
@@ -568,4 +568,116 @@ interface CerVerificationResult {
568
568
  */
569
569
  declare function verifyAiCerBundleDetailed(bundle: unknown): CerVerificationResult;
570
570
 
571
- export { AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerContextSignal, CerMeta, CerVerificationError, type CerVerificationResult, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, type CheckStatus, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, ReasonCode, ReasonCode as ReasonCodeType, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, type VerificationStatus, type VerifyRunSummaryOptions, attest, attestIfNeeded, certifyAndAttestDecision, certifyAndAttestRun, certifyDecision, certifyDecisionFromProviderCall, computeInputHash, computeOutputHash, createClient, createSnapshot, exportCer, exportVerifiableRedacted, fetchNodeKeys, getAttestationReceipt, hasAttestation, hashCanonicalJson, hashToolOutput, hashUtf8, importCer, makeToolEvent, mapToAiefReason, redactBeforeSeal, sanitizeForAttestation, sanitizeForStamp, sanitizeForStorage, sealCer, selectNodeKey, sha256Hex, toCanonicalJson, validateProfile, verifyCer as verify, verifyAiCerBundleDetailed, verifyAief, verifyBundleAttestation, verifyCer, verifyNodeReceiptSignature, verifyRunSummary, verifySnapshot };
571
+ /**
572
+ * @nexart/ai-execution — CER package helpers (v0.12.0)
573
+ *
574
+ * A "CER package" is a transport/export envelope that wraps a sealed
575
+ * cer.ai.execution.v1 bundle with optional receipt, signature, and
576
+ * attestation metadata.
577
+ *
578
+ * These helpers sit around the existing core and do NOT change CER hashing,
579
+ * canonicalization, attestation, or verification semantics in any way.
580
+ *
581
+ * @example
582
+ * ```ts
583
+ * import { certifyDecision } from '@nexart/ai-execution';
584
+ * import { createCerPackage, exportCerPackage, importCerPackage } from '@nexart/ai-execution';
585
+ *
586
+ * const cer = certifyDecision({ ... });
587
+ * const pkg = createCerPackage({ cer });
588
+ * const json = exportCerPackage(pkg);
589
+ * const restored = importCerPackage(json); // verifies inner CER
590
+ * ```
591
+ */
592
+
593
+ /**
594
+ * A CER package — a transport/export envelope for a sealed CER bundle.
595
+ *
596
+ * The `cer` field is the only required field. All other fields are additive
597
+ * transport/export metadata and do not affect CER hashing or verification.
598
+ */
599
+ interface AiCerPackage {
600
+ /** The sealed cer.ai.execution.v1 bundle. Required. */
601
+ cer: CerAiExecutionBundle;
602
+ /** Optional attestation receipt from a NexArt attestation node. */
603
+ receipt?: AttestationReceipt;
604
+ /**
605
+ * Optional base64url-encoded signature covering the package.
606
+ * NexArt does not interpret or verify this field — it is opaque transport metadata.
607
+ */
608
+ signature?: string;
609
+ /**
610
+ * Optional attestation summary block.
611
+ * NexArt does not interpret or verify its contents.
612
+ */
613
+ attestation?: Record<string, unknown>;
614
+ /**
615
+ * Optional verification envelope metadata.
616
+ * NexArt does not interpret or verify its contents.
617
+ */
618
+ verificationEnvelope?: Record<string, unknown>;
619
+ /**
620
+ * Optional base64url-encoded signature covering verificationEnvelope.
621
+ * NexArt does not interpret or verify this field — it is opaque transport metadata.
622
+ */
623
+ verificationEnvelopeSignature?: string;
624
+ }
625
+ /** Input parameters for createCerPackage(). Structurally identical to AiCerPackage. */
626
+ type CreateCerPackageParams = AiCerPackage;
627
+ /**
628
+ * Type guard: returns true if `value` is shaped like a CER package.
629
+ *
630
+ * A value qualifies as a CER package if it is a plain object whose `cer`
631
+ * field is a plain object with `bundleType === 'cer.ai.execution.v1'`.
632
+ *
633
+ * Lightweight structural check only — does NOT verify the inner CER hash.
634
+ * Use `verifyCerPackage()` or `importCerPackage()` for integrity verification.
635
+ */
636
+ declare function isCerPackage(value: unknown): value is AiCerPackage;
637
+ /**
638
+ * Assemble a CER package from a sealed CER bundle and optional transport metadata.
639
+ *
640
+ * Simple assembly only. Does NOT sign, re-hash, or re-verify the CER.
641
+ * The `cer.certificateHash` is taken as-is and remains authoritative.
642
+ * Only fields explicitly provided in `params` are included in the returned package.
643
+ */
644
+ declare function createCerPackage(params: CreateCerPackageParams): AiCerPackage;
645
+ /**
646
+ * Extract the inner CER bundle from a CER package.
647
+ *
648
+ * Throws `CerVerificationError` if `pkg` is not a valid CER package shape.
649
+ * Does NOT re-verify the CER hash — use `verifyCerPackage()` if verification is needed.
650
+ */
651
+ declare function getCerFromPackage(pkg: unknown): CerAiExecutionBundle;
652
+ /**
653
+ * Serialize a CER package to a stable canonical JSON string for transport or storage.
654
+ *
655
+ * Uses the same canonicalJson serializer as the rest of the SDK for
656
+ * predictable, stable output across environments.
657
+ */
658
+ declare function exportCerPackage(pkg: AiCerPackage): string;
659
+ /**
660
+ * Parse a CER package JSON string, validate its shape, and verify the inner CER bundle.
661
+ *
662
+ * Throws `CerVerificationError` if:
663
+ * - the JSON string is malformed
664
+ * - the parsed value is not a CER package shape
665
+ * - the inner `cer` bundle fails `verifyCer()`
666
+ *
667
+ * Does NOT change or reinterpret the bundle — returns it exactly as parsed.
668
+ */
669
+ declare function importCerPackage(json: string): AiCerPackage;
670
+ /**
671
+ * Verify the inner CER bundle of a package using the existing `verifyCer()`.
672
+ *
673
+ * Conservative by design:
674
+ * - ONLY verifies the inner `cer` bundle (certificate hash, snapshot hashes, input/output hashes).
675
+ * - Does NOT verify `receipt`, `signature`, `verificationEnvelope`, or any other
676
+ * package-level fields — those require provider-specific trust semantics outside this SDK.
677
+ *
678
+ * Returns the same `VerificationResult` shape as `verifyCer()`.
679
+ * When `pkg` is not a valid package shape, returns `ok: false` with code `SCHEMA_ERROR`.
680
+ */
681
+ declare function verifyCerPackage(pkg: unknown): VerificationResult;
682
+
683
+ export { type AiCerPackage, AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerContextSignal, CerMeta, CerVerificationError, type CerVerificationResult, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, type CheckStatus, type CreateCerPackageParams, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, ReasonCode, ReasonCode as ReasonCodeType, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, type VerificationStatus, type VerifyRunSummaryOptions, attest, attestIfNeeded, certifyAndAttestDecision, certifyAndAttestRun, certifyDecision, certifyDecisionFromProviderCall, computeInputHash, computeOutputHash, createCerPackage, createClient, createSnapshot, exportCer, exportCerPackage, exportVerifiableRedacted, fetchNodeKeys, getAttestationReceipt, getCerFromPackage, hasAttestation, hashCanonicalJson, hashToolOutput, hashUtf8, importCer, importCerPackage, isCerPackage, makeToolEvent, mapToAiefReason, redactBeforeSeal, sanitizeForAttestation, sanitizeForStamp, sanitizeForStorage, sealCer, selectNodeKey, sha256Hex, toCanonicalJson, validateProfile, verifyCer as verify, verifyAiCerBundleDetailed, verifyAief, verifyBundleAttestation, verifyCer, verifyCerPackage, verifyNodeReceiptSignature, verifyRunSummary, verifySnapshot };
package/dist/index.d.ts CHANGED
@@ -568,4 +568,116 @@ interface CerVerificationResult {
568
568
  */
569
569
  declare function verifyAiCerBundleDetailed(bundle: unknown): CerVerificationResult;
570
570
 
571
- export { AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerContextSignal, CerMeta, CerVerificationError, type CerVerificationResult, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, type CheckStatus, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, ReasonCode, ReasonCode as ReasonCodeType, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, type VerificationStatus, type VerifyRunSummaryOptions, attest, attestIfNeeded, certifyAndAttestDecision, certifyAndAttestRun, certifyDecision, certifyDecisionFromProviderCall, computeInputHash, computeOutputHash, createClient, createSnapshot, exportCer, exportVerifiableRedacted, fetchNodeKeys, getAttestationReceipt, hasAttestation, hashCanonicalJson, hashToolOutput, hashUtf8, importCer, makeToolEvent, mapToAiefReason, redactBeforeSeal, sanitizeForAttestation, sanitizeForStamp, sanitizeForStorage, sealCer, selectNodeKey, sha256Hex, toCanonicalJson, validateProfile, verifyCer as verify, verifyAiCerBundleDetailed, verifyAief, verifyBundleAttestation, verifyCer, verifyNodeReceiptSignature, verifyRunSummary, verifySnapshot };
571
+ /**
572
+ * @nexart/ai-execution — CER package helpers (v0.12.0)
573
+ *
574
+ * A "CER package" is a transport/export envelope that wraps a sealed
575
+ * cer.ai.execution.v1 bundle with optional receipt, signature, and
576
+ * attestation metadata.
577
+ *
578
+ * These helpers sit around the existing core and do NOT change CER hashing,
579
+ * canonicalization, attestation, or verification semantics in any way.
580
+ *
581
+ * @example
582
+ * ```ts
583
+ * import { certifyDecision } from '@nexart/ai-execution';
584
+ * import { createCerPackage, exportCerPackage, importCerPackage } from '@nexart/ai-execution';
585
+ *
586
+ * const cer = certifyDecision({ ... });
587
+ * const pkg = createCerPackage({ cer });
588
+ * const json = exportCerPackage(pkg);
589
+ * const restored = importCerPackage(json); // verifies inner CER
590
+ * ```
591
+ */
592
+
593
+ /**
594
+ * A CER package — a transport/export envelope for a sealed CER bundle.
595
+ *
596
+ * The `cer` field is the only required field. All other fields are additive
597
+ * transport/export metadata and do not affect CER hashing or verification.
598
+ */
599
+ interface AiCerPackage {
600
+ /** The sealed cer.ai.execution.v1 bundle. Required. */
601
+ cer: CerAiExecutionBundle;
602
+ /** Optional attestation receipt from a NexArt attestation node. */
603
+ receipt?: AttestationReceipt;
604
+ /**
605
+ * Optional base64url-encoded signature covering the package.
606
+ * NexArt does not interpret or verify this field — it is opaque transport metadata.
607
+ */
608
+ signature?: string;
609
+ /**
610
+ * Optional attestation summary block.
611
+ * NexArt does not interpret or verify its contents.
612
+ */
613
+ attestation?: Record<string, unknown>;
614
+ /**
615
+ * Optional verification envelope metadata.
616
+ * NexArt does not interpret or verify its contents.
617
+ */
618
+ verificationEnvelope?: Record<string, unknown>;
619
+ /**
620
+ * Optional base64url-encoded signature covering verificationEnvelope.
621
+ * NexArt does not interpret or verify this field — it is opaque transport metadata.
622
+ */
623
+ verificationEnvelopeSignature?: string;
624
+ }
625
+ /** Input parameters for createCerPackage(). Structurally identical to AiCerPackage. */
626
+ type CreateCerPackageParams = AiCerPackage;
627
+ /**
628
+ * Type guard: returns true if `value` is shaped like a CER package.
629
+ *
630
+ * A value qualifies as a CER package if it is a plain object whose `cer`
631
+ * field is a plain object with `bundleType === 'cer.ai.execution.v1'`.
632
+ *
633
+ * Lightweight structural check only — does NOT verify the inner CER hash.
634
+ * Use `verifyCerPackage()` or `importCerPackage()` for integrity verification.
635
+ */
636
+ declare function isCerPackage(value: unknown): value is AiCerPackage;
637
+ /**
638
+ * Assemble a CER package from a sealed CER bundle and optional transport metadata.
639
+ *
640
+ * Simple assembly only. Does NOT sign, re-hash, or re-verify the CER.
641
+ * The `cer.certificateHash` is taken as-is and remains authoritative.
642
+ * Only fields explicitly provided in `params` are included in the returned package.
643
+ */
644
+ declare function createCerPackage(params: CreateCerPackageParams): AiCerPackage;
645
+ /**
646
+ * Extract the inner CER bundle from a CER package.
647
+ *
648
+ * Throws `CerVerificationError` if `pkg` is not a valid CER package shape.
649
+ * Does NOT re-verify the CER hash — use `verifyCerPackage()` if verification is needed.
650
+ */
651
+ declare function getCerFromPackage(pkg: unknown): CerAiExecutionBundle;
652
+ /**
653
+ * Serialize a CER package to a stable canonical JSON string for transport or storage.
654
+ *
655
+ * Uses the same canonicalJson serializer as the rest of the SDK for
656
+ * predictable, stable output across environments.
657
+ */
658
+ declare function exportCerPackage(pkg: AiCerPackage): string;
659
+ /**
660
+ * Parse a CER package JSON string, validate its shape, and verify the inner CER bundle.
661
+ *
662
+ * Throws `CerVerificationError` if:
663
+ * - the JSON string is malformed
664
+ * - the parsed value is not a CER package shape
665
+ * - the inner `cer` bundle fails `verifyCer()`
666
+ *
667
+ * Does NOT change or reinterpret the bundle — returns it exactly as parsed.
668
+ */
669
+ declare function importCerPackage(json: string): AiCerPackage;
670
+ /**
671
+ * Verify the inner CER bundle of a package using the existing `verifyCer()`.
672
+ *
673
+ * Conservative by design:
674
+ * - ONLY verifies the inner `cer` bundle (certificate hash, snapshot hashes, input/output hashes).
675
+ * - Does NOT verify `receipt`, `signature`, `verificationEnvelope`, or any other
676
+ * package-level fields — those require provider-specific trust semantics outside this SDK.
677
+ *
678
+ * Returns the same `VerificationResult` shape as `verifyCer()`.
679
+ * When `pkg` is not a valid package shape, returns `ok: false` with code `SCHEMA_ERROR`.
680
+ */
681
+ declare function verifyCerPackage(pkg: unknown): VerificationResult;
682
+
683
+ export { type AiCerPackage, AiExecutionSnapshotV1, AiefProfile, AiefVerifyResult, AttestOptions, AttestationReceipt, AttestationResult, BundleDeclaration, CerAiExecutionBundle, CerAttestationError, CerContextSignal, CerMeta, CerVerificationError, type CerVerificationResult, CerVerifyCode, CerVerifyCode as CerVerifyCodeType, type CertifyAndAttestRunOptions, type CertifyAndAttestRunResult, CertifyDecisionParams, type CheckStatus, type CreateCerPackageParams, CreateSnapshotParams, type ExportVerifiableRedactedOptions, type ExportVerifiableRedactedProvenance, type ExportVerifiableRedactedResult, type MakeToolEventParams, NodeKeysDocument, NodeReceiptVerifyResult, type ProfileValidationResult, ReasonCode, ReasonCode as ReasonCodeType, type RedactBeforeSealPolicy, RunBuilder, RunBuilderOptions, RunSummary, RunSummaryVerifyResult, SanitizeStorageOptions, SignedAttestationReceipt, StepParams, ToolEvent, VerificationResult, type VerificationStatus, type VerifyRunSummaryOptions, attest, attestIfNeeded, certifyAndAttestDecision, certifyAndAttestRun, certifyDecision, certifyDecisionFromProviderCall, computeInputHash, computeOutputHash, createCerPackage, createClient, createSnapshot, exportCer, exportCerPackage, exportVerifiableRedacted, fetchNodeKeys, getAttestationReceipt, getCerFromPackage, hasAttestation, hashCanonicalJson, hashToolOutput, hashUtf8, importCer, importCerPackage, isCerPackage, makeToolEvent, mapToAiefReason, redactBeforeSeal, sanitizeForAttestation, sanitizeForStamp, sanitizeForStorage, sealCer, selectNodeKey, sha256Hex, toCanonicalJson, validateProfile, verifyCer as verify, verifyAiCerBundleDetailed, verifyAief, verifyBundleAttestation, verifyCer, verifyCerPackage, verifyNodeReceiptSignature, verifyRunSummary, verifySnapshot };
package/dist/index.mjs CHANGED
@@ -2656,6 +2656,67 @@ function certifyLangChainRun(input, _options) {
2656
2656
  }
2657
2657
  return createLangChainCer(input);
2658
2658
  }
2659
+
2660
+ // src/package.ts
2661
+ function isCerPackage(value) {
2662
+ if (typeof value !== "object" || value === null) return false;
2663
+ const pkg = value;
2664
+ if (typeof pkg["cer"] !== "object" || pkg["cer"] === null) return false;
2665
+ const cer = pkg["cer"];
2666
+ return cer["bundleType"] === "cer.ai.execution.v1";
2667
+ }
2668
+ function createCerPackage(params) {
2669
+ const pkg = { cer: params.cer };
2670
+ if (params.receipt !== void 0) pkg.receipt = params.receipt;
2671
+ if (params.signature !== void 0) pkg.signature = params.signature;
2672
+ if (params.attestation !== void 0) pkg.attestation = params.attestation;
2673
+ if (params.verificationEnvelope !== void 0) pkg.verificationEnvelope = params.verificationEnvelope;
2674
+ if (params.verificationEnvelopeSignature !== void 0) pkg.verificationEnvelopeSignature = params.verificationEnvelopeSignature;
2675
+ return pkg;
2676
+ }
2677
+ function getCerFromPackage(pkg) {
2678
+ if (!isCerPackage(pkg)) {
2679
+ throw new CerVerificationError([
2680
+ "getCerFromPackage: value is not a valid CER package (missing or invalid cer field)"
2681
+ ]);
2682
+ }
2683
+ return pkg.cer;
2684
+ }
2685
+ function exportCerPackage(pkg) {
2686
+ return toCanonicalJson(pkg);
2687
+ }
2688
+ function importCerPackage(json) {
2689
+ let parsed;
2690
+ try {
2691
+ parsed = JSON.parse(json);
2692
+ } catch (err2) {
2693
+ throw new CerVerificationError([
2694
+ `importCerPackage: invalid JSON: ${err2.message}`
2695
+ ]);
2696
+ }
2697
+ if (!isCerPackage(parsed)) {
2698
+ throw new CerVerificationError([
2699
+ "importCerPackage: parsed value is not a CER package (missing or invalid cer field)"
2700
+ ]);
2701
+ }
2702
+ const result = verifyCer(parsed.cer);
2703
+ if (!result.ok) {
2704
+ throw new CerVerificationError([
2705
+ `importCerPackage: inner CER failed verification: ${result.errors.join("; ")}`
2706
+ ]);
2707
+ }
2708
+ return parsed;
2709
+ }
2710
+ function verifyCerPackage(pkg) {
2711
+ if (!isCerPackage(pkg)) {
2712
+ return {
2713
+ ok: false,
2714
+ errors: ["verifyCerPackage: value is not a CER package (missing or invalid cer field)"],
2715
+ code: CerVerifyCode.SCHEMA_ERROR
2716
+ };
2717
+ }
2718
+ return verifyCer(pkg.cer);
2719
+ }
2659
2720
  export {
2660
2721
  CerAttestationError,
2661
2722
  CerVerificationError,
@@ -2671,18 +2732,23 @@ export {
2671
2732
  certifyLangChainRun,
2672
2733
  computeInputHash,
2673
2734
  computeOutputHash,
2735
+ createCerPackage,
2674
2736
  createClient,
2675
2737
  createLangChainCer,
2676
2738
  createSnapshot,
2677
2739
  exportCer,
2740
+ exportCerPackage,
2678
2741
  exportVerifiableRedacted,
2679
2742
  fetchNodeKeys,
2680
2743
  getAttestationReceipt,
2744
+ getCerFromPackage,
2681
2745
  hasAttestation,
2682
2746
  hashCanonicalJson,
2683
2747
  hashToolOutput,
2684
2748
  hashUtf8,
2685
2749
  importCer,
2750
+ importCerPackage,
2751
+ isCerPackage,
2686
2752
  makeToolEvent,
2687
2753
  mapToAiefReason,
2688
2754
  redactBeforeSeal,
@@ -2699,6 +2765,7 @@ export {
2699
2765
  verifyAief,
2700
2766
  verifyBundleAttestation,
2701
2767
  verifyCer,
2768
+ verifyCerPackage,
2702
2769
  verifyNodeReceiptSignature,
2703
2770
  verifyRunSummary,
2704
2771
  verifySnapshot,