arifa-client 1.0.4 → 1.0.6

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
@@ -57,14 +57,24 @@ sub.unsubscribe();
57
57
  ```js
58
58
  const res = await client.notify({
59
59
  recipient: "RECIPIENT_UUID",
60
- payload: { title: "Hello", message: "Welcome to Arifa!" }, // Can be any JSON data
60
+ payload: {
61
+ title: "Hello",
62
+ message: "Welcome to Arifa!",
63
+ }, // Can be any JSON data
64
+ origin: "https://your-registered-domain.com", // Optional, use if web
65
+ client: "web", // Optional, "web" or "mobile"
61
66
  });
67
+
62
68
  console.log(res);
63
69
  ```
64
70
 
65
- `recipient` → UUID of the user
66
- `payload`→ Any JSON object
67
- `client` Optional, "web" or "mobile"
71
+ - `recipient` → UUID of the user
72
+
73
+ - `payload`→ Any JSON object
74
+
75
+ - `orign`→ Optional string; typically your registered domain when sending from web.
76
+
77
+ - `client` → Optional, "web" or "mobile"
68
78
 
69
79
  **Note**: The notify method returns a result object with the notification status.
70
80
  Example responses:
@@ -107,7 +117,7 @@ client.onConnectionChange((state) => {
107
117
  console.log("Connection state:", state); // "connected" or "disconnected"
108
118
  });
109
119
 
110
- // Subscribe to a recipient (UUID required)
120
+ // Subscribe a recipient (UUID required)
111
121
  const sub = client.subscribe("RECIPIENT_UUID");
112
122
 
113
123
  // Listen for incoming events
@@ -10,6 +10,7 @@ interface NotifyPayload {
10
10
  recipient: string;
11
11
  payload: Record<string, any>;
12
12
  client?: "web" | "mobile";
13
+ origin?: string;
13
14
  }
14
15
  interface NotifyResponse {
15
16
  success: boolean;
@@ -41,7 +42,7 @@ export declare class ArifaClient {
41
42
  /** Connect WebSocket */
42
43
  private connect;
43
44
  /** Send notification */
44
- notify({ recipient, payload, client, }: NotifyPayload): Promise<NotifyResponse>;
45
+ notify({ recipient, payload, client, origin, }: NotifyPayload): Promise<NotifyResponse>;
45
46
  /** Disconnect WS */
46
47
  disconnect(): void;
47
48
  /** Return connection state */
@@ -80,7 +80,7 @@ export class ArifaClient {
80
80
  };
81
81
  }
82
82
  /** Send notification */
83
- async notify({ recipient, payload, client, }) {
83
+ async notify({ recipient, payload, client, origin, }) {
84
84
  if (!recipient || !payload) {
85
85
  throw new Error("recipient and payload are required");
86
86
  }
@@ -94,7 +94,7 @@ export class ArifaClient {
94
94
  method: "POST",
95
95
  headers: {
96
96
  "Content-Type": "application/json",
97
- Origin: window.location.origin,
97
+ Origin: origin || window.location.origin,
98
98
  },
99
99
  body: JSON.stringify(body),
100
100
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arifa-client",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "JavaScript/TypeScript client SDK for Arifa Realtime Notification Service",
5
5
  "main": "dist/ArifaClient.js",
6
6
  "module": "dist/ArifaClient.js",