smule.js 1.2.5 → 1.3.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/dist/index.cjs CHANGED
@@ -647,7 +647,7 @@ var CustomFormData = class {
647
647
  };
648
648
  }
649
649
  get(key) {
650
- return this.data[key].value;
650
+ return this.data[key]?.value;
651
651
  }
652
652
  serialize() {
653
653
  let boundary = "--1335a53d-7c46-4dd6-8e1e-c2f96c3987c5";
@@ -2719,8 +2719,10 @@ var SmuleDigest;
2719
2719
  }
2720
2720
  }
2721
2721
  if (multiPartBody != null) {
2722
- neededParameters["pop"] = parameters["pop"];
2723
- neededParameters["jsonData"] = multiPartBody.get("jsonData");
2722
+ if (parameters["pop"])
2723
+ neededParameters["pop"] = parameters["pop"];
2724
+ if (multiPartBody.get("jsonData"))
2725
+ neededParameters["jsonData"] = multiPartBody.get("jsonData");
2724
2726
  }
2725
2727
  return neededParameters;
2726
2728
  }
@@ -3718,7 +3720,13 @@ var Smule = class {
3718
3720
  if (!this.internal._handleNon200(req)) return;
3719
3721
  return this.internal._getResponseData(req);
3720
3722
  },
3721
- // TODO: test and doc
3723
+ /**
3724
+ * Fetches songs created by a certain user
3725
+ * @param ownerId The account's id
3726
+ * @param offset The start offset
3727
+ * @param limit How many
3728
+ * @returns The songs
3729
+ */
3722
3730
  fetchOwnedBy: async (ownerId, offset = 0, limit = 10) => {
3723
3731
  const req = await this.internal._createRequest(SmuleUrls.ArrOwned, { ownerAccountId: ownerId, offset, limit });
3724
3732
  if (!this.internal._handleNon200(req)) return;
@@ -4584,11 +4592,14 @@ var SmuleDotComUrls;
4584
4592
  SmuleDotComUrls2.baseUrl = "https://www.smule.com";
4585
4593
  SmuleDotComUrls2.baseWebApiUrl = SmuleDotComUrls2.baseUrl + "/api";
4586
4594
  SmuleDotComUrls2.baseSiteApiUrl = SmuleDotComUrls2.baseUrl + "/s";
4595
+ SmuleDotComUrls2.baseWebUploadUrl = SmuleDotComUrls2.baseWebApiUrl + "/upload";
4587
4596
  SmuleDotComUrls2.baseSiteUploadUrl = SmuleDotComUrls2.baseSiteApiUrl + "/upload";
4588
4597
  SmuleDotComUrls2.songUploadArrApi = SmuleDotComUrls2.baseSiteUploadUrl + "/arr";
4589
4598
  SmuleDotComUrls2.UserCheckEmail = SmuleDotComUrls2.baseWebApiUrl + "/user/check_email";
4590
4599
  SmuleDotComUrls2.UserEmailLogin = SmuleDotComUrls2.baseWebApiUrl + "/user/email_login";
4591
- SmuleDotComUrls2.UploadAutocomplete = SmuleDotComUrls2.baseSiteUploadUrl + "/autocomplete";
4600
+ SmuleDotComUrls2.Profile = SmuleDotComUrls2.baseWebApiUrl + "/profile";
4601
+ SmuleDotComUrls2.ProfileSongs = SmuleDotComUrls2.baseWebApiUrl + "/profile/songs";
4602
+ SmuleDotComUrls2.UploadAutocomplete = SmuleDotComUrls2.baseWebUploadUrl + "/autocomplete";
4592
4603
  SmuleDotComUrls2.UploadAutocompleteTitle = SmuleDotComUrls2.UploadAutocomplete + "/title";
4593
4604
  SmuleDotComUrls2.UploadAutocompleteArtist = SmuleDotComUrls2.UploadAutocomplete + "/artist";
4594
4605
  SmuleDotComUrls2.UploadAutocompleteGenre = SmuleDotComUrls2.UploadAutocomplete + "/genre";
@@ -4613,6 +4624,7 @@ var SmuleDotComSmulen;
4613
4624
  SmuleDotComSmulen2.digest = digest;
4614
4625
  })(SmuleDotComSmulen || (SmuleDotComSmulen = {}));
4615
4626
  var SmuleDotCom = class {
4627
+ accountData = null;
4616
4628
  xsrfToken = "";
4617
4629
  cookies = {};
4618
4630
  /**
@@ -4621,6 +4633,13 @@ var SmuleDotCom = class {
4621
4633
  resetCookies() {
4622
4634
  this.cookies = {};
4623
4635
  }
4636
+ /**
4637
+ * Fetches the locally saved user data
4638
+ * @returns The user data
4639
+ */
4640
+ getAccount() {
4641
+ return this.accountData;
4642
+ }
4624
4643
  /**
4625
4644
  * Fetches a new CSRF token, required for certain actions
4626
4645
  */
@@ -4685,8 +4704,21 @@ var SmuleDotCom = class {
4685
4704
  tzOffset: 10800
4686
4705
  });
4687
4706
  const data = req.data;
4707
+ this.accountData = data.user;
4688
4708
  return data.success;
4689
4709
  }
