playkit-sdk 1.2.8-beta.5 → 1.2.9
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/dist/playkit-sdk.cjs.js +208 -158
- package/dist/playkit-sdk.cjs.js.map +1 -1
- package/dist/playkit-sdk.d.ts +57 -1
- package/dist/playkit-sdk.esm.js +208 -158
- package/dist/playkit-sdk.esm.js.map +1 -1
- package/dist/playkit-sdk.umd.js +208 -158
- package/dist/playkit-sdk.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/playkit-sdk.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* playkit-sdk v1.2.
|
|
2
|
+
* playkit-sdk v1.2.9
|
|
3
3
|
* PlayKit SDK for JavaScript
|
|
4
4
|
* @license SEE LICENSE IN LICENSE
|
|
5
5
|
*/
|
|
@@ -1147,41 +1147,40 @@ class AuthFlowManager extends EventEmitter {
|
|
|
1147
1147
|
left: 0;
|
|
1148
1148
|
right: 0;
|
|
1149
1149
|
bottom: 0;
|
|
1150
|
-
background: rgba(0, 0, 0, 0.
|
|
1151
|
-
backdrop-filter: blur(8px);
|
|
1150
|
+
background: rgba(0, 0, 0, 0.8);
|
|
1152
1151
|
}
|
|
1153
1152
|
|
|
1154
1153
|
.playkit-auth-container {
|
|
1155
1154
|
position: relative;
|
|
1156
|
-
background: #
|
|
1157
|
-
border
|
|
1158
|
-
box-shadow: 0
|
|
1155
|
+
background: #fff;
|
|
1156
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
1157
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.05);
|
|
1159
1158
|
width: 90%;
|
|
1160
|
-
max-width:
|
|
1159
|
+
max-width: 320px;
|
|
1161
1160
|
overflow: hidden;
|
|
1162
1161
|
}
|
|
1163
1162
|
|
|
1164
1163
|
.playkit-auth-panel {
|
|
1165
|
-
padding:
|
|
1164
|
+
padding: 24px;
|
|
1166
1165
|
}
|
|
1167
1166
|
|
|
1168
1167
|
.playkit-auth-header {
|
|
1169
1168
|
text-align: center;
|
|
1170
|
-
margin-bottom:
|
|
1169
|
+
margin-bottom: 20px;
|
|
1171
1170
|
position: relative;
|
|
1172
1171
|
}
|
|
1173
1172
|
|
|
1174
1173
|
.playkit-auth-header h2 {
|
|
1175
1174
|
margin: 0 0 8px 0;
|
|
1176
|
-
font-size:
|
|
1175
|
+
font-size: 14px;
|
|
1177
1176
|
font-weight: 600;
|
|
1178
|
-
color: #
|
|
1177
|
+
color: #171717;
|
|
1179
1178
|
}
|
|
1180
1179
|
|
|
1181
1180
|
.playkit-auth-header p {
|
|
1182
1181
|
margin: 0;
|
|
1183
1182
|
font-size: 14px;
|
|
1184
|
-
color: #
|
|
1183
|
+
color: #666;
|
|
1185
1184
|
line-height: 1.5;
|
|
1186
1185
|
}
|
|
1187
1186
|
|
|
@@ -1193,22 +1192,20 @@ class AuthFlowManager extends EventEmitter {
|
|
|
1193
1192
|
border: none;
|
|
1194
1193
|
cursor: pointer;
|
|
1195
1194
|
padding: 4px;
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
transition: background-color 0.15s ease, color 0.15s ease;
|
|
1195
|
+
color: #666;
|
|
1196
|
+
transition: background-color 0.2s ease, color 0.2s ease;
|
|
1199
1197
|
}
|
|
1200
1198
|
|
|
1201
1199
|
.playkit-back-button:hover {
|
|
1202
|
-
background: #
|
|
1203
|
-
color: #
|
|
1200
|
+
background: #f5f5f5;
|
|
1201
|
+
color: #171717;
|
|
1204
1202
|
}
|
|
1205
1203
|
|
|
1206
1204
|
.playkit-auth-toggle {
|
|
1207
1205
|
display: flex;
|
|
1208
|
-
background: #
|
|
1209
|
-
border-radius: 2px;
|
|
1206
|
+
background: #f5f5f5;
|
|
1210
1207
|
padding: 2px;
|
|
1211
|
-
margin-bottom:
|
|
1208
|
+
margin-bottom: 20px;
|
|
1212
1209
|
gap: 2px;
|
|
1213
1210
|
}
|
|
1214
1211
|
|
|
@@ -1218,9 +1215,8 @@ class AuthFlowManager extends EventEmitter {
|
|
|
1218
1215
|
justify-content: center;
|
|
1219
1216
|
align-items: center;
|
|
1220
1217
|
padding: 10px 16px;
|
|
1221
|
-
border-radius: 2px;
|
|
1222
1218
|
cursor: pointer;
|
|
1223
|
-
transition: background-color 0.
|
|
1219
|
+
transition: background-color 0.2s ease;
|
|
1224
1220
|
}
|
|
1225
1221
|
|
|
1226
1222
|
.playkit-toggle-option input {
|
|
@@ -1230,20 +1226,20 @@ class AuthFlowManager extends EventEmitter {
|
|
|
1230
1226
|
.playkit-toggle-option span {
|
|
1231
1227
|
font-size: 14px;
|
|
1232
1228
|
font-weight: 500;
|
|
1233
|
-
color: #
|
|
1234
|
-
transition: color 0.
|
|
1229
|
+
color: #666;
|
|
1230
|
+
transition: color 0.2s ease;
|
|
1235
1231
|
}
|
|
1236
1232
|
|
|
1237
1233
|
.playkit-toggle-option input:checked + span {
|
|
1238
|
-
color: #
|
|
1234
|
+
color: #fff;
|
|
1239
1235
|
}
|
|
1240
1236
|
|
|
1241
1237
|
.playkit-toggle-option:has(input:checked) {
|
|
1242
|
-
background: #
|
|
1238
|
+
background: #171717;
|
|
1243
1239
|
}
|
|
1244
1240
|
|
|
1245
1241
|
.playkit-auth-input-group {
|
|
1246
|
-
margin-bottom:
|
|
1242
|
+
margin-bottom: 20px;
|
|
1247
1243
|
}
|
|
1248
1244
|
|
|
1249
1245
|
.playkit-input-wrapper {
|
|
@@ -1255,29 +1251,27 @@ class AuthFlowManager extends EventEmitter {
|
|
|
1255
1251
|
.playkit-input-icon {
|
|
1256
1252
|
position: absolute;
|
|
1257
1253
|
left: 12px;
|
|
1258
|
-
color: #
|
|
1254
|
+
color: #999;
|
|
1259
1255
|
pointer-events: none;
|
|
1260
1256
|
}
|
|
1261
1257
|
|
|
1262
1258
|
.playkit-input-wrapper input {
|
|
1263
1259
|
width: 100%;
|
|
1264
|
-
padding:
|
|
1265
|
-
border: 1px solid #
|
|
1266
|
-
border-radius: 2px;
|
|
1260
|
+
padding: 10px 12px 10px 44px;
|
|
1261
|
+
border: 1px solid #e5e7eb;
|
|
1267
1262
|
font-size: 14px;
|
|
1268
|
-
transition: border-color 0.
|
|
1263
|
+
transition: border-color 0.2s ease;
|
|
1269
1264
|
box-sizing: border-box;
|
|
1270
|
-
background: #
|
|
1265
|
+
background: #fff;
|
|
1271
1266
|
}
|
|
1272
1267
|
|
|
1273
1268
|
.playkit-input-wrapper input:hover {
|
|
1274
|
-
border-color: #
|
|
1269
|
+
border-color: #d4d4d4;
|
|
1275
1270
|
}
|
|
1276
1271
|
|
|
1277
1272
|
.playkit-input-wrapper input:focus {
|
|
1278
1273
|
outline: none;
|
|
1279
|
-
border-color: #
|
|
1280
|
-
box-shadow: 0 0 0 3px rgba(39, 110, 241, 0.1);
|
|
1274
|
+
border-color: #171717;
|
|
1281
1275
|
}
|
|
1282
1276
|
|
|
1283
1277
|
.playkit-code-inputs {
|
|
@@ -1287,16 +1281,15 @@ class AuthFlowManager extends EventEmitter {
|
|
|
1287
1281
|
}
|
|
1288
1282
|
|
|
1289
1283
|
.playkit-code-input {
|
|
1290
|
-
width:
|
|
1291
|
-
height:
|
|
1284
|
+
width: 40px !important;
|
|
1285
|
+
height: 48px;
|
|
1292
1286
|
text-align: center;
|
|
1293
|
-
font-size:
|
|
1287
|
+
font-size: 20px;
|
|
1294
1288
|
font-weight: 600;
|
|
1295
|
-
border: 1px solid #
|
|
1296
|
-
border-radius: 2px;
|
|
1289
|
+
border: 1px solid #e5e7eb !important;
|
|
1297
1290
|
padding: 0 !important;
|
|
1298
|
-
transition: border-color 0.
|
|
1299
|
-
background: #
|
|
1291
|
+
transition: border-color 0.2s ease;
|
|
1292
|
+
background: #fff;
|
|
1300
1293
|
-moz-appearance: textfield;
|
|
1301
1294
|
}
|
|
1302
1295
|
|
|
@@ -1307,48 +1300,46 @@ class AuthFlowManager extends EventEmitter {
|
|
|
1307
1300
|
}
|
|
1308
1301
|
|
|
1309
1302
|
.playkit-code-input:hover {
|
|
1310
|
-
border-color: #
|
|
1303
|
+
border-color: #d4d4d4 !important;
|
|
1311
1304
|
}
|
|
1312
1305
|
|
|
1313
1306
|
.playkit-code-input:focus {
|
|
1314
1307
|
outline: none;
|
|
1315
|
-
border-color: #
|
|
1316
|
-
box-shadow: 0 0 0 3px rgba(39, 110, 241, 0.1);
|
|
1308
|
+
border-color: #171717 !important;
|
|
1317
1309
|
}
|
|
1318
1310
|
|
|
1319
1311
|
.playkit-auth-button {
|
|
1320
1312
|
width: 100%;
|
|
1321
|
-
padding:
|
|
1322
|
-
background: #
|
|
1323
|
-
color:
|
|
1313
|
+
padding: 10px 16px;
|
|
1314
|
+
background: #171717;
|
|
1315
|
+
color: white;
|
|
1324
1316
|
border: none;
|
|
1325
|
-
border-radius: 2px;
|
|
1326
1317
|
font-size: 14px;
|
|
1327
1318
|
font-weight: 500;
|
|
1328
1319
|
cursor: pointer;
|
|
1329
|
-
transition: background
|
|
1320
|
+
transition: background 0.2s ease;
|
|
1330
1321
|
}
|
|
1331
1322
|
|
|
1332
1323
|
.playkit-auth-button:hover:not(:disabled) {
|
|
1333
|
-
background: #
|
|
1324
|
+
background: #404040;
|
|
1334
1325
|
}
|
|
1335
1326
|
|
|
1336
1327
|
.playkit-auth-button:active:not(:disabled) {
|
|
1337
|
-
background: #
|
|
1328
|
+
background: #0a0a0a;
|
|
1338
1329
|
}
|
|
1339
1330
|
|
|
1340
1331
|
.playkit-auth-button:disabled {
|
|
1341
|
-
background: #
|
|
1332
|
+
background: #e5e7eb;
|
|
1333
|
+
color: #999;
|
|
1342
1334
|
cursor: not-allowed;
|
|
1343
1335
|
}
|
|
1344
1336
|
|
|
1345
1337
|
.playkit-auth-error {
|
|
1346
1338
|
margin-top: 16px;
|
|
1347
1339
|
padding: 12px 16px;
|
|
1348
|
-
background: #
|
|
1349
|
-
border: 1px solid #
|
|
1350
|
-
|
|
1351
|
-
color: #CC3333;
|
|
1340
|
+
background: #fef2f2;
|
|
1341
|
+
border: 1px solid #fecaca;
|
|
1342
|
+
color: #dc2626;
|
|
1352
1343
|
font-size: 13px;
|
|
1353
1344
|
text-align: left;
|
|
1354
1345
|
display: none;
|
|
@@ -1368,16 +1359,15 @@ class AuthFlowManager extends EventEmitter {
|
|
|
1368
1359
|
display: flex;
|
|
1369
1360
|
justify-content: center;
|
|
1370
1361
|
align-items: center;
|
|
1371
|
-
border-radius: 4px;
|
|
1372
1362
|
}
|
|
1373
1363
|
|
|
1374
1364
|
.playkit-spinner {
|
|
1375
|
-
width:
|
|
1376
|
-
height:
|
|
1377
|
-
border:
|
|
1378
|
-
border-top:
|
|
1365
|
+
width: 24px;
|
|
1366
|
+
height: 24px;
|
|
1367
|
+
border: 2px solid #e5e7eb;
|
|
1368
|
+
border-top: 2px solid #171717;
|
|
1379
1369
|
border-radius: 50%;
|
|
1380
|
-
animation: playkit-spin
|
|
1370
|
+
animation: playkit-spin 1s linear infinite;
|
|
1381
1371
|
}
|
|
1382
1372
|
|
|
1383
1373
|
@keyframes playkit-spin {
|
|
@@ -1389,17 +1379,16 @@ class AuthFlowManager extends EventEmitter {
|
|
|
1389
1379
|
.playkit-auth-container {
|
|
1390
1380
|
width: 95%;
|
|
1391
1381
|
max-width: none;
|
|
1392
|
-
border-radius: 2px;
|
|
1393
1382
|
}
|
|
1394
1383
|
|
|
1395
1384
|
.playkit-auth-panel {
|
|
1396
|
-
padding:
|
|
1385
|
+
padding: 20px;
|
|
1397
1386
|
}
|
|
1398
1387
|
|
|
1399
1388
|
.playkit-code-input {
|
|
1400
|
-
width:
|
|
1401
|
-
height:
|
|
1402
|
-
font-size:
|
|
1389
|
+
width: 36px !important;
|
|
1390
|
+
height: 44px;
|
|
1391
|
+
font-size: 18px;
|
|
1403
1392
|
}
|
|
1404
1393
|
|
|
1405
1394
|
.playkit-code-inputs {
|
|
@@ -2608,6 +2597,25 @@ class AuthManager extends EventEmitter {
|
|
|
2608
2597
|
isAuthenticated() {
|
|
2609
2598
|
return this.authState.isAuthenticated;
|
|
2610
2599
|
}
|
|
2600
|
+
/**
|
|
2601
|
+
* Check if current authentication is using developerToken
|
|
2602
|
+
*/
|
|
2603
|
+
isDeveloperTokenAuth() {
|
|
2604
|
+
return this.authState.tokenType === 'developer';
|
|
2605
|
+
}
|
|
2606
|
+
/**
|
|
2607
|
+
* Clear developerToken authentication state.
|
|
2608
|
+
* Used when falling back to player login after developerToken failure.
|
|
2609
|
+
*/
|
|
2610
|
+
clearDeveloperToken() {
|
|
2611
|
+
if (this.authState.tokenType === 'developer') {
|
|
2612
|
+
this.authState = {
|
|
2613
|
+
isAuthenticated: false,
|
|
2614
|
+
};
|
|
2615
|
+
// Also clear the developerToken from config to prevent re-use
|
|
2616
|
+
this.config.developerToken = undefined;
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2611
2619
|
/**
|
|
2612
2620
|
* Check if token is expired
|
|
2613
2621
|
*/
|
|
@@ -3050,13 +3058,13 @@ class RechargeManager extends EventEmitter {
|
|
|
3050
3058
|
left: 0;
|
|
3051
3059
|
right: 0;
|
|
3052
3060
|
bottom: 0;
|
|
3053
|
-
background
|
|
3054
|
-
backdrop-filter: blur(4px);
|
|
3061
|
+
background: rgba(0, 0, 0, 0.8);
|
|
3055
3062
|
display: flex;
|
|
3056
3063
|
justify-content: center;
|
|
3057
3064
|
align-items: center;
|
|
3058
3065
|
z-index: 999999;
|
|
3059
3066
|
animation: playkit-recharge-fadeIn 0.2s ease-out;
|
|
3067
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
3060
3068
|
}
|
|
3061
3069
|
|
|
3062
3070
|
@keyframes playkit-recharge-fadeIn {
|
|
@@ -3069,140 +3077,111 @@ class RechargeManager extends EventEmitter {
|
|
|
3069
3077
|
}
|
|
3070
3078
|
|
|
3071
3079
|
.playkit-recharge-modal {
|
|
3072
|
-
background:
|
|
3073
|
-
border
|
|
3074
|
-
box-shadow: 0
|
|
3075
|
-
padding:
|
|
3076
|
-
max-width:
|
|
3080
|
+
background: #fff;
|
|
3081
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
3082
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.05);
|
|
3083
|
+
padding: 24px;
|
|
3084
|
+
max-width: 320px;
|
|
3077
3085
|
width: 90%;
|
|
3078
3086
|
position: relative;
|
|
3079
|
-
|
|
3080
|
-
}
|
|
3081
|
-
|
|
3082
|
-
@keyframes playkit-recharge-slideUp {
|
|
3083
|
-
from {
|
|
3084
|
-
transform: translateY(20px);
|
|
3085
|
-
opacity: 0;
|
|
3086
|
-
}
|
|
3087
|
-
to {
|
|
3088
|
-
transform: translateY(0);
|
|
3089
|
-
opacity: 1;
|
|
3090
|
-
}
|
|
3087
|
+
text-align: center;
|
|
3091
3088
|
}
|
|
3092
3089
|
|
|
3093
3090
|
.playkit-recharge-title {
|
|
3094
|
-
font-size:
|
|
3095
|
-
font-weight:
|
|
3096
|
-
color: #
|
|
3097
|
-
margin: 0 0
|
|
3091
|
+
font-size: 14px;
|
|
3092
|
+
font-weight: 600;
|
|
3093
|
+
color: #171717;
|
|
3094
|
+
margin: 0 0 8px 0;
|
|
3098
3095
|
text-align: center;
|
|
3099
3096
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
3100
3097
|
}
|
|
3101
3098
|
|
|
3102
3099
|
.playkit-recharge-message {
|
|
3103
|
-
font-size:
|
|
3104
|
-
color:
|
|
3105
|
-
margin: 0 0
|
|
3100
|
+
font-size: 14px;
|
|
3101
|
+
color: #666;
|
|
3102
|
+
margin: 0 0 20px 0;
|
|
3106
3103
|
text-align: center;
|
|
3107
3104
|
line-height: 1.5;
|
|
3108
3105
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
3109
3106
|
}
|
|
3110
3107
|
|
|
3111
3108
|
.playkit-recharge-balance {
|
|
3112
|
-
background:
|
|
3113
|
-
border
|
|
3109
|
+
background: #f5f5f5;
|
|
3110
|
+
border: 1px solid #e5e7eb;
|
|
3114
3111
|
padding: 16px;
|
|
3115
|
-
margin: 0 0
|
|
3112
|
+
margin: 0 0 20px 0;
|
|
3116
3113
|
text-align: center;
|
|
3117
|
-
backdrop-filter: blur(10px);
|
|
3118
3114
|
}
|
|
3119
3115
|
|
|
3120
3116
|
.playkit-recharge-balance-label {
|
|
3121
|
-
font-size:
|
|
3122
|
-
color:
|
|
3117
|
+
font-size: 12px;
|
|
3118
|
+
color: #666;
|
|
3123
3119
|
margin: 0 0 8px 0;
|
|
3124
3120
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
3125
3121
|
}
|
|
3126
3122
|
|
|
3127
3123
|
.playkit-recharge-balance-value {
|
|
3128
|
-
font-size:
|
|
3124
|
+
font-size: 24px;
|
|
3129
3125
|
font-weight: bold;
|
|
3130
|
-
color: #
|
|
3126
|
+
color: #171717;
|
|
3131
3127
|
margin: 0;
|
|
3132
3128
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
3133
3129
|
}
|
|
3134
3130
|
|
|
3135
3131
|
.playkit-recharge-balance-unit {
|
|
3136
|
-
font-size:
|
|
3137
|
-
color:
|
|
3138
|
-
margin-left:
|
|
3132
|
+
font-size: 14px;
|
|
3133
|
+
color: #666;
|
|
3134
|
+
margin-left: 4px;
|
|
3139
3135
|
}
|
|
3140
3136
|
|
|
3141
3137
|
.playkit-recharge-buttons {
|
|
3142
3138
|
display: flex;
|
|
3143
|
-
|
|
3144
|
-
|
|
3139
|
+
flex-direction: column;
|
|
3140
|
+
gap: 8px;
|
|
3145
3141
|
}
|
|
3146
3142
|
|
|
3147
3143
|
.playkit-recharge-button {
|
|
3148
|
-
|
|
3149
|
-
padding:
|
|
3144
|
+
width: 100%;
|
|
3145
|
+
padding: 10px 16px;
|
|
3150
3146
|
border: none;
|
|
3151
|
-
|
|
3152
|
-
font-
|
|
3153
|
-
font-weight: 600;
|
|
3147
|
+
font-size: 14px;
|
|
3148
|
+
font-weight: 500;
|
|
3154
3149
|
cursor: pointer;
|
|
3155
3150
|
transition: all 0.2s ease;
|
|
3156
3151
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
3157
3152
|
}
|
|
3158
3153
|
|
|
3159
3154
|
.playkit-recharge-button-primary {
|
|
3160
|
-
background: #
|
|
3161
|
-
color:
|
|
3155
|
+
background: #171717;
|
|
3156
|
+
color: white;
|
|
3162
3157
|
}
|
|
3163
3158
|
|
|
3164
3159
|
.playkit-recharge-button-primary:hover {
|
|
3165
|
-
|
|
3166
|
-
box-shadow: 0 8px 16px rgba(255, 255, 255, 0.2);
|
|
3160
|
+
background: #404040;
|
|
3167
3161
|
}
|
|
3168
3162
|
|
|
3169
3163
|
.playkit-recharge-button-primary:active {
|
|
3170
|
-
|
|
3164
|
+
background: #0a0a0a;
|
|
3171
3165
|
}
|
|
3172
3166
|
|
|
3173
3167
|
.playkit-recharge-button-secondary {
|
|
3174
|
-
background:
|
|
3175
|
-
color: #
|
|
3176
|
-
border: 1px solid
|
|
3168
|
+
background: transparent;
|
|
3169
|
+
color: #666;
|
|
3170
|
+
border: 1px solid #e5e7eb;
|
|
3177
3171
|
}
|
|
3178
3172
|
|
|
3179
3173
|
.playkit-recharge-button-secondary:hover {
|
|
3180
|
-
background:
|
|
3174
|
+
background: #f5f5f5;
|
|
3175
|
+
border-color: #d4d4d4;
|
|
3181
3176
|
}
|
|
3182
3177
|
|
|
3183
3178
|
.playkit-recharge-button-secondary:active {
|
|
3184
|
-
background:
|
|
3179
|
+
background: #e5e5e5;
|
|
3185
3180
|
}
|
|
3186
3181
|
|
|
3187
3182
|
@media (max-width: 480px) {
|
|
3188
3183
|
.playkit-recharge-modal {
|
|
3189
|
-
padding:
|
|
3190
|
-
}
|
|
3191
|
-
|
|
3192
|
-
.playkit-recharge-title {
|
|
3193
|
-
font-size: 20px;
|
|
3194
|
-
}
|
|
3195
|
-
|
|
3196
|
-
.playkit-recharge-message {
|
|
3197
|
-
font-size: 14px;
|
|
3198
|
-
}
|
|
3199
|
-
|
|
3200
|
-
.playkit-recharge-balance-value {
|
|
3201
|
-
font-size: 28px;
|
|
3202
|
-
}
|
|
3203
|
-
|
|
3204
|
-
.playkit-recharge-buttons {
|
|
3205
|
-
flex-direction: column;
|
|
3184
|
+
padding: 20px;
|
|
3206
3185
|
}
|
|
3207
3186
|
}
|
|
3208
3187
|
|
|
@@ -3211,9 +3190,9 @@ class RechargeManager extends EventEmitter {
|
|
|
3211
3190
|
position: fixed;
|
|
3212
3191
|
top: 20px;
|
|
3213
3192
|
right: 20px;
|
|
3214
|
-
background:
|
|
3215
|
-
border
|
|
3216
|
-
box-shadow: 0
|
|
3193
|
+
background: #fff;
|
|
3194
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
3195
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
|
|
3217
3196
|
padding: 16px 20px;
|
|
3218
3197
|
min-width: 240px;
|
|
3219
3198
|
max-width: 320px;
|
|
@@ -3222,6 +3201,7 @@ class RechargeManager extends EventEmitter {
|
|
|
3222
3201
|
display: flex;
|
|
3223
3202
|
align-items: flex-start;
|
|
3224
3203
|
gap: 12px;
|
|
3204
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
3225
3205
|
}
|
|
3226
3206
|
|
|
3227
3207
|
.playkit-daily-refresh-toast.hiding {
|
|
@@ -3253,7 +3233,7 @@ class RechargeManager extends EventEmitter {
|
|
|
3253
3233
|
.playkit-toast-icon {
|
|
3254
3234
|
width: 24px;
|
|
3255
3235
|
height: 24px;
|
|
3256
|
-
background:
|
|
3236
|
+
background: #171717;
|
|
3257
3237
|
border-radius: 50%;
|
|
3258
3238
|
display: flex;
|
|
3259
3239
|
align-items: center;
|
|
@@ -3271,7 +3251,7 @@ class RechargeManager extends EventEmitter {
|
|
|
3271
3251
|
flex: 1;
|
|
3272
3252
|
font-size: 14px;
|
|
3273
3253
|
font-weight: 500;
|
|
3274
|
-
color: #
|
|
3254
|
+
color: #171717;
|
|
3275
3255
|
line-height: 1.4;
|
|
3276
3256
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
3277
3257
|
}
|
|
@@ -6103,6 +6083,8 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6103
6083
|
// Initialize logging system
|
|
6104
6084
|
this.initializeLogging(this.config);
|
|
6105
6085
|
this.logger = Logger.getLogger('PlayKitSDK');
|
|
6086
|
+
// Initialize fallback configuration with defaults
|
|
6087
|
+
this.fallbackConfig = Object.assign({ enabled: true }, config.developerTokenFallback);
|
|
6106
6088
|
// Initialize managers and providers
|
|
6107
6089
|
this.authManager = new AuthManager(this.config);
|
|
6108
6090
|
this.playerClient = new PlayerClient(this.authManager, this.config, this.config.recharge);
|
|
@@ -6160,7 +6142,8 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6160
6142
|
await this.authManager.initialize();
|
|
6161
6143
|
this.initialized = true;
|
|
6162
6144
|
// Show developer token indicator if using developer token (browser mode only)
|
|
6163
|
-
|
|
6145
|
+
const isDeveloperTokenMode = this.authManager.isDeveloperTokenAuth();
|
|
6146
|
+
if (isDeveloperTokenMode && this.config.mode !== 'server' && typeof window !== 'undefined') {
|
|
6164
6147
|
this.showDeveloperTokenIndicator();
|
|
6165
6148
|
}
|
|
6166
6149
|
// Always verify token validity and fetch user info after authentication
|
|
@@ -6170,20 +6153,26 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6170
6153
|
this.logger.debug('Token validated and user info fetched');
|
|
6171
6154
|
}
|
|
6172
6155
|
catch (error) {
|
|
6173
|
-
//
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
// Auto-restart login flow in browser environment
|
|
6177
|
-
if (typeof window !== 'undefined') {
|
|
6178
|
-
this.logger.debug('Restarting authentication flow...');
|
|
6179
|
-
const authMethod = this.config.authMethod || 'device';
|
|
6180
|
-
await this.authManager.startAuthFlow(authMethod);
|
|
6181
|
-
// Retry getting player info after re-authentication
|
|
6182
|
-
await this.playerClient.getPlayerInfo();
|
|
6183
|
-
this.logger.debug('Re-authentication successful, token validated');
|
|
6156
|
+
// Check if this is a developerToken failure
|
|
6157
|
+
if (isDeveloperTokenMode) {
|
|
6158
|
+
await this.handleDeveloperTokenFailure(error);
|
|
6184
6159
|
}
|
|
6185
6160
|
else {
|
|
6186
|
-
|
|
6161
|
+
// If token is invalid, logout and restart auth flow
|
|
6162
|
+
this.logger.error('Token validation failed:', error);
|
|
6163
|
+
await this.authManager.logout();
|
|
6164
|
+
// Auto-restart login flow in browser environment
|
|
6165
|
+
if (typeof window !== 'undefined') {
|
|
6166
|
+
this.logger.debug('Restarting authentication flow...');
|
|
6167
|
+
const authMethod = this.config.authMethod || 'device';
|
|
6168
|
+
await this.authManager.startAuthFlow(authMethod);
|
|
6169
|
+
// Retry getting player info after re-authentication
|
|
6170
|
+
await this.playerClient.getPlayerInfo();
|
|
6171
|
+
this.logger.debug('Re-authentication successful, token validated');
|
|
6172
|
+
}
|
|
6173
|
+
else {
|
|
6174
|
+
throw new Error('Token validation failed: ' + (error instanceof Error ? error.message : String(error)));
|
|
6175
|
+
}
|
|
6187
6176
|
}
|
|
6188
6177
|
}
|
|
6189
6178
|
}
|
|
@@ -6195,6 +6184,50 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6195
6184
|
throw error;
|
|
6196
6185
|
}
|
|
6197
6186
|
}
|
|
6187
|
+
/**
|
|
6188
|
+
* Handle developerToken authentication failure with optional fallback to player login.
|
|
6189
|
+
* This is called when a developerToken is provided but fails validation.
|
|
6190
|
+
*
|
|
6191
|
+
* @param error - The error that caused the developerToken failure
|
|
6192
|
+
*/
|
|
6193
|
+
async handleDeveloperTokenFailure(error) {
|
|
6194
|
+
const willFallback = this.fallbackConfig.enabled !== false &&
|
|
6195
|
+
typeof window !== 'undefined' &&
|
|
6196
|
+
this.config.mode !== 'server';
|
|
6197
|
+
// Emit developer_token_failed event
|
|
6198
|
+
this.emit('developer_token_failed', {
|
|
6199
|
+
error,
|
|
6200
|
+
willFallback,
|
|
6201
|
+
});
|
|
6202
|
+
this.logger.warn('DeveloperToken validation failed', { error, willFallback });
|
|
6203
|
+
// Clear developer token state and indicator
|
|
6204
|
+
this.authManager.clearDeveloperToken();
|
|
6205
|
+
this.hideDeveloperTokenIndicator();
|
|
6206
|
+
if (!willFallback) {
|
|
6207
|
+
// Fallback disabled or not in browser - throw the error
|
|
6208
|
+
throw new PlayKitError('DeveloperToken validation failed: ' + (error instanceof Error ? error.message : String(error)), 'DEVELOPER_TOKEN_INVALID');
|
|
6209
|
+
}
|
|
6210
|
+
// Emit fallback started event
|
|
6211
|
+
const fallbackMethod = this.config.authMethod || 'device';
|
|
6212
|
+
this.emit('developer_token_fallback_started', { fallbackMethod });
|
|
6213
|
+
this.logger.debug('Starting fallback to player login', { fallbackMethod });
|
|
6214
|
+
try {
|
|
6215
|
+
// Start player login flow
|
|
6216
|
+
await this.authManager.startAuthFlow(fallbackMethod);
|
|
6217
|
+
// Verify the new token
|
|
6218
|
+
await this.playerClient.getPlayerInfo();
|
|
6219
|
+
// Emit fallback completed event
|
|
6220
|
+
const authState = this.authManager.getAuthState();
|
|
6221
|
+
this.emit('developer_token_fallback_completed', { authState });
|
|
6222
|
+
this.logger.debug('DeveloperToken fallback completed successfully');
|
|
6223
|
+
}
|
|
6224
|
+
catch (fallbackError) {
|
|
6225
|
+
// Emit fallback failed event
|
|
6226
|
+
this.emit('developer_token_fallback_failed', { error: fallbackError });
|
|
6227
|
+
this.logger.error('DeveloperToken fallback failed', fallbackError);
|
|
6228
|
+
throw fallbackError;
|
|
6229
|
+
}
|
|
6230
|
+
}
|
|
6198
6231
|
/**
|
|
6199
6232
|
* Show developer token indicator in top-left corner
|
|
6200
6233
|
*/
|
|
@@ -6268,10 +6301,20 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6268
6301
|
await this.authManager.logout();
|
|
6269
6302
|
this.hideDeveloperTokenIndicator();
|
|
6270
6303
|
}
|
|
6304
|
+
/**
|
|
6305
|
+
* Ensure SDK is initialized before making API calls
|
|
6306
|
+
* @throws PlayKitError if not initialized
|
|
6307
|
+
*/
|
|
6308
|
+
ensureInitialized() {
|
|
6309
|
+
if (!this.initialized) {
|
|
6310
|
+
throw new PlayKitError('SDK not initialized. Call await sdk.initialize() before using API methods.', 'NOT_INITIALIZED');
|
|
6311
|
+
}
|
|
6312
|
+
}
|
|
6271
6313
|
/**
|
|
6272
6314
|
* Get player information
|
|
6273
6315
|
*/
|
|
6274
6316
|
async getPlayerInfo() {
|
|
6317
|
+
this.ensureInitialized();
|
|
6275
6318
|
return await this.playerClient.getPlayerInfo();
|
|
6276
6319
|
}
|
|
6277
6320
|
/**
|
|
@@ -6279,6 +6322,7 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6279
6322
|
* Automatically uses the SDK's schema library
|
|
6280
6323
|
*/
|
|
6281
6324
|
createChatClient(model) {
|
|
6325
|
+
this.ensureInitialized();
|
|
6282
6326
|
const client = new ChatClient(this.chatProvider, model || this.config.defaultChatModel);
|
|
6283
6327
|
// Automatically use the SDK's schema library
|
|
6284
6328
|
client.setSchemaLibrary(this.schemaLibrary);
|
|
@@ -6288,6 +6332,7 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6288
6332
|
* Create an image client
|
|
6289
6333
|
*/
|
|
6290
6334
|
createImageClient(model) {
|
|
6335
|
+
this.ensureInitialized();
|
|
6291
6336
|
return new ImageClient(this.imageProvider, model || this.config.defaultImageModel);
|
|
6292
6337
|
}
|
|
6293
6338
|
/**
|
|
@@ -6295,6 +6340,7 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6295
6340
|
* @param model - Transcription model to use (default: 'whisper-large')
|
|
6296
6341
|
*/
|
|
6297
6342
|
createTranscriptionClient(model) {
|
|
6343
|
+
this.ensureInitialized();
|
|
6298
6344
|
return new TranscriptionClient(this.transcriptionProvider, model || this.config.defaultTranscriptionModel);
|
|
6299
6345
|
}
|
|
6300
6346
|
/**
|
|
@@ -6302,6 +6348,7 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6302
6348
|
* Automatically registers with AIContextManager
|
|
6303
6349
|
*/
|
|
6304
6350
|
createNPCClient(config) {
|
|
6351
|
+
this.ensureInitialized();
|
|
6305
6352
|
const chatClient = this.createChatClient(config === null || config === void 0 ? void 0 : config.model);
|
|
6306
6353
|
const npc = new NPCClient(chatClient, config);
|
|
6307
6354
|
// Register with context manager
|
|
@@ -6400,6 +6447,7 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6400
6447
|
* Show insufficient balance modal
|
|
6401
6448
|
*/
|
|
6402
6449
|
async showInsufficientBalanceModal(customMessage) {
|
|
6450
|
+
this.ensureInitialized();
|
|
6403
6451
|
return await this.playerClient.showInsufficientBalanceModal(customMessage);
|
|
6404
6452
|
}
|
|
6405
6453
|
/**
|
|
@@ -6433,6 +6481,7 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6433
6481
|
* Refresh and get player's current balance
|
|
6434
6482
|
*/
|
|
6435
6483
|
async refreshBalance() {
|
|
6484
|
+
this.ensureInitialized();
|
|
6436
6485
|
const playerInfo = await this.playerClient.refreshPlayerInfo();
|
|
6437
6486
|
return playerInfo.balance;
|
|
6438
6487
|
}
|
|
@@ -6453,6 +6502,7 @@ class PlayKitSDK extends EventEmitter {
|
|
|
6453
6502
|
* @throws PlayKitError if validation fails or token type is invalid
|
|
6454
6503
|
*/
|
|
6455
6504
|
async setNickname(nickname) {
|
|
6505
|
+
this.ensureInitialized();
|
|
6456
6506
|
return await this.playerClient.setNickname(nickname);
|
|
6457
6507
|
}
|
|
6458
6508
|
// ============================================================
|