@empereur-rouge/pms-sdk 0.1.0 → 0.2.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 CHANGED
@@ -31,9 +31,10 @@ const wallet = PmsWallet.generate();
31
31
  console.log("Mnemonic:", wallet.mnemonic);
32
32
  console.log("Address:", wallet.address);
33
33
 
34
- // 2. Connecter au réseau
34
+ // 2. Connecter au réseau (clé API obligatoire)
35
35
  const client = new PmsClient({
36
- nodeUrl: "https://node.pms.network"
36
+ nodeUrl: "https://node.pms.network",
37
+ apiKey: "pk_live_votre_cle_ici",
37
38
  });
38
39
 
39
40
  // 3. Consulter la balance
@@ -116,6 +117,7 @@ Le client permet d'interagir avec l'API REST des nœuds PMS.
116
117
  ```typescript
117
118
  const client = new PmsClient({
118
119
  nodeUrl: "https://node.pms.network", // URL du nœud principal
120
+ apiKey: "pk_live_votre_cle_ici", // Clé API (obligatoire)
119
121
  seedNodes: [ // Optionnel: nœuds de secours
120
122
  "https://node2.pms.network",
121
123
  "https://node3.pms.network",
@@ -127,6 +129,9 @@ const client = new PmsClient({
127
129
  });
128
130
  ```
129
131
 
132
+ > [!IMPORTANT]
133
+ > La clé API est **obligatoire**. Obtenez-la depuis votre dashboard PMS ou auprès de l'administrateur du réseau.
134
+
130
135
  #### Méthodes de Lecture
131
136
 
132
137
  ```typescript
@@ -480,6 +485,7 @@ Cela améliore :
480
485
  // Désactiver si non souhaité
481
486
  const client = new PmsClient({
482
487
  nodeUrl: "...",
488
+ apiKey: "pk_live_...",
483
489
  enableRacing: false,
484
490
  });
485
491
  ```
package/dist/index.cjs CHANGED
@@ -331,6 +331,11 @@ var PmsClient = class {
331
331
  * @param config.seedNodes - Liste des nœuds de seed
332
332
  */
333
333
  constructor(config) {
334
+ if (!config.apiKey || config.apiKey.trim() === "") {
335
+ throw new Error(
336
+ "PmsClient requires an API key. Get yours at https://dashboard.pms.network or contact your administrator. Usage: new PmsClient({ nodeUrl: '...', apiKey: 'pk_live_...' })"
337
+ );
338
+ }
334
339
  this.config = {
335
340
  ...DEFAULT_CONFIG,
336
341
  seedNodes: config.seedNodes ?? [],
@@ -1027,6 +1032,9 @@ var PmsClient = class {
1027
1032
  ...init,
1028
1033
  headers: {
1029
1034
  "Content-Type": "application/json",
1035
+ // Injection automatique de la clé API dans chaque requête.
1036
+ // Le serveur PMS vérifie ce header pour autoriser l'accès.
1037
+ "X-API-Key": this.config.apiKey,
1030
1038
  ...init?.headers
1031
1039
  },
1032
1040
  signal
package/dist/index.d.cts CHANGED
@@ -473,6 +473,14 @@ interface BalanceInfo {
473
473
  interface PmsClientConfig {
474
474
  /** URL du nœud principal (ex: "https://node.pms.network") */
475
475
  nodeUrl: string;
476
+ /**
477
+ * Clé d'API pour authentifier les requêtes.
478
+ * Obligatoire pour accéder à l'API PMS.
479
+ * Obtenue depuis le dashboard PMS ou fournie par l'administrateur.
480
+ *
481
+ * Exemple: "pk_live_abc123..." ou "pk_test_xyz789..."
482
+ */
483
+ apiKey: string;
476
484
  /** URLs des noeuds seeds (optionnel, pour racing et fallback) */
477
485
  seedNodes?: string[];
478
486
  /** ID du réseau (défaut: "pms-mainnet") */
package/dist/index.d.ts CHANGED
@@ -473,6 +473,14 @@ interface BalanceInfo {
473
473
  interface PmsClientConfig {
474
474
  /** URL du nœud principal (ex: "https://node.pms.network") */
475
475
  nodeUrl: string;
476
+ /**
477
+ * Clé d'API pour authentifier les requêtes.
478
+ * Obligatoire pour accéder à l'API PMS.
479
+ * Obtenue depuis le dashboard PMS ou fournie par l'administrateur.
480
+ *
481
+ * Exemple: "pk_live_abc123..." ou "pk_test_xyz789..."
482
+ */
483
+ apiKey: string;
476
484
  /** URLs des noeuds seeds (optionnel, pour racing et fallback) */
477
485
  seedNodes?: string[];
478
486
  /** ID du réseau (défaut: "pms-mainnet") */
package/dist/index.js CHANGED
@@ -298,6 +298,11 @@ var PmsClient = class {
298
298
  * @param config.seedNodes - Liste des nœuds de seed
299
299
  */
300
300
  constructor(config) {
301
+ if (!config.apiKey || config.apiKey.trim() === "") {
302
+ throw new Error(
303
+ "PmsClient requires an API key. Get yours at https://dashboard.pms.network or contact your administrator. Usage: new PmsClient({ nodeUrl: '...', apiKey: 'pk_live_...' })"
304
+ );
305
+ }
301
306
  this.config = {
302
307
  ...DEFAULT_CONFIG,
303
308
  seedNodes: config.seedNodes ?? [],
@@ -994,6 +999,9 @@ var PmsClient = class {
994
999
  ...init,
995
1000
  headers: {
996
1001
  "Content-Type": "application/json",
1002
+ // Injection automatique de la clé API dans chaque requête.
1003
+ // Le serveur PMS vérifie ce header pour autoriser l'accès.
1004
+ "X-API-Key": this.config.apiKey,
997
1005
  ...init?.headers
998
1006
  },
999
1007
  signal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empereur-rouge/pms-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript SDK for PMS (Planetary Monetary System) — wallet management, transactions, NFTs, and DAG interactions",
5
5
  "author": "empereur-rouge",
6
6
  "license": "MIT",