4710
+ /**
4711
+ * Fetches the currently logged in user
4712
+ * @returns Either the user, or null
4713
+ */
4714
+ async fetchAccount() {
4715
+ const req = await import_axios2.default.get(SmuleDotComUrls.baseUrl, { headers: this.getHeaders() });
4716
+ for (const match of req.data.matchAll(/init: (.+),/g)) {
4717
+ const loginData = JSON.parse(match[1]);
4718
+ this.accountData = loginData.currentUser;
4719
+ return this.accountData;
4720
+ }
4721
+ }
4690
4722
  /// MORE INFO REGARDING ARRANGEMENT UPLOADS
4691
4723
  // these are designed to be used in the following order (on the site)
4692
4724
  // 1. create the arrangement by uploading the mp3 file
@@ -4874,6 +4906,34 @@ var SmuleDotCom = class {
4874
4906
  });
4875
4907
  return req.data;
4876
4908
  }
4909
+ /**
4910
+ * Fetches a user's profile
4911
+ * @param username The user's username
4912
+ * @returns The user's profile
4913
+ */
4914
+ async fetchProfile(username) {
4915
+ const req = await import_axios2.default.get(SmuleDotComUrls.Profile + "?handle=" + encodeURIComponent(username), {
4916
+ headers: {
4917
+ ...this.getHeaders()
4918
+ }
4919
+ });
4920
+ return req.data;
4921
+ }
4922
+ /**
4923
+ * Fetches the songs of a user
4924
+ * @param accountId The user's account id
4925
+ * @param offset Start index
4926
+ * @param limit How many
4927
+ * @returns The user's songs
4928
+ */
4929
+ async fetchSongs(accountId, offset = 0, limit = 10) {
4930
+ const req = await import_axios2.default.get(SmuleDotComUrls.ProfileSongs + "?accountId=" + accountId + "&offset=" + offset + "&limit=" + limit, {
4931
+ headers: {
4932
+ ...this.getHeaders()
4933
+ }
4934
+ });
4935
+ return req.data;
4936
+ }
4877
4937
  };
4878
4938
  // Annotate the CommonJS export names for ESM import in node:
