@interncom/diplomatic 0.24.0 → 0.25.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.
@@ -1,8 +1,7 @@
1
1
  import { ICodecStruct } from "../codec.ts";
2
- import { IFileHead } from "./fileHead.ts";
2
+ import { type IFileHead } from "./fileHead.ts";
3
3
  export interface IFile {
4
4
  head: IFileHead;
5
- indexEnc: Uint8Array;
6
- bodyEnc: Uint8Array;
5
+ chunks: Uint8Array;
7
6
  }
8
7
  export declare const fileCodec: ICodecStruct<IFile>;
@@ -1,10 +1,12 @@
1
1
  import { ICodecStruct } from "../codec.ts";
2
- import { Hash } from "../types.ts";
2
+ import type { Hash } from "../types.ts";
3
+ import { type ValStat } from "../valstat.ts";
4
+ import { type IFileRealm } from "./fileRealm.ts";
3
5
  export interface IFileHead {
4
- lbl: string;
5
- idx: number;
6
- num: number;
6
+ nonce: Uint8Array;
7
+ realms: IFileRealm[];
7
8
  hsh: Hash;
8
9
  sig: Uint8Array;
9
10
  }
11
+ export declare function fileHeadPreimage(nonce: Uint8Array, realms: readonly IFileRealm[]): ValStat<Uint8Array>;
10
12
  export declare const fileHeadCodec: ICodecStruct<IFileHead>;
@@ -3,6 +3,5 @@ export interface IFileIndexItem {
3
3
  kdm: Uint8Array;
4
4
  headCph: Uint8Array;
5
5
  lenBody: number;
6
- offBody?: number;
7
6
  }
8
7
  export declare const fileIndexItemCodec: ICodecStruct<IFileIndexItem>;
@@ -0,0 +1,9 @@
1
+ import { ICodecStruct } from "../codec.ts";
2
+ import type { Hash } from "../types.ts";
3
+ import { type IKDM } from "./kdm.ts";
4
+ export interface IFileRealm {
5
+ realm: IKDM;
6
+ num: number;
7
+ hsh: Hash;
8
+ }
9
+ export declare const fileRealmCodec: ICodecStruct<IFileRealm>;
@@ -11,6 +11,7 @@ export declare const Purpose: {
11
11
  readonly RealmKey: "diplomatic.realmKey.v1";
12
12
  readonly RealmID: "diplomatic.realmID.v1";
13
13
  readonly HostRLM: "diplomatic.hostRLM.v1";
14
+ readonly Export: "diplomatic.export.v1";
14
15
  };
15
16
  export type Purpose = typeof Purpose[keyof typeof Purpose];
16
17
  declare const pdkSymbol: unique symbol;
@@ -126,6 +126,7 @@ declare class OuterEnclave {
126
126
  id: number;
127
127
  persist?: boolean;
128
128
  }): Worker;
129
+ exportKey(nonce: Uint8Array): Promise<ValStat<PDK["Export"]>>;
129
130
  bagman(idKDM: IKDM, realmKDM: IKDM): Promise<ValStat<BagManager>>;
130
131
  fingerprint(kdm?: Uint8Array | IKDM): Promise<ValStat<PDK["Fingerprint"]>>;
131
132
  }
@@ -0,0 +1,22 @@
1
+ import { type IKDM } from "../codecs/kdm.ts";
2
+ import { ICrypto, IMessageHead } from "../types.ts";
3
+ import { ValStat } from "../valstat.ts";
4
+ import { type PDK } from "./derivation.ts";
5
+ import { Enclave } from "./enclave.ts";
6
+ export interface IExportMsg {
7
+ head: IMessageHead;
8
+ body?: Uint8Array;
9
+ }
10
+ export interface IExportRealm {
11
+ realm: IKDM;
12
+ msgs: IExportMsg[];
13
+ }
14
+ export declare namespace Exim {
15
+ const defaultFileExtension = "dpl";
16
+ function exportNonce(file: Uint8Array): ValStat<Uint8Array>;
17
+ function sealExport(realms: Iterable<IExportRealm>, crypto: ICrypto, key: PDK["Export"], nonce: Uint8Array): Promise<ValStat<Uint8Array>>;
18
+ function exportFile(enclave: Enclave, crypto: ICrypto, realms: Iterable<IExportRealm>): Promise<ValStat<Uint8Array>>;
19
+ function encodeFile(realms: Iterable<IExportRealm>, crypto: ICrypto, key: PDK["Export"], nonce: Uint8Array): Promise<ValStat<Uint8Array>>;
20
+ function decodeFile(file: Uint8Array, crypto: ICrypto, key: PDK["Export"]): Promise<ValStat<IExportRealm[]>>;
21
+ function migrateFile(file: Uint8Array, crypto: ICrypto, keyIn: PDK["Export"], keyOut: PDK["Export"], nonce: Uint8Array, transform: (realms: Iterable<IExportRealm>) => Iterable<IExportRealm> | Promise<Iterable<IExportRealm>>): Promise<ValStat<Uint8Array>>;
22
+ }
@@ -0,0 +1,5 @@
1
+ import type { IKDM } from "../codecs/kdm.ts";
2
+ import { type ValStat } from "../valstat.ts";
3
+ import { BagManager } from "./bagman.ts";
4
+ import { type PDK } from "./derivation.ts";
5
+ export declare function bagmanForExport(key: PDK["Export"], realmKDM: IKDM): Promise<ValStat<BagManager>>;