@vizbeetv/homesso-sdk-qa 1.0.1

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 ADDED
@@ -0,0 +1,319 @@
1
+ # @vizbeetv/homesso-sdk-qa
2
+
3
+ TV app authentication library — enables mobile-to-TV Single Sign-On (SSO) via the Vizbee platform.
4
+
5
+ > **This is the QA build.** For production use, install [`@vizbeetv/homesso-sdk`](https://www.npmjs.com/package/@vizbeetv/homesso-sdk) instead.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @vizbeetv/homesso-sdk-qa
11
+ ```
12
+
13
+ The default entry point ships ES5 output, safe for all TV platforms. An explicit ES6 subpath is available for modern engines.
14
+
15
+ ## Prerequisites
16
+
17
+ This SDK requires the [Vizbee SDK (`@vizbeetv/sdk-qa`)](https://www.npmjs.com/package/@vizbeetv/sdk-qa) to be loaded first. That SDK populates `window.vizbee.continuity` and fires the `VIZBEE_SDK_READY` event, which this SDK listens for during initialisation.
18
+
19
+ Install it alongside this package:
20
+
21
+ ```bash
22
+ npm install @vizbeetv/sdk-qa @vizbeetv/homesso-sdk-qa
23
+ ```
24
+
25
+ ---
26
+
27
+ ## Quick start
28
+
29
+ ```typescript
30
+ import { HomeSSOContext, ProgressStatus, SuccessStatus, FailureStatus } from '@vizbeetv/homesso-sdk-qa';
31
+
32
+ const manager = HomeSSOContext.getInstance().getHomeSSOManager();
33
+
34
+ // Provide current sign-in state for the device
35
+ manager.setSignInInfoGetter(async () => [
36
+ { userLoginType: 'email', isSignedIn: true, userLogin: 'user@example.com' },
37
+ ]);
38
+
39
+ // Handle an incoming sign-in request from a mobile device
40
+ manager.setSignInHandler((signInInfo, statusCallback) => {
41
+ const { signInType } = signInInfo;
42
+
43
+ statusCallback(new ProgressStatus(signInType, { regcode: 'ABC123' }));
44
+
45
+ performSignIn(signInInfo)
46
+ .then(user => statusCallback(new SuccessStatus(signInType, user.id, { email: user.email })))
47
+ .catch(() => statusCallback(new FailureStatus(signInType, false, 'Sign-in failed')));
48
+ });
49
+
50
+ // Initialise the session (call after the Vizbee Continuity SDK is ready)
51
+ manager.init();
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Package variants
57
+
58
+ | Import path | JS target | Use when |
59
+ |---|---|---|
60
+ | `@vizbeetv/homesso-sdk-qa` | ES5 (default) | All TV platforms, legacy engines |
61
+ | `@vizbeetv/homesso-sdk-qa/es5` | ES5 | Same as default, explicit |
62
+ | `@vizbeetv/homesso-sdk-qa/es6` | ES6 | Tizen 5.5+, webOS 6+, Chrome 72+ |
63
+
64
+ ```typescript
65
+ // ES6 build — modern bundlers / TV platforms that support ES2015+
66
+ import { HomeSSOContext } from '@vizbeetv/homesso-sdk-qa/es6';
67
+ ```
68
+
69
+ ---
70
+
71
+ ## API reference
72
+
73
+ ### `HomeSSOContext`
74
+
75
+ The main entry point. Use `getInstance()` to get the singleton.
76
+
77
+ ```typescript
78
+ const context = HomeSSOContext.getInstance();
79
+ const manager = context.getHomeSSOManager();
80
+ const uiManager = context.getHomeSSOUIManager();
81
+
82
+ // Toggle logging
83
+ context.enableLogger(true);
84
+ context.setLoggerLevel(LogLevel.DEBUG);
85
+ ```
86
+
87
+ ---
88
+
89
+ ### `VizbeeHomeSSOManager`
90
+
91
+ Retrieved via `HomeSSOContext.getInstance().getHomeSSOManager()`.
92
+
93
+ #### `init()`
94
+
95
+ Connects to the Vizbee session. Call this after `window.vizbee.continuity` is available (i.e. inside your app's Vizbee ready callback).
96
+
97
+ ```typescript
98
+ manager.init();
99
+ ```
100
+
101
+ #### `setSignInInfoGetter(getter)`
102
+
103
+ Provides the current sign-in state of the TV device. Called internally before deciding whether to trigger a sign-in flow.
104
+
105
+ ```typescript
106
+ import type { VizbeeSignInInfo } from '@vizbeetv/homesso-sdk-qa';
107
+
108
+ manager.setSignInInfoGetter(async (): Promise<VizbeeSignInInfo[]> => {
109
+ return [
110
+ {
111
+ userLoginType: 'email', // must match the signInType sent by the mobile app
112
+ isSignedIn: isUserLoggedIn(),
113
+ userLogin: getCurrentUserEmail(),
114
+ },
115
+ ];
116
+ });
117
+ ```
118
+
119
+ #### `setSignInHandler(handler)`
120
+
121
+ Receives sign-in requests from mobile devices. The handler is called with a `signInInfo` payload and a `statusCallback` to report progress.
122
+
123
+ ```typescript
124
+ import { ProgressStatus, SuccessStatus, FailureStatus } from '@vizbeetv/homesso-sdk-qa';
125
+
126
+ manager.setSignInHandler((signInInfo, statusCallback) => {
127
+ const { signInType } = signInInfo;
128
+
129
+ // Report in-progress (shows the progress snackbar; regcode is required)
130
+ statusCallback(new ProgressStatus(signInType, { regcode: 'ABC123' }));
131
+
132
+ // Later, report success (email in customData is required to show success UI)
133
+ statusCallback(new SuccessStatus(signInType, 'user-id-123', { email: 'user@example.com' }));
134
+
135
+ // Or report failure / cancellation
136
+ statusCallback(new FailureStatus(signInType, false, 'Authentication failed'));
137
+ statusCallback(new FailureStatus(signInType, true)); // isCancelled = true
138
+ });
139
+ ```
140
+
141
+ #### `addCustomEventAttributes(attributes)`
142
+
143
+ Attaches custom key/value pairs to all analytics events emitted by the SDK.
144
+
145
+ ```typescript
146
+ manager.addCustomEventAttributes({ appVersion: '3.2.1', platform: 'tizen' });
147
+ ```
148
+
149
+ ---
150
+
151
+ ### Status classes
152
+
153
+ #### `ProgressStatus`
154
+
155
+ Signals that sign-in is in progress. `customData.regcode` is **required** to trigger the progress UI.
156
+
157
+ ```typescript
158
+ new ProgressStatus(
159
+ signInType, // string — matches the mobile app's sign-in type
160
+ { regcode: 'XYZ' }, // customData — must include regcode
161
+ )
162
+ ```
163
+
164
+ #### `SuccessStatus`
165
+
166
+ Signals a successful sign-in. `customData.email` is **required** to trigger the success UI.
167
+
168
+ ```typescript
169
+ new SuccessStatus(
170
+ signInType, // string
171
+ 'user-id-123', // userId (optional)
172
+ { email: 'user@example.com' }, // customData — must include email
173
+ )
174
+ ```
175
+
176
+ #### `FailureStatus`
177
+
178
+ Signals a failed or cancelled sign-in.
179
+
180
+ ```typescript
181
+ new FailureStatus(
182
+ signInType, // string
183
+ false, // isCancelled
184
+ 'Reason string', // reason (optional)
185
+ new Error('...'), // exception (optional)
186
+ { key: 'value' }, // customData (optional)
187
+ )
188
+ ```
189
+
190
+ ---
191
+
192
+ ### `VizbeeHomeSSOUIManager`
193
+
194
+ Retrieved via `HomeSSOContext.getInstance().getHomeSSOUIManager()`.
195
+
196
+ Controls the appearance of the three snackbar states: **informational** (sign-in requested), **progress** (sign-in underway), and **success** (sign-in complete).
197
+
198
+ #### Apply a theme
199
+
200
+ ```typescript
201
+ import type { VizbeeHomeSSOTheme } from '@vizbeetv/homesso-sdk-qa';
202
+
203
+ uiManager.setTheme({
204
+ primaryColor: '#1a1a2e',
205
+ secondaryColor: '#16213e',
206
+ tertiaryColor: '#e94560',
207
+ subTextColor: '#ffffff',
208
+ primaryFont: 'Roboto, sans-serif',
209
+ direction: 'ltr', // 'ltr' | 'rtl'
210
+ });
211
+ ```
212
+
213
+ Default theme:
214
+
215
+ | Property | Default |
216
+ |---|---|
217
+ | `primaryColor` | `#000000` |
218
+ | `secondaryColor` | `#262626` |
219
+ | `tertiaryColor` | `#FFFFFF` |
220
+ | `subTextColor` | `undefined` (inherits tertiary) |
221
+ | `direction` | `ltr` |
222
+
223
+ #### Override common modal options
224
+
225
+ ```typescript
226
+ uiManager.setCommonModalConfig({
227
+ borderRadius: '16px',
228
+ borderWidth: '2px',
229
+ boxShadow: '0 0 20px rgba(0, 200, 83, 0.6)',
230
+ width: '480px',
231
+ padding: '24px',
232
+ iconWidth: '64px',
233
+ iconHeight: '64px',
234
+ });
235
+ ```
236
+
237
+ #### Override per-state modal options
238
+
239
+ ```typescript
240
+ uiManager.setInformationalSignInModalConfig({
241
+ titleText: 'Sign in with your phone',
242
+ descriptionText: 'Open the app on your mobile device to continue.',
243
+ position: 'bottom-right',
244
+ iconBase64String: '<your-base64-icon>',
245
+ });
246
+
247
+ uiManager.setProgressSignInModalConfig({
248
+ descriptionText: 'Signing you in…',
249
+ position: 'bottom-right',
250
+ });
251
+
252
+ uiManager.setSuccessSignInModalConfig({
253
+ titleText: 'Welcome!',
254
+ descriptionText: 'Sign-in successful. Start watching.',
255
+ duration: 5000,
256
+ position: 'bottom-right',
257
+ });
258
+ ```
259
+
260
+ Default modal copy:
261
+
262
+ | State | Title | Description |
263
+ |---|---|---|
264
+ | Informational | `Mobile Sign In` | `Please use your mobile app to complete the sign in process.` |
265
+ | Progress | _(none)_ | `Signing in using your mobile app ...` |
266
+ | Success | `Mobile Sign In Successful!` | `Cast or select any content to start watching.` |
267
+
268
+ ---
269
+
270
+ ### Logging
271
+
272
+ ```typescript
273
+ import { LogLevel } from '@vizbeetv/homesso-sdk-qa';
274
+
275
+ const context = HomeSSOContext.getInstance();
276
+
277
+ context.enableLogger(true);
278
+ context.setLoggerLevel(LogLevel.DEBUG);
279
+ ```
280
+
281
+ | `LogLevel` | Value | Description |
282
+ |---|---|---|
283
+ | `ERROR` | 0 | Critical errors |
284
+ | `WARN` | 1 | Non-fatal warnings |
285
+ | `INFO` | 2 | General operational info |
286
+ | `DEBUG` | 3 | Detailed diagnostics |
287
+ | `TRACE` | 4 | Verbose execution flow |
288
+
289
+ ---
290
+
291
+ ## TypeScript types
292
+
293
+ All public types are exported from the package root:
294
+
295
+ ```typescript
296
+ import type {
297
+ VizbeeSignInInfo,
298
+ VizbeeSignInStatusCallback,
299
+ MessagePayload,
300
+ VizbeeSenderDevice,
301
+ IVizbeeMessagingClient,
302
+ IVizbeeSession,
303
+ IVizbeeBicastSessionManager,
304
+ ISessionStateListener,
305
+ IVizbeeAnalyticsProvider,
306
+ IVizbeeXMessages,
307
+ VizbeeHomeSSOTheme,
308
+ CommonModalPreferenceOptions,
309
+ InformationalSignInPreferenceOptions,
310
+ ProgressSignInPreferenceOptions,
311
+ SuccessSignInPreferenceOptions,
312
+ } from '@vizbeetv/homesso-sdk-qa';
313
+ ```
314
+
315
+ ---
316
+
317
+ ## License
318
+
319
+ MIT