discord-player-deezer 2.6.0 → 3.0.0-dev.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/.yarn/install-state.gz +0 -0
- package/.yarnrc.yml +1 -1
- package/LICENSE +121 -121
- package/dist/index.d.ts +140 -6
- package/dist/index.js +362 -45
- package/package.json +36 -36
- package/readme.md +57 -35
- package/src/Cache/CacheTapStream.ts +81 -0
- package/src/Cache/DiskAudioCache.ts +232 -0
- package/src/Cache/IAudioCache.ts +30 -0
- package/src/Cache/index.ts +2 -0
- package/src/Crypto/BaseDecryptor.ts +11 -11
- package/src/Crypto/JSDecryptor.ts +110 -9
- package/src/Crypto/NodeDecryptor.ts +65 -12
- package/src/Crypto/StripeDecryptStream.ts +73 -0
- package/src/Crypto/index.ts +4 -3
- package/src/DeezerExtractor.ts +263 -259
- package/src/index.ts +4 -3
- package/src/utils/crypto.ts +10 -0
- package/src/utils/util.ts +274 -266
- package/tsconfig.json +24 -24
- package/tslint.json +2 -2
- package/tsup.config.ts +8 -8
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/.yarnrc.yml
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
nodeLinker: node-modules
|
|
1
|
+
nodeLinker: node-modules
|
package/LICENSE
CHANGED
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
Creative Commons Legal Code
|
|
2
|
-
|
|
3
|
-
CC0 1.0 Universal
|
|
4
|
-
|
|
5
|
-
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
6
|
-
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
7
|
-
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
8
|
-
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
9
|
-
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
10
|
-
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
11
|
-
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
12
|
-
HEREUNDER.
|
|
13
|
-
|
|
14
|
-
Statement of Purpose
|
|
15
|
-
|
|
16
|
-
The laws of most jurisdictions throughout the world automatically confer
|
|
17
|
-
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
18
|
-
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
19
|
-
authorship and/or a database (each, a "Work").
|
|
20
|
-
|
|
21
|
-
Certain owners wish to permanently relinquish those rights to a Work for
|
|
22
|
-
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
-
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
-
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
-
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
26
|
-
and for any purposes, including without limitation commercial purposes.
|
|
27
|
-
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
-
culture and the further production of creative, cultural and scientific
|
|
29
|
-
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
-
part through the use and efforts of others.
|
|
31
|
-
|
|
32
|
-
For these and/or other purposes and motivations, and without any
|
|
33
|
-
expectation of additional consideration or compensation, the person
|
|
34
|
-
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
35
|
-
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
-
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
37
|
-
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
38
|
-
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
-
|
|
40
|
-
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
-
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
-
Related Rights"). Copyright and Related Rights include, but are not
|
|
43
|
-
limited to, the following:
|
|
44
|
-
|
|
45
|
-
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
-
communicate, and translate a Work;
|
|
47
|
-
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
-
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
-
likeness depicted in a Work;
|
|
50
|
-
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
-
subject to the limitations in paragraph 4(a), below;
|
|
52
|
-
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
53
|
-
in a Work;
|
|
54
|
-
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
55
|
-
European Parliament and of the Council of 11 March 1996 on the legal
|
|
56
|
-
protection of databases, and under any national implementation
|
|
57
|
-
thereof, including any amended or successor version of such
|
|
58
|
-
directive); and
|
|
59
|
-
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
-
world based on applicable law or treaty, and any national
|
|
61
|
-
implementations thereof.
|
|
62
|
-
|
|
63
|
-
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
64
|
-
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
65
|
-
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
66
|
-
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
67
|
-
of action, whether now known or unknown (including existing as well as
|
|
68
|
-
future claims and causes of action), in the Work (i) in all territories
|
|
69
|
-
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
70
|
-
treaty (including future time extensions), (iii) in any current or future
|
|
71
|
-
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
72
|
-
including without limitation commercial, advertising or promotional
|
|
73
|
-
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
74
|
-
member of the public at large and to the detriment of Affirmer's heirs and
|
|
75
|
-
successors, fully intending that such Waiver shall not be subject to
|
|
76
|
-
revocation, rescission, cancellation, termination, or any other legal or
|
|
77
|
-
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
78
|
-
as contemplated by Affirmer's express Statement of Purpose.
|
|
79
|
-
|
|
80
|
-
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
-
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
-
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
-
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
-
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
-
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
-
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
-
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
-
maximum duration provided by applicable law or treaty (including future
|
|
89
|
-
time extensions), (iii) in any current or future medium and for any number
|
|
90
|
-
of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
-
limitation commercial, advertising or promotional purposes (the
|
|
92
|
-
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
-
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
-
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
-
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
-
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
-
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
-
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
-
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
-
express Statement of Purpose.
|
|
101
|
-
|
|
102
|
-
4. Limitations and Disclaimers.
|
|
103
|
-
|
|
104
|
-
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
-
surrendered, licensed or otherwise affected by this document.
|
|
106
|
-
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
-
warranties of any kind concerning the Work, express, implied,
|
|
108
|
-
statutory or otherwise, including without limitation warranties of
|
|
109
|
-
title, merchantability, fitness for a particular purpose, non
|
|
110
|
-
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
-
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
-
the greatest extent permissible under applicable law.
|
|
113
|
-
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
-
that may apply to the Work or any use thereof, including without
|
|
115
|
-
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
-
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
-
consents, permissions or other rights required for any use of the
|
|
118
|
-
Work.
|
|
119
|
-
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
120
|
-
party to this document and has no duty or obligation with respect to
|
|
121
|
-
this CC0 or use of the Work.
|
|
1
|
+
Creative Commons Legal Code
|
|
2
|
+
|
|
3
|
+
CC0 1.0 Universal
|
|
4
|
+
|
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
12
|
+
HEREUNDER.
|
|
13
|
+
|
|
14
|
+
Statement of Purpose
|
|
15
|
+
|
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
19
|
+
authorship and/or a database (each, a "Work").
|
|
20
|
+
|
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
26
|
+
and for any purposes, including without limitation commercial purposes.
|
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
+
culture and the further production of creative, cultural and scientific
|
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
+
part through the use and efforts of others.
|
|
31
|
+
|
|
32
|
+
For these and/or other purposes and motivations, and without any
|
|
33
|
+
expectation of additional consideration or compensation, the person
|
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
35
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
37
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
38
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
+
|
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
|
43
|
+
limited to, the following:
|
|
44
|
+
|
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
+
communicate, and translate a Work;
|
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
+
likeness depicted in a Work;
|
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
53
|
+
in a Work;
|
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
55
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
|
56
|
+
protection of databases, and under any national implementation
|
|
57
|
+
thereof, including any amended or successor version of such
|
|
58
|
+
directive); and
|
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
+
world based on applicable law or treaty, and any national
|
|
61
|
+
implementations thereof.
|
|
62
|
+
|
|
63
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
64
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
65
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
66
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
67
|
+
of action, whether now known or unknown (including existing as well as
|
|
68
|
+
future claims and causes of action), in the Work (i) in all territories
|
|
69
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
70
|
+
treaty (including future time extensions), (iii) in any current or future
|
|
71
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
72
|
+
including without limitation commercial, advertising or promotional
|
|
73
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
74
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
|
75
|
+
successors, fully intending that such Waiver shall not be subject to
|
|
76
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
|
77
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
78
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
|
79
|
+
|
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
|
89
|
+
time extensions), (iii) in any current or future medium and for any number
|
|
90
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
+
express Statement of Purpose.
|
|
101
|
+
|
|
102
|
+
4. Limitations and Disclaimers.
|
|
103
|
+
|
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
+
the greatest extent permissible under applicable law.
|
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
+
that may apply to the Work or any use thereof, including without
|
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
+
consents, permissions or other rights required for any use of the
|
|
118
|
+
Work.
|
|
119
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
120
|
+
party to this document and has no duty or obligation with respect to
|
|
121
|
+
this CC0 or use of the Work.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,77 @@
|
|
|
1
1
|
import { Playlist, Track as Track$1 } from '@mithron/deezer-music-metadata';
|
|
2
2
|
import { Track, ExtractorStreamable, BaseExtractor, SearchQueryType, ExtractorSearchContext, Playlist as Playlist$1, ExtractorInfo, Player } from 'discord-player';
|
|
3
|
+
import { Readable, Writable, Transform, TransformCallback } from 'node:stream';
|
|
4
|
+
import { Readable as Readable$1 } from 'stream';
|
|
3
5
|
import * as crypto from 'crypto';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Storage backend for decrypted audio.
|
|
9
|
+
*
|
|
10
|
+
* A cache is read before the track is fetched and written while the track is
|
|
11
|
+
* being streamed, so implementations should support concurrent streams.
|
|
12
|
+
*/
|
|
13
|
+
interface IAudioCache {
|
|
14
|
+
/**
|
|
15
|
+
* Returns a readable stream for the cached track, or `null` when the key
|
|
16
|
+
* is not present.
|
|
17
|
+
*/
|
|
18
|
+
read(key: string): Promise<Readable | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Opens a writable for the given key. The entry is committed when the
|
|
21
|
+
* writable finishes and discarded if it is destroyed first.
|
|
22
|
+
*/
|
|
23
|
+
write(key: string): Promise<Writable>;
|
|
24
|
+
/** Removes a single entry. Missing entries are ignored. */
|
|
25
|
+
delete(key: string): Promise<void>;
|
|
26
|
+
/** Applies the cache's age and size limits. */
|
|
27
|
+
cleanup(): Promise<void>;
|
|
28
|
+
/** Stops any background maintenance. Optional. */
|
|
29
|
+
close?(): void | Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface DiskAudioCacheOptions {
|
|
33
|
+
/** Directory used to store decrypted tracks. */
|
|
34
|
+
directory?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Maximum number of cached songs. Oldest entries are removed first.
|
|
37
|
+
* Set to `0` to disable the count limit.
|
|
38
|
+
*/
|
|
39
|
+
maxSongs?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Remove entries older than this many milliseconds.
|
|
42
|
+
* Set to `0` to disable age-based expiry.
|
|
43
|
+
*/
|
|
44
|
+
maxAge?: number;
|
|
45
|
+
/**
|
|
46
|
+
* How often background cleanup runs, in milliseconds.
|
|
47
|
+
* Set to `0` to only clean up after writes.
|
|
48
|
+
*/
|
|
49
|
+
cleanupInterval?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Disk-backed audio cache. Keys are hashed, so arbitrary strings can be used
|
|
53
|
+
* without risking path traversal. Audio is written to a temporary file and
|
|
54
|
+
* renamed into place once complete, so partially downloaded tracks are never
|
|
55
|
+
* served.
|
|
56
|
+
*/
|
|
57
|
+
declare class DiskAudioCache implements IAudioCache {
|
|
58
|
+
readonly directory: string;
|
|
59
|
+
readonly maxSongs: number;
|
|
60
|
+
readonly maxAge: number;
|
|
61
|
+
readonly cleanupInterval: number;
|
|
62
|
+
private readonly ready;
|
|
63
|
+
private cleaning?;
|
|
64
|
+
private timer?;
|
|
65
|
+
private closed;
|
|
66
|
+
constructor(options?: DiskAudioCacheOptions);
|
|
67
|
+
read(key: string): Promise<Readable | null>;
|
|
68
|
+
write(key: string): Promise<Writable>;
|
|
69
|
+
delete(key: string): Promise<void>;
|
|
70
|
+
cleanup(): Promise<void>;
|
|
71
|
+
close(): Promise<void>;
|
|
72
|
+
private pathFor;
|
|
73
|
+
private runCleanup;
|
|
74
|
+
}
|
|
6
75
|
|
|
7
76
|
declare class BaseDecryptor {
|
|
8
77
|
key: Buffer;
|
|
@@ -27,6 +96,8 @@ type DeezerExtractorOptions = {
|
|
|
27
96
|
priority?: number;
|
|
28
97
|
arl: string;
|
|
29
98
|
decryptor?: typeof BaseDecryptor;
|
|
99
|
+
/** Opt-in cache for decrypted audio. */
|
|
100
|
+
cache?: IAudioCache;
|
|
30
101
|
};
|
|
31
102
|
type DeezerUserInfo = {
|
|
32
103
|
cookie: string;
|
|
@@ -53,7 +124,42 @@ declare class DeezerExtractor extends BaseExtractor<DeezerExtractorOptions> {
|
|
|
53
124
|
stream(info: Track): Promise<ExtractorStreamable>;
|
|
54
125
|
}
|
|
55
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Passes audio through while mirroring it into a cache writable.
|
|
129
|
+
*
|
|
130
|
+
* The readable side is driven by the consumer, so enabling the cache does not
|
|
131
|
+
* make the download eager: if playback stalls or is aborted, the source is
|
|
132
|
+
* not drained into the cache.
|
|
133
|
+
*/
|
|
134
|
+
declare class CacheTapStream extends Transform {
|
|
135
|
+
private readonly sink;
|
|
136
|
+
private sinkFailed;
|
|
137
|
+
private flushed;
|
|
138
|
+
constructor(sink: Writable);
|
|
139
|
+
_transform(chunk: Buffer, _encoding: BufferEncoding, callback: TransformCallback): void;
|
|
140
|
+
_flush(callback: TransformCallback): void;
|
|
141
|
+
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Decrypts a Deezer stripe stream as it flows through.
|
|
146
|
+
*
|
|
147
|
+
* Using a `Transform` means the HTTP body is only pulled when the consumer
|
|
148
|
+
* actually reads: if playback/ffmpeg slows down, backpressure pauses the
|
|
149
|
+
* download instead of buffering the whole track in memory.
|
|
150
|
+
*/
|
|
151
|
+
declare class StripeDecryptStream extends Transform {
|
|
152
|
+
private stripeIndex;
|
|
153
|
+
private remainder;
|
|
154
|
+
private readonly decryptor;
|
|
155
|
+
constructor(decryptor: BaseDecryptor);
|
|
156
|
+
_transform(chunk: Buffer, _encoding: BufferEncoding, callback: TransformCallback): Promise<void>;
|
|
157
|
+
_flush(callback: TransformCallback): Promise<void>;
|
|
158
|
+
private decodeStripe;
|
|
159
|
+
}
|
|
160
|
+
|
|
56
161
|
declare function getCrypto(): Promise<typeof crypto>;
|
|
162
|
+
|
|
57
163
|
declare function isUrl(query: string): boolean;
|
|
58
164
|
declare function search(query: string, limit?: number): Promise<DeezerSearchTrackResponse>;
|
|
59
165
|
type ArrayOrObject<T> = T | T[];
|
|
@@ -77,7 +183,7 @@ interface DeezerSearchTrackResponse {
|
|
|
77
183
|
declare function buildTrackFromSearch(track: DeezerSearchTrackResponse, player: Player, requestedBy?: Track["requestedBy"]): Track<unknown>[];
|
|
78
184
|
declare function extractTrackId(query: string): string;
|
|
79
185
|
declare function searchOneTrack(query: string): Promise<DeezerSearchTrackResponse | undefined>;
|
|
80
|
-
declare function streamTrack(track: Track, ext: DeezerExtractor): Promise<
|
|
186
|
+
declare function streamTrack(track: Track, ext: DeezerExtractor): Promise<Readable$1 | CacheTapStream | StripeDecryptStream>;
|
|
81
187
|
declare const deezerRegex: {
|
|
82
188
|
readonly track: RegExp;
|
|
83
189
|
readonly playlistNalbums: RegExp;
|
|
@@ -85,15 +191,43 @@ declare const deezerRegex: {
|
|
|
85
191
|
};
|
|
86
192
|
declare function validate(query: string): boolean;
|
|
87
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Blowfish-CBC decryptor for Deezer's BF_CBC_STRIPE streams.
|
|
196
|
+
*
|
|
197
|
+
* `blowfish-node`'s `decode()` allocates (and copies) several times per call
|
|
198
|
+
* and runs the block cipher through helper functions and array destructuring.
|
|
199
|
+
* Since this is the hot path for every encrypted 2048-byte stripe, we use the
|
|
200
|
+
* library only to run the key schedule once and then decrypt in place with a
|
|
201
|
+
* tight loop.
|
|
202
|
+
*/
|
|
88
203
|
declare class JSDecryptor extends BaseDecryptor {
|
|
89
|
-
|
|
204
|
+
private readonly p;
|
|
205
|
+
private readonly s0;
|
|
206
|
+
private readonly s1;
|
|
207
|
+
private readonly s2;
|
|
208
|
+
private readonly s3;
|
|
209
|
+
private readonly iv0;
|
|
210
|
+
private readonly iv1;
|
|
90
211
|
constructor(...args: ConstructorParameters<typeof BaseDecryptor>);
|
|
91
212
|
decrypt(chunk: Buffer): Promise<Buffer>;
|
|
92
213
|
}
|
|
93
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Native (`bf-cbc`) decryptor.
|
|
217
|
+
*
|
|
218
|
+
* A `Decipher` keeps its expanded key schedule for as long as it lives, but
|
|
219
|
+
* `createDecipheriv()` rebuilds that schedule on every call. Creating one per
|
|
220
|
+
* 2048-byte stripe is therefore slower than the pure-JS decryptor. Instead we
|
|
221
|
+
* keep a single cipher for the whole track and repair the CBC chain at stripe
|
|
222
|
+
* boundaries: Deezer restarts every stripe from the same IV, while the cipher
|
|
223
|
+
* carries the previous stripe's last ciphertext block forward. Only the first
|
|
224
|
+
* block of each stripe differs, and it can be fixed with one XOR.
|
|
225
|
+
*/
|
|
94
226
|
declare class NodeDecryptor extends BaseDecryptor {
|
|
95
|
-
|
|
227
|
+
private decipher?;
|
|
228
|
+
private previousCipherBlock?;
|
|
229
|
+
private firstChunk;
|
|
96
230
|
decrypt(chunk: Buffer): Promise<Buffer>;
|
|
97
231
|
}
|
|
98
232
|
|
|
99
|
-
export { type ArrayOrObject, BaseDecryptor, DeezerExtractor, type DeezerExtractorOptions, type DeezerSearchTrackResponse, type DeezerUserInfo, JSDecryptor, NodeDecryptor, Warnings, buildTrackFromSearch, deezerRegex, extractTrackId, getCrypto, isUrl, search, searchOneTrack, streamTrack, validate };
|
|
233
|
+
export { type ArrayOrObject, BaseDecryptor, DeezerExtractor, type DeezerExtractorOptions, type DeezerSearchTrackResponse, type DeezerUserInfo, DiskAudioCache, type DiskAudioCacheOptions, type IAudioCache, JSDecryptor, NodeDecryptor, StripeDecryptStream, Warnings, buildTrackFromSearch, deezerRegex, extractTrackId, getCrypto, isUrl, search, searchOneTrack, streamTrack, validate };
|