soundcloud-api-ts 1.12.0 → 1.13.0
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 +37 -25
- package/dist/{chunk-JLRQJWU5.mjs → chunk-JH7TLL2C.mjs} +55 -3
- package/dist/chunk-JH7TLL2C.mjs.map +1 -0
- package/dist/{chunk-D7AF372V.js → chunk-VBDIRSOG.js} +56 -2
- package/dist/chunk-VBDIRSOG.js.map +1 -0
- package/dist/cli.js +6 -6
- package/dist/cli.mjs +1 -1
- package/dist/index-DX6Anc1-.d.mts +582 -0
- package/dist/index-DX6Anc1-.d.ts +582 -0
- package/dist/index.d.mts +148 -3
- package/dist/index.d.ts +148 -3
- package/dist/index.js +74 -66
- package/dist/index.mjs +1 -1
- package/dist/types/index.d.mts +1 -555
- package/dist/types/index.d.ts +1 -555
- package/package.json +2 -2
- package/dist/chunk-D7AF372V.js.map +0 -1
- package/dist/chunk-JLRQJWU5.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SoundCloudTrack, SoundCloudPlaylist, SoundCloudToken, SoundCloudPaginatedResponse, SoundCloudMe, SoundCloudActivitiesResponse, SoundCloudUser, SoundCloudWebProfile, SoundCloudStreams, SoundCloudComment } from './
|
|
2
|
-
export { SoundCloudActivity, SoundCloudCommentUser, SoundCloudError, SoundCloudQuota, SoundCloudSubscription, SoundCloudSubscriptionProduct } from './
|
|
1
|
+
import { S as SoundCloudTrack, a as SoundCloudPlaylist, b as SoundCloudToken, c as SoundCloudPaginatedResponse, d as SoundCloudMe, e as SoundCloudActivitiesResponse, f as SoundCloudUser, g as SoundCloudConnection, h as SoundCloudWebProfile, i as SoundCloudStreams, j as SoundCloudComment } from './index-DX6Anc1-.mjs';
|
|
2
|
+
export { k as SoundCloudActivity, l as SoundCloudCommentUser, m as SoundCloudError, n as SoundCloudQuota, o as SoundCloudSubscription, p as SoundCloudSubscriptionProduct } from './index-DX6Anc1-.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Options for making a request to the SoundCloud API via {@link scFetch}.
|
|
@@ -855,6 +855,24 @@ declare namespace SoundCloudClient {
|
|
|
855
855
|
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_tracks
|
|
856
856
|
*/
|
|
857
857
|
getTracks(limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
|
|
858
|
+
/**
|
|
859
|
+
* List the authenticated user's connected external social accounts.
|
|
860
|
+
*
|
|
861
|
+
* @param options - Optional token override
|
|
862
|
+
* @returns Array of connection objects for linked social services (Twitter, Facebook, etc.)
|
|
863
|
+
* @throws {SoundCloudError} When the API returns an error
|
|
864
|
+
*
|
|
865
|
+
* @remarks This endpoint may require elevated API access or app approval.
|
|
866
|
+
*
|
|
867
|
+
* @example
|
|
868
|
+
* ```ts
|
|
869
|
+
* const connections = await sc.me.getConnections();
|
|
870
|
+
* connections.forEach(c => console.log(c.service, c.display_name));
|
|
871
|
+
* ```
|
|
872
|
+
*
|
|
873
|
+
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_connections
|
|
874
|
+
*/
|
|
875
|
+
getConnections(options?: TokenOption): Promise<SoundCloudConnection[]>;
|
|
858
876
|
}
|
|
859
877
|
/**
|
|
860
878
|
* User profile namespace — fetch public user data.
|
|
@@ -1001,6 +1019,23 @@ declare namespace SoundCloudClient {
|
|
|
1001
1019
|
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id_
|
|
1002
1020
|
*/
|
|
1003
1021
|
getTrack(trackId: string | number, options?: TokenOption): Promise<SoundCloudTrack>;
|
|
1022
|
+
/**
|
|
1023
|
+
* Fetch multiple tracks by their IDs in a single request.
|
|
1024
|
+
*
|
|
1025
|
+
* @param ids - Array of track IDs (numeric or string URNs)
|
|
1026
|
+
* @param options - Optional token override
|
|
1027
|
+
* @returns Array of track objects (may be shorter than `ids` if some tracks are unavailable)
|
|
1028
|
+
* @throws {SoundCloudError} When the API returns an error
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```ts
|
|
1032
|
+
* const tracks = await sc.tracks.getTracks([123456, 234567, 345678]);
|
|
1033
|
+
* tracks.forEach(t => console.log(t.title));
|
|
1034
|
+
* ```
|
|
1035
|
+
*
|
|
1036
|
+
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks
|
|
1037
|
+
*/
|
|
1038
|
+
getTracks(ids: (string | number)[], options?: TokenOption): Promise<SoundCloudTrack[]>;
|
|
1004
1039
|
/**
|
|
1005
1040
|
* Get stream URLs for a track.
|
|
1006
1041
|
*
|
|
@@ -1723,6 +1758,75 @@ declare function generateCodeVerifier(): string;
|
|
|
1723
1758
|
*/
|
|
1724
1759
|
declare function generateCodeChallenge(verifier: string): Promise<string>;
|
|
1725
1760
|
|
|
1761
|
+
/**
|
|
1762
|
+
* Contract for a pluggable token provider that manages OAuth token lifecycle.
|
|
1763
|
+
*
|
|
1764
|
+
* Implement this interface to integrate soundcloud-api-ts with your
|
|
1765
|
+
* framework's session management, e.g. NextAuth, Clerk, Redis, or a simple
|
|
1766
|
+
* in-memory store.
|
|
1767
|
+
*
|
|
1768
|
+
* @example
|
|
1769
|
+
* ```ts
|
|
1770
|
+
* class InMemoryTokenProvider implements TokenProvider {
|
|
1771
|
+
* private _accessToken?: string;
|
|
1772
|
+
* private _refreshToken?: string;
|
|
1773
|
+
*
|
|
1774
|
+
* getAccessToken() { return this._accessToken; }
|
|
1775
|
+
* setTokens(access: string, refresh?: string) {
|
|
1776
|
+
* this._accessToken = access;
|
|
1777
|
+
* this._refreshToken = refresh;
|
|
1778
|
+
* }
|
|
1779
|
+
* async refreshIfNeeded(client: SoundCloudClient) {
|
|
1780
|
+
* if (!this._refreshToken) throw new Error('No refresh token');
|
|
1781
|
+
* const token = await client.auth.refreshUserToken(this._refreshToken);
|
|
1782
|
+
* this.setTokens(token.access_token, token.refresh_token);
|
|
1783
|
+
* return token.access_token;
|
|
1784
|
+
* }
|
|
1785
|
+
* }
|
|
1786
|
+
* ```
|
|
1787
|
+
*
|
|
1788
|
+
* @see docs/auth-guide.md
|
|
1789
|
+
*/
|
|
1790
|
+
interface TokenProvider {
|
|
1791
|
+
/** Returns the current access token, or undefined if none is stored. */
|
|
1792
|
+
getAccessToken(): string | undefined | Promise<string | undefined>;
|
|
1793
|
+
/** Persist new tokens (called after a successful token grant or refresh). */
|
|
1794
|
+
setTokens(accessToken: string, refreshToken?: string): void | Promise<void>;
|
|
1795
|
+
/**
|
|
1796
|
+
* Ensure a valid access token is available, refreshing if necessary.
|
|
1797
|
+
* Called automatically when a request returns 401 Unauthorized.
|
|
1798
|
+
*/
|
|
1799
|
+
refreshIfNeeded(client: SoundCloudClient): Promise<string> | string;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Minimal synchronous key–value store for OAuth tokens.
|
|
1803
|
+
*
|
|
1804
|
+
* Useful for implementing a simple in-memory or cookie-backed token store
|
|
1805
|
+
* without the full async lifecycle of {@link TokenProvider}.
|
|
1806
|
+
*
|
|
1807
|
+
* @example
|
|
1808
|
+
* ```ts
|
|
1809
|
+
* class CookieTokenStore implements TokenStore {
|
|
1810
|
+
* getAccessToken() { return getCookie('sc_access_token') ?? undefined; }
|
|
1811
|
+
* getRefreshToken() { return getCookie('sc_refresh_token') ?? undefined; }
|
|
1812
|
+
* setTokens(a, r) { setCookie('sc_access_token', a); if (r) setCookie('sc_refresh_token', r); }
|
|
1813
|
+
* clearTokens() { deleteCookie('sc_access_token'); deleteCookie('sc_refresh_token'); }
|
|
1814
|
+
* }
|
|
1815
|
+
* ```
|
|
1816
|
+
*
|
|
1817
|
+
* @see docs/auth-guide.md
|
|
1818
|
+
*/
|
|
1819
|
+
interface TokenStore {
|
|
1820
|
+
/** Returns the stored access token, or undefined if none. */
|
|
1821
|
+
getAccessToken(): string | undefined;
|
|
1822
|
+
/** Returns the stored refresh token, or undefined if none. */
|
|
1823
|
+
getRefreshToken(): string | undefined;
|
|
1824
|
+
/** Persist new tokens. */
|
|
1825
|
+
setTokens(accessToken: string, refreshToken?: string): void;
|
|
1826
|
+
/** Remove all stored tokens (call on sign-out). */
|
|
1827
|
+
clearTokens(): void;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1726
1830
|
/**
|
|
1727
1831
|
* Fetch the authenticated user's profile.
|
|
1728
1832
|
*
|
|
@@ -1929,6 +2033,26 @@ declare const getUserWebProfiles: (token: string, userId: string | number) => Pr
|
|
|
1929
2033
|
*/
|
|
1930
2034
|
declare const getTrack: (token: string, trackId: string | number) => Promise<SoundCloudTrack>;
|
|
1931
2035
|
|
|
2036
|
+
/**
|
|
2037
|
+
* Fetch multiple tracks by their IDs in a single request.
|
|
2038
|
+
*
|
|
2039
|
+
* @param token - OAuth access token
|
|
2040
|
+
* @param ids - Array of track IDs (numeric or string URNs)
|
|
2041
|
+
* @returns Array of track objects (may be shorter than `ids` if some tracks are unavailable)
|
|
2042
|
+
* @throws {SoundCloudError} When the API returns an error
|
|
2043
|
+
*
|
|
2044
|
+
* @example
|
|
2045
|
+
* ```ts
|
|
2046
|
+
* import { getTracks } from 'soundcloud-api-ts';
|
|
2047
|
+
*
|
|
2048
|
+
* const tracks = await getTracks(token, [123456, 234567, 345678]);
|
|
2049
|
+
* tracks.forEach(t => console.log(t.title));
|
|
2050
|
+
* ```
|
|
2051
|
+
*
|
|
2052
|
+
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks
|
|
2053
|
+
*/
|
|
2054
|
+
declare const getTracks: (token: string, ids: (string | number)[]) => Promise<SoundCloudTrack[]>;
|
|
2055
|
+
|
|
1932
2056
|
/**
|
|
1933
2057
|
* Fetch comments on a track.
|
|
1934
2058
|
*
|
|
@@ -2505,6 +2629,27 @@ declare const getMePlaylists: (token: string, limit?: number) => Promise<SoundCl
|
|
|
2505
2629
|
*/
|
|
2506
2630
|
declare const getMeTracks: (token: string, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
|
|
2507
2631
|
|
|
2632
|
+
/**
|
|
2633
|
+
* List the authenticated user's connected external social accounts.
|
|
2634
|
+
*
|
|
2635
|
+
* @param token - OAuth access token (user token required)
|
|
2636
|
+
* @returns Array of connection objects for linked social services
|
|
2637
|
+
* @throws {SoundCloudError} When the API returns an error
|
|
2638
|
+
*
|
|
2639
|
+
* @remarks This endpoint may require elevated API access or app approval.
|
|
2640
|
+
*
|
|
2641
|
+
* @example
|
|
2642
|
+
* ```ts
|
|
2643
|
+
* import { getMeConnections } from 'soundcloud-api-ts';
|
|
2644
|
+
*
|
|
2645
|
+
* const connections = await getMeConnections(token);
|
|
2646
|
+
* connections.forEach(c => console.log(c.service, c.display_name));
|
|
2647
|
+
* ```
|
|
2648
|
+
*
|
|
2649
|
+
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_connections
|
|
2650
|
+
*/
|
|
2651
|
+
declare const getMeConnections: (token: string) => Promise<SoundCloudConnection[]>;
|
|
2652
|
+
|
|
2508
2653
|
/**
|
|
2509
2654
|
* Like a playlist as the authenticated user.
|
|
2510
2655
|
*
|
|
@@ -2625,4 +2770,4 @@ declare const unrepostPlaylist: (token: string, playlistId: string | number) =>
|
|
|
2625
2770
|
*/
|
|
2626
2771
|
declare const getSoundCloudWidgetUrl: (trackId: string | number) => string;
|
|
2627
2772
|
|
|
2628
|
-
export { type CreatePlaylistParams, IMPLEMENTED_OPERATIONS, InFlightDeduper, RawClient, type RawResponse, type RequestOptions, type RetryConfig, type RetryInfo, type SCRequestTelemetry, SoundCloudActivitiesResponse, type SoundCloudCache, type SoundCloudCacheEntry, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };
|
|
2773
|
+
export { type CreatePlaylistParams, IMPLEMENTED_OPERATIONS, InFlightDeduper, RawClient, type RawResponse, type RequestOptions, type RetryConfig, type RetryInfo, type SCRequestTelemetry, SoundCloudActivitiesResponse, type SoundCloudCache, type SoundCloudCacheEntry, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudConnection, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type TokenProvider, type TokenStore, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeConnections, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getTracks, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SoundCloudTrack, SoundCloudPlaylist, SoundCloudToken, SoundCloudPaginatedResponse, SoundCloudMe, SoundCloudActivitiesResponse, SoundCloudUser, SoundCloudWebProfile, SoundCloudStreams, SoundCloudComment } from './
|
|
2
|
-
export { SoundCloudActivity, SoundCloudCommentUser, SoundCloudError, SoundCloudQuota, SoundCloudSubscription, SoundCloudSubscriptionProduct } from './
|
|
1
|
+
import { S as SoundCloudTrack, a as SoundCloudPlaylist, b as SoundCloudToken, c as SoundCloudPaginatedResponse, d as SoundCloudMe, e as SoundCloudActivitiesResponse, f as SoundCloudUser, g as SoundCloudConnection, h as SoundCloudWebProfile, i as SoundCloudStreams, j as SoundCloudComment } from './index-DX6Anc1-.js';
|
|
2
|
+
export { k as SoundCloudActivity, l as SoundCloudCommentUser, m as SoundCloudError, n as SoundCloudQuota, o as SoundCloudSubscription, p as SoundCloudSubscriptionProduct } from './index-DX6Anc1-.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Options for making a request to the SoundCloud API via {@link scFetch}.
|
|
@@ -855,6 +855,24 @@ declare namespace SoundCloudClient {
|
|
|
855
855
|
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_tracks
|
|
856
856
|
*/
|
|
857
857
|
getTracks(limit?: number, options?: TokenOption): Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
|
|
858
|
+
/**
|
|
859
|
+
* List the authenticated user's connected external social accounts.
|
|
860
|
+
*
|
|
861
|
+
* @param options - Optional token override
|
|
862
|
+
* @returns Array of connection objects for linked social services (Twitter, Facebook, etc.)
|
|
863
|
+
* @throws {SoundCloudError} When the API returns an error
|
|
864
|
+
*
|
|
865
|
+
* @remarks This endpoint may require elevated API access or app approval.
|
|
866
|
+
*
|
|
867
|
+
* @example
|
|
868
|
+
* ```ts
|
|
869
|
+
* const connections = await sc.me.getConnections();
|
|
870
|
+
* connections.forEach(c => console.log(c.service, c.display_name));
|
|
871
|
+
* ```
|
|
872
|
+
*
|
|
873
|
+
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_connections
|
|
874
|
+
*/
|
|
875
|
+
getConnections(options?: TokenOption): Promise<SoundCloudConnection[]>;
|
|
858
876
|
}
|
|
859
877
|
/**
|
|
860
878
|
* User profile namespace — fetch public user data.
|
|
@@ -1001,6 +1019,23 @@ declare namespace SoundCloudClient {
|
|
|
1001
1019
|
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks__track_id_
|
|
1002
1020
|
*/
|
|
1003
1021
|
getTrack(trackId: string | number, options?: TokenOption): Promise<SoundCloudTrack>;
|
|
1022
|
+
/**
|
|
1023
|
+
* Fetch multiple tracks by their IDs in a single request.
|
|
1024
|
+
*
|
|
1025
|
+
* @param ids - Array of track IDs (numeric or string URNs)
|
|
1026
|
+
* @param options - Optional token override
|
|
1027
|
+
* @returns Array of track objects (may be shorter than `ids` if some tracks are unavailable)
|
|
1028
|
+
* @throws {SoundCloudError} When the API returns an error
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```ts
|
|
1032
|
+
* const tracks = await sc.tracks.getTracks([123456, 234567, 345678]);
|
|
1033
|
+
* tracks.forEach(t => console.log(t.title));
|
|
1034
|
+
* ```
|
|
1035
|
+
*
|
|
1036
|
+
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks
|
|
1037
|
+
*/
|
|
1038
|
+
getTracks(ids: (string | number)[], options?: TokenOption): Promise<SoundCloudTrack[]>;
|
|
1004
1039
|
/**
|
|
1005
1040
|
* Get stream URLs for a track.
|
|
1006
1041
|
*
|
|
@@ -1723,6 +1758,75 @@ declare function generateCodeVerifier(): string;
|
|
|
1723
1758
|
*/
|
|
1724
1759
|
declare function generateCodeChallenge(verifier: string): Promise<string>;
|
|
1725
1760
|
|
|
1761
|
+
/**
|
|
1762
|
+
* Contract for a pluggable token provider that manages OAuth token lifecycle.
|
|
1763
|
+
*
|
|
1764
|
+
* Implement this interface to integrate soundcloud-api-ts with your
|
|
1765
|
+
* framework's session management, e.g. NextAuth, Clerk, Redis, or a simple
|
|
1766
|
+
* in-memory store.
|
|
1767
|
+
*
|
|
1768
|
+
* @example
|
|
1769
|
+
* ```ts
|
|
1770
|
+
* class InMemoryTokenProvider implements TokenProvider {
|
|
1771
|
+
* private _accessToken?: string;
|
|
1772
|
+
* private _refreshToken?: string;
|
|
1773
|
+
*
|
|
1774
|
+
* getAccessToken() { return this._accessToken; }
|
|
1775
|
+
* setTokens(access: string, refresh?: string) {
|
|
1776
|
+
* this._accessToken = access;
|
|
1777
|
+
* this._refreshToken = refresh;
|
|
1778
|
+
* }
|
|
1779
|
+
* async refreshIfNeeded(client: SoundCloudClient) {
|
|
1780
|
+
* if (!this._refreshToken) throw new Error('No refresh token');
|
|
1781
|
+
* const token = await client.auth.refreshUserToken(this._refreshToken);
|
|
1782
|
+
* this.setTokens(token.access_token, token.refresh_token);
|
|
1783
|
+
* return token.access_token;
|
|
1784
|
+
* }
|
|
1785
|
+
* }
|
|
1786
|
+
* ```
|
|
1787
|
+
*
|
|
1788
|
+
* @see docs/auth-guide.md
|
|
1789
|
+
*/
|
|
1790
|
+
interface TokenProvider {
|
|
1791
|
+
/** Returns the current access token, or undefined if none is stored. */
|
|
1792
|
+
getAccessToken(): string | undefined | Promise<string | undefined>;
|
|
1793
|
+
/** Persist new tokens (called after a successful token grant or refresh). */
|
|
1794
|
+
setTokens(accessToken: string, refreshToken?: string): void | Promise<void>;
|
|
1795
|
+
/**
|
|
1796
|
+
* Ensure a valid access token is available, refreshing if necessary.
|
|
1797
|
+
* Called automatically when a request returns 401 Unauthorized.
|
|
1798
|
+
*/
|
|
1799
|
+
refreshIfNeeded(client: SoundCloudClient): Promise<string> | string;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Minimal synchronous key–value store for OAuth tokens.
|
|
1803
|
+
*
|
|
1804
|
+
* Useful for implementing a simple in-memory or cookie-backed token store
|
|
1805
|
+
* without the full async lifecycle of {@link TokenProvider}.
|
|
1806
|
+
*
|
|
1807
|
+
* @example
|
|
1808
|
+
* ```ts
|
|
1809
|
+
* class CookieTokenStore implements TokenStore {
|
|
1810
|
+
* getAccessToken() { return getCookie('sc_access_token') ?? undefined; }
|
|
1811
|
+
* getRefreshToken() { return getCookie('sc_refresh_token') ?? undefined; }
|
|
1812
|
+
* setTokens(a, r) { setCookie('sc_access_token', a); if (r) setCookie('sc_refresh_token', r); }
|
|
1813
|
+
* clearTokens() { deleteCookie('sc_access_token'); deleteCookie('sc_refresh_token'); }
|
|
1814
|
+
* }
|
|
1815
|
+
* ```
|
|
1816
|
+
*
|
|
1817
|
+
* @see docs/auth-guide.md
|
|
1818
|
+
*/
|
|
1819
|
+
interface TokenStore {
|
|
1820
|
+
/** Returns the stored access token, or undefined if none. */
|
|
1821
|
+
getAccessToken(): string | undefined;
|
|
1822
|
+
/** Returns the stored refresh token, or undefined if none. */
|
|
1823
|
+
getRefreshToken(): string | undefined;
|
|
1824
|
+
/** Persist new tokens. */
|
|
1825
|
+
setTokens(accessToken: string, refreshToken?: string): void;
|
|
1826
|
+
/** Remove all stored tokens (call on sign-out). */
|
|
1827
|
+
clearTokens(): void;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1726
1830
|
/**
|
|
1727
1831
|
* Fetch the authenticated user's profile.
|
|
1728
1832
|
*
|
|
@@ -1929,6 +2033,26 @@ declare const getUserWebProfiles: (token: string, userId: string | number) => Pr
|
|
|
1929
2033
|
*/
|
|
1930
2034
|
declare const getTrack: (token: string, trackId: string | number) => Promise<SoundCloudTrack>;
|
|
1931
2035
|
|
|
2036
|
+
/**
|
|
2037
|
+
* Fetch multiple tracks by their IDs in a single request.
|
|
2038
|
+
*
|
|
2039
|
+
* @param token - OAuth access token
|
|
2040
|
+
* @param ids - Array of track IDs (numeric or string URNs)
|
|
2041
|
+
* @returns Array of track objects (may be shorter than `ids` if some tracks are unavailable)
|
|
2042
|
+
* @throws {SoundCloudError} When the API returns an error
|
|
2043
|
+
*
|
|
2044
|
+
* @example
|
|
2045
|
+
* ```ts
|
|
2046
|
+
* import { getTracks } from 'soundcloud-api-ts';
|
|
2047
|
+
*
|
|
2048
|
+
* const tracks = await getTracks(token, [123456, 234567, 345678]);
|
|
2049
|
+
* tracks.forEach(t => console.log(t.title));
|
|
2050
|
+
* ```
|
|
2051
|
+
*
|
|
2052
|
+
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/tracks/get_tracks
|
|
2053
|
+
*/
|
|
2054
|
+
declare const getTracks: (token: string, ids: (string | number)[]) => Promise<SoundCloudTrack[]>;
|
|
2055
|
+
|
|
1932
2056
|
/**
|
|
1933
2057
|
* Fetch comments on a track.
|
|
1934
2058
|
*
|
|
@@ -2505,6 +2629,27 @@ declare const getMePlaylists: (token: string, limit?: number) => Promise<SoundCl
|
|
|
2505
2629
|
*/
|
|
2506
2630
|
declare const getMeTracks: (token: string, limit?: number) => Promise<SoundCloudPaginatedResponse<SoundCloudTrack>>;
|
|
2507
2631
|
|
|
2632
|
+
/**
|
|
2633
|
+
* List the authenticated user's connected external social accounts.
|
|
2634
|
+
*
|
|
2635
|
+
* @param token - OAuth access token (user token required)
|
|
2636
|
+
* @returns Array of connection objects for linked social services
|
|
2637
|
+
* @throws {SoundCloudError} When the API returns an error
|
|
2638
|
+
*
|
|
2639
|
+
* @remarks This endpoint may require elevated API access or app approval.
|
|
2640
|
+
*
|
|
2641
|
+
* @example
|
|
2642
|
+
* ```ts
|
|
2643
|
+
* import { getMeConnections } from 'soundcloud-api-ts';
|
|
2644
|
+
*
|
|
2645
|
+
* const connections = await getMeConnections(token);
|
|
2646
|
+
* connections.forEach(c => console.log(c.service, c.display_name));
|
|
2647
|
+
* ```
|
|
2648
|
+
*
|
|
2649
|
+
* @see https://developers.soundcloud.com/docs/api/explorer/open-api#/me/get_me_connections
|
|
2650
|
+
*/
|
|
2651
|
+
declare const getMeConnections: (token: string) => Promise<SoundCloudConnection[]>;
|
|
2652
|
+
|
|
2508
2653
|
/**
|
|
2509
2654
|
* Like a playlist as the authenticated user.
|
|
2510
2655
|
*
|
|
@@ -2625,4 +2770,4 @@ declare const unrepostPlaylist: (token: string, playlistId: string | number) =>
|
|
|
2625
2770
|
*/
|
|
2626
2771
|
declare const getSoundCloudWidgetUrl: (trackId: string | number) => string;
|
|
2627
2772
|
|
|
2628
|
-
export { type CreatePlaylistParams, IMPLEMENTED_OPERATIONS, InFlightDeduper, RawClient, type RawResponse, type RequestOptions, type RetryConfig, type RetryInfo, type SCRequestTelemetry, SoundCloudActivitiesResponse, type SoundCloudCache, type SoundCloudCacheEntry, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };
|
|
2773
|
+
export { type CreatePlaylistParams, IMPLEMENTED_OPERATIONS, InFlightDeduper, RawClient, type RawResponse, type RequestOptions, type RetryConfig, type RetryInfo, type SCRequestTelemetry, SoundCloudActivitiesResponse, type SoundCloudCache, type SoundCloudCacheEntry, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudConnection, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type TokenProvider, type TokenStore, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeConnections, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getTracks, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };
|