@capgo/capacitor-stream-call 0.0.88 → 0.0.89

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
@@ -254,6 +254,7 @@ export class CallService {
254
254
  * [`getCallInfo(...)`](#getcallinfo)
255
255
  * [`setDynamicStreamVideoApikey(...)`](#setdynamicstreamvideoapikey)
256
256
  * [`getDynamicStreamVideoApikey()`](#getdynamicstreamvideoapikey)
257
+ * [`getCurrentUser()`](#getcurrentuser)
257
258
  * [Interfaces](#interfaces)
258
259
  * [Type Aliases](#type-aliases)
259
260
  * [Enums](#enums)
@@ -538,6 +539,19 @@ Get the currently set dynamic Stream Video API key
538
539
  --------------------
539
540
 
540
541
 
542
+ ### getCurrentUser()
543
+
544
+ ```typescript
545
+ getCurrentUser() => Promise<CurrentUserResponse>
546
+ ```
547
+
548
+ Get the current user's information
549
+
550
+ **Returns:** <code>Promise&lt;<a href="#currentuserresponse">CurrentUserResponse</a>&gt;</code>
551
+
552
+ --------------------
553
+
554
+
541
555
  ### Interfaces
542
556
 
543
557
 
@@ -819,6 +833,16 @@ The JSON representation for <a href="#listvalue">`ListValue`</a> is JSON array.
819
833
  | **`hasDynamicKey`** | <code>boolean</code> | Whether a dynamic key is currently set |
820
834
 
821
835
 
836
+ #### CurrentUserResponse
837
+
838
+ | Prop | Type | Description |
839
+ | ---------------- | -------------------- | --------------------------------------- |
840
+ | **`userId`** | <code>string</code> | User ID of the current user |
841
+ | **`name`** | <code>string</code> | Display name of the current user |
842
+ | **`imageURL`** | <code>string</code> | Avatar URL of the current user |
843
+ | **`isLoggedIn`** | <code>boolean</code> | Whether the user is currently logged in |
844
+
845
+
822
846
  ### Type Aliases
823
847
 
824
848
 
@@ -18,9 +18,9 @@ class CustomStreamIntentResolver(private val context: Application) : StreamInten
18
18
  override fun searchIncomingCallPendingIntent(callId: StreamCallId, notificationId: Int): PendingIntent? {
19
19
  val launchIntent = context.packageManager.getLaunchIntentForPackage(context.packageName)?.apply {
20
20
  flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP
21
- putExtra("callCid", callId.cid)
22
- putExtra("action", "accept")
23
- action = "io.getstream.video.android.action.ACCEPT_CALL"
21
+ putExtra(NotificationHandler.INTENT_EXTRA_CALL_CID, callId)
22
+ action = "io.getstream.video.android.action.INCOMING_CALL"
23
+
24
24
  }
25
25
 
26
26
  return PendingIntent.getActivity(
@@ -200,16 +200,20 @@ class StreamCallPlugin : Plugin() {
200
200
  }
201
201
 
202
202
  override fun load() {
203
+ Log.d("StreamCallPlugin", "Plugin load() called")
203
204
  try {
204
205
  val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
205
206
  if (packageInfo.firstInstallTime == packageInfo.lastUpdateTime) {
206
207
  Log.d("StreamCallPlugin", "Fresh install detected, clearing user credentials.")
207
208
  SecureUserRepository.getInstance(context).removeCurrentUser()
209
+ } else {
210
+ Log.d("StreamCallPlugin", "App update or existing installation detected")
208
211
  }
209
212
  } catch (e: Exception) {
210
213
  Log.e("StreamCallPlugin", "Error checking for fresh install", e)
211
214
  }
212
215
  // general init
216
+ Log.d("StreamCallPlugin", "Calling initializeStreamVideo() from load()")
213
217
  initializeStreamVideo()
214
218
  setupViews()
215
219
  super.load()
@@ -586,8 +590,8 @@ class StreamCallPlugin : Plugin() {
586
590
  ),
587
591
  requestPermissionOnAppLaunch = { true },
588
592
  notificationHandler = CompatibilityStreamNotificationHandler(
589
- application = contextToUse as Application,
590
- intentResolver = CustomStreamIntentResolver(contextToUse),
593
+ application = application,
594
+ intentResolver = CustomStreamIntentResolver(application),
591
595
  initialNotificationBuilderInterceptor = object : StreamNotificationBuilderInterceptors() {
592
596
  override fun onBuildIncomingCallNotification(
593
597
  builder: NotificationCompat.Builder,
@@ -2499,6 +2503,35 @@ class StreamCallPlugin : Plugin() {
2499
2503
  }
2500
2504
  }
2501
2505
 
2506
+ @PluginMethod
2507
+ fun getCurrentUser(call: PluginCall) {
2508
+ Log.d("StreamCallPlugin", "getCurrentUser called")
2509
+ try {
2510
+ val savedCredentials = SecureUserRepository.getInstance(context).loadCurrentUser()
2511
+ val ret = JSObject()
2512
+
2513
+ if (savedCredentials != null) {
2514
+ Log.d("StreamCallPlugin", "getCurrentUser: Found saved credentials for user: ${savedCredentials.user.id}")
2515
+ ret.put("userId", savedCredentials.user.id)
2516
+ ret.put("name", savedCredentials.user.name ?: "")
2517
+ ret.put("imageURL", savedCredentials.user.image ?: "")
2518
+ ret.put("isLoggedIn", true)
2519
+ } else {
2520
+ Log.d("StreamCallPlugin", "getCurrentUser: No saved credentials found")
2521
+ ret.put("userId", "")
2522
+ ret.put("name", "")
2523
+ ret.put("imageURL", "")
2524
+ ret.put("isLoggedIn", false)
2525
+ }
2526
+
2527
+ Log.d("StreamCallPlugin", "getCurrentUser: Returning ${ret}")
2528
+ call.resolve(ret)
2529
+ } catch (e: Exception) {
2530
+ Log.e("StreamCallPlugin", "getCurrentUser: Failed to get current user", e)
2531
+ call.reject("Failed to get current user", e)
2532
+ }
2533
+ }
2534
+
2502
2535
  companion object {
2503
2536
  @JvmStatic fun preLoadInit(ctx: Context, app: Application) {
2504
2537
  holder ?: run {
@@ -50,6 +50,8 @@ class SecureUserRepository private constructor(context: Context) : UserRepositor
50
50
  }
51
51
 
52
52
  override fun save(user: UserCredentials) {
53
+ android.util.Log.d("SecureUserRepository", "Saving user credentials for: ${user.user.id}")
54
+
53
55
  val customJson = user.user.custom?.let { customMap ->
54
56
  JSONObject().apply {
55
57
  customMap.forEach { (key, value) ->
@@ -70,6 +72,8 @@ class SecureUserRepository private constructor(context: Context) : UserRepositor
70
72
  putString(KEY_USER, userJson.toString())
71
73
  putString(KEY_TOKEN, user.tokenValue)
72
74
  }
75
+
76
+ android.util.Log.d("SecureUserRepository", "User credentials saved successfully for: ${user.user.id}")
73
77
  }
74
78
 
75
79
  override fun save(token: String) {
@@ -77,6 +81,8 @@ class SecureUserRepository private constructor(context: Context) : UserRepositor
77
81
  }
78
82
 
79
83
  override fun loadCurrentUser(): UserCredentials? {
84
+ android.util.Log.d("SecureUserRepository", "Loading current user credentials")
85
+
80
86
  val userJson = sharedPreferences.getString(KEY_USER, null)
81
87
  val token = sharedPreferences.getString(KEY_TOKEN, null)
82
88
 
@@ -91,20 +97,26 @@ class SecureUserRepository private constructor(context: Context) : UserRepositor
91
97
  role = jsonObject.optString("role"),
92
98
  custom = ArrayMap()
93
99
  )
94
- UserCredentials(user, token)
100
+ val credentials = UserCredentials(user, token)
101
+ android.util.Log.d("SecureUserRepository", "Successfully loaded credentials for user: ${user.id}")
102
+ credentials
95
103
  } else {
104
+ android.util.Log.d("SecureUserRepository", "No stored credentials found (userJson: ${userJson != null}, token: ${token != null})")
96
105
  null
97
106
  }
98
107
  } catch (e: Exception) {
108
+ android.util.Log.e("SecureUserRepository", "Error loading user credentials", e)
99
109
  e.printStackTrace()
100
110
  null
101
111
  }
102
112
  }
103
113
 
104
114
  override fun removeCurrentUser() {
115
+ android.util.Log.d("SecureUserRepository", "Removing current user credentials")
105
116
  sharedPreferences.edit {
106
117
  remove(KEY_USER)
107
118
  remove(KEY_TOKEN)
108
119
  }
120
+ android.util.Log.d("SecureUserRepository", "User credentials removed successfully")
109
121
  }
110
- }
122
+ }
package/dist/docs.json CHANGED
@@ -483,6 +483,27 @@
483
483
  "DynamicApiKeyResponse"
484
484
  ],
485
485
  "slug": "getdynamicstreamvideoapikey"
486
+ },
487
+ {
488
+ "name": "getCurrentUser",
489
+ "signature": "() => Promise<CurrentUserResponse>",
490
+ "parameters": [],
491
+ "returns": "Promise<CurrentUserResponse>",
492
+ "tags": [
493
+ {
494
+ "name": "returns",
495
+ "text": "Current user information"
496
+ },
497
+ {
498
+ "name": "example",
499
+ "text": "const currentUser = await StreamCall.getCurrentUser();\nconsole.log(currentUser);"
500
+ }
501
+ ],
502
+ "docs": "Get the current user's information",
503
+ "complexTypes": [
504
+ "CurrentUserResponse"
505
+ ],
506
+ "slug": "getcurrentuser"
486
507
  }
487
508
  ],
488
509
  "properties": []
@@ -1462,6 +1483,68 @@
1462
1483
  "type": "boolean"
1463
1484
  }
1464
1485
  ]
1486
+ },
1487
+ {
1488
+ "name": "CurrentUserResponse",
1489
+ "slug": "currentuserresponse",
1490
+ "docs": "",
1491
+ "tags": [
1492
+ {
1493
+ "text": "CurrentUserResponse",
1494
+ "name": "interface"
1495
+ },
1496
+ {
1497
+ "text": "Response from getCurrentUser containing user information",
1498
+ "name": "description"
1499
+ },
1500
+ {
1501
+ "text": "{string} userId - User ID of the current user",
1502
+ "name": "property"
1503
+ },
1504
+ {
1505
+ "text": "{string} name - Display name of the current user",
1506
+ "name": "property"
1507
+ },
1508
+ {
1509
+ "text": "{string} [imageURL] - Avatar URL of the current user",
1510
+ "name": "property"
1511
+ },
1512
+ {
1513
+ "text": "{boolean} isLoggedIn - Whether the user is currently logged in",
1514
+ "name": "property"
1515
+ }
1516
+ ],
1517
+ "methods": [],
1518
+ "properties": [
1519
+ {
1520
+ "name": "userId",
1521
+ "tags": [],
1522
+ "docs": "User ID of the current user",
1523
+ "complexTypes": [],
1524
+ "type": "string"
1525
+ },
1526
+ {
1527
+ "name": "name",
1528
+ "tags": [],
1529
+ "docs": "Display name of the current user",
1530
+ "complexTypes": [],
1531
+ "type": "string"
1532
+ },
1533
+ {
1534
+ "name": "imageURL",
1535
+ "tags": [],
1536
+ "docs": "Avatar URL of the current user",
1537
+ "complexTypes": [],
1538
+ "type": "string | undefined"
1539
+ },
1540
+ {
1541
+ "name": "isLoggedIn",
1542
+ "tags": [],
1543
+ "docs": "Whether the user is currently logged in",
1544
+ "complexTypes": [],
1545
+ "type": "boolean"
1546
+ }
1547
+ ]
1465
1548
  }
1466
1549
  ],
1467
1550
  "enums": [
@@ -98,6 +98,24 @@ export interface DynamicApiKeyResponse {
98
98
  /** Whether a dynamic key is currently set */
99
99
  hasDynamicKey: boolean;
100
100
  }
101
+ /**
102
+ * @interface CurrentUserResponse
103
+ * @description Response from getCurrentUser containing user information
104
+ * @property {string} userId - User ID of the current user
105
+ * @property {string} name - Display name of the current user
106
+ * @property {string} [imageURL] - Avatar URL of the current user
107
+ * @property {boolean} isLoggedIn - Whether the user is currently logged in
108
+ */
109
+ export interface CurrentUserResponse {
110
+ /** User ID of the current user */
111
+ userId: string;
112
+ /** Display name of the current user */
113
+ name: string;
114
+ /** Avatar URL of the current user */
115
+ imageURL?: string;
116
+ /** Whether the user is currently logged in */
117
+ isLoggedIn: boolean;
118
+ }
101
119
  /**
102
120
  * @interface SuccessResponse
103
121
  * @description Standard response indicating operation success/failure
@@ -299,6 +317,14 @@ export interface StreamCallPlugin {
299
317
  * }
300
318
  */
301
319
  getDynamicStreamVideoApikey(): Promise<DynamicApiKeyResponse>;
320
+ /**
321
+ * Get the current user's information
322
+ * @returns {Promise<CurrentUserResponse>} Current user information
323
+ * @example
324
+ * const currentUser = await StreamCall.getCurrentUser();
325
+ * console.log(currentUser);
326
+ */
327
+ getCurrentUser(): Promise<CurrentUserResponse>;
302
328
  }
303
329
  /**
304
330
  * @interface IncomingCallPayload
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @interface LoginOptions\n * @description Configuration options for logging into the Stream Video service\n * @property {string} token - Stream Video API token for authentication\n * @property {string} userId - Unique identifier for the current user\n * @property {string} name - Display name for the current user\n * @property {string} [imageURL] - Avatar URL for the current user\n * @property {string} apiKey - Stream Video API key for your application\n * @property {string} [magicDivId] - DOM element ID where video will be rendered\n */\nexport interface LoginOptions {\n /** Stream Video API token */\n token: string;\n /** User ID for the current user */\n userId: string;\n /** Display name for the current user */\n name: string;\n /** Optional avatar URL for the current user */\n imageURL?: string;\n /** Stream Video API key */\n apiKey: string;\n /** ID of the HTML element where the video will be rendered */\n magicDivId?: string;\n pushNotificationsConfig?: PushNotificationsConfig;\n}\n\nexport interface PushNotificationsConfig {\n pushProviderName: string;\n voipProviderName: string;\n}\n\n/**\n * @typedef CallState\n * @description Represents all possible call states from API and UI\n */\nexport type CallState =\n // User-facing states\n | 'idle'\n | 'ringing'\n | 'joining'\n | 'reconnecting'\n | 'joined'\n | 'leaving'\n | 'left'\n // Event-specific states\n | 'created'\n | 'session_started'\n | 'rejected'\n | 'missed'\n | 'accepted'\n | 'ended'\n | 'camera_enabled'\n | 'camera_disabled'\n | 'microphone_enabled'\n | 'microphone_disabled'\n | 'unknown';\n\n/**\n * @typedef CallType\n * @description Represents the pre-defined types of a call.\n * - `default`: Simple 1-1 or group video calling with sensible defaults. Video/audio enabled, backstage disabled. Admins/hosts have elevated permissions.\n * - `audio_room`: For audio-only spaces (like Clubhouse). Backstage enabled (requires `goLive`), pre-configured permissions for requesting to speak.\n * - `livestream`: For one-to-many streaming. Backstage enabled (requires `goLive`), access granted to all authenticated users.\n * - `development`: For testing ONLY. All permissions enabled, backstage disabled. **Not recommended for production.**\n */\nexport type CallType = 'default' | 'audio_room' | 'livestream' | 'development';\n\n/**\n * @interface CallMember\n * @description Information about a call member/participant\n * @property {string} userId - User ID of the member\n * @property {string} [name] - Display name of the user\n * @property {string} [imageURL] - Profile image URL of the user\n * @property {string} [role] - Role of the user in the call\n */\nexport interface CallMember {\n /** User ID of the member */\n userId: string;\n /** Display name of the user */\n name?: string;\n /** Profile image URL of the user */\n imageURL?: string;\n /** Role of the user in the call */\n role?: string;\n}\n\n/**\n * @interface CallEvent\n * @description Event emitted when call state changes\n * @property {string} callId - Unique identifier of the call\n * @property {CallState} state - Current state of the call\n * @property {string} [userId] - User ID of the participant who triggered the event\n * @property {string} [reason] - Reason for the call state change\n * @property {CallMember} [caller] - Information about the caller (for incoming calls)\n * @property {CallMember[]} [members] - List of call members\n */\nexport interface CallEvent {\n /** ID of the call */\n callId: string;\n /** Current state of the call */\n state: CallState;\n /** User ID of the participant in the call who triggered the event */\n userId?: string;\n /** Reason for the call state change, if applicable */\n reason?: string;\n /** Information about the caller (for incoming calls) */\n caller?: CallMember;\n /** List of call members */\n members?: CallMember[];\n}\n\nexport interface CameraEnabledResponse {\n enabled: boolean;\n}\n\n/**\n * @interface DynamicApiKeyResponse\n * @description Response from getDynamicStreamVideoApikey\n * @property {string|null} apiKey - The dynamic API key if set, null if not\n * @property {boolean} hasDynamicKey - Whether a dynamic key is currently set\n */\nexport interface DynamicApiKeyResponse {\n /** The dynamic API key if set, null if not */\n apiKey: string | null;\n /** Whether a dynamic key is currently set */\n hasDynamicKey: boolean;\n}\n\n/**\n * @interface SuccessResponse\n * @description Standard response indicating operation success/failure\n * @property {boolean} success - Whether the operation succeeded\n */\nexport interface SuccessResponse {\n /** Whether the operation was successful */\n success: boolean;\n}\n\n/**\n * @interface CallOptions\n * @description Options for initiating a video call\n * @property {string[]} userIds - IDs of the users to call\n * @property {CallType} [type=default] - Type of call\n * @property {boolean} [ring=true] - Whether to send ring notification\n * @property {string} [team] - Team name to call\n */\nexport interface CallOptions {\n /** User ID of the person to call */\n userIds: string[];\n /** Type of call, defaults to 'default' */\n type?: CallType;\n /** Whether to ring the other user, defaults to true */\n ring?: boolean;\n /** Team name to call */\n team?: string;\n /** Whether to start the call with video enabled, defaults to false */\n video?: boolean;\n /** Custom data to be passed to the call */\n custom?: Record<\n string,\n | string\n | boolean\n | number\n | null\n | Record<string, string | boolean | number | null>\n | string[]\n | boolean[]\n | number[]\n >;\n}\n\n/**\n * @interface StreamCallPlugin\n * @description Capacitor plugin for Stream Video calling functionality\n */\nexport interface StreamCallPlugin {\n /**\n * Login to Stream Video service\n * @param {LoginOptions} options - Login configuration\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.login({\n * token: 'your-token',\n * userId: 'user-123',\n * name: 'John Doe',\n * apiKey: 'your-api-key'\n * });\n */\n login(options: LoginOptions): Promise<SuccessResponse>;\n\n /**\n * Logout from Stream Video service\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.logout();\n */\n logout(): Promise<SuccessResponse>;\n\n /**\n * Initiate a call to another user\n * @param {CallOptions} options - Call configuration\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.call({\n * userId: 'user-456',\n * type: 'video',\n * ring: true\n * });\n */\n call(options: CallOptions): Promise<SuccessResponse>;\n\n /**\n * End the current call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.endCall();\n */\n endCall(): Promise<SuccessResponse>;\n\n /**\n * Enable or disable microphone\n * @param {{ enabled: boolean }} options - Microphone state\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setMicrophoneEnabled({ enabled: false });\n */\n setMicrophoneEnabled(options: { enabled: boolean }): Promise<SuccessResponse>;\n\n /**\n * Enable or disable camera\n * @param {{ enabled: boolean }} options - Camera state\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setCameraEnabled({ enabled: false });\n */\n setCameraEnabled(options: { enabled: boolean }): Promise<SuccessResponse>;\n\n /**\n * Add listener for call events\n * @param {'callEvent'} eventName - Name of the event to listen for\n * @param {(event: CallEvent) => void} listenerFunc - Callback function\n * @returns {Promise<{ remove: () => Promise<void> }>} Function to remove listener\n * @example\n * const listener = await StreamCall.addListener('callEvent', (event) => {\n * console.log(`Call ${event.callId} is now ${event.state}`);\n * });\n */\n addListener(\n eventName: 'callEvent',\n listenerFunc: (event: CallEvent) => void,\n ): Promise<{ remove: () => Promise<void> }>;\n\n /**\n * Listen for lock-screen incoming call (Android only).\n * Fired when the app is shown by full-screen intent before user interaction.\n */\n addListener(\n eventName: 'incomingCall',\n listenerFunc: (event: IncomingCallPayload) => void,\n ): Promise<{ remove: () => Promise<void> }>;\n\n /**\n * Remove all event listeners\n * @returns {Promise<void>}\n * @example\n * await StreamCall.removeAllListeners();\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Accept an incoming call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.acceptCall();\n */\n acceptCall(): Promise<SuccessResponse>;\n\n /**\n * Reject an incoming call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.rejectCall();\n */\n rejectCall(): Promise<SuccessResponse>;\n\n /**\n * Check if camera is enabled\n * @returns {Promise<CameraEnabledResponse>} Camera enabled status\n * @example\n * const isCameraEnabled = await StreamCall.isCameraEnabled();\n * console.log(isCameraEnabled);\n */\n isCameraEnabled(): Promise<CameraEnabledResponse>;\n\n /**\n * Get the current call status\n * @returns {Promise<CallEvent>} Current call status as a CallEvent\n * @example\n * const callStatus = await StreamCall.getCallStatus();\n * console.log(callStatus);\n */\n getCallStatus(): Promise<CallEvent>;\n\n /**\n * Set speakerphone on\n * @param {{ name: string }} options - Speakerphone name\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setSpeaker({ name: 'speaker' });\n */\n setSpeaker(options: { name: string }): Promise<SuccessResponse>;\n\n /**\n * Switch camera\n * @param {{ camera: 'front' | 'back' }} options - Camera to switch to\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.switchCamera({ camera: 'back' });\n */\n switchCamera(options: { camera: 'front' | 'back' }): Promise<SuccessResponse>;\n\n /**\n * Get detailed information about an active call including caller details\n * @param options - Options containing the call ID\n */\n getCallInfo(options: { callId: string }): Promise<CallEvent>;\n\n /**\n * Set a dynamic Stream Video API key that overrides the static one\n * @param {{ apiKey: string }} options - The API key to set\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setDynamicStreamVideoApikey({ apiKey: 'new-api-key' });\n */\n setDynamicStreamVideoApikey(options: { apiKey: string }): Promise<SuccessResponse>;\n\n /**\n * Get the currently set dynamic Stream Video API key\n * @returns {Promise<DynamicApiKeyResponse>} The dynamic API key and whether it's set\n * @example\n * const result = await StreamCall.getDynamicStreamVideoApikey();\n * if (result.hasDynamicKey) {\n * console.log('Dynamic API key:', result.apiKey);\n * } else {\n * console.log('Using static API key from resources');\n * }\n */\n getDynamicStreamVideoApikey(): Promise<DynamicApiKeyResponse>;\n}\n\n/**\n * @interface IncomingCallPayload\n * @description Payload delivered with \"incomingCall\" event (Android lock-screen).\n * @property {string} cid - Call CID (type:id)\n * @property {string} type - Always \"incoming\" for this event\n * @property {CallMember} [caller] - Information about the caller\n */\nexport interface IncomingCallPayload {\n /** Full call CID (e.g. default:123) */\n cid: string;\n /** Event type (currently always \"incoming\") */\n type: 'incoming';\n /** Information about the caller */\n caller?: CallMember;\n /** Custom data to be passed to the call */\n custom?: Record<\n string,\n | string\n | boolean\n | number\n | null\n | Record<string, string | boolean | number | null>\n | string[]\n | boolean[]\n | number[]\n >;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @interface LoginOptions\n * @description Configuration options for logging into the Stream Video service\n * @property {string} token - Stream Video API token for authentication\n * @property {string} userId - Unique identifier for the current user\n * @property {string} name - Display name for the current user\n * @property {string} [imageURL] - Avatar URL for the current user\n * @property {string} apiKey - Stream Video API key for your application\n * @property {string} [magicDivId] - DOM element ID where video will be rendered\n */\nexport interface LoginOptions {\n /** Stream Video API token */\n token: string;\n /** User ID for the current user */\n userId: string;\n /** Display name for the current user */\n name: string;\n /** Optional avatar URL for the current user */\n imageURL?: string;\n /** Stream Video API key */\n apiKey: string;\n /** ID of the HTML element where the video will be rendered */\n magicDivId?: string;\n pushNotificationsConfig?: PushNotificationsConfig;\n}\n\nexport interface PushNotificationsConfig {\n pushProviderName: string;\n voipProviderName: string;\n}\n\n/**\n * @typedef CallState\n * @description Represents all possible call states from API and UI\n */\nexport type CallState =\n // User-facing states\n | 'idle'\n | 'ringing'\n | 'joining'\n | 'reconnecting'\n | 'joined'\n | 'leaving'\n | 'left'\n // Event-specific states\n | 'created'\n | 'session_started'\n | 'rejected'\n | 'missed'\n | 'accepted'\n | 'ended'\n | 'camera_enabled'\n | 'camera_disabled'\n | 'microphone_enabled'\n | 'microphone_disabled'\n | 'unknown';\n\n/**\n * @typedef CallType\n * @description Represents the pre-defined types of a call.\n * - `default`: Simple 1-1 or group video calling with sensible defaults. Video/audio enabled, backstage disabled. Admins/hosts have elevated permissions.\n * - `audio_room`: For audio-only spaces (like Clubhouse). Backstage enabled (requires `goLive`), pre-configured permissions for requesting to speak.\n * - `livestream`: For one-to-many streaming. Backstage enabled (requires `goLive`), access granted to all authenticated users.\n * - `development`: For testing ONLY. All permissions enabled, backstage disabled. **Not recommended for production.**\n */\nexport type CallType = 'default' | 'audio_room' | 'livestream' | 'development';\n\n/**\n * @interface CallMember\n * @description Information about a call member/participant\n * @property {string} userId - User ID of the member\n * @property {string} [name] - Display name of the user\n * @property {string} [imageURL] - Profile image URL of the user\n * @property {string} [role] - Role of the user in the call\n */\nexport interface CallMember {\n /** User ID of the member */\n userId: string;\n /** Display name of the user */\n name?: string;\n /** Profile image URL of the user */\n imageURL?: string;\n /** Role of the user in the call */\n role?: string;\n}\n\n/**\n * @interface CallEvent\n * @description Event emitted when call state changes\n * @property {string} callId - Unique identifier of the call\n * @property {CallState} state - Current state of the call\n * @property {string} [userId] - User ID of the participant who triggered the event\n * @property {string} [reason] - Reason for the call state change\n * @property {CallMember} [caller] - Information about the caller (for incoming calls)\n * @property {CallMember[]} [members] - List of call members\n */\nexport interface CallEvent {\n /** ID of the call */\n callId: string;\n /** Current state of the call */\n state: CallState;\n /** User ID of the participant in the call who triggered the event */\n userId?: string;\n /** Reason for the call state change, if applicable */\n reason?: string;\n /** Information about the caller (for incoming calls) */\n caller?: CallMember;\n /** List of call members */\n members?: CallMember[];\n}\n\nexport interface CameraEnabledResponse {\n enabled: boolean;\n}\n\n/**\n * @interface DynamicApiKeyResponse\n * @description Response from getDynamicStreamVideoApikey\n * @property {string|null} apiKey - The dynamic API key if set, null if not\n * @property {boolean} hasDynamicKey - Whether a dynamic key is currently set\n */\nexport interface DynamicApiKeyResponse {\n /** The dynamic API key if set, null if not */\n apiKey: string | null;\n /** Whether a dynamic key is currently set */\n hasDynamicKey: boolean;\n}\n\n/**\n * @interface CurrentUserResponse\n * @description Response from getCurrentUser containing user information\n * @property {string} userId - User ID of the current user\n * @property {string} name - Display name of the current user\n * @property {string} [imageURL] - Avatar URL of the current user\n * @property {boolean} isLoggedIn - Whether the user is currently logged in\n */\nexport interface CurrentUserResponse {\n /** User ID of the current user */\n userId: string;\n /** Display name of the current user */\n name: string;\n /** Avatar URL of the current user */\n imageURL?: string;\n /** Whether the user is currently logged in */\n isLoggedIn: boolean;\n}\n\n/**\n * @interface SuccessResponse\n * @description Standard response indicating operation success/failure\n * @property {boolean} success - Whether the operation succeeded\n */\nexport interface SuccessResponse {\n /** Whether the operation was successful */\n success: boolean;\n}\n\n/**\n * @interface CallOptions\n * @description Options for initiating a video call\n * @property {string[]} userIds - IDs of the users to call\n * @property {CallType} [type=default] - Type of call\n * @property {boolean} [ring=true] - Whether to send ring notification\n * @property {string} [team] - Team name to call\n */\nexport interface CallOptions {\n /** User ID of the person to call */\n userIds: string[];\n /** Type of call, defaults to 'default' */\n type?: CallType;\n /** Whether to ring the other user, defaults to true */\n ring?: boolean;\n /** Team name to call */\n team?: string;\n /** Whether to start the call with video enabled, defaults to false */\n video?: boolean;\n /** Custom data to be passed to the call */\n custom?: Record<\n string,\n | string\n | boolean\n | number\n | null\n | Record<string, string | boolean | number | null>\n | string[]\n | boolean[]\n | number[]\n >;\n}\n\n/**\n * @interface StreamCallPlugin\n * @description Capacitor plugin for Stream Video calling functionality\n */\nexport interface StreamCallPlugin {\n /**\n * Login to Stream Video service\n * @param {LoginOptions} options - Login configuration\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.login({\n * token: 'your-token',\n * userId: 'user-123',\n * name: 'John Doe',\n * apiKey: 'your-api-key'\n * });\n */\n login(options: LoginOptions): Promise<SuccessResponse>;\n\n /**\n * Logout from Stream Video service\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.logout();\n */\n logout(): Promise<SuccessResponse>;\n\n /**\n * Initiate a call to another user\n * @param {CallOptions} options - Call configuration\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.call({\n * userId: 'user-456',\n * type: 'video',\n * ring: true\n * });\n */\n call(options: CallOptions): Promise<SuccessResponse>;\n\n /**\n * End the current call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.endCall();\n */\n endCall(): Promise<SuccessResponse>;\n\n /**\n * Enable or disable microphone\n * @param {{ enabled: boolean }} options - Microphone state\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setMicrophoneEnabled({ enabled: false });\n */\n setMicrophoneEnabled(options: { enabled: boolean }): Promise<SuccessResponse>;\n\n /**\n * Enable or disable camera\n * @param {{ enabled: boolean }} options - Camera state\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setCameraEnabled({ enabled: false });\n */\n setCameraEnabled(options: { enabled: boolean }): Promise<SuccessResponse>;\n\n /**\n * Add listener for call events\n * @param {'callEvent'} eventName - Name of the event to listen for\n * @param {(event: CallEvent) => void} listenerFunc - Callback function\n * @returns {Promise<{ remove: () => Promise<void> }>} Function to remove listener\n * @example\n * const listener = await StreamCall.addListener('callEvent', (event) => {\n * console.log(`Call ${event.callId} is now ${event.state}`);\n * });\n */\n addListener(\n eventName: 'callEvent',\n listenerFunc: (event: CallEvent) => void,\n ): Promise<{ remove: () => Promise<void> }>;\n\n /**\n * Listen for lock-screen incoming call (Android only).\n * Fired when the app is shown by full-screen intent before user interaction.\n */\n addListener(\n eventName: 'incomingCall',\n listenerFunc: (event: IncomingCallPayload) => void,\n ): Promise<{ remove: () => Promise<void> }>;\n\n /**\n * Remove all event listeners\n * @returns {Promise<void>}\n * @example\n * await StreamCall.removeAllListeners();\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Accept an incoming call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.acceptCall();\n */\n acceptCall(): Promise<SuccessResponse>;\n\n /**\n * Reject an incoming call\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.rejectCall();\n */\n rejectCall(): Promise<SuccessResponse>;\n\n /**\n * Check if camera is enabled\n * @returns {Promise<CameraEnabledResponse>} Camera enabled status\n * @example\n * const isCameraEnabled = await StreamCall.isCameraEnabled();\n * console.log(isCameraEnabled);\n */\n isCameraEnabled(): Promise<CameraEnabledResponse>;\n\n /**\n * Get the current call status\n * @returns {Promise<CallEvent>} Current call status as a CallEvent\n * @example\n * const callStatus = await StreamCall.getCallStatus();\n * console.log(callStatus);\n */\n getCallStatus(): Promise<CallEvent>;\n\n /**\n * Set speakerphone on\n * @param {{ name: string }} options - Speakerphone name\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setSpeaker({ name: 'speaker' });\n */\n setSpeaker(options: { name: string }): Promise<SuccessResponse>;\n\n /**\n * Switch camera\n * @param {{ camera: 'front' | 'back' }} options - Camera to switch to\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.switchCamera({ camera: 'back' });\n */\n switchCamera(options: { camera: 'front' | 'back' }): Promise<SuccessResponse>;\n\n /**\n * Get detailed information about an active call including caller details\n * @param options - Options containing the call ID\n */\n getCallInfo(options: { callId: string }): Promise<CallEvent>;\n\n /**\n * Set a dynamic Stream Video API key that overrides the static one\n * @param {{ apiKey: string }} options - The API key to set\n * @returns {Promise<SuccessResponse>} Success status\n * @example\n * await StreamCall.setDynamicStreamVideoApikey({ apiKey: 'new-api-key' });\n */\n setDynamicStreamVideoApikey(options: { apiKey: string }): Promise<SuccessResponse>;\n\n /**\n * Get the currently set dynamic Stream Video API key\n * @returns {Promise<DynamicApiKeyResponse>} The dynamic API key and whether it's set\n * @example\n * const result = await StreamCall.getDynamicStreamVideoApikey();\n * if (result.hasDynamicKey) {\n * console.log('Dynamic API key:', result.apiKey);\n * } else {\n * console.log('Using static API key from resources');\n * }\n */\n getDynamicStreamVideoApikey(): Promise<DynamicApiKeyResponse>;\n\n /**\n * Get the current user's information\n * @returns {Promise<CurrentUserResponse>} Current user information\n * @example\n * const currentUser = await StreamCall.getCurrentUser();\n * console.log(currentUser);\n */\n getCurrentUser(): Promise<CurrentUserResponse>;\n}\n\n/**\n * @interface IncomingCallPayload\n * @description Payload delivered with \"incomingCall\" event (Android lock-screen).\n * @property {string} cid - Call CID (type:id)\n * @property {string} type - Always \"incoming\" for this event\n * @property {CallMember} [caller] - Information about the caller\n */\nexport interface IncomingCallPayload {\n /** Full call CID (e.g. default:123) */\n cid: string;\n /** Event type (currently always \"incoming\") */\n type: 'incoming';\n /** Information about the caller */\n caller?: CallMember;\n /** Custom data to be passed to the call */\n custom?: Record<\n string,\n | string\n | boolean\n | number\n | null\n | Record<string, string | boolean | number | null>\n | string[]\n | boolean[]\n | number[]\n >;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { CallOptions, StreamCallPlugin, SuccessResponse, LoginOptions, CameraEnabledResponse, CallEvent, DynamicApiKeyResponse } from './definitions';
2
+ import type { CallOptions, StreamCallPlugin, SuccessResponse, LoginOptions, CameraEnabledResponse, CallEvent, DynamicApiKeyResponse, CurrentUserResponse } from './definitions';
3
3
  export declare class StreamCallWeb extends WebPlugin implements StreamCallPlugin {
4
4
  private client?;
5
5
  private currentCall?;
@@ -13,6 +13,7 @@ export declare class StreamCallWeb extends WebPlugin implements StreamCallPlugin
13
13
  private participantLeftListener?;
14
14
  private participantResponses;
15
15
  private callMembersExpected;
16
+ private currentUser?;
16
17
  private setupCallRingListener;
17
18
  private setupCallEventListeners;
18
19
  private ringCallback;
@@ -54,4 +55,5 @@ export declare class StreamCallWeb extends WebPlugin implements StreamCallPlugin
54
55
  apiKey: string;
55
56
  }): Promise<SuccessResponse>;
56
57
  getDynamicStreamVideoApikey(): Promise<DynamicApiKeyResponse>;
58
+ getCurrentUser(): Promise<CurrentUserResponse>;
57
59
  }
package/dist/esm/web.js CHANGED
@@ -465,6 +465,12 @@ export class StreamCallWeb extends WebPlugin {
465
465
  user: { id: options.userId, name: options.name, image: options.imageURL },
466
466
  token: options.token,
467
467
  });
468
+ // Store current user data
469
+ this.currentUser = {
470
+ userId: options.userId,
471
+ name: options.name,
472
+ imageURL: options.imageURL,
473
+ };
468
474
  this.magicDivId = options.magicDivId;
469
475
  this.setupCallRingListener();
470
476
  return { success: true };
@@ -480,6 +486,7 @@ export class StreamCallWeb extends WebPlugin {
480
486
  this.callStateSubscription = undefined;
481
487
  await this.client.disconnectUser();
482
488
  this.client = undefined;
489
+ this.currentUser = undefined;
483
490
  this.currentCall = undefined;
484
491
  return { success: true };
485
492
  }
@@ -710,5 +717,23 @@ export class StreamCallWeb extends WebPlugin {
710
717
  async getDynamicStreamVideoApikey() {
711
718
  throw new Error('getDynamicStreamVideoApikey is not implemented on web platform');
712
719
  }
720
+ async getCurrentUser() {
721
+ if (this.currentUser && this.client) {
722
+ return {
723
+ userId: this.currentUser.userId,
724
+ name: this.currentUser.name,
725
+ imageURL: this.currentUser.imageURL || '',
726
+ isLoggedIn: true,
727
+ };
728
+ }
729
+ else {
730
+ return {
731
+ userId: '',
732
+ name: '',
733
+ imageURL: '',
734
+ isLoggedIn: false,
735
+ };
736
+ }
737
+ }
713
738
  }
714
739
  //# sourceMappingURL=web.js.map