@oesp/all 1.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/README.md +149 -0
- package/dist/index.cjs +32 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# @oesp/all
|
|
2
|
+
|
|
3
|
+
Meta-package officiel regroupant l'intégralité du SDK OESP (Open Entrust & Sync Protocol) pour TypeScript.
|
|
4
|
+
|
|
5
|
+
Ce package est conçu pour offrir une expérience "tout-en-un", incluant le cœur du protocole, les implémentations cryptographiques, ainsi que les modules de transport (BLE) et de synchronisation asynchrone (HTTP).
|
|
6
|
+
|
|
7
|
+
## Sommaire
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Modules Inclus](#modules-inclus)
|
|
10
|
+
- [Tutoriel Complet : De l'Identité au Transfert](#tutoriel-complet--de-lidentité-au-transfert)
|
|
11
|
+
- [1. Initialisation](#1-initialisation)
|
|
12
|
+
- [2. Création du Message (Pack)](#2-création-du-message-pack)
|
|
13
|
+
- [3. Transfert Physique (Transport BLE)](#3-transfert-physique-transport-ble)
|
|
14
|
+
- [4. Synchronisation Cloud (Async HTTP)](#4-synchronisation-cloud-async-http)
|
|
15
|
+
- [5. Réception et Lecture (Unpack)](#5-réception-et-lecture-unpack)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @oesp/all
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Modules Inclus
|
|
26
|
+
|
|
27
|
+
En installant `@oesp/all`, vous accédez aux modules suivants :
|
|
28
|
+
- **@oesp/core** : Logique cœur (agnostique) pour le packaging des données.
|
|
29
|
+
- **@oesp/crypto-sodium** : Fournisseur cryptographique utilisant `libsodium`.
|
|
30
|
+
- **@oesp/transport-ble-gatt** : Gestion du transport P2P via Bluetooth Low Energy.
|
|
31
|
+
- **@oesp/sync-http** : Client asynchrone pour la synchronisation avec un serveur cloud.
|
|
32
|
+
- **@oesp/storage-memory** : Gestionnaire de rejeu (anti-replay) en mémoire.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Tutoriel Complet : De l'Identité au Transfert
|
|
37
|
+
|
|
38
|
+
### 1. Initialisation
|
|
39
|
+
|
|
40
|
+
La première étape consiste à configurer votre client avec ses dépendances (Crypto, KeyStore, Storage).
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import {
|
|
44
|
+
OESPClient,
|
|
45
|
+
createSodiumCryptoProvider,
|
|
46
|
+
MemoryReplayStore,
|
|
47
|
+
Identity
|
|
48
|
+
} from '@oesp/all';
|
|
49
|
+
|
|
50
|
+
// 1. Initialiser le moteur de calcul (libsodium)
|
|
51
|
+
const crypto = await createSodiumCryptoProvider();
|
|
52
|
+
|
|
53
|
+
// 2. Créer un store pour éviter les attaques par rejeu
|
|
54
|
+
const replay = new MemoryReplayStore();
|
|
55
|
+
|
|
56
|
+
// 3. Définir un KeyStore (ici simplifié pour l'exemple)
|
|
57
|
+
const keystore = {
|
|
58
|
+
getOrCreateIdentity: async () => ({
|
|
59
|
+
ed25519Priv: new Uint8Array(64), // Votre clé privée persistée
|
|
60
|
+
ed25519Pub: new Uint8Array(32),
|
|
61
|
+
x25519Priv: new Uint8Array(32),
|
|
62
|
+
x25519Pub: new Uint8Array(32),
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// 4. Créer le client OESP
|
|
67
|
+
const client = new OESPClient({ crypto, keystore, replay });
|
|
68
|
+
|
|
69
|
+
// Obtenir votre identifiant unique (DID)
|
|
70
|
+
const myDid = await client.getDid();
|
|
71
|
+
console.log(`Mon identité OESP : ${myDid}`);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 2. Création du Message (Pack)
|
|
75
|
+
|
|
76
|
+
Chiffrez et signez une donnée pour un destinataire spécifique.
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const recipientDid = "did:oesp:target-device-uuid";
|
|
80
|
+
const data = { temperature: 22.5, status: "ok" };
|
|
81
|
+
|
|
82
|
+
// Génère un token OESP1 sécurisé (chiffré pour le destinataire, signé par vous)
|
|
83
|
+
const token = await client.pack(recipientDid, data);
|
|
84
|
+
console.log("Token généré :", token);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 3. Transfert Physique (Transport BLE)
|
|
88
|
+
|
|
89
|
+
Utilisez le transport Bluetooth pour envoyer le token à un appareil à proximité, même sans internet.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { OESPBleGattTransport } from '@oesp/all';
|
|
93
|
+
|
|
94
|
+
// Initialiser le transport (nécessite une fonction de hashage pour les acquittements)
|
|
95
|
+
const transport = new OESPBleGattTransport({
|
|
96
|
+
sha256: (data) => crypto.sha256(data)
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// 'link' doit être une implémentation de l'interface BleGattLink adaptée à votre plateforme
|
|
100
|
+
// (ex: Web Bluetooth, react-native-ble-plx)
|
|
101
|
+
await transport.sendToken(token, link);
|
|
102
|
+
console.log("Token envoyé via Bluetooth !");
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 4. Synchronisation Cloud (Async HTTP)
|
|
106
|
+
|
|
107
|
+
Si vous avez une connexion internet, vous pouvez synchroniser vos données avec un serveur central de manière asynchrone.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { OESPSyncClient } from '@oesp/all';
|
|
111
|
+
|
|
112
|
+
const syncClient = new OESPSyncClient({
|
|
113
|
+
baseUrl: "https://api.votre-serveur-oesp.com",
|
|
114
|
+
sha256: async (data) => crypto.sha256(data)
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Envoi asynchrone de plusieurs tokens au serveur
|
|
118
|
+
const result = await syncClient.syncTokens([token], myDid);
|
|
119
|
+
|
|
120
|
+
if (result.success) {
|
|
121
|
+
console.log(`Synchronisation réussie. Session ID: ${result.sessionId}`);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 5. Réception et Lecture (Unpack)
|
|
126
|
+
|
|
127
|
+
À la réception d'un token (via BLE ou Sync), vérifiez sa provenance et déchiffrez-le.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
try {
|
|
131
|
+
const decoded = await client.unpack(receivedToken);
|
|
132
|
+
|
|
133
|
+
console.log(`Message reçu de : ${decoded.fromDid}`);
|
|
134
|
+
console.log(`Contenu :`, decoded.plaintext); // { temperature: 22.5, ... }
|
|
135
|
+
} catch (e) {
|
|
136
|
+
console.error("Échec de la vérification ou du déchiffrement", e);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Support et Documentation
|
|
143
|
+
|
|
144
|
+
Pour plus de détails sur chaque module, consultez les dossiers individuels du dépôt :
|
|
145
|
+
- [Cœur du SDK (@oesp/core)](../sdk/README.md)
|
|
146
|
+
- [Transport Bluetooth (@oesp/transport-ble-gatt)](../transport-ble-gatt/README.md)
|
|
147
|
+
- [Sync HTTP (@oesp/sync-http)](../sync-http/README.md)
|
|
148
|
+
|
|
149
|
+
Licence MIT.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/index.ts
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("@oesp/sdk"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("@oesp/crypto-sodium"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("@oesp/storage-memory"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("@oesp/sync-http"), module.exports);
|
|
24
|
+
__reExport(index_exports, require("@oesp/transport-ble-gatt"), module.exports);
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
...require("@oesp/sdk"),
|
|
28
|
+
...require("@oesp/crypto-sodium"),
|
|
29
|
+
...require("@oesp/storage-memory"),
|
|
30
|
+
...require("@oesp/sync-http"),
|
|
31
|
+
...require("@oesp/transport-ble-gatt")
|
|
32
|
+
});
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oesp/all",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Meta-package including all OESP TypeScript SDK modules",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"oesp",
|
|
20
|
+
"sdk",
|
|
21
|
+
"did",
|
|
22
|
+
"crypto",
|
|
23
|
+
"bluetooth",
|
|
24
|
+
"sync"
|
|
25
|
+
],
|
|
26
|
+
"author": "OESP Team",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@oesp/core": "workspace:*",
|
|
30
|
+
"@oesp/crypto-sodium": "workspace:*",
|
|
31
|
+
"@oesp/storage-memory": "workspace:*",
|
|
32
|
+
"@oesp/sync-http": "workspace:*",
|
|
33
|
+
"@oesp/transport-ble-gatt": "workspace:*"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|