@oesp/keystore-node 4.0.0 → 5.0.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.ts CHANGED
@@ -1,9 +1,6 @@
1
- import { KeyStore, Identity } from '@oesp/core';
2
-
3
- declare class NodeFileKeyStore implements KeyStore {
1
+ import type { KeyStore, Identity } from '@oesp/core';
2
+ export declare class NodeFileKeyStore implements KeyStore {
4
3
  private path;
5
4
  constructor(path: string);
6
5
  getOrCreateIdentity(): Promise<Identity>;
7
6
  }
8
-
9
- export { NodeFileKeyStore };
package/dist/index.js CHANGED
@@ -1,48 +1,38 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- // src/index.ts
9
- import { promises as fs } from "fs";
10
- import sodium from "libsodium-wrappers-sumo";
11
- var NodeFileKeyStore = class {
12
- constructor(path) {
13
- this.path = path;
14
- }
15
- async getOrCreateIdentity() {
16
- await sodium.ready;
17
- try {
18
- const buf = await fs.readFile(this.path);
19
- const json = JSON.parse(buf.toString("utf-8"));
20
- return {
21
- ed25519Priv: Uint8Array.from(json.ed25519Priv),
22
- ed25519Pub: Uint8Array.from(json.ed25519Pub),
23
- x25519Priv: Uint8Array.from(json.x25519Priv),
24
- x25519Pub: Uint8Array.from(json.x25519Pub)
25
- };
26
- } catch {
27
- const ed = sodium.crypto_sign_keypair();
28
- const x = sodium.crypto_kx_keypair();
29
- const id = {
30
- ed25519Priv: ed.privateKey,
31
- ed25519Pub: ed.publicKey,
32
- x25519Priv: x.privateKey,
33
- x25519Pub: x.publicKey
34
- };
35
- await fs.mkdir(__require("path").dirname(this.path), { recursive: true });
36
- await fs.writeFile(this.path, JSON.stringify({
37
- ed25519Priv: Array.from(id.ed25519Priv),
38
- ed25519Pub: Array.from(id.ed25519Pub),
39
- x25519Priv: Array.from(id.x25519Priv),
40
- x25519Pub: Array.from(id.x25519Pub)
41
- }));
42
- return id;
1
+ import { promises as fs } from 'fs';
2
+ import sodium from 'libsodium-wrappers-sumo';
3
+ export class NodeFileKeyStore {
4
+ constructor(path) {
5
+ this.path = path;
43
6
  }
44
- }
45
- };
46
- export {
47
- NodeFileKeyStore
48
- };
7
+ async getOrCreateIdentity() {
8
+ await sodium.ready;
9
+ try {
10
+ const buf = await fs.readFile(this.path);
11
+ const json = JSON.parse(buf.toString('utf-8'));
12
+ return {
13
+ ed25519Priv: Uint8Array.from(json.ed25519Priv),
14
+ ed25519Pub: Uint8Array.from(json.ed25519Pub),
15
+ x25519Priv: Uint8Array.from(json.x25519Priv),
16
+ x25519Pub: Uint8Array.from(json.x25519Pub)
17
+ };
18
+ }
19
+ catch {
20
+ const ed = sodium.crypto_sign_keypair();
21
+ const x = sodium.crypto_kx_keypair(); // curve25519 keypair
22
+ const id = {
23
+ ed25519Priv: ed.privateKey,
24
+ ed25519Pub: ed.publicKey,
25
+ x25519Priv: x.privateKey,
26
+ x25519Pub: x.publicKey
27
+ };
28
+ await fs.mkdir(require('path').dirname(this.path), { recursive: true });
29
+ await fs.writeFile(this.path, JSON.stringify({
30
+ ed25519Priv: Array.from(id.ed25519Priv),
31
+ ed25519Pub: Array.from(id.ed25519Pub),
32
+ x25519Priv: Array.from(id.x25519Priv),
33
+ x25519Pub: Array.from(id.x25519Pub)
34
+ }));
35
+ return id;
36
+ }
37
+ }
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oesp/keystore-node",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "private": false,
5
5
  "description": "KeyStore Node (fichier JSON)",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "libsodium-wrappers-sumo": "^0.7.14",
26
- "@oesp/core": "4.0.0"
26
+ "@oesp/core": "5.0.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/libsodium-wrappers": "^0.7.14",
@@ -32,7 +32,7 @@
32
32
  "typescript": "^5.6.3"
33
33
  },
34
34
  "scripts": {
35
- "build": "tsup src/index.ts --dts --format esm,cjs",
35
+ "build": "tsc -p tsconfig.build.json",
36
36
  "lint": "tsc -p tsconfig.json --noEmit"
37
37
  }
38
38
  }