4879
4939
  0 && (module.exports = {
package/dist/index.d.cts CHANGED
@@ -1446,6 +1446,11 @@ type ArrBookmarkListResult = {
1446
1446
  cursor: Cursor;
1447
1447
  totalCount: number;
1448
1448
  };
1449
+ type ArrOwnedBy = {
1450
+ arrVersionLites: Arr[];
1451
+ arrCount: number;
1452
+ next: number;
1453
+ };
1449
1454
  type AvTemplateCategoryListResult = {
1450
1455
  recAvTemplateLites: Array<{
1451
1456
  avtemplateLite: AvTemplateLite;
@@ -2585,7 +2590,14 @@ declare class Smule {
2585
2590
  * @returns The details of the songs.
2586
2591
  */
2587
2592
  fetch: (keys: string[]) => Promise<ArrByKeysResult>;
2588
- fetchOwnedBy: (ownerId: number, offset?: number, limit?: number) => Promise<any>;
2593
+ /**
2594
+ * Fetches songs created by a certain user
2595
+ * @param ownerId The account's id
2596
+ * @param offset The start offset
2597
+ * @param limit How many
2598
+ * @returns The songs
2599
+ */
2600
+ fetchOwnedBy: (ownerId: number, offset?: number, limit?: number) => Promise<ArrOwnedBy>;
2589
2601
  /**
2590
2602
  * Fetches free songs from a list of genres
2591
2603
  *
@@ -3044,16 +3056,42 @@ declare class Smule {
3044
3056
 
3045
3057
  type SDCLoginResult = {
3046
3058
  success: boolean;
3047
- user: {
3048
- account_id: number;
3049
- handle: string;
3050
- pic_url: string;
3051
- url: string;
3052
- jid: string;
3053
- xmpp_host: string[];
3054
- session: string;
3055
- is_verified: boolean;
3056
- };
3059
+ user: SDCUser;
3060
+ };
3061
+ type SDCProfileResult = {
3062
+ account_id: number;
3063
+ is_current_user_profile: boolean;
3064
+ handle: string;
3065
+ location?: any;
3066
+ pic_url: string;
3067
+ url: string;
3068
+ followers: string;
3069
+ followees: string;
3070
+ num_performances: string;
3071
+ blurb: string;
3072
+ is_following: boolean;
3073
+ is_vip: boolean;
3074
+ is_verified: boolean;
3075
+ verified_type: "unverified" | string;
3076
+ sfam_count: number;
3077
+ wallet: {
3078
+ credit: number;
3079
+ };
3080
+ installed_apps: string[];
3081
+ };
3082
+ type SDCProfileSongsResult = {
3083
+ list: SDCSong[];
3084
+ next_offset: number;
3085
+ };
3086
+ type SDCUser = {
3087
+ account_id: number;
3088
+ handle: string;
3089
+ pic_url: string;
3090
+ url: string;
3091
+ jid: string;
3092
+ xmpp_host: string[];
3093
+ session: string;
3094
+ is_verified: boolean;
3057
3095
  };
3058
3096
  type SDCLanguage = {
3059
3097
  id: string;
@@ -3188,6 +3226,22 @@ type SDCDetectLanguageResponse = {
3188
3226
  probability: number;
3189
3227
  };
3190
3228
  };
3229
+ type SDCSong = {
3230
+ artist: string;
3231
+ cover_url: string;
3232
+ created_at: Date;
3233
+ highly_rated: boolean;
3234
+ key: string;
3235
+ lyrics: boolean;
3236
+ owner: SDCProfileResult;
3237
+ title: string;
3238
+ total_votes: number;
3239
+ web_url: string;
3240
+ lyrics_list: any[];
3241
+ app_family: "SING";
3242
+ last_published_ver: number;
3243
+ process_state: number;
3244
+ };
3191
3245
 
3192
3246
  /**
3193
3247
  * The public interface for Smule's website API
@@ -3196,6 +3250,7 @@ type SDCDetectLanguageResponse = {
3196
3250
  * otherwise it will error out lol
3197
3251
  */
3198
3252
  declare class SmuleDotCom {
3253
+ private accountData;
3199
3254
  private xsrfToken;
3200
3255
  cookies: {
3201
3256
  [key: string]: string;
@@ -3204,6 +3259,11 @@ declare class SmuleDotCom {
3204
3259
  * Clears the saved cookies
3205
3260
  */
3206
3261
  resetCookies(): void;
3262
+ /**
3263
+ * Fetches the locally saved user data
3264
+ * @returns The user data
3265
+ */
3266
+ getAccount(): SDCUser;
3207
3267
  /**
3208
3268
  * Fetches a new CSRF token, required for certain actions
3209
3269
  */
@@ -3221,6 +3281,11 @@ declare class SmuleDotCom {
3221
3281
  * @returns whether the action was successful
3222
3282
  */
3223
3283
  login(email: string, password: string): Promise<boolean>;
3284
+ /**
3285
+ * Fetches the currently logged in user
3286
+ * @returns Either the user, or null
3287
+ */
3288
+ fetchAccount(): Promise<SDCUser>;
3224
3289
  /**
3225
3290
  * Creates a new arrangement
3226
3291
  * @param songFile The mp3 file you wish to upload
@@ -3296,6 +3361,20 @@ declare class SmuleDotCom {
3296
3361
  * @param arrKey The arrangement's key
3297
3362
  */
3298
3363
  deleteArr(arrKey: string): Promise<ApiResult<{}>>;
3364
+ /**
3365
+ * Fetches a user's profile
3366
+ * @param username The user's username
3367
+ * @returns The user's profile
3368
+ */
3369
+ fetchProfile(username: string): Promise<SDCProfileResult>;
3370
+ /**
3371
+ * Fetches the songs of a user
3372
+ * @param accountId The user's account id
3373
+ * @param offset Start index
3374
+ * @param limit How many
3375
+ * @returns The user's songs
3376
+ */
3377
+ fetchSongs(accountId: number | string, offset?: number, limit?: number): Promise<SDCProfileSongsResult>;
3299
3378
  }
3300
3379
 
3301
3380
  declare namespace SmuleUrls {
@@ -3716,4 +3795,4 @@ type SmulePitchesData = {
3716
3795
  smallestNote: number;
3717
3796
  };
3718
3797
 
3719
- export { type AccessTokenResult, type AccountExploreResult, type AccountIcon, type AccountLookupResult, type AccountProfileStatsViewsResult, type AccountWalletResult, type ApiResult, Arr, type ArrBookmarkListResult, type ArrByKeysResult, type ArrExtended, type ArrResult, AvTemplateCategoryListRequest, type AvTemplateCategoryListResult, type AvTemplateLite, Banner, type BannersResult, type Campfire, type CampfireListResult, type CampfirePlayStream, type CampfireSyncResult, type CategoryListResult, CategoryRequest, type CategorySongsResult, type Comment, type Contact, type ContactFindResult, type Cursor, CustomFormData, Device, type DeviceSettingsResult, type EnsembleType, type FeedItem, type GiftIcon, type GiftsResult, type InviteListResult, type InviteMeResult, IsFollowingRequest, type ListEntitlementsResult, LoginAsGuestRequest, type LoginAsGuestResult, LoginCommonData, type LoginInfoResult, LoginRequest, type LoginResult, type ParticipationIcon, type PerformanceBookmarkSeedResult, type PerformanceByKeysResult, type PerformanceCommentsResult, type PerformanceCreateCommentResult, PerformanceCreateRequest, type PerformanceCreateResult, type PerformanceDetail, type PerformanceDetailsResult, type PerformanceIcon, PerformanceList, PerformancePartsRequest, type PerformancePartsResult, PerformanceReq, type PerformanceResult, type PerformanceSortMethod, type PerformancesByAvTemplateResult, type PerformancesByUserResult, type PerformancesFillStatus, PerformancesListRequest, type PerformancesSortOrder, type Playlist, type PlaylistDetailed, type PlaylistExploreResult, type PlaylistGetResult, type PlaylistIcon, type PlaylistSortMethod, type PlaylistViewResult, type PlaylistVisibility, PreferencesRequest, type PreferencesResult, PreuploadRequest, type PreuploadResult, type Profile, RecAccount, type RecAccountsResult, type RecPerformanceIcon, type RecTrendingSearchResult, type SDCArr, type SDCArrSongConfig, type SDCDetectLanguageResponse, type SDCGeneratedSegmentsResponse, type SDCGenre, type SDCLanguage, type SDCLoginResult, type SDCLyric, type SDCLyricVideoParagraph, type SDCResourceCreationResult, type SDCSaveArrResponse, type SDCSegment, type SFam, type SFamInfoResult, type SFamList, type SFamListResult, type SFamMemberListResult, type SFamMembershipType, type SMULE_APP, SearchAutocompleteRequest, type SearchAutocompleteResult, SearchRequest, type SearchResult, type SearchResultCategory, type SearchResultSort, type SearchResultType, SettingsRequest, type SettingsResult, type SingProfile, SingUserProfileRequest, type SingUserProfileResult, Smule, type SmuleChatContainer, type SmuleChatState, SmuleDotCom, SmuleErrorCode, type SmuleLyric, type SmuleLyricsData, type SmuleMessage, type SmuleMidiData, type SmulePartnerStatus, type SmulePitch, type SmulePitchesData, SmuleRegisterErrorCode, SmuleSession, type SmuleSyllable, SmuleUrls, SmuleUserSinging, SmuleUtil, type SocialBlockListResult, type SocialCommentLikesResult, type SocialFeedListResult, type SocialFolloweesResult, type SocialFollowersResult, type SocialInvite, type SocialInvite2, type SocialIsFollowingResult, type Song, type SongCategory, SongbookRequest, type SongbookResult, type StoreSubscriptionStatusResult, type TippingHandleType, type TopicChooseResult, type TopicOptionResult, type TrendingSearch, UpdateFollowingRequest, type UserTippingPref, type UserTippingProvider, type UserUploadPictureResult, Util, type Wallet, type avTmplSegment };
3798
+ export { type AccessTokenResult, type AccountExploreResult, type AccountIcon, type AccountLookupResult, type AccountProfileStatsViewsResult, type AccountWalletResult, type ApiResult, Arr, type ArrBookmarkListResult, type ArrByKeysResult, type ArrExtended, type ArrOwnedBy, type ArrResult, AvTemplateCategoryListRequest, type AvTemplateCategoryListResult, type AvTemplateLite, Banner, type BannersResult, type Campfire, type CampfireListResult, type CampfirePlayStream, type CampfireSyncResult, type CategoryListResult, CategoryRequest, type CategorySongsResult, type Comment, type Contact, type ContactFindResult, type Cursor, CustomFormData, Device, type DeviceSettingsResult, type EnsembleType, type FeedItem, type GiftIcon, type GiftsResult, type InviteListResult, type InviteMeResult, IsFollowingRequest, type ListEntitlementsResult, LoginAsGuestRequest, type LoginAsGuestResult, LoginCommonData, type LoginInfoResult, LoginRequest, type LoginResult, type ParticipationIcon, type PerformanceBookmarkSeedResult, type PerformanceByKeysResult, type PerformanceCommentsResult, type PerformanceCreateCommentResult, PerformanceCreateRequest, type PerformanceCreateResult, type PerformanceDetail, type PerformanceDetailsResult, type PerformanceIcon, PerformanceList, PerformancePartsRequest, type PerformancePartsResult, PerformanceReq, type PerformanceResult, type PerformanceSortMethod, type PerformancesByAvTemplateResult, type PerformancesByUserResult, type PerformancesFillStatus, PerformancesListRequest, type PerformancesSortOrder, type Playlist, type PlaylistDetailed, type PlaylistExploreResult, type PlaylistGetResult, type PlaylistIcon, type PlaylistSortMethod, type PlaylistViewResult, type PlaylistVisibility, PreferencesRequest, type PreferencesResult, PreuploadRequest, type PreuploadResult, type Profile, RecAccount, type RecAccountsResult, type RecPerformanceIcon, type RecTrendingSearchResult, type SDCArr, type SDCArrSongConfig, type SDCDetectLanguageResponse, type SDCGeneratedSegmentsResponse, type SDCGenre, type SDCLanguage, type SDCLoginResult, type SDCLyric, type SDCLyricVideoParagraph, type SDCProfileResult, type SDCProfileSongsResult, type SDCResourceCreationResult, type SDCSaveArrResponse, type SDCSegment, type SDCSong, type SDCUser, type SFam, type SFamInfoResult, type SFamList, type SFamListResult, type SFamMemberListResult, type SFamMembershipType, type SMULE_APP, SearchAutocompleteRequest, type SearchAutocompleteResult, SearchRequest, type SearchResult, type SearchResultCategory, type SearchResultSort, type SearchResultType, SettingsRequest, type SettingsResult, type SingProfile, SingUserProfileRequest, type SingUserProfileResult, Smule, type SmuleChatContainer, type SmuleChatState, SmuleDotCom, SmuleErrorCode, type SmuleLyric, type SmuleLyricsData, type SmuleMessage, type SmuleMidiData, type SmulePartnerStatus, type SmulePitch, type SmulePitchesData, SmuleRegisterErrorCode, SmuleSession, type SmuleSyllable, SmuleUrls, SmuleUserSinging, SmuleUtil, type SocialBlockListResult, type SocialCommentLikesResult, type SocialFeedListResult, type SocialFolloweesResult, type SocialFollowersResult, type SocialInvite, type SocialInvite2, type SocialIsFollowingResult, type Song, type SongCategory, SongbookRequest, type SongbookResult, type StoreSubscriptionStatusResult, type TippingHandleType, type TopicChooseResult, type TopicOptionResult, type TrendingSearch, UpdateFollowingRequest, type UserTippingPref, type UserTippingProvider, type UserUploadPictureResult, Util, type Wallet, type avTmplSegment };
package/dist/index.d.ts CHANGED
@@ -1446,6 +1446,11 @@ type ArrBookmarkListResult = {
1446
1446
  cursor: Cursor;
1447
1447
  totalCount: number;
1448
1448
  };
1449
+ type ArrOwnedBy = {
1450
+ arrVersionLites: Arr[];
1451
+ arrCount: number;
1452
+ next: number;
1453
+ };
1449
1454
  type AvTemplateCategoryListResult = {
1450
1455
  recAvTemplateLites: Array<{
1451
1456
  avtemplateLite: AvTemplateLite;
@@ -2585,7 +2590,14 @@ declare class Smule {
2585
2590
  * @returns The details of the songs.
2586
2591
  */
2587
2592
  fetch: (keys: string[]) => Promise<ArrByKeysResult>;
2588
- fetchOwnedBy: (ownerId: number, offset?: number, limit?: number) => Promise<any>;
2593
+ /**
2594
+ * Fetches songs created by a certain user
2595
+ * @param ownerId The account's id
2596
+ * @param offset The start offset
2597
+ * @param limit How many
2598
+ * @returns The songs
2599
+ */
2600
+ fetchOwnedBy: (ownerId: number, offset?: number, limit?: number) => Promise<ArrOwnedBy>;
2589
2601
  /**
2590
2602
  * Fetches free songs from a list of genres
2591
2603
  *
@@ -3044,16 +3056,42 @@ declare class Smule {
3044
3056
 
3045
3057
  type SDCLoginResult = {
3046
3058
  success: boolean;
3047
- user: {
3048
- account_id: number;
3049
- handle: string;
3050
- pic_url: string;
3051
- url: string;
3052
- jid: string;
3053
- xmpp_host: string[];
3054
- session: string;
3055
- is_verified: boolean;
3056
- };
3059
+ user: SDCUser;
3060
+ };
3061
+ type SDCProfileResult = {
3062
+ account_id: number;
3063
+ is_current_user_profile: boolean;
3064
+ handle: string;
3065
+ location?: any;
3066
+ pic_url: string;
3067
+ url: string;
3068
+ followers: string;
3069
+ followees: string;
3070
+ num_performances: string;
3071
+ blurb: string;
3072
+ is_following: boolean;
3073
+ is_vip: boolean;
3074
+ is_verified: boolean;
3075
+ verified_type: "unverified" | string;
3076
+ sfam_count: number;
3077
+ wallet: {
3078
+ credit: number;
3079
+ };
3080
+ installed_apps: string[];
3081
+ };
3082
+ type SDCProfileSongsResult = {
3083
+ list: SDCSong[];
3084
+ next_offset: number;
3085
+ };
3086
+ type SDCUser = {
3087
+ account_id: number;
3088
+ handle: string;
3089
+ pic_url: string;
3090
+ url: string;
3091
+ jid: string;
3092
+ xmpp_host: string[];
3093
+ session: string;
3094
+ is_verified: boolean;
3057
3095
  };
3058
3096
  type SDCLanguage = {
3059
3097
  id: string;
@@ -3188,6 +3226,22 @@ type SDCDetectLanguageResponse = {
3188
3226
  probability: number;
3189
3227
  };
3190
3228
  };
3229
+ type SDCSong = {
3230
+ artist: string;
3231
+ cover_url: string;
3232
+ created_at: Date;
3233
+ highly_rated: boolean;
3234
+ key: string;
3235
+ lyrics: boolean;
3236
+ owner: SDCProfileResult;
3237
+ title: string;
3238
+ total_votes: number;
3239
+ web_url: string;
3240
+ lyrics_list: any[];
3241
+ app_family: "SING";
3242
+ last_published_ver: number;
3243
+ process_state: number;
3244
+ };
3191
3245
 
3192
3246
  /**
3193
3247
  * The public interface for Smule's website API
@@ -3196,6 +3250,7 @@ type SDCDetectLanguageResponse = {
3196
3250
  * otherwise it will error out lol
3197
3251
  */
3198
3252
  declare class SmuleDotCom {
3253
+ private accountData;
3199
3254
  private xsrfToken;
3200
3255
  cookies: {
3201
3256
  [key: string]: string;
@@ -3204,6 +3259,11 @@ declare class SmuleDotCom {
3204
3259
  * Clears the saved cookies
3205
3260
  */
3206
3261
  resetCookies(): void;
3262
+ /**
3263
+ * Fetches the locally saved user data
3264
+ * @returns The user data
3265
+ */
3266
+ getAccount(): SDCUser;
3207
3267
  /**
3208
3268
  * Fetches a new CSRF token, required for certain actions
3209
3269
  */
@@ -3221,6 +3281,11 @@ declare class SmuleDotCom {
3221
3281
  * @returns whether the action was successful
3222
3282
  */
3223
3283
  login(email: string, password: string): Promise<boolean>;
3284
+ /**
3285
+ * Fetches the currently logged in user
3286
+ * @returns Either the user, or null
3287
+ */
3288
+ fetchAccount(): Promise<SDCUser>;
3224
3289
  /**
3225
3290
  * Creates a new arrangement
3226
3291
  * @param songFile The mp3 file you wish to upload
@@ -3296,6 +3361,20 @@ declare class SmuleDotCom {
3296
3361
  * @param arrKey The arrangement's key
3297
3362
  */
3298
3363
  deleteArr(arrKey: string): Promise<ApiResult<{}>>;
3364
+ /**
3365
+ * Fetches a user's profile
3366
+ * @param username The user's username
3367
+ * @returns The user's profile
3368
+ */
3369
+ fetchProfile(username: string): Promise<SDCProfileResult>;
3370
+ /**
3371
+ * Fetches the songs of a user
3372
+ * @param accountId The user's account id
3373
+ * @param offset Start index
3374
+ * @param limit How many
3375
+ * @returns The user's songs
3376
+ */
3377
+ fetchSongs(accountId: number | string, offset?: number, limit?: number): Promise<SDCProfileSongsResult>;
3299
3378
  }
3300
3379
 
3301
3380
  declare namespace SmuleUrls {
@@ -3716,4 +3795,4 @@ type SmulePitchesData = {
3716
3795
  smallestNote: number;
3717
3796
  };
3718
3797
 
3719
- export { type AccessTokenResult, type AccountExploreResult, type AccountIcon, type AccountLookupResult, type AccountProfileStatsViewsResult, type AccountWalletResult, type ApiResult, Arr, type ArrBookmarkListResult, type ArrByKeysResult, type ArrExtended, type ArrResult, AvTemplateCategoryListRequest, type AvTemplateCategoryListResult, type AvTemplateLite, Banner, type BannersResult, type Campfire, type CampfireListResult, type CampfirePlayStream, type CampfireSyncResult, type CategoryListResult, CategoryRequest, type CategorySongsResult, type Comment, type Contact, type ContactFindResult, type Cursor, CustomFormData, Device, type DeviceSettingsResult, type EnsembleType, type FeedItem, type GiftIcon, type GiftsResult, type InviteListResult, type InviteMeResult, IsFollowingRequest, type ListEntitlementsResult, LoginAsGuestRequest, type LoginAsGuestResult, LoginCommonData, type LoginInfoResult, LoginRequest, type LoginResult, type ParticipationIcon, type PerformanceBookmarkSeedResult, type PerformanceByKeysResult, type PerformanceCommentsResult, type PerformanceCreateCommentResult, PerformanceCreateRequest, type PerformanceCreateResult, type PerformanceDetail, type PerformanceDetailsResult, type PerformanceIcon, PerformanceList, PerformancePartsRequest, type PerformancePartsResult, PerformanceReq, type PerformanceResult, type PerformanceSortMethod, type PerformancesByAvTemplateResult, type PerformancesByUserResult, type PerformancesFillStatus, PerformancesListRequest, type PerformancesSortOrder, type Playlist, type PlaylistDetailed, type PlaylistExploreResult, type PlaylistGetResult, type PlaylistIcon, type PlaylistSortMethod, type PlaylistViewResult, type PlaylistVisibility, PreferencesRequest, type PreferencesResult, PreuploadRequest, type PreuploadResult, type Profile, RecAccount, type RecAccountsResult, type RecPerformanceIcon, type RecTrendingSearchResult, type SDCArr, type SDCArrSongConfig, type SDCDetectLanguageResponse, type SDCGeneratedSegmentsResponse, type SDCGenre, type SDCLanguage, type SDCLoginResult, type SDCLyric, type SDCLyricVideoParagraph, type SDCResourceCreationResult, type SDCSaveArrResponse, type SDCSegment, type SFam, type SFamInfoResult, type SFamList, type SFamListResult, type SFamMemberListResult, type SFamMembershipType, type SMULE_APP, SearchAutocompleteRequest, type SearchAutocompleteResult, SearchRequest, type SearchResult, type SearchResultCategory, type SearchResultSort, type SearchResultType, SettingsRequest, type SettingsResult, type SingProfile, SingUserProfileRequest, type SingUserProfileResult, Smule, type SmuleChatContainer, type SmuleChatState, SmuleDotCom, SmuleErrorCode, type SmuleLyric, type SmuleLyricsData, type SmuleMessage, type SmuleMidiData, type SmulePartnerStatus, type SmulePitch, type SmulePitchesData, SmuleRegisterErrorCode, SmuleSession, type SmuleSyllable, SmuleUrls, SmuleUserSinging, SmuleUtil, type SocialBlockListResult, type SocialCommentLikesResult, type SocialFeedListResult, type SocialFolloweesResult, type SocialFollowersResult, type SocialInvite, type SocialInvite2, type SocialIsFollowingResult, type Song, type SongCategory, SongbookRequest, type SongbookResult, type StoreSubscriptionStatusResult, type TippingHandleType, type TopicChooseResult, type TopicOptionResult, type TrendingSearch, UpdateFollowingRequest, type UserTippingPref, type UserTippingProvider, type UserUploadPictureResult, Util, type Wallet, type avTmplSegment };
3798
+ export { type AccessTokenResult, type AccountExploreResult, type AccountIcon, type AccountLookupResult, type AccountProfileStatsViewsResult, type AccountWalletResult, type ApiResult, Arr, type ArrBookmarkListResult, type ArrByKeysResult, type ArrExtended, type ArrOwnedBy, type ArrResult, AvTemplateCategoryListRequest, type AvTemplateCategoryListResult, type AvTemplateLite, Banner, type BannersResult, type Campfire, type CampfireListResult, type CampfirePlayStream, type CampfireSyncResult, type CategoryListResult, CategoryRequest, type CategorySongsResult, type Comment, type Contact, type ContactFindResult, type Cursor, CustomFormData, Device, type DeviceSettingsResult, type EnsembleType, type FeedItem, type GiftIcon, type GiftsResult, type InviteListResult, type InviteMeResult, IsFollowingRequest, type ListEntitlementsResult, LoginAsGuestRequest, type LoginAsGuestResult, LoginCommonData, type LoginInfoResult, LoginRequest, type LoginResult, type ParticipationIcon, type PerformanceBookmarkSeedResult, type PerformanceByKeysResult, type PerformanceCommentsResult, type PerformanceCreateCommentResult, PerformanceCreateRequest, type PerformanceCreateResult, type PerformanceDetail, type PerformanceDetailsResult, type PerformanceIcon, PerformanceList, PerformancePartsRequest, type PerformancePartsResult, PerformanceReq, type PerformanceResult, type PerformanceSortMethod, type PerformancesByAvTemplateResult, type PerformancesByUserResult, type PerformancesFillStatus, PerformancesListRequest, type PerformancesSortOrder, type Playlist, type PlaylistDetailed, type PlaylistExploreResult, type PlaylistGetResult, type PlaylistIcon, type PlaylistSortMethod, type PlaylistViewResult, type PlaylistVisibility, PreferencesRequest, type PreferencesResult, PreuploadRequest, type PreuploadResult, type Profile, RecAccount, type RecAccountsResult, type RecPerformanceIcon, type RecTrendingSearchResult, type SDCArr, type SDCArrSongConfig, type SDCDetectLanguageResponse, type SDCGeneratedSegmentsResponse, type SDCGenre, type SDCLanguage, type SDCLoginResult, type SDCLyric, type SDCLyricVideoParagraph, type SDCProfileResult, type SDCProfileSongsResult, type SDCResourceCreationResult, type SDCSaveArrResponse, type SDCSegment, type SDCSong, type SDCUser, type SFam, type SFamInfoResult, type SFamList, type SFamListResult, type SFamMemberListResult, type SFamMembershipType, type SMULE_APP, SearchAutocompleteRequest, type SearchAutocompleteResult, SearchRequest, type SearchResult, type SearchResultCategory, type SearchResultSort, type SearchResultType, SettingsRequest, type SettingsResult, type SingProfile, SingUserProfileRequest, type SingUserProfileResult, Smule, type SmuleChatContainer, type SmuleChatState, SmuleDotCom, SmuleErrorCode, type SmuleLyric, type SmuleLyricsData, type SmuleMessage, type SmuleMidiData, type SmulePartnerStatus, type SmulePitch, type SmulePitchesData, SmuleRegisterErrorCode, SmuleSession, type SmuleSyllable, SmuleUrls, SmuleUserSinging, SmuleUtil, type SocialBlockListResult, type SocialCommentLikesResult, type SocialFeedListResult, type SocialFolloweesResult, type SocialFollowersResult, type SocialInvite, type SocialInvite2, type SocialIsFollowingResult, type Song, type SongCategory, SongbookRequest, type SongbookResult, type StoreSubscriptionStatusResult, type TippingHandleType, type TopicChooseResult, type TopicOptionResult, type TrendingSearch, UpdateFollowingRequest, type UserTippingPref, type UserTippingProvider, type UserUploadPictureResult, Util, type Wallet, type avTmplSegment };
package/dist/index.js CHANGED
@@ -584,7 +584,7 @@ var CustomFormData = class {
584
584
  };
585
585
  }
586
586
  get(key) {
587
- return this.data[key].value;
587
+ return this.data[key]?.value;
588
588
  }
589
589
  serialize() {
590
590
  let boundary = "--1335a53d-7c46-4dd6-8e1e-c2f96c3987c5";
@@ -2656,8 +2656,10 @@ var SmuleDigest;
2656
2656
  }
2657
2657
  }
2658
2658
  if (multiPartBody != null) {
2659
- neededParameters["pop"] = parameters["pop"];
2660
- neededParameters["jsonData"] = multiPartBody.get("jsonData");
2659
+ if (parameters["pop"])
2660
+ neededParameters["pop"] = parameters["pop"];
2661
+ if (multiPartBody.get("jsonData"))
2662
+ neededParameters["jsonData"] = multiPartBody.get("jsonData");
2661
2663
  }
2662
2664
  return neededParameters;
2663
2665
  }
@@ -3655,7 +3657,13 @@ var Smule = class {
3655
3657
  if (!this.internal._handleNon200(req)) return;
3656
3658
  return this.internal._getResponseData(req);
3657
3659
  },
3658
- // TODO: test and doc
3660
+ /**
3661
+ * Fetches songs created by a certain user
3662
+ * @param ownerId The account's id
3663
+ * @param offset The start offset
3664
+ * @param limit How many
3665
+ * @returns The songs
3666
+ */
3659
3667
  fetchOwnedBy: async (ownerId, offset = 0, limit = 10) => {
3660
3668
  const req = await this.internal._createRequest(SmuleUrls.ArrOwned, { ownerAccountId: ownerId, offset, limit });
3661
3669
  if (!this.internal._handleNon200(req)) return;
@@ -4521,11 +4529,14 @@ var SmuleDotComUrls;
4521
4529
  SmuleDotComUrls2.baseUrl = "https://www.smule.com";
4522
4530
  SmuleDotComUrls2.baseWebApiUrl = SmuleDotComUrls2.baseUrl + "/api";
4523
4531
  SmuleDotComUrls2.baseSiteApiUrl = SmuleDotComUrls2.baseUrl + "/s";
4532
+ SmuleDotComUrls2.baseWebUploadUrl = SmuleDotComUrls2.baseWebApiUrl + "/upload";
4524
4533
  SmuleDotComUrls2.baseSiteUploadUrl = SmuleDotComUrls2.baseSiteApiUrl + "/upload";
4525
4534
  SmuleDotComUrls2.songUploadArrApi = SmuleDotComUrls2.baseSiteUploadUrl + "/arr";
4526
4535
  SmuleDotComUrls2.UserCheckEmail = SmuleDotComUrls2.baseWebApiUrl + "/user/check_email";
4527
4536
  SmuleDotComUrls2.UserEmailLogin = SmuleDotComUrls2.baseWebApiUrl + "/user/email_login";
4528
- SmuleDotComUrls2.UploadAutocomplete = SmuleDotComUrls2.baseSiteUploadUrl + "/autocomplete";
4537
+ SmuleDotComUrls2.Profile = SmuleDotComUrls2.baseWebApiUrl + "/profile";
4538
+ SmuleDotComUrls2.ProfileSongs = SmuleDotComUrls2.baseWebApiUrl + "/profile/songs";
4539
+ SmuleDotComUrls2.UploadAutocomplete = SmuleDotComUrls2.baseWebUploadUrl + "/autocomplete";
4529
4540
  SmuleDotComUrls2.UploadAutocompleteTitle = SmuleDotComUrls2.UploadAutocomplete + "/title";
4530
4541
  SmuleDotComUrls2.UploadAutocompleteArtist = SmuleDotComUrls2.UploadAutocomplete + "/artist";
4531
4542
  SmuleDotComUrls2.UploadAutocompleteGenre = SmuleDotComUrls2.UploadAutocomplete + "/genre";
@@ -4550,6 +4561,7 @@ var SmuleDotComSmulen;
4550
4561
  SmuleDotComSmulen2.digest = digest;
4551
4562
  })(SmuleDotComSmulen || (SmuleDotComSmulen = {}));
4552
4563
  var SmuleDotCom = class {
4564
+ accountData = null;
4553
4565
  xsrfToken = "";
4554
4566
  cookies = {};
4555
4567
  /**
@@ -4558,6 +4570,13 @@ var SmuleDotCom = class {
4558
4570
  resetCookies() {
4559
4571
  this.cookies = {};
4560
4572
  }
4573
+ /**
4574
+ * Fetches the locally saved user data
4575
+ * @returns The user data
4576
+ */
4577
+ getAccount() {
4578
+ return this.accountData;
4579
+ }
4561
4580
  /**
4562
4581
  * Fetches a new CSRF token, required for certain actions
4563
4582
  */
@@ -4622,8 +4641,21 @@ var SmuleDotCom = class {
4622
4641
  tzOffset: 10800
4623
4642
  });
4624
4643
  const data = req.data;
4644
+ this.accountData = data.user;
4625
4645
  return data.success;
4626
4646
  }
4647
+ /**
4648
+ * Fetches the currently logged in user
4649
+ * @returns Either the user, or null
4650
+ */
4651
+ async fetchAccount() {
4652
+ const req = await axios2.get(SmuleDotComUrls.baseUrl, { headers: this.getHeaders() });
4653
+ for (const match of req.data.matchAll(/init: (.+),/g)) {
4654
+ const loginData = JSON.parse(match[1]);
4655
+ this.accountData = loginData.currentUser;
4656
+ return this.accountData;
4657
+ }
4658
+ }
4627
4659
  /// MORE INFO REGARDING ARRANGEMENT UPLOADS
4628
4660
  // these are designed to be used in the following order (on the site)
4629
4661
  // 1. create the arrangement by uploading the mp3 file
@@ -4811,6 +4843,34 @@ var SmuleDotCom = class {
4811
4843
  });
4812
4844
  return req.data;
4813
4845
  }
4846
+ /**
4847
+ * Fetches a user's profile
4848
+ * @param username The user's username
4849
+ * @returns The user's profile
4850
+ */
4851
+ async fetchProfile(username) {
4852
+ const req = await axios2.get(SmuleDotComUrls.Profile + "?handle=" + encodeURIComponent(username), {
4853
+ headers: {
4854
+ ...this.getHeaders()
4855
+ }
4856
+ });
4857
+ return req.data;
4858
+ }
4859
+ /**
4860
+ * Fetches the songs of a user
4861
+ * @param accountId The user's account id
4862
+ * @param offset Start index
4863
+ * @param limit How many
4864
+ * @returns The user's songs
4865
+ */
4866
+ async fetchSongs(accountId, offset = 0, limit = 10) {
4867
+ const req = await axios2.get(SmuleDotComUrls.ProfileSongs + "?accountId=" + accountId + "&offset=" + offset + "&limit=" + limit, {
4868
+ headers: {
4869
+ ...this.getHeaders()
4870
+ }
4871
+ });
4872
+ return req.data;
4873
+ }
4814
4874
  };
4815
4875
  export {
4816
4876
  AvTemplateCategoryListRequest,
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "https://github.com/michei69"
8
8
  },
9
9
  "license": "MIT",
10
- "version": "1.2.5",
10
+ "version": "1.3.1",
11
11
  "scripts": {
12
12
  "build": "tsup src/index.ts --format cjs,esm --dts --clean",
13
13
  "dev": "tsup src/index.ts --format esm --watch --dts",