@lindorm/oct 0.1.0 → 0.1.2

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 CHANGED
@@ -3,6 +3,21 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.1.2](https://github.com/lindorm-io/monorepo/compare/@lindorm/oct@0.1.1...@lindorm/oct@0.1.2) (2024-05-20)
7
+
8
+ **Note:** Version bump only for package @lindorm/oct
9
+
10
+ ## [0.1.1](https://github.com/lindorm-io/monorepo/compare/@lindorm/oct@0.1.0...@lindorm/oct@0.1.1) (2024-05-19)
11
+
12
+ ### Bug Fixes
13
+
14
+ - align with kryptos changes ([344c4e2](https://github.com/lindorm-io/monorepo/commit/344c4e2fad07e66c91f7e0820bfc929c1f8ffcab))
15
+ - amend wrong options type name ([2392e65](https://github.com/lindorm-io/monorepo/commit/2392e65dc8779a72948f9f98e0c6847cb8d21474))
16
+ - assert oct key size for hmac ([2746dbb](https://github.com/lindorm-io/monorepo/commit/2746dbb358885100dda4b63412040e6d2699cdcf))
17
+ - improve kryptos generate method ([9e7098d](https://github.com/lindorm-io/monorepo/commit/9e7098d4b219b11140e28e554ffd573204772249))
18
+ - rename interfaces ([3b1f457](https://github.com/lindorm-io/monorepo/commit/3b1f45736f88b8c2d4481cbeca6da87bf8443bde))
19
+ - simplify interfaces with kryptos metadata ([c4075d2](https://github.com/lindorm-io/monorepo/commit/c4075d2e133c2fe0a1fafa548da68db34b3407c6))
20
+
6
21
  # 0.1.0 (2024-05-12)
7
22
 
8
23
  ### Features
@@ -1,9 +1,8 @@
1
- import { OctSignatureKitOptions } from "../types";
1
+ import { OctKitOptions } from "../types";
2
2
  export declare class OctKit {
3
- private readonly algorithm;
4
3
  private readonly format;
5
4
  private readonly kryptos;
6
- constructor(options: OctSignatureKitOptions);
5
+ constructor(options: OctKitOptions);
7
6
  sign(data: string): string;
8
7
  verify(data: string, signature: string): boolean;
9
8
  assert(data: string, signature: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"OctKit.d.ts","sourceRoot":"","sources":["../../src/classes/OctKit.ts"],"names":[],"mappings":"AACA,OAAO,EAA6C,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAO7F,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoC;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAEf,OAAO,EAAE,sBAAsB;IAM3C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAS1B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAUhD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CASrD"}
1
+ {"version":3,"file":"OctKit.d.ts","sourceRoot":"","sources":["../../src/classes/OctKit.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAOzC,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;gBAEnB,OAAO,EAAE,aAAa;IAUlC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQ1B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAShD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAQrD"}
@@ -1,19 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OctKit = void 0;
4
+ const kryptos_1 = require("@lindorm/kryptos");
5
+ const errors_1 = require("../errors");
4
6
  const oct_signature_1 = require("../utils/private/oct-signature");
5
7
  class OctKit {
6
- algorithm;
7
8
  format;
8
9
  kryptos;
9
10
  constructor(options) {
10
- this.algorithm = options.algorithm;
11
- this.format = options.format;
11
+ this.format = options.format ?? "base64";
12
+ if (!kryptos_1.Kryptos.isOct(options.kryptos)) {
13
+ throw new errors_1.OctError("Invalid Kryptos instance");
14
+ }
12
15
  this.kryptos = options.kryptos;
13
16
  }
14
17
  sign(data) {
15
18
  return (0, oct_signature_1._createOctSignature)({
16
- algorithm: this.algorithm,
17
19
  data,
18
20
  format: this.format,
19
21
  kryptos: this.kryptos,
@@ -21,7 +23,6 @@ class OctKit {
21
23
  }
22
24
  verify(data, signature) {
23
25
  return (0, oct_signature_1._verifyOctSignature)({
24
- algorithm: this.algorithm,
25
26
  data,
26
27
  format: this.format,
27
28
  kryptos: this.kryptos,
@@ -30,7 +31,6 @@ class OctKit {
30
31
  }
31
32
  assert(data, signature) {
32
33
  return (0, oct_signature_1._assertOctSignature)({
33
- algorithm: this.algorithm,
34
34
  data,
35
35
  format: this.format,
36
36
  kryptos: this.kryptos,
@@ -1 +1 @@
1
- {"version":3,"file":"OctKit.js","sourceRoot":"","sources":["../../src/classes/OctKit.ts"],"names":[],"mappings":";;;AAEA,kEAIwC;AAExC,MAAa,MAAM;IACA,SAAS,CAAoC;IAC7C,MAAM,CAAiC;IACvC,OAAO,CAAU;IAElC,YAAmB,OAA+B;QAChD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;IAEM,IAAI,CAAC,IAAY;QACtB,OAAO,IAAA,mCAAmB,EAAC;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IAE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AC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS;SACV,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,IAAY,EAAE,SAAiB;QAC3C,OAAO,IAAA,mCAAmB,EAAC;YACzB,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS;SACV,CAAC,CAAC;IACL,CAAC;CACF;AAvCD,wBAuCC"}
@@ -1,22 +1,18 @@
1
- import { Kryptos } from "@lindorm/kryptos";
2
- export type OctSignatureAlgorithm = "SHA256" | "SHA384" | "SHA512";
3
- export type OctSignatureFormat = "base64" | "base64url" | "hex";
1
+ import { IKryptos, IKryptosOct } from "@lindorm/kryptos";
2
+ import { BufferFormat } from "@lindorm/types";
4
3
  export type CreateOctSignatureOptions = {
5
- algorithm?: OctSignatureAlgorithm;
6
4
  data: string;
7
- format?: OctSignatureFormat;
8
- kryptos: Kryptos;
5
+ format: BufferFormat;
6
+ kryptos: IKryptosOct;
9
7
  };
10
8
  export type VerifyOctSignatureOptions = {
11
- algorithm?: OctSignatureAlgorithm;
12
9
  data: string;
13
- format?: OctSignatureFormat;
14
- kryptos: Kryptos;
10
+ format: BufferFormat;
11
+ kryptos: IKryptosOct;
15
12
  signature: string;
16
13
  };
17
- export type OctSignatureKitOptions = {
18
- algorithm?: OctSignatureAlgorithm;
19
- format?: OctSignatureFormat;
20
- kryptos: Kryptos;
14
+ export type OctKitOptions = {
15
+ format?: BufferFormat;
16
+ kryptos: IKryptos;
21
17
  };
22
18
  //# sourceMappingURL=oct-kit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oct-kit.d.ts","sourceRoot":"","sources":["../../src/types/oct-kit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE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1,4 @@
1
+ /// <reference types="node" />
2
+ import { ShaAlgorithm } from "@lindorm/types";
3
+ export declare const _assertKeySize: (algorithm: ShaAlgorithm, privateKey: Buffer) => void;
4
+ //# sourceMappingURL=assert-key-size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-key-size.d.ts","sourceRoot":"","sources":["../../../src/utils/private/assert-key-size.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,cAAc,cAAe,YAAY,cAAc,MAAM,KAAG,IAiB5E,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._assertKeySize = void 0;
4
+ const errors_1 = require("../../errors");
5
+ const _assertKeySize = (algorithm, privateKey) => {
6
+ switch (algorithm) {
7
+ case "SHA256":
8
+ if (privateKey.length >= 16)
9
+ return;
10
+ throw new errors_1.OctError("Invalid key size for SHA256");
11
+ case "SHA384":
12
+ if (privateKey.length >= 24)
13
+ return;
14
+ throw new errors_1.OctError("Invalid key size for SHA384");
15
+ case "SHA512":
16
+ if (privateKey.length >= 32)
17
+ return;
18
+ throw new errors_1.OctError("Invalid key size for SHA512");
19
+ default:
20
+ throw new errors_1.OctError("Unsupported algorithm", { debug: { algorithm } });
21
+ }
22
+ };
23
+ exports._assertKeySize = _assertKeySize;
24
+ //# sourceMappingURL=assert-key-size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-key-size.js","sourceRoot":"","sources":["../../../src/utils/private/assert-key-size.ts"],"names":[],"mappings":";;;AACA,yCAAwC;AAEjC,MAAM,cAAc,GAAG,CAAC,SAAuB,EAAE,UAAkB,EAAQ,EAAE;IAClF,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,QAAQ;YACX,IAAI,UAAU,CAAC,MAAM,IAAI,EAAE;gBAAE,OAAO;YACpC,MAAM,IAAI,iBAAQ,CAAC,6BAA6B,CAAC,CAAC;QAEpD,KAAK,QAAQ;YACX,IAAI,UAAU,CAAC,MAAM,IAAI,EAAE;gBAAE,OAAO;YACpC,MAAM,IAAI,iBAAQ,CAAC,6BAA6B,CAAC,CAAC;QAEpD,KAAK,QAAQ;YACX,IAAI,UAAU,CAAC,MAAM,IAAI,EAAE;gBAAE,OAAO;YACpC,MAAM,IAAI,iBAAQ,CAAC,6BAA6B,CAAC,CAAC;QAEpD;YACE,MAAM,IAAI,iBAAQ,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CAAC;AAjBW,QAAA,cAAc,kBAiBzB"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import { IKryptosOct } from "@lindorm/kryptos";
3
+ export declare const _getPrivateKey: (kryptos: IKryptosOct) => Buffer;
4
+ //# sourceMappingURL=get-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-key.d.ts","sourceRoot":"","sources":["../../../src/utils/private/get-key.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,eAAO,MAAM,cAAc,YAAa,WAAW,KAAG,MAQrD,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._getPrivateKey = void 0;
4
+ const errors_1 = require("../../errors");
5
+ const _getPrivateKey = (kryptos) => {
6
+ const { privateKey } = kryptos.export("der");
7
+ if (!privateKey) {
8
+ throw new errors_1.OctError("Missing private key");
9
+ }
10
+ return privateKey;
11
+ };
12
+ exports._getPrivateKey = _getPrivateKey;
13
+ //# sourceMappingURL=get-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-key.js","sourceRoot":"","sources":["../../../src/utils/private/get-key.ts"],"names":[],"mappings":";;;AACA,yCAAwC;AAEjC,MAAM,cAAc,GAAG,CAAC,OAAoB,EAAU,EAAE;IAC7D,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,iBAAQ,CAAC,qBAAqB,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB"}
@@ -0,0 +1,4 @@
1
+ import { IKryptosOct } from "@lindorm/kryptos";
2
+ import { ShaAlgorithm } from "@lindorm/types";
3
+ export declare const _mapOctAlgorithm: (kryptos: IKryptosOct) => ShaAlgorithm;
4
+ //# sourceMappingURL=map-algorithm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-algorithm.d.ts","sourceRoot":"","sources":["../../../src/utils/private/map-algorithm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,gBAAgB,YAAa,WAAW,KAAG,YAMvD,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._mapOctAlgorithm = void 0;
4
+ const errors_1 = require("../../errors");
5
+ const _mapOctAlgorithm = (kryptos) => {
6
+ if (kryptos.algorithm.endsWith("256"))
7
+ return "SHA256";
8
+ if (kryptos.algorithm.endsWith("384"))
9
+ return "SHA384";
10
+ if (kryptos.algorithm.endsWith("512"))
11
+ return "SHA512";
12
+ throw new errors_1.OctError("Unsupported OCT algorithm", { debug: { kryptos } });
13
+ };
14
+ exports._mapOctAlgorithm = _mapOctAlgorithm;
15
+ //# sourceMappingURL=map-algorithm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-algorithm.js","sourceRoot":"","sources":["../../../src/utils/private/map-algorithm.ts"],"names":[],"mappings":";;;AAEA,yCAAwC;AAEjC,MAAM,gBAAgB,GAAG,CAAC,OAAoB,EAAgB,EAAE;IACrE,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvD,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvD,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAEvD,MAAM,IAAI,iBAAQ,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AANW,QAAA,gBAAgB,oBAM3B"}
@@ -1,5 +1,5 @@
1
1
  import { CreateOctSignatureOptions, VerifyOctSignatureOptions } from "../../types";
2
- export declare const _createOctSignature: ({ algorithm, data, format, kryptos, }: CreateOctSignatureOptions) => string;
3
- export declare const _verifyOctSignature: ({ algorithm, data, format, kryptos, signature, }: VerifyOctSignatureOptions) => boolean;
2
+ export declare const _createOctSignature: ({ data, format, kryptos, }: CreateOctSignatureOptions) => string;
3
+ export declare const _verifyOctSignature: ({ data, format, kryptos, signature, }: VerifyOctSignatureOptions) => boolean;
4
4
  export declare const _assertOctSignature: (options: VerifyOctSignatureOptions) => void;
5
5
  //# sourceMappingURL=oct-signature.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oct-signature.d.ts","sourceRoot":"","sources":["../../../src/utils/private/oct-signature.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAEnF,eAAO,MAAM,mBAAmB,0CAK7B,yBAAyB,KAAG,MAY9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,qDAM7B,yBAAyB,KAAG,OAC0C,CAAC;AAE1E,eAAO,MAAM,mBAAmB,YAAa,yBAAyB,KAAG,IAGxE,CAAC"}
1
+ {"version":3,"file":"oct-signature.d.ts","sourceRoot":"","sources":["../../../src/utils/private/oct-signature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAKnF,eAAO,MAAM,mBAAmB,+BAI7B,yBAAyB,KAAG,MAO9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,0CAK7B,yBAAyB,KAAG,OAC+B,CAAC;AAE/D,eAAO,MAAM,mBAAmB,YAAa,yBAAyB,KAAG,IAGxE,CAAC"}
@@ -1,21 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._assertOctSignature = exports._verifyOctSignature = exports._createOctSignature = void 0;
4
- const kryptos_1 = require("@lindorm/kryptos");
5
4
  const crypto_1 = require("crypto");
6
5
  const errors_1 = require("../../errors");
7
- const _createOctSignature = ({ algorithm = "SHA256", data, format = "base64", kryptos, }) => {
8
- if (!kryptos_1.Kryptos.isOct(kryptos)) {
9
- throw new errors_1.OctError("Invalid kryptos type");
10
- }
11
- const { privateKey } = kryptos.export("pem");
12
- if (!privateKey) {
13
- throw new errors_1.OctError("Missing private key");
14
- }
6
+ const assert_key_size_1 = require("./assert-key-size");
7
+ const get_key_1 = require("./get-key");
8
+ const map_algorithm_1 = require("./map-algorithm");
9
+ const _createOctSignature = ({ data, format, kryptos, }) => {
10
+ const algorithm = (0, map_algorithm_1._mapOctAlgorithm)(kryptos);
11
+ const privateKey = (0, get_key_1._getPrivateKey)(kryptos);
12
+ (0, assert_key_size_1._assertKeySize)(algorithm, privateKey);
15
13
  return (0, crypto_1.createHmac)(algorithm, privateKey).update(data).digest(format);
16
14
  };
17
15
  exports._createOctSignature = _createOctSignature;
18
- const _verifyOctSignature = ({ algorithm = "SHA256", data, format = "base64", kryptos, signature, }) => (0, exports._createOctSignature)({ algorithm, data, format, kryptos }) === signature;
16
+ const _verifyOctSignature = ({ data, format, kryptos, signature, }) => (0, exports._createOctSignature)({ data, format, kryptos }) === signature;
19
17
  exports._verifyOctSignature = _verifyOctSignature;
20
18
  const _assertOctSignature = (options) => {
21
19
  if ((0, exports._verifyOctSignature)(options))
@@ -1 +1 @@
1
- {"version":3,"file":"oct-signature.js","sourceRoot":"","sources":["../../../src/utils/private/oct-signature.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAC3C,mCAAoC;AACpC,yCAAwC;AAGjC,MAAM,mBAAmB,GAAG,CAAC,EAClC,SAAS,GAAG,QAAQ,EACpB,IAAI,EACJ,MAAM,GAAG,QAAQ,EACjB,OAAO,GACmB,EAAU,EAAE;IACtC,IAAI,CAAC,iBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,iBAAQ,CAAC,sBAAsB,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,iBAAQ,CAAC,qBAAqB,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,IAAA,mBAAU,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACvE,CAAC,CAAC;AAjBW,QAAA,mBAAmB,uBAiB9B;AAEK,MAAM,mBAAmB,GAAG,CAAC,EAClC,SAAS,GAAG,QAAQ,EACpB,IAAI,EACJ,MAAM,GAAG,QAAQ,EACjB,OAAO,EACP,SAAS,GACiB,EAAW,EAAE,CACvC,IAAA,2BAAmB,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,SAAS,CAAC;AAP7D,QAAA,mBAAmB,uBAO0C;AAEnE,MAAM,mBAAmB,GAAG,CAAC,OAAkC,EAAQ,EAAE;IAC9E,IAAI,IAAA,2BAAmB,EAAC,OAAO,CAAC;QAAE,OAAO;IACzC,MAAM,IAAI,iBAAQ,CAAC,6BAA6B,CAAC,CAAC;AACpD,CAAC,CAAC;AAHW,QAAA,mBAAmB,uBAG9B"}
1
+ {"version":3,"file":"oct-signature.js","sourceRoot":"","sources":["../../../src/utils/private/oct-signature.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,yCAAwC;AAExC,uDAAmD;AACnD,uCAA2C;AAC3C,mDAAmD;AAE5C,MAAM,mBAAmB,GAAG,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,OAAO,GACmB,EAAU,EAAE;IACtC,MAAM,SAAS,GAAG,IAAA,gCAAgB,EAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAA,wBAAc,EAAC,OAAO,CAAC,CAAC;IAE3C,IAAA,gCAAc,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAEtC,OAAO,IAAA,mBAAU,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACvE,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B;AAEK,MAAM,mBAAmB,GAAG,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,SAAS,GACiB,EAAW,EAAE,CACvC,IAAA,2BAAmB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,SAAS,CAAC;AANlD,QAAA,mBAAmB,uBAM+B;AAExD,MAAM,mBAAmB,GAAG,CAAC,OAAkC,EAAQ,EAAE;IAC9E,IAAI,IAAA,2BAAmB,EAAC,OAAO,CAAC;QAAE,OAAO;IACzC,MAAM,IAAI,iBAAQ,CAAC,6BAA6B,CAAC,CAAC;AACpD,CAAC,CAAC;AAHW,QAAA,mBAAmB,uBAG9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lindorm/oct",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "author": "Jonn Nilsson",
6
6
  "repository": {
@@ -26,8 +26,11 @@
26
26
  "update": "ncu -u"
27
27
  },
28
28
  "dependencies": {
29
- "@lindorm/errors": "^0.1.4",
30
- "@lindorm/kryptos": "^0.2.1"
29
+ "@lindorm/errors": "^0.1.5",
30
+ "@lindorm/kryptos": "^0.3.1"
31
31
  },
32
- "gitHead": "cb57e5e2cc3e7ee6a1db97875e05bebb910a1efe"
32
+ "devDependencies": {
33
+ "@lindorm/types": "^0.1.4"
34
+ },
35
+ "gitHead": "b2bcea52f09a87f312028c18b12dcb5632ffaf35"
33
36
  }