@scalemule/sdk 0.0.27 → 0.0.29
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/index.d.mts +236 -1
- package/dist/index.d.ts +236 -1
- package/dist/index.js +408 -14
- package/dist/index.mjs +397 -14
- package/package.json +3 -6
package/dist/index.js
CHANGED
|
@@ -308,6 +308,7 @@ __export(index_exports, {
|
|
|
308
308
|
ChatService: () => ChatService,
|
|
309
309
|
CommunicationService: () => CommunicationService,
|
|
310
310
|
ComplianceService: () => ComplianceService,
|
|
311
|
+
CreatorMakerService: () => CreatorMakerService,
|
|
311
312
|
DataService: () => DataService,
|
|
312
313
|
ErrorCodes: () => ErrorCodes,
|
|
313
314
|
EventsService: () => EventsService,
|
|
@@ -321,7 +322,7 @@ __export(index_exports, {
|
|
|
321
322
|
LoggerService: () => LoggerService,
|
|
322
323
|
NotificationsService: () => NotificationsService,
|
|
323
324
|
OrchestratorService: () => OrchestratorService,
|
|
324
|
-
PHONE_COUNTRIES: () =>
|
|
325
|
+
PHONE_COUNTRIES: () => PHONE_COUNTRIES,
|
|
325
326
|
PHOTO_BREAKPOINTS: () => PHOTO_BREAKPOINTS,
|
|
326
327
|
PermissionsService: () => PermissionsService,
|
|
327
328
|
PhotoService: () => PhotoService,
|
|
@@ -346,22 +347,22 @@ __export(index_exports, {
|
|
|
346
347
|
buildClientContextHeaders: () => buildClientContextHeaders,
|
|
347
348
|
calculateTotalParts: () => calculateTotalParts,
|
|
348
349
|
canPerform: () => canPerform,
|
|
349
|
-
composePhoneNumber: () =>
|
|
350
|
-
countryFlag: () =>
|
|
350
|
+
composePhoneNumber: () => composePhoneNumber,
|
|
351
|
+
countryFlag: () => countryFlag,
|
|
351
352
|
createUploadPlan: () => createUploadPlan,
|
|
352
353
|
default: () => index_default,
|
|
353
|
-
detectCountryFromE164: () =>
|
|
354
|
+
detectCountryFromE164: () => detectCountryFromE164,
|
|
354
355
|
detectNetworkClass: () => detectNetworkClass,
|
|
355
356
|
extractClientContext: () => extractClientContext,
|
|
356
|
-
findPhoneCountryByCode: () =>
|
|
357
|
-
findPhoneCountryByDialCode: () =>
|
|
357
|
+
findPhoneCountryByCode: () => findPhoneCountryByCode,
|
|
358
|
+
findPhoneCountryByDialCode: () => findPhoneCountryByDialCode,
|
|
358
359
|
generateUploadSessionId: () => generateUploadSessionId,
|
|
359
360
|
getMeasuredBandwidthMbps: () => getMeasuredBandwidthMbps,
|
|
360
361
|
getPartRange: () => getPartRange,
|
|
361
362
|
hasMinRoleLevel: () => hasMinRoleLevel,
|
|
362
|
-
isValidE164Phone: () =>
|
|
363
|
-
normalizeAndValidatePhone: () =>
|
|
364
|
-
normalizePhoneNumber: () =>
|
|
363
|
+
isValidE164Phone: () => isValidE164Phone,
|
|
364
|
+
normalizeAndValidatePhone: () => normalizeAndValidatePhone,
|
|
365
|
+
normalizePhoneNumber: () => normalizePhoneNumber,
|
|
365
366
|
resolveStrategy: () => resolveStrategy,
|
|
366
367
|
uploadMultipartToS3: () => uploadMultipartToS3,
|
|
367
368
|
uploadSingleToS3: () => uploadSingleToS3,
|
|
@@ -474,6 +475,7 @@ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
|
|
|
474
475
|
var ANONYMOUS_ID_STORAGE_KEY = "scalemule_anonymous_id";
|
|
475
476
|
var SESSION_POOL_KEY = "scalemule_session_pool";
|
|
476
477
|
var ACTIVE_ACCOUNT_KEY = "scalemule_active_account";
|
|
478
|
+
var KNOWN_ACCOUNTS_KEY = "scalemule_known_accounts";
|
|
477
479
|
var GATEWAY_URLS = {
|
|
478
480
|
dev: "https://api-dev.scalemule.com",
|
|
479
481
|
prod: "https://api.scalemule.com"
|
|
@@ -523,6 +525,54 @@ function statusToErrorCode(status) {
|
|
|
523
525
|
return status >= 500 ? "internal_error" : `http_${status}`;
|
|
524
526
|
}
|
|
525
527
|
}
|
|
528
|
+
var MAX_KNOWN_ACCOUNTS = 10;
|
|
529
|
+
function maskEmail(email) {
|
|
530
|
+
const parts = email.split("@");
|
|
531
|
+
const local = parts[0] ?? "";
|
|
532
|
+
const domain = parts[1];
|
|
533
|
+
if (!domain) return "***@***.***";
|
|
534
|
+
const tldDot = domain.lastIndexOf(".");
|
|
535
|
+
const tld = tldDot > 0 ? domain.slice(tldDot) : "";
|
|
536
|
+
const domainBase = tldDot > 0 ? domain.slice(0, tldDot) : domain;
|
|
537
|
+
return `${local[0] || "*"}***@${domainBase[0] || "*"}***${tld}`;
|
|
538
|
+
}
|
|
539
|
+
function stableColorIndex(userId) {
|
|
540
|
+
let hash = 0;
|
|
541
|
+
for (let i = 0; i < userId.length; i++) {
|
|
542
|
+
hash = (hash << 5) - hash + userId.charCodeAt(i) | 0;
|
|
543
|
+
}
|
|
544
|
+
return Math.abs(hash) % 8;
|
|
545
|
+
}
|
|
546
|
+
function applyPrivacy(account, privacy) {
|
|
547
|
+
switch (privacy) {
|
|
548
|
+
case "full":
|
|
549
|
+
return {
|
|
550
|
+
userId: account.userId,
|
|
551
|
+
email: account.email,
|
|
552
|
+
fullName: account.fullName,
|
|
553
|
+
avatarUrl: account.avatarUrl,
|
|
554
|
+
provider: account.provider,
|
|
555
|
+
lastActiveAt: account.lastActiveAt
|
|
556
|
+
};
|
|
557
|
+
case "masked":
|
|
558
|
+
return {
|
|
559
|
+
userId: account.userId,
|
|
560
|
+
email: account.email ? maskEmail(account.email) : void 0,
|
|
561
|
+
fullName: account.fullName && account.fullName.length > 0 ? `${account.fullName[0].toUpperCase()}.` : void 0,
|
|
562
|
+
provider: account.provider,
|
|
563
|
+
lastActiveAt: account.lastActiveAt,
|
|
564
|
+
colorIndex: stableColorIndex(account.userId)
|
|
565
|
+
};
|
|
566
|
+
case "minimal":
|
|
567
|
+
return {
|
|
568
|
+
userId: account.userId,
|
|
569
|
+
provider: account.provider,
|
|
570
|
+
lastActiveAt: account.lastActiveAt,
|
|
571
|
+
displayLabel: "Account",
|
|
572
|
+
colorIndex: stableColorIndex(account.userId)
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}
|
|
526
576
|
function createDefaultStorage() {
|
|
527
577
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
528
578
|
return {
|
|
@@ -669,6 +719,7 @@ var ScaleMuleClient = class {
|
|
|
669
719
|
this.workspaceId = null;
|
|
670
720
|
this.anonymousId = null;
|
|
671
721
|
this.sessionPool = /* @__PURE__ */ new Map();
|
|
722
|
+
this.knownAccounts = /* @__PURE__ */ new Map();
|
|
672
723
|
this.apiKey = config.apiKey;
|
|
673
724
|
this.applicationId = config.applicationId || null;
|
|
674
725
|
this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
|
|
@@ -685,6 +736,8 @@ var ScaleMuleClient = class {
|
|
|
685
736
|
this.offlineQueue.setOnlineCallback(() => this.syncOfflineQueue());
|
|
686
737
|
}
|
|
687
738
|
this.multiSessionEnabled = config.enableMultiSession || false;
|
|
739
|
+
this.accountSwitcherEnabled = config.enableAccountSwitcher || false;
|
|
740
|
+
this.accountSwitcherPrivacy = config.accountSwitcherPrivacy || "full";
|
|
688
741
|
}
|
|
689
742
|
// --------------------------------------------------------------------------
|
|
690
743
|
// Session Management
|
|
@@ -727,6 +780,27 @@ var ScaleMuleClient = class {
|
|
|
727
780
|
this.userId = activeId;
|
|
728
781
|
}
|
|
729
782
|
}
|
|
783
|
+
if (this.accountSwitcherEnabled) {
|
|
784
|
+
const knownJson = await this.storage.getItem(KNOWN_ACCOUNTS_KEY);
|
|
785
|
+
if (knownJson) {
|
|
786
|
+
try {
|
|
787
|
+
const entries = JSON.parse(knownJson);
|
|
788
|
+
this.knownAccounts = new Map(Object.entries(entries));
|
|
789
|
+
let changed = false;
|
|
790
|
+
for (const [userId2, entry] of this.knownAccounts) {
|
|
791
|
+
const normalized = applyPrivacy(entry, this.accountSwitcherPrivacy);
|
|
792
|
+
if (JSON.stringify(normalized) !== JSON.stringify(entry)) {
|
|
793
|
+
this.knownAccounts.set(userId2, normalized);
|
|
794
|
+
changed = true;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
if (changed) {
|
|
798
|
+
await this.persistKnownAccounts();
|
|
799
|
+
}
|
|
800
|
+
} catch {
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
730
804
|
if (this.debug)
|
|
731
805
|
console.log(
|
|
732
806
|
"[ScaleMule] Initialized, session:",
|
|
@@ -734,7 +808,9 @@ var ScaleMuleClient = class {
|
|
|
734
808
|
"anonymousId:",
|
|
735
809
|
anonId,
|
|
736
810
|
"poolSize:",
|
|
737
|
-
this.sessionPool.size
|
|
811
|
+
this.sessionPool.size,
|
|
812
|
+
"knownAccounts:",
|
|
813
|
+
this.knownAccounts.size
|
|
738
814
|
);
|
|
739
815
|
}
|
|
740
816
|
async setSession(token, userId) {
|
|
@@ -858,6 +934,57 @@ var ScaleMuleClient = class {
|
|
|
858
934
|
}
|
|
859
935
|
await this.storage.setItem(SESSION_POOL_KEY, JSON.stringify(obj));
|
|
860
936
|
}
|
|
937
|
+
// --------------------------------------------------------------------------
|
|
938
|
+
// Account Switcher (Secure — metadata only, no tokens)
|
|
939
|
+
// --------------------------------------------------------------------------
|
|
940
|
+
isAccountSwitcherEnabled() {
|
|
941
|
+
return this.accountSwitcherEnabled;
|
|
942
|
+
}
|
|
943
|
+
getAccountSwitcherPrivacy() {
|
|
944
|
+
return this.accountSwitcherPrivacy;
|
|
945
|
+
}
|
|
946
|
+
/** Get all known accounts that have logged in on this device (privacy-transformed) */
|
|
947
|
+
getKnownAccounts() {
|
|
948
|
+
return Array.from(this.knownAccounts.values());
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Record an account as "known" on this device.
|
|
952
|
+
* Applies privacy transforms before storing — full email is never persisted
|
|
953
|
+
* in masked/minimal modes. Evicts oldest accounts if over the cap.
|
|
954
|
+
* Called automatically after successful login/register when account switcher is enabled.
|
|
955
|
+
*/
|
|
956
|
+
async addKnownAccount(account) {
|
|
957
|
+
const display = applyPrivacy(account, this.accountSwitcherPrivacy);
|
|
958
|
+
this.knownAccounts.set(account.userId, display);
|
|
959
|
+
if (this.knownAccounts.size > MAX_KNOWN_ACCOUNTS) {
|
|
960
|
+
const sorted = Array.from(this.knownAccounts.entries()).sort(
|
|
961
|
+
(a, b) => (a[1].lastActiveAt || "").localeCompare(b[1].lastActiveAt || "")
|
|
962
|
+
);
|
|
963
|
+
while (this.knownAccounts.size > MAX_KNOWN_ACCOUNTS && sorted.length > 0) {
|
|
964
|
+
const oldest = sorted.shift();
|
|
965
|
+
this.knownAccounts.delete(oldest[0]);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
await this.persistKnownAccounts();
|
|
969
|
+
}
|
|
970
|
+
/** Remove a specific account from the known accounts list ("forget this account") */
|
|
971
|
+
async removeKnownAccount(userId) {
|
|
972
|
+
this.knownAccounts.delete(userId);
|
|
973
|
+
await this.persistKnownAccounts();
|
|
974
|
+
}
|
|
975
|
+
/** Clear all known accounts ("forget all accounts on this device") */
|
|
976
|
+
async clearKnownAccounts() {
|
|
977
|
+
this.knownAccounts.clear();
|
|
978
|
+
await this.storage.removeItem(KNOWN_ACCOUNTS_KEY);
|
|
979
|
+
}
|
|
980
|
+
/** Persist known accounts to storage */
|
|
981
|
+
async persistKnownAccounts() {
|
|
982
|
+
const obj = {};
|
|
983
|
+
for (const [k, v] of this.knownAccounts) {
|
|
984
|
+
obj[k] = v;
|
|
985
|
+
}
|
|
986
|
+
await this.storage.setItem(KNOWN_ACCOUNTS_KEY, JSON.stringify(obj));
|
|
987
|
+
}
|
|
861
988
|
getBaseUrl() {
|
|
862
989
|
return this.baseUrl;
|
|
863
990
|
}
|
|
@@ -1352,8 +1479,138 @@ function asString(parent, key) {
|
|
|
1352
1479
|
return typeof value === "string" ? value : void 0;
|
|
1353
1480
|
}
|
|
1354
1481
|
|
|
1355
|
-
//
|
|
1356
|
-
var
|
|
1482
|
+
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1483
|
+
var PHONE_COUNTRIES = [
|
|
1484
|
+
{ code: "US", name: "United States", dialCode: "+1" },
|
|
1485
|
+
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
1486
|
+
{ code: "GB", name: "United Kingdom", dialCode: "+44" },
|
|
1487
|
+
{ code: "AU", name: "Australia", dialCode: "+61" },
|
|
1488
|
+
{ code: "DE", name: "Germany", dialCode: "+49" },
|
|
1489
|
+
{ code: "FR", name: "France", dialCode: "+33" },
|
|
1490
|
+
{ code: "IT", name: "Italy", dialCode: "+39" },
|
|
1491
|
+
{ code: "ES", name: "Spain", dialCode: "+34" },
|
|
1492
|
+
{ code: "NL", name: "Netherlands", dialCode: "+31" },
|
|
1493
|
+
{ code: "BE", name: "Belgium", dialCode: "+32" },
|
|
1494
|
+
{ code: "CH", name: "Switzerland", dialCode: "+41" },
|
|
1495
|
+
{ code: "AT", name: "Austria", dialCode: "+43" },
|
|
1496
|
+
{ code: "SE", name: "Sweden", dialCode: "+46" },
|
|
1497
|
+
{ code: "NO", name: "Norway", dialCode: "+47" },
|
|
1498
|
+
{ code: "DK", name: "Denmark", dialCode: "+45" },
|
|
1499
|
+
{ code: "FI", name: "Finland", dialCode: "+358" },
|
|
1500
|
+
{ code: "IE", name: "Ireland", dialCode: "+353" },
|
|
1501
|
+
{ code: "PT", name: "Portugal", dialCode: "+351" },
|
|
1502
|
+
{ code: "PL", name: "Poland", dialCode: "+48" },
|
|
1503
|
+
{ code: "CZ", name: "Czech Republic", dialCode: "+420" },
|
|
1504
|
+
{ code: "GR", name: "Greece", dialCode: "+30" },
|
|
1505
|
+
{ code: "RU", name: "Russia", dialCode: "+7" },
|
|
1506
|
+
{ code: "JP", name: "Japan", dialCode: "+81" },
|
|
1507
|
+
{ code: "KR", name: "South Korea", dialCode: "+82" },
|
|
1508
|
+
{ code: "CN", name: "China", dialCode: "+86" },
|
|
1509
|
+
{ code: "HK", name: "Hong Kong", dialCode: "+852" },
|
|
1510
|
+
{ code: "TW", name: "Taiwan", dialCode: "+886" },
|
|
1511
|
+
{ code: "SG", name: "Singapore", dialCode: "+65" },
|
|
1512
|
+
{ code: "MY", name: "Malaysia", dialCode: "+60" },
|
|
1513
|
+
{ code: "TH", name: "Thailand", dialCode: "+66" },
|
|
1514
|
+
{ code: "VN", name: "Vietnam", dialCode: "+84" },
|
|
1515
|
+
{ code: "PH", name: "Philippines", dialCode: "+63" },
|
|
1516
|
+
{ code: "ID", name: "Indonesia", dialCode: "+62" },
|
|
1517
|
+
{ code: "IN", name: "India", dialCode: "+91" },
|
|
1518
|
+
{ code: "PK", name: "Pakistan", dialCode: "+92" },
|
|
1519
|
+
{ code: "BD", name: "Bangladesh", dialCode: "+880" },
|
|
1520
|
+
{ code: "AE", name: "UAE", dialCode: "+971" },
|
|
1521
|
+
{ code: "SA", name: "Saudi Arabia", dialCode: "+966" },
|
|
1522
|
+
{ code: "IL", name: "Israel", dialCode: "+972" },
|
|
1523
|
+
{ code: "TR", name: "Turkey", dialCode: "+90" },
|
|
1524
|
+
{ code: "EG", name: "Egypt", dialCode: "+20" },
|
|
1525
|
+
{ code: "ZA", name: "South Africa", dialCode: "+27" },
|
|
1526
|
+
{ code: "NG", name: "Nigeria", dialCode: "+234" },
|
|
1527
|
+
{ code: "KE", name: "Kenya", dialCode: "+254" },
|
|
1528
|
+
{ code: "BR", name: "Brazil", dialCode: "+55" },
|
|
1529
|
+
{ code: "MX", name: "Mexico", dialCode: "+52" },
|
|
1530
|
+
{ code: "AR", name: "Argentina", dialCode: "+54" },
|
|
1531
|
+
{ code: "CL", name: "Chile", dialCode: "+56" },
|
|
1532
|
+
{ code: "CO", name: "Colombia", dialCode: "+57" },
|
|
1533
|
+
{ code: "PE", name: "Peru", dialCode: "+51" },
|
|
1534
|
+
{ code: "NZ", name: "New Zealand", dialCode: "+64" }
|
|
1535
|
+
];
|
|
1536
|
+
var E164_REGEX = /^\+[1-9]\d{6,14}$/;
|
|
1537
|
+
function isValidE164Phone(input) {
|
|
1538
|
+
return E164_REGEX.test(input);
|
|
1539
|
+
}
|
|
1540
|
+
function normalizePhoneNumber(input) {
|
|
1541
|
+
if (typeof input !== "string") return "";
|
|
1542
|
+
const trimmed = input.trim();
|
|
1543
|
+
if (!trimmed) return "";
|
|
1544
|
+
const digitsOnly = trimmed.replace(/\D/g, "");
|
|
1545
|
+
if (!digitsOnly) return "";
|
|
1546
|
+
if (trimmed.startsWith("+")) {
|
|
1547
|
+
return `+${digitsOnly}`;
|
|
1548
|
+
}
|
|
1549
|
+
if (trimmed.startsWith("00") && digitsOnly.length > 2) {
|
|
1550
|
+
return `+${digitsOnly.slice(2)}`;
|
|
1551
|
+
}
|
|
1552
|
+
return `+${digitsOnly}`;
|
|
1553
|
+
}
|
|
1554
|
+
function normalizeAndValidatePhone(input) {
|
|
1555
|
+
const normalized = normalizePhoneNumber(input);
|
|
1556
|
+
if (!normalized) {
|
|
1557
|
+
return {
|
|
1558
|
+
input,
|
|
1559
|
+
normalized: null,
|
|
1560
|
+
valid: false,
|
|
1561
|
+
error: "Phone number is required"
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
if (!E164_REGEX.test(normalized)) {
|
|
1565
|
+
return {
|
|
1566
|
+
input,
|
|
1567
|
+
normalized,
|
|
1568
|
+
valid: false,
|
|
1569
|
+
error: "Phone number must be in E.164 format (+[country code][number])"
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
return {
|
|
1573
|
+
input,
|
|
1574
|
+
normalized,
|
|
1575
|
+
valid: true,
|
|
1576
|
+
error: null
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
function composePhoneNumber(countryDialCode, localNumber) {
|
|
1580
|
+
const normalizedDial = normalizePhoneNumber(countryDialCode);
|
|
1581
|
+
if (!normalizedDial) return "";
|
|
1582
|
+
const localDigits = typeof localNumber === "string" ? localNumber.replace(/\D/g, "") : "";
|
|
1583
|
+
if (!localDigits) return "";
|
|
1584
|
+
return `${normalizedDial}${localDigits}`;
|
|
1585
|
+
}
|
|
1586
|
+
function findPhoneCountryByCode(code) {
|
|
1587
|
+
if (!code) return void 0;
|
|
1588
|
+
const upperCode = code.toUpperCase();
|
|
1589
|
+
return PHONE_COUNTRIES.find((country) => country.code === upperCode);
|
|
1590
|
+
}
|
|
1591
|
+
function findPhoneCountryByDialCode(dialCode) {
|
|
1592
|
+
if (!dialCode) return void 0;
|
|
1593
|
+
const normalized = dialCode.startsWith("+") ? dialCode : `+${dialCode}`;
|
|
1594
|
+
return PHONE_COUNTRIES.find((country) => country.dialCode === normalized);
|
|
1595
|
+
}
|
|
1596
|
+
var DIAL_CODES_DESC = [...PHONE_COUNTRIES].sort((a, b) => b.dialCode.length - a.dialCode.length);
|
|
1597
|
+
function detectCountryFromE164(e164) {
|
|
1598
|
+
if (!e164 || !e164.startsWith("+")) return null;
|
|
1599
|
+
const normalized = "+" + e164.slice(1).replace(/\D/g, "");
|
|
1600
|
+
for (const country of DIAL_CODES_DESC) {
|
|
1601
|
+
const prefix = country.dialCode;
|
|
1602
|
+
if (normalized.startsWith(prefix)) {
|
|
1603
|
+
const local = normalized.slice(prefix.length);
|
|
1604
|
+
if (local.length > 0) {
|
|
1605
|
+
return { country, local };
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
return null;
|
|
1610
|
+
}
|
|
1611
|
+
function countryFlag(code) {
|
|
1612
|
+
return [...code.toUpperCase()].map((c) => String.fromCodePoint(127462 + c.charCodeAt(0) - 65)).join("");
|
|
1613
|
+
}
|
|
1357
1614
|
|
|
1358
1615
|
// src/services/auth.ts
|
|
1359
1616
|
function collectDeviceFingerprint() {
|
|
@@ -1460,7 +1717,7 @@ var AuthService = class extends ServiceModule {
|
|
|
1460
1717
|
}
|
|
1461
1718
|
sanitizePhoneField(value) {
|
|
1462
1719
|
if (typeof value !== "string") return value;
|
|
1463
|
-
const normalized =
|
|
1720
|
+
const normalized = normalizePhoneNumber(value);
|
|
1464
1721
|
return normalized || void 0;
|
|
1465
1722
|
}
|
|
1466
1723
|
// --------------------------------------------------------------------------
|
|
@@ -1484,6 +1741,16 @@ var AuthService = class extends ServiceModule {
|
|
|
1484
1741
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1485
1742
|
});
|
|
1486
1743
|
}
|
|
1744
|
+
if (result.data && this.client.isAccountSwitcherEnabled()) {
|
|
1745
|
+
await this.client.addKnownAccount({
|
|
1746
|
+
userId: result.data.user.id,
|
|
1747
|
+
email: result.data.user.email,
|
|
1748
|
+
fullName: result.data.user.full_name,
|
|
1749
|
+
avatarUrl: result.data.user.avatar_url,
|
|
1750
|
+
provider: "email",
|
|
1751
|
+
lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1487
1754
|
return result;
|
|
1488
1755
|
}
|
|
1489
1756
|
async login(data, options) {
|
|
@@ -1504,6 +1771,16 @@ var AuthService = class extends ServiceModule {
|
|
|
1504
1771
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1505
1772
|
});
|
|
1506
1773
|
}
|
|
1774
|
+
if (result.data && this.client.isAccountSwitcherEnabled()) {
|
|
1775
|
+
await this.client.addKnownAccount({
|
|
1776
|
+
userId: result.data.user.id,
|
|
1777
|
+
email: result.data.user.email,
|
|
1778
|
+
fullName: result.data.user.full_name,
|
|
1779
|
+
avatarUrl: result.data.user.avatar_url,
|
|
1780
|
+
provider: "email",
|
|
1781
|
+
lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1507
1784
|
return result;
|
|
1508
1785
|
}
|
|
1509
1786
|
async logout(options) {
|
|
@@ -1645,7 +1922,18 @@ var AuthService = class extends ServiceModule {
|
|
|
1645
1922
|
}
|
|
1646
1923
|
async handleOAuthCallback(data, options) {
|
|
1647
1924
|
const { provider, ...rest } = data;
|
|
1648
|
-
|
|
1925
|
+
const result = await this._get(this.withQuery(`/oauth/${provider}/callback`, rest), options);
|
|
1926
|
+
if (result.data && this.client.isAccountSwitcherEnabled()) {
|
|
1927
|
+
await this.client.addKnownAccount({
|
|
1928
|
+
userId: result.data.user.id,
|
|
1929
|
+
email: result.data.user.email,
|
|
1930
|
+
fullName: result.data.user.full_name,
|
|
1931
|
+
avatarUrl: result.data.user.avatar_url,
|
|
1932
|
+
provider,
|
|
1933
|
+
lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
return result;
|
|
1649
1937
|
}
|
|
1650
1938
|
async listOAuthProviders(options) {
|
|
1651
1939
|
return this._get("/oauth/providers", options);
|
|
@@ -5888,6 +6176,73 @@ var FlagContentService = class extends ServiceModule {
|
|
|
5888
6176
|
}
|
|
5889
6177
|
};
|
|
5890
6178
|
|
|
6179
|
+
// src/services/creator-maker.ts
|
|
6180
|
+
var CreatorMakerService = class extends ServiceModule {
|
|
6181
|
+
constructor() {
|
|
6182
|
+
super(...arguments);
|
|
6183
|
+
this.basePath = "/v1/creator-maker";
|
|
6184
|
+
}
|
|
6185
|
+
/** Submit a generation job. */
|
|
6186
|
+
async generate(data, options) {
|
|
6187
|
+
return this.post("/jobs", data, options);
|
|
6188
|
+
}
|
|
6189
|
+
/** Get a generation job by ID. */
|
|
6190
|
+
async getJob(jobId, options) {
|
|
6191
|
+
return this._get(`/jobs/${jobId}`, options);
|
|
6192
|
+
}
|
|
6193
|
+
/** Long-poll for job completion (server holds up to 30s). */
|
|
6194
|
+
async pollJob(jobId, options) {
|
|
6195
|
+
return this._get(`/jobs/${jobId}/poll`, {
|
|
6196
|
+
...options,
|
|
6197
|
+
timeout: 35e3
|
|
6198
|
+
});
|
|
6199
|
+
}
|
|
6200
|
+
/** List the current user's generation jobs. */
|
|
6201
|
+
async listJobs(params, options) {
|
|
6202
|
+
return this._list("/jobs", params, options);
|
|
6203
|
+
}
|
|
6204
|
+
/** Cancel a pending or queued job. */
|
|
6205
|
+
async cancelJob(jobId, options) {
|
|
6206
|
+
return this.post(`/jobs/${jobId}/cancel`, void 0, options);
|
|
6207
|
+
}
|
|
6208
|
+
/** Retry a failed job. */
|
|
6209
|
+
async retryJob(jobId, options) {
|
|
6210
|
+
return this.post(`/jobs/${jobId}/retry`, void 0, options);
|
|
6211
|
+
}
|
|
6212
|
+
/** Generate variations of a completed job. */
|
|
6213
|
+
async generateVariations(jobId, options) {
|
|
6214
|
+
return this.post(`/jobs/${jobId}/variations`, void 0, options);
|
|
6215
|
+
}
|
|
6216
|
+
/** List available style presets, optionally filtered by mode. */
|
|
6217
|
+
async listPresets(params, options) {
|
|
6218
|
+
return this._get(this.withQuery("/presets", params), options);
|
|
6219
|
+
}
|
|
6220
|
+
/** Get a style preset by slug. */
|
|
6221
|
+
async getPreset(slug, options) {
|
|
6222
|
+
return this._get(`/presets/${slug}`, options);
|
|
6223
|
+
}
|
|
6224
|
+
/** Create a project. */
|
|
6225
|
+
async createProject(data, options) {
|
|
6226
|
+
return this.post("/projects", data, options);
|
|
6227
|
+
}
|
|
6228
|
+
/** List the current user's projects. */
|
|
6229
|
+
async listProjects(params, options) {
|
|
6230
|
+
return this._list("/projects", params, options);
|
|
6231
|
+
}
|
|
6232
|
+
/** Get generation usage and credit balance. */
|
|
6233
|
+
async getUsage(options) {
|
|
6234
|
+
return this._get("/usage", options);
|
|
6235
|
+
}
|
|
6236
|
+
/** Get a generation output by ID. */
|
|
6237
|
+
async getOutput(outputId, options) {
|
|
6238
|
+
return this._get(`/outputs/${outputId}`, options);
|
|
6239
|
+
}
|
|
6240
|
+
/** Get a download URL for a generation output. */
|
|
6241
|
+
async getDownloadUrl(outputId, options) {
|
|
6242
|
+
return this._get(`/outputs/${outputId}/download`, options);
|
|
6243
|
+
}
|
|
6244
|
+
};
|
|
6245
|
+
|
|
5891
6246
|
// src/services/agent-auth.ts
|
|
5892
6247
|
var AgentAuthService = class extends ServiceModule {
|
|
5893
6248
|
constructor() {
|
|
@@ -6094,6 +6449,13 @@ var AgentProjectsService = class extends ServiceModule {
|
|
|
6094
6449
|
options
|
|
6095
6450
|
);
|
|
6096
6451
|
}
|
|
6452
|
+
async startTask(taskId, agentId, applicationId, options) {
|
|
6453
|
+
return this.post(
|
|
6454
|
+
this.withAppId(`/tasks/${taskId}/start`, applicationId),
|
|
6455
|
+
{ agent_id: agentId },
|
|
6456
|
+
options
|
|
6457
|
+
);
|
|
6458
|
+
}
|
|
6097
6459
|
async submit(taskId, data, applicationId, options) {
|
|
6098
6460
|
return this.post(this.withAppId(`/tasks/${taskId}/submit`, applicationId), data, options);
|
|
6099
6461
|
}
|
|
@@ -6400,6 +6762,7 @@ var ScaleMule = class {
|
|
|
6400
6762
|
this.functions = new FunctionsService(this._client);
|
|
6401
6763
|
this.photo = new PhotoService(this._client);
|
|
6402
6764
|
this.flagContent = new FlagContentService(this._client);
|
|
6765
|
+
this.creatorMaker = new CreatorMakerService(this._client);
|
|
6403
6766
|
this.compliance = new ComplianceService(this._client);
|
|
6404
6767
|
this.orchestrator = new OrchestratorService(this._client);
|
|
6405
6768
|
this.agentAuth = new AgentAuthService(this._client);
|
|
@@ -6479,6 +6842,36 @@ var ScaleMule = class {
|
|
|
6479
6842
|
async clearAllAccounts() {
|
|
6480
6843
|
return this._client.clearAllAccounts();
|
|
6481
6844
|
}
|
|
6845
|
+
// --------------------------------------------------------------------------
|
|
6846
|
+
// Account Switcher (Secure — metadata only, re-auth required)
|
|
6847
|
+
// --------------------------------------------------------------------------
|
|
6848
|
+
/** Whether the account switcher is enabled */
|
|
6849
|
+
isAccountSwitcherEnabled() {
|
|
6850
|
+
return this._client.isAccountSwitcherEnabled();
|
|
6851
|
+
}
|
|
6852
|
+
/** The configured privacy level for the account switcher */
|
|
6853
|
+
getAccountSwitcherPrivacy() {
|
|
6854
|
+
return this._client.getAccountSwitcherPrivacy();
|
|
6855
|
+
}
|
|
6856
|
+
/**
|
|
6857
|
+
* Get all accounts that have previously logged in on this device.
|
|
6858
|
+
* Returns privacy-transformed display data — no raw PII in masked/minimal modes.
|
|
6859
|
+
* Requires `enableAccountSwitcher: true` in config.
|
|
6860
|
+
*/
|
|
6861
|
+
getKnownAccounts() {
|
|
6862
|
+
return this._client.getKnownAccounts();
|
|
6863
|
+
}
|
|
6864
|
+
/**
|
|
6865
|
+
* Forget a specific account — removes it from the known accounts list.
|
|
6866
|
+
* Does NOT affect any active session.
|
|
6867
|
+
*/
|
|
6868
|
+
async removeKnownAccount(userId) {
|
|
6869
|
+
return this._client.removeKnownAccount(userId);
|
|
6870
|
+
}
|
|
6871
|
+
/** Forget all known accounts on this device. */
|
|
6872
|
+
async clearKnownAccounts() {
|
|
6873
|
+
return this._client.clearKnownAccounts();
|
|
6874
|
+
}
|
|
6482
6875
|
/** The base URL being used for API requests. */
|
|
6483
6876
|
getBaseUrl() {
|
|
6484
6877
|
return this._client.getBaseUrl();
|
|
@@ -6518,6 +6911,7 @@ var index_default = ScaleMule;
|
|
|
6518
6911
|
ChatService,
|
|
6519
6912
|
CommunicationService,
|
|
6520
6913
|
ComplianceService,
|
|
6914
|
+
CreatorMakerService,
|
|
6521
6915
|
DataService,
|
|
6522
6916
|
ErrorCodes,
|
|
6523
6917
|
EventsService,